summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wayland/meta-wayland-surface.c19
-rw-r--r--src/wayland/meta-window-wayland.c21
-rw-r--r--src/wayland/meta-window-wayland.h5
3 files changed, 33 insertions, 12 deletions
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 51bcf3817..e352e07ce 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -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)
{
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 10a006d52..e3323419d 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -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;
+}
diff --git a/src/wayland/meta-window-wayland.h b/src/wayland/meta-window-wayland.h
index c57b45da6..9287db8de 100644
--- a/src/wayland/meta-window-wayland.h
+++ b/src/wayland/meta-window-wayland.h
@@ -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