[mutter] backend: Ensure the backend gets notified of monitor state having changed



commit d7b87799c84099ccce60840a2271b882e05cac24
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Jul 6 15:27:45 2016 +0800

    backend: Ensure the backend gets notified of monitor state having changed
    
    Being a listener to a signal, it is inconvenient to enforce order of
    execution between different signal listeners. If there are things in
    the backend that should be updated before various other signal
    handlers, make sure so is done by emitting the signal after having
    explicitly notified the backend.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768976

 src/backends/meta-backend-private.h |    2 ++
 src/backends/meta-backend.c         |   13 ++++++-------
 src/backends/meta-monitor-manager.c |    8 ++++++++
 3 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index 08b2499..5c65ff9 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 2ad6b84..1889fdb 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 e00d3ce..8fb79fc 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]