mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
overlay: take into account <core><gap> for region overlay
This commit is contained in:
parent
38e57891b5
commit
6e7c4a181e
3 changed files with 52 additions and 42 deletions
|
|
@ -504,6 +504,7 @@ enum view_edge view_edge_invert(enum view_edge edge);
|
|||
/* If view is NULL, the size of SSD is not considered */
|
||||
struct wlr_box view_get_edge_snap_box(struct view *view, struct output *output,
|
||||
enum view_edge edge);
|
||||
struct wlr_box view_get_region_snap_box(struct view *view, struct region *region);
|
||||
|
||||
/**
|
||||
* view_is_focusable() - Check whether or not a view can be focused
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ show_region_overlay(struct seat *seat, struct region *region)
|
|||
inactivate_overlay(&seat->overlay);
|
||||
seat->overlay.active.region = region;
|
||||
|
||||
show_overlay(seat, &seat->overlay.region_rect, ®ion->geo);
|
||||
struct wlr_box geo = view_get_region_snap_box(NULL, region);
|
||||
show_overlay(seat, &seat->overlay.region_rect, &geo);
|
||||
}
|
||||
|
||||
static struct wlr_box get_edge_snap_box(enum view_edge edge, struct output *output)
|
||||
|
|
|
|||
90
src/view.c
90
src/view.c
|
|
@ -1195,6 +1195,54 @@ view_apply_natural_geometry(struct view *view)
|
|||
view_move_resize(view, geometry);
|
||||
}
|
||||
|
||||
struct wlr_box
|
||||
view_get_region_snap_box(struct view *view, struct region *region)
|
||||
{
|
||||
struct wlr_box geo = region->geo;
|
||||
|
||||
/* Adjust for rc.gap */
|
||||
if (rc.gap) {
|
||||
double half_gap = rc.gap / 2.0;
|
||||
struct wlr_fbox offset = {
|
||||
.x = half_gap,
|
||||
.y = half_gap,
|
||||
.width = -rc.gap,
|
||||
.height = -rc.gap
|
||||
};
|
||||
struct wlr_box usable =
|
||||
output_usable_area_in_layout_coords(region->output);
|
||||
if (geo.x == usable.x) {
|
||||
offset.x += half_gap;
|
||||
offset.width -= half_gap;
|
||||
}
|
||||
if (geo.y == usable.y) {
|
||||
offset.y += half_gap;
|
||||
offset.height -= half_gap;
|
||||
}
|
||||
if (geo.x + geo.width == usable.x + usable.width) {
|
||||
offset.width -= half_gap;
|
||||
}
|
||||
if (geo.y + geo.height == usable.y + usable.height) {
|
||||
offset.height -= half_gap;
|
||||
}
|
||||
geo.x += offset.x;
|
||||
geo.y += offset.y;
|
||||
geo.width += offset.width;
|
||||
geo.height += offset.height;
|
||||
}
|
||||
|
||||
/* And adjust for current view */
|
||||
if (view) {
|
||||
struct border margin = ssd_get_margin(view->ssd);
|
||||
geo.x += margin.left;
|
||||
geo.y += margin.top;
|
||||
geo.width -= margin.left + margin.right;
|
||||
geo.height -= margin.top + margin.bottom;
|
||||
}
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
static void
|
||||
view_apply_region_geometry(struct view *view)
|
||||
{
|
||||
|
|
@ -1220,47 +1268,7 @@ view_apply_region_geometry(struct view *view)
|
|||
}
|
||||
}
|
||||
|
||||
/* Create a copy of the original region geometry */
|
||||
struct wlr_box geo = view->tiled_region->geo;
|
||||
|
||||
/* Adjust for rc.gap */
|
||||
if (rc.gap) {
|
||||
double half_gap = rc.gap / 2.0;
|
||||
struct wlr_fbox offset = {
|
||||
.x = half_gap,
|
||||
.y = half_gap,
|
||||
.width = -rc.gap,
|
||||
.height = -rc.gap
|
||||
};
|
||||
struct wlr_box usable =
|
||||
output_usable_area_in_layout_coords(output);
|
||||
if (geo.x == usable.x) {
|
||||
offset.x += half_gap;
|
||||
offset.width -= half_gap;
|
||||
}
|
||||
if (geo.y == usable.y) {
|
||||
offset.y += half_gap;
|
||||
offset.height -= half_gap;
|
||||
}
|
||||
if (geo.x + geo.width == usable.x + usable.width) {
|
||||
offset.width -= half_gap;
|
||||
}
|
||||
if (geo.y + geo.height == usable.y + usable.height) {
|
||||
offset.height -= half_gap;
|
||||
}
|
||||
geo.x += offset.x;
|
||||
geo.y += offset.y;
|
||||
geo.width += offset.width;
|
||||
geo.height += offset.height;
|
||||
}
|
||||
|
||||
/* And adjust for current view */
|
||||
struct border margin = ssd_get_margin(view->ssd);
|
||||
geo.x += margin.left;
|
||||
geo.y += margin.top;
|
||||
geo.width -= margin.left + margin.right;
|
||||
geo.height -= margin.top + margin.bottom;
|
||||
|
||||
struct wlr_box geo = view_get_region_snap_box(view, view->tiled_region);
|
||||
view_move_resize(view, geo);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue