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:
Jonas Ådahl
2015-03-25 14:39:30 +08:00
parent fbd237bc66
commit db6caa2c49
3 changed files with 33 additions and 12 deletions

View File

@@ -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;
}