[mutter] backends/native: Move pause/resume handling to backend



commit cf6b7bcb796bf8d5078b27e9b981cbbe56ab4961
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Mar 10 13:55:33 2017 +0800

    backends/native: Move pause/resume handling to backend
    
    Move the handling of pause/resume events from the launcher to the
    backend.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779837

 src/backends/native/meta-backend-native.c |   35 +++++++++++++++++++++++
 src/backends/native/meta-backend-native.h |    4 ++
 src/backends/native/meta-launcher.c       |   44 +++-------------------------
 3 files changed, 44 insertions(+), 39 deletions(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 83060d1..22312d7 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -31,6 +31,8 @@
 #include <clutter/evdev/clutter-evdev.h>
 #include <libupower-glib/upower.h>
 
+#include "clutter/egl/clutter-egl.h"
+#include "clutter/evdev/clutter-evdev.h"
 #include "meta-barrier-native.h"
 #include "meta-idle-monitor-native.h"
 #include "meta-monitor-manager-kms.h"
@@ -531,3 +533,36 @@ meta_activate_session (void)
 
   return TRUE;
 }
+
+void
+meta_backend_native_pause (MetaBackendNative *native)
+{
+  clutter_evdev_release_devices ();
+  clutter_egl_freeze_master_clock ();
+}
+
+void meta_backend_native_resume (MetaBackendNative *native)
+{
+  MetaBackend *backend = META_BACKEND (native);
+  MetaRenderer *renderer;
+  MetaCursorRenderer *cursor_renderer;
+  MetaCursorRendererNative *cursor_renderer_native;
+  ClutterActor *stage;
+  MetaIdleMonitor *idle_monitor;
+
+  renderer = meta_backend_get_renderer (backend);
+  meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
+
+  clutter_evdev_reclaim_devices ();
+  clutter_egl_thaw_master_clock ();
+
+  stage = meta_backend_get_stage (backend);
+  clutter_actor_queue_redraw (stage);
+
+  cursor_renderer = meta_backend_get_cursor_renderer (backend);
+  cursor_renderer_native = META_CURSOR_RENDERER_NATIVE (cursor_renderer);
+  meta_cursor_renderer_native_force_update (cursor_renderer_native);
+
+  idle_monitor = meta_backend_get_idle_monitor (backend, 0);
+  meta_idle_monitor_native_reset_idletime (idle_monitor);
+}
diff --git a/src/backends/native/meta-backend-native.h b/src/backends/native/meta-backend-native.h
index 08e48d7..3ba57a0 100644
--- a/src/backends/native/meta-backend-native.h
+++ b/src/backends/native/meta-backend-native.h
@@ -34,4 +34,8 @@ G_DECLARE_FINAL_TYPE (MetaBackendNative, meta_backend_native,
 
 gboolean meta_activate_vt (int vt, GError **error);
 
+void meta_backend_native_pause (MetaBackendNative *backend_native);
+
+void meta_backend_native_resume (MetaBackendNative *backend_native);
+
 #endif /* META_BACKEND_NATIVE_H */
diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c
index b93a172..4a9a727 100644
--- a/src/backends/native/meta-launcher.c
+++ b/src/backends/native/meta-launcher.c
@@ -24,7 +24,6 @@
 #include <gio/gunixfdlist.h>
 
 #include <clutter/clutter.h>
-#include <clutter/egl/clutter-egl.h>
 #include <clutter/evdev/clutter-evdev.h>
 
 #include <sys/types.h>
@@ -43,6 +42,7 @@
 #include "meta-dbus-login1.h"
 
 #include "backends/meta-backend-private.h"
+#include "backends/native/meta-backend-native.h"
 #include "meta-cursor-renderer-native.h"
 #include "meta-idle-monitor-native.h"
 #include "meta-renderer-native.h"
@@ -110,42 +110,6 @@ get_seat_proxy (GCancellable *cancellable,
   return seat;
 }
 
-static void
-session_unpause (void)
-{
-  MetaBackend *backend;
-  MetaRenderer *renderer;
-
-  backend = meta_get_backend ();
-  renderer = meta_backend_get_renderer (backend);
-  meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
-
-  clutter_evdev_reclaim_devices ();
-  clutter_egl_thaw_master_clock ();
-
-  {
-    MetaBackend *backend = meta_get_backend ();
-    MetaCursorRendererNative *cursor_renderer_native =
-      META_CURSOR_RENDERER_NATIVE (meta_backend_get_cursor_renderer (backend));
-    ClutterActor *stage = meta_backend_get_stage (backend);
-
-    /* When we mode-switch back, we need to immediately queue a redraw
-     * in case nothing else queued one for us, and force the cursor to
-     * update. */
-
-    clutter_actor_queue_redraw (stage);
-    meta_cursor_renderer_native_force_update (cursor_renderer_native);
-    meta_idle_monitor_native_reset_idletime (meta_idle_monitor_get_core ());
-  }
-}
-
-static void
-session_pause (void)
-{
-  clutter_evdev_release_devices ();
-  clutter_egl_freeze_master_clock ();
-}
-
 static gboolean
 take_device (Login1Session *session_proxy,
              int            dev_major,
@@ -281,6 +245,8 @@ out:
 static void
 sync_active (MetaLauncher *self)
 {
+  MetaBackend *backend = meta_get_backend ();
+  MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
   gboolean active = login1_session_get_active (LOGIN1_SESSION (self->session_proxy));
 
   if (active == self->session_active)
@@ -289,9 +255,9 @@ sync_active (MetaLauncher *self)
   self->session_active = active;
 
   if (active)
-    session_unpause ();
+    meta_backend_native_resume (backend_native);
   else
-    session_pause ();
+    meta_backend_native_pause (backend_native);
 }
 
 static void


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