void regions_update(struct output *output);
void regions_destroy(struct wl_list *regions);
+struct region *regions_from_name(const char *region_name, struct output *output);
+
#endif /* __LABWC_REGIONS_H */
#include "debug.h"
#include "labwc.h"
#include "menu/menu.h"
+#include "regions.h"
#include "ssd.h"
#include "view.h"
#include "workspaces.h"
ACTION_TYPE_RESIZE,
ACTION_TYPE_GO_TO_DESKTOP,
ACTION_TYPE_SEND_TO_DESKTOP,
+ ACTION_TYPE_SNAP_TO_REGION
};
const char *action_names[] = {
"Resize",
"GoToDesktop",
"SendToDesktop",
+ "SnapToRegion",
NULL
};
} else if (!strcmp(nodename, "to.action")) {
/* GoToDesktop, SendToDesktop */
action_arg_add_str(action, NULL, content);
+ } else if (!strcmp(nodename, "region.action")) {
+ /* SnapToRegion */
+ action_arg_add_str(action, NULL, content);
}
}
}
}
break;
+ case ACTION_TYPE_SNAP_TO_REGION:
+ if (!arg) {
+ wlr_log(WLR_ERROR, "Missing argument for SnapToRegion");
+ break;
+ }
+ if (!view) {
+ break;
+ }
+ struct output *output = view->output;
+ if (!output) {
+ break;
+ }
+ const char *region_name = action_str_from_arg(arg);
+ struct region *region = regions_from_name(region_name, output);
+ if (region) {
+ view_snap_to_region(view, region,
+ /*store_natural_geometry*/ true);
+ } else {
+ wlr_log(WLR_ERROR, "Invalid SnapToRegion id: '%s'", region_name);
+ }
+ break;
case ACTION_TYPE_NONE:
break;
case ACTION_TYPE_INVALID:
/* To be filled later */
}
+struct region *
+regions_from_name(const char *region_name, struct output *output)
+{
+ assert(region_name);
+ assert(output);
+ struct region *region;
+ wl_list_for_each(region, &output->regions, link) {
+ if (!strcmp(region->name, region_name)) {
+ return region;
+ }
+ }
+ return NULL;
+}
+
void
regions_update(struct output *output)
{