diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h index 08b249924..5c65ff969 100644 --- a/src/backends/meta-backend-private.h +++ b/src/backends/meta-backend-private.h @@ -142,4 +142,6 @@ void meta_backend_set_client_pointer_constraint (MetaBackend *backend, ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend); +void meta_backend_monitors_changed (MetaBackend *backend); + #endif /* META_BACKEND_PRIVATE_H */ diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 2ad6b8445..1889fdb94 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -116,11 +116,11 @@ center_pointer (MetaBackend *backend) primary->rect.y + primary->rect.height / 2); } -static void -on_monitors_changed (MetaMonitorManager *monitors, - gpointer user_data) +void +meta_backend_monitors_changed (MetaBackend *backend) { - MetaBackend *backend = META_BACKEND (user_data); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); ClutterDeviceManager *manager = clutter_device_manager_get_default (); ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE); ClutterPoint point; @@ -130,7 +130,8 @@ on_monitors_changed (MetaMonitorManager *monitors, if (clutter_input_device_get_coords (device, NULL, &point)) { /* If we're outside all monitors, warp the pointer back inside */ - if (meta_monitor_manager_get_monitor_at_point (monitors, point.x, point.y) < 0) + if (meta_monitor_manager_get_monitor_at_point (monitor_manager, + point.x, point.y) < 0) center_pointer (backend); } } @@ -278,8 +279,6 @@ meta_backend_real_post_init (MetaBackend *backend) priv->monitor_manager = create_monitor_manager (backend); - g_signal_connect (priv->monitor_manager, "monitors-changed", - G_CALLBACK (on_monitors_changed), backend); meta_backend_sync_screen_size (backend); priv->cursor_renderer = META_BACKEND_GET_CLASS (backend)->create_cursor_renderer (backend); diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index e00d3cedd..8fb79fc61 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1379,6 +1379,7 @@ meta_monitor_manager_read_current_config (MetaMonitorManager *manager) void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager) { + MetaBackend *backend = meta_get_backend (); MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_GET_CLASS (manager); MetaMonitorInfo *old_monitor_infos; unsigned old_n_monitor_infos; @@ -1408,6 +1409,13 @@ meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager) manager_class->delete_monitor (manager, old_monitor_infos[i].monitor_winsys_xid); } } + + /* Tell the backend about that the monitors changed before emitting the + * signal, so that the backend can prepare itself before all the signal + * consumers. + */ + meta_backend_monitors_changed (backend); + g_signal_emit_by_name (manager, "monitors-changed"); g_free (old_monitor_infos);