diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index e9223a9a2..591a1ed6c 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -1463,6 +1463,7 @@ xdg_surface_constructor_get_toplevel (struct wl_client *client, window = meta_window_wayland_new (meta_get_display (), surface); meta_wayland_surface_set_window (surface, window); + meta_window_update_monitor (window, FALSE); } static void diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 1b3e0909b..fd630ca74 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -334,19 +334,31 @@ scale_rect_size (MetaRectangle *rect, static void meta_window_wayland_update_main_monitor (MetaWindow *window) { + MetaWindow *toplevel_window; const MetaMonitorInfo *from; const MetaMonitorInfo *to; const MetaMonitorInfo *scaled_new; float scale; MetaRectangle rect; - /* Require both the current and the new monitor would be the new main monitor, - * even given the resulting scale the window would end up having. This is - * needed to avoid jumping back and forth between the new and the old, since - * changing main monitor may cause the window to be resized so that it no - * longer have that same new main monitor. */ from = window->monitor; - to = meta_screen_calculate_monitor_for_window (window->screen, window); + + /* If the window is not a toplevel window (i.e. it's a popup window) just use + * the monitor of the toplevel. */ + toplevel_window = meta_wayland_surface_get_toplevel_window (window->surface); + if (toplevel_window != window) + { + to = toplevel_window->monitor; + } + else + { + /* Require both the current and the new monitor would be the new main monitor, + * even given the resulting scale the window would end up having. This is + * needed to avoid jumping back and forth between the new and the old, since + * changing main monitor may cause the window to be resized so that it no + * longer have that same new main monitor. */ + to = meta_screen_calculate_monitor_for_window (window->screen, window); + } if (from == to) return;