mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
SnapToRegion: Wire up output and handle usable_area changes
This commit is contained in:
parent
43fe138385
commit
67952cd749
3 changed files with 42 additions and 2 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "common/graphic-helpers.h"
|
||||
#include "common/list.h"
|
||||
#include "common/mem.h"
|
||||
#include "labwc.h"
|
||||
#include "regions.h"
|
||||
|
|
@ -27,7 +28,34 @@ regions_init(struct server *server, struct seat *seat)
|
|||
void
|
||||
regions_update(struct output *output)
|
||||
{
|
||||
/* To be filled later */
|
||||
assert(output);
|
||||
|
||||
struct region *region;
|
||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
||||
|
||||
/* Initialize regions */
|
||||
if (wl_list_empty(&output->regions)) {
|
||||
wl_list_for_each(region, &rc.regions, link) {
|
||||
struct region *region_new = znew(*region_new);
|
||||
/* Create a copy */
|
||||
region_new->name = xstrdup(region->name);
|
||||
region_new->percentage = region->percentage;
|
||||
wl_list_append(&output->regions, ®ion_new->link);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update regions */
|
||||
struct wlr_box *perc, *geo;
|
||||
wl_list_for_each(region, &output->regions, link) {
|
||||
geo = ®ion->geo;
|
||||
perc = ®ion->percentage;
|
||||
geo->x = usable.x + usable.width * perc->x / 100;
|
||||
geo->y = usable.y + usable.height * perc->y / 100;
|
||||
geo->width = usable.width * perc->width / 100;
|
||||
geo->height = usable.height * perc->height / 100;
|
||||
region->center.x = geo->x + geo->width / 2;
|
||||
region->center.y = geo->y + geo->height / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue