mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
wayland/window: Update toplevel main monitor before non-toplevel
When updating the main monitor, make sure to update the toplevel main monitor before trying to use that as the main monitor for non-toplevel windows (such as popups). Without this, when the main monitor is updated as a side effect to monitors being changed (for example due to a hot plug event, or coming back from being suspended) the main monitor pointer may, after 'monitors-changed' has completed, point to freed memory resulting in undefined behaviour. https://bugzilla.gnome.org/show_bug.cgi?id=784867
This commit is contained in:
parent
408292959e
commit
4afa66fe41
@ -531,7 +531,8 @@ struct _MetaWindowClass
|
||||
cairo_surface_t **icon,
|
||||
cairo_surface_t **mini_icon);
|
||||
uint32_t (*get_client_pid) (MetaWindow *window);
|
||||
void (*update_main_monitor) (MetaWindow *window);
|
||||
void (*update_main_monitor) (MetaWindow *window,
|
||||
gboolean user_op);
|
||||
void (*main_monitor_changed) (MetaWindow *window,
|
||||
const MetaLogicalMonitor *old);
|
||||
};
|
||||
|
@ -3603,7 +3603,7 @@ meta_window_update_monitor (MetaWindow *window,
|
||||
const MetaLogicalMonitor *old;
|
||||
|
||||
old = window->monitor;
|
||||
META_WINDOW_GET_CLASS (window)->update_main_monitor (window);
|
||||
META_WINDOW_GET_CLASS (window)->update_main_monitor (window, user_op);
|
||||
if (old != window->monitor)
|
||||
{
|
||||
meta_window_on_all_workspaces_changed (window);
|
||||
|
@ -350,7 +350,8 @@ scale_rect_size (MetaRectangle *rect,
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_wayland_update_main_monitor (MetaWindow *window)
|
||||
meta_window_wayland_update_main_monitor (MetaWindow *window,
|
||||
gboolean user_op)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
@ -370,6 +371,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window)
|
||||
toplevel_window = meta_wayland_surface_get_toplevel_window (window->surface);
|
||||
if (toplevel_window != window)
|
||||
{
|
||||
meta_window_update_monitor (toplevel_window, user_op);
|
||||
window->monitor = toplevel_window->monitor;
|
||||
return;
|
||||
}
|
||||
|
@ -1456,7 +1456,8 @@ meta_window_x11_update_icon (MetaWindow *window,
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_x11_update_main_monitor (MetaWindow *window)
|
||||
meta_window_x11_update_main_monitor (MetaWindow *window,
|
||||
gboolean user_op)
|
||||
{
|
||||
window->monitor = meta_window_calculate_main_logical_monitor (window);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user