From: tokyo4j Date: Sat, 5 Jul 2025 07:06:38 +0000 (+0900) Subject: overlay: take into account for edge overlay X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=38e57891b5df3e7d9293baf9e73e3f505e4f5467;p=proto%2Flabwc.git overlay: take into account for edge overlay This also deduplicates get_edge_snap_box() in interactive.c and view_get_edge_snap_box() in view.c. --- diff --git a/include/labwc.h b/include/labwc.h index feae372e..0cfdce19 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -429,7 +429,6 @@ void interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo); void interactive_begin(struct view *view, enum input_mode mode, uint32_t edges); void interactive_finish(struct view *view); void interactive_cancel(struct view *view); -/* Possibly returns VIEW_EDGE_CENTER if is yes */ enum view_edge edge_from_cursor(struct seat *seat, struct output **dest_output); void handle_tearing_new_object(struct wl_listener *listener, void *data); diff --git a/include/view.h b/include/view.h index 5e1c5baf..04ed7d64 100644 --- a/include/view.h +++ b/include/view.h @@ -501,6 +501,10 @@ bool view_contains_window_type(struct view *view, enum window_type window_type); */ 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); + /** * view_is_focusable() - Check whether or not a view can be focused * @view: view to be checked diff --git a/src/interactive.c b/src/interactive.c index f6fd5450..15b4323d 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -195,11 +195,7 @@ edge_from_cursor(struct seat *seat, struct output **dest_output) } else if (cursor_x >= area->x + area->width - snap_range) { return VIEW_EDGE_RIGHT; } else if (cursor_y <= area->y + snap_range) { - if (rc.snap_top_maximize) { - return VIEW_EDGE_CENTER; - } else { - return VIEW_EDGE_UP; - } + return VIEW_EDGE_UP; } else if (cursor_y >= area->y + area->height - snap_range) { return VIEW_EDGE_DOWN; } else { @@ -223,7 +219,7 @@ snap_to_edge(struct view *view) * Don't store natural geometry here (it was * stored already in interactive_begin()) */ - if (edge == VIEW_EDGE_CENTER) { + if (edge == VIEW_EDGE_UP && rc.snap_top_maximize) { /* */ view_maximize(view, VIEW_AXIS_BOTH, /*store_natural_geometry*/ false); diff --git a/src/overlay.c b/src/overlay.c index 4b1c33cd..3424f160 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -114,31 +114,13 @@ show_region_overlay(struct seat *seat, struct region *region) show_overlay(seat, &seat->overlay.region_rect, ®ion->geo); } -/* TODO: share logic with view_get_edge_snap_box() */ static struct wlr_box get_edge_snap_box(enum view_edge edge, struct output *output) { - struct wlr_box box = output_usable_area_in_layout_coords(output); - switch (edge) { - case VIEW_EDGE_RIGHT: - box.x += box.width / 2; - /* fallthrough */ - case VIEW_EDGE_LEFT: - box.width /= 2; - break; - case VIEW_EDGE_DOWN: - box.y += box.height / 2; - /* fallthrough */ - case VIEW_EDGE_UP: - box.height /= 2; - break; - case VIEW_EDGE_CENTER: - /* */ - break; - default: - /* not reached */ - assert(false); + if (edge == VIEW_EDGE_UP && rc.snap_top_maximize) { + return output_usable_area_in_layout_coords(output); + } else { + return view_get_edge_snap_box(NULL, output, edge); } - return box; } static int diff --git a/src/view.c b/src/view.c index d6ac89b9..2f6e6277 100644 --- a/src/view.c +++ b/src/view.c @@ -440,7 +440,7 @@ view_edge_invert(enum view_edge edge) } } -static struct wlr_box +struct wlr_box view_get_edge_snap_box(struct view *view, struct output *output, enum view_edge edge) { @@ -469,14 +469,21 @@ view_get_edge_snap_box(struct view *view, struct output *output, break; } - struct border margin = ssd_get_margin(view->ssd); struct wlr_box dst = { - .x = x_offset + usable.x + margin.left, - .y = y_offset + usable.y + margin.top, - .width = base_width - margin.left - margin.right, - .height = base_height - margin.top - margin.bottom, + .x = x_offset + usable.x, + .y = y_offset + usable.y, + .width = base_width, + .height = base_height, }; + if (view) { + struct border margin = ssd_get_margin(view->ssd); + dst.x += margin.left; + dst.y += margin.top; + dst.width -= margin.left + margin.right; + dst.height -= margin.top + margin.bottom; + } + return dst; }