view: ensure that floating views don't overlap top panels

The top_left_edge_boundary_check() function in xwayland.c ensures that
views trying to position themselves at 0,0 don't end up with a titlebar
offscreen. However, it doesn't take into account the usable area and
thus these views can still end up overlapping a top panel.

Also, there is no good reason for top_left_edge_boundary_check() to be
xwayland-specific. This logic should really be part of
view_adjust_for_layout_change().

To fix all this, add a new view_adjust_floating_geometry() function,
which replaces the existing similar (and duplicated) logic in
view_apply_natural_geometry() and view_adjust_for_layout_change().

view_adjust_for_layout_change() is already being called from xwayland's
set_initial_position(), so top_left_edge_boundary_check() is now
redundant and can just be deleted.

Lightly tested with waybar and feh --geometry 640x480+0+0. The feh
window is now correctly positioned below waybar, even if started before
waybar (in that case, the feh window is moved when waybar starts).
This commit is contained in:
John Lindgren 2023-11-03 12:38:07 -04:00 committed by Johan Malm
parent 984aeb0b0b
commit 57075ce864
3 changed files with 49 additions and 33 deletions

View file

@ -480,19 +480,6 @@ set_initial_position(struct view *view,
}
}
static void
top_left_edge_boundary_check(struct view *view)
{
struct wlr_box deco = ssd_max_extents(view);
if (deco.x < 0) {
view->current.x -= deco.x;
}
if (deco.y < 0) {
view->current.y -= deco.y;
}
view->impl->configure(view, view->current);
}
static void
init_foreign_toplevel(struct view *view)
{
@ -589,10 +576,6 @@ xwayland_view_map(struct view *view)
view_moved(view);
}
if (view->ssd_enabled && view_is_floating(view)) {
top_left_edge_boundary_check(view);
}
/* Add commit here, as xwayland map/unmap can change the wlr_surface */
wl_signal_add(&xwayland_surface->surface->events.commit, &view->commit);
view->commit.notify = handle_commit;