From 6feb0f9f55a8bb02b48fc185775cc1cba3db2510 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 15 Apr 2015 12:23:56 -0500 Subject: desktop-shell: use work area instead of panel size to constrain moves This fixes the case where an output isn't at y = 0, where the panel height isn't correct for constraints. It also kills a bug - moving a window with a mod-drag off the top of the screen clamped earlier than it should. Signed-off-by: Derek Foreman Reviewed-by: Bryce Harrington --- desktop-shell/shell.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'desktop-shell') diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 35f719b6..0137ca31 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1668,24 +1668,27 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy) { struct shell_surface *shsurf = move->base.shsurf; struct weston_pointer *pointer = move->base.grab.pointer; - int x, y, panel_width, panel_height, bottom; + int x, y, bottom; const int safety = 50; + pixman_rectangle32_t area; x = wl_fixed_to_int(pointer->x + move->dx); y = wl_fixed_to_int(pointer->y + move->dy); if (shsurf->shell->panel_position == DESKTOP_SHELL_PANEL_POSITION_TOP) { - get_output_panel_size(shsurf->shell, shsurf->surface->output, - &panel_width, &panel_height); + get_output_work_area(shsurf->shell, + shsurf->surface->output, + &area); - bottom = y + shsurf->geometry.height; - if (bottom - panel_height < safety) - y = panel_height + safety - - shsurf->geometry.height; + bottom = y + shsurf->geometry.height + shsurf->geometry.y; + if (bottom - safety < area.y) + y = area.y + safety - shsurf->geometry.height + - shsurf->geometry.y; if (move->client_initiated && - y + shsurf->geometry.y < panel_height) - y = panel_height - shsurf->geometry.y; + y + shsurf->geometry.y < area.y) + y = area.y - shsurf->geometry.y; + } *cx = x; -- cgit v1.2.1