wayland: Take scale into account when placing windows relatively
When placing a popup and the legacy transient wl_shell_surface surfaces, take the current scale of the window into account. This commit doesn't fix relative positioning in case a window scale would change, but since the use case for relative positioning is mostly popups, which would be dismissed before the parent window would be moved, it should not be that much of a problem. https://bugzilla.gnome.org/show_bug.cgi?id=744934
This commit is contained in:
parent
fbd237bc66
commit
db6caa2c49
@ -1401,11 +1401,8 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
|
||||
&surface->popup.parent_destroy_listener);
|
||||
|
||||
window = meta_window_wayland_new (display, surface);
|
||||
meta_window_move_frame (window, FALSE,
|
||||
parent_surf->window->buffer_rect.x + x,
|
||||
parent_surf->window->buffer_rect.y + y);
|
||||
meta_window_wayland_place_relative_to (window, parent_surf->window, x, y);
|
||||
window->showing_for_first_time = FALSE;
|
||||
window->placed = TRUE;
|
||||
|
||||
meta_wayland_surface_set_window (surface, window);
|
||||
|
||||
@ -1569,10 +1566,9 @@ wl_shell_surface_set_transient (struct wl_client *client,
|
||||
wl_shell_surface_set_state (surface, SURFACE_STATE_TOPLEVEL);
|
||||
|
||||
meta_window_set_transient_for (surface->window, parent_surf->window);
|
||||
meta_window_move_frame (surface->window, FALSE,
|
||||
parent_surf->window->rect.x + x,
|
||||
parent_surf->window->rect.y + y);
|
||||
surface->window->placed = TRUE;
|
||||
meta_window_wayland_place_relative_to (surface->window,
|
||||
parent_surf->window,
|
||||
x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1621,10 +1617,9 @@ wl_shell_surface_set_popup (struct wl_client *client,
|
||||
}
|
||||
|
||||
meta_window_set_transient_for (surface->window, parent_surf->window);
|
||||
meta_window_move_frame (surface->window, FALSE,
|
||||
parent_surf->window->rect.x + x,
|
||||
parent_surf->window->rect.y + y);
|
||||
surface->window->placed = TRUE;
|
||||
meta_window_wayland_place_relative_to (surface->window,
|
||||
parent_surf->window,
|
||||
x, y);
|
||||
|
||||
if (!surface->popup.parent)
|
||||
{
|
||||
|
@ -595,3 +595,24 @@ meta_window_wayland_move_resize (MetaWindow *window,
|
||||
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_wayland_place_relative_to (MetaWindow *window,
|
||||
MetaWindow *other,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int monitor_scale;
|
||||
|
||||
/* If there is no monitor, we can't position the window reliably. */
|
||||
if (!other->monitor)
|
||||
return;
|
||||
|
||||
/* Scale the relative coordinate (x, y) from logical pixels to physical
|
||||
* pixels. */
|
||||
monitor_scale = other->monitor->scale;
|
||||
meta_window_move_frame (window, FALSE,
|
||||
other->buffer_rect.x + (x * monitor_scale),
|
||||
other->buffer_rect.y + (y * monitor_scale));
|
||||
window->placed = TRUE;
|
||||
}
|
||||
|
@ -52,4 +52,9 @@ void meta_window_wayland_move_resize (MetaWindow *window,
|
||||
int dy);
|
||||
int meta_window_wayland_get_main_monitor_scale (MetaWindow *window);
|
||||
|
||||
void meta_window_wayland_place_relative_to (MetaWindow *window,
|
||||
MetaWindow *other,
|
||||
int x,
|
||||
int y);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user