SnapToRegion: Allow for live config updates

This commit is contained in:
Consolatis 2023-01-01 18:12:20 +01:00
parent 550e40b56b
commit 07ee56176d
8 changed files with 99 additions and 29 deletions

View file

@ -315,7 +315,6 @@ struct output {
struct wlr_box usable_area;
struct wl_list regions; /* struct region.link */
struct wlr_box regions_usable_area;
struct lab_data_buffer *osd_buffer;

View file

@ -33,12 +33,43 @@ struct region_overlay {
/* Can be used as a cheap check to detect if there are any regions configured */
bool regions_available(void);
void regions_update(struct output *output);
/**
* regions_reconfigure*() - re-initializes all regions from struct rc.
*
* - all views are evacuated from the given output (or all of them)
* - all output local regions are destroyed
* - new output local regions are created from struct rc
* - the region geometry is re-calculated
*/
void regions_reconfigure(struct server *server);
void regions_reconfigure_output(struct output *output);
/* re-calculate the geometry based on usable area */
void regions_update_geometry(struct output *output);
/**
* Mark all views which are currently region-tiled to the given output as
* evacuated. This means that the view->tiled_region pointer is reset to
* NULL but view->tiled_region_evacuate is set to a copy of the region name.
*
* The next time desktop_arrange_all_views() causes a call to
* view_apply_region_geometry() it will try to find a new output and then
* search for a region with the same name. If found, view->tiled_region will
* be set to the new region and view->tiled_region_evacuate will be free'd.
*
* If no region with the old name is found (e.g. the user deleted or renamed
* the region in rc.xml and caused a Reconfigure) the view will be reset to
* non-tiled state and view->tiled_region_evacuate will be free'd.
*/
void regions_evacuate_output(struct output *output);
/* Free all regions in given wl_list pointer */
void regions_destroy(struct seat *seat, struct wl_list *regions);
/* Get output local region from cursor or name, may be NULL */
struct region *regions_from_cursor(struct server *server);
struct region *regions_from_name(const char *region_name, struct output *output);
void regions_show_overlay(struct view *view, struct seat *seat, struct region *region);
void regions_hide_overlay(struct seat *seat);

View file

@ -51,7 +51,7 @@ struct view {
bool maximized;
uint32_t tiled; /* private, enum view_edge in src/view.c */
/* Pointer to an output owned struct region, may be NULL or already free'd */
/* Pointer to an output owned struct region, may be NULL */
struct region *tiled_region;
/* Set to region->name when tiled_region is free'd by a destroying output */
char *tiled_region_evacuate;
@ -132,6 +132,7 @@ void view_toggle_maximize(struct view *view);
void view_toggle_decorations(struct view *view);
void view_toggle_always_on_top(struct view *view);
bool view_is_always_on_top(struct view *view);
bool view_is_tiled(struct view *view);
void view_move_to_workspace(struct view *view, struct workspace *workspace);
void view_set_decorations(struct view *view, bool decorations);
void view_toggle_fullscreen(struct view *view);