[clutter/wip/wayland-for-demo: 15/15] paused part 2



commit beda44f828c9d8e27e404b7eda937384e55ea016
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 3 12:41:48 2014 -0500

    paused part 2

 clutter/evdev/clutter-device-manager-evdev.c |  101 +++++++-------------------
 clutter/evdev/clutter-evdev.h                |    6 +-
 2 files changed, 27 insertions(+), 80 deletions(-)
---
diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c
index a639502..eb1d7ae 100644
--- a/clutter/evdev/clutter-device-manager-evdev.c
+++ b/clutter/evdev/clutter-device-manager-evdev.c
@@ -94,7 +94,6 @@ struct _ClutterDeviceManagerEvdevPrivate
   struct libinput *libinput;
 
   ClutterStage *stage;
-  gboolean released;
 
   ClutterEventSource *event_source;
 
@@ -120,6 +119,8 @@ static ClutterOpenDeviceCallback  open_callback;
 static ClutterCloseDeviceCallback close_callback;
 static gpointer                   open_callback_data;
 
+static gboolean _paused = FALSE;
+
 static const char *device_type_str[] = {
   "pointer",            /* CLUTTER_POINTER_DEVICE */
   "keyboard",           /* CLUTTER_KEYBOARD_DEVICE */
@@ -1155,6 +1156,19 @@ static const struct libinput_interface libinput_interface = {
   close_restricted
 };
 
+static void
+clutter_device_manager_evdev_sync_paused (ClutterDeviceManagerEvdev *manager)
+{
+  ClutterDeviceManagerEvdevPrivate *priv = manager->priv;
+
+  if (_paused)
+    libinput_suspend (priv->libinput);
+  else
+    libinput_resume (priv->libinput);
+
+  process_events (manager);
+}
+
 /*
  * GObject implementation
  */
@@ -1189,6 +1203,7 @@ clutter_device_manager_evdev_constructed (GObject *gobject)
       return;
     }
 
+  clutter_device_manager_evdev_sync_paused (manager_evdev);
   dispatch_libinput (manager_evdev);
 
   g_assert (priv->main_seat != NULL);
@@ -1377,85 +1392,19 @@ _clutter_events_evdev_uninit (ClutterBackend *backend)
   CLUTTER_NOTE (EVENT, "Uninitializing evdev backend");
 }
 
-/**
- * clutter_evdev_release_devices:
- *
- * Releases all the evdev devices that Clutter is currently managing. This api
- * is typically used when switching away from the Clutter application when
- * switching tty. The devices can be reclaimed later with a call to
- * clutter_evdev_reclaim_devices().
- *
- * This function should only be called after clutter has been initialized.
- *
- * Since: 1.10
- * Stability: unstable
- */
-void
-clutter_evdev_release_devices (void)
-{
-  ClutterDeviceManager *manager = clutter_device_manager_get_default ();
-  ClutterDeviceManagerEvdev *manager_evdev;
-  ClutterDeviceManagerEvdevPrivate *priv;
-
-  if (!manager)
-    {
-      g_warning ("clutter_evdev_release_devices shouldn't be called "
-                 "before clutter_init()");
-      return;
-    }
-
-  g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER_EVDEV (manager));
-
-  manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (manager);
-  priv = manager_evdev->priv;
-
-  if (priv->released)
-    {
-      g_warning ("clutter_evdev_release_devices() shouldn't be called "
-                 "multiple times without a corresponding call to "
-                 "clutter_evdev_reclaim_devices() first");
-      return;
-    }
-
-  libinput_suspend (priv->libinput);
-  process_events (manager_evdev);
-
-  priv->released = TRUE;
-}
-
-/**
- * clutter_evdev_reclaim_devices:
- *
- * This causes Clutter to re-probe for evdev devices. This is must only be
- * called after a corresponding call to clutter_evdev_release_devices()
- * was previously used to release all evdev devices. This API is typically
- * used when a clutter application using evdev has regained focus due to
- * switching ttys.
- *
- * This function should only be called after clutter has been initialized.
- *
- * Since: 1.10
- * Stability: unstable
- */
 void
-clutter_evdev_reclaim_devices (void)
+clutter_evdev_set_paused (gboolean paused)
 {
-  ClutterDeviceManager *manager = clutter_device_manager_get_default ();
-  ClutterDeviceManagerEvdev *manager_evdev =
-    CLUTTER_DEVICE_MANAGER_EVDEV (manager);
-  ClutterDeviceManagerEvdevPrivate *priv = manager_evdev->priv;
-
-  if (!priv->released)
-    {
-      g_warning ("Spurious call to clutter_evdev_reclaim_devices() without "
-                 "previous call to clutter_evdev_release_devices");
-      return;
-    }
+  if (_paused == paused)
+    return;
 
-  libinput_resume (priv->libinput);
-  process_events (manager_evdev);
+  _paused = paused;
 
-  priv->released = FALSE;
+  {
+    ClutterDeviceManager *manager = clutter_device_manager_get_default ();
+    if (manager)
+      clutter_device_manager_evdev_sync_paused (CLUTTER_DEVICE_MANAGER_EVDEV (manager));
+  }
 }
 
 /**
diff --git a/clutter/evdev/clutter-evdev.h b/clutter/evdev/clutter-evdev.h
index beed9fa..5603b6e 100644
--- a/clutter/evdev/clutter-evdev.h
+++ b/clutter/evdev/clutter-evdev.h
@@ -56,10 +56,8 @@ void  clutter_evdev_set_open_callback (ClutterOpenDeviceCallback  open_callback,
                                        ClutterCloseDeviceCallback close_callback,
                                        gpointer                   user_data);
 
-CLUTTER_AVAILABLE_IN_1_10
-void  clutter_evdev_release_devices (void);
-CLUTTER_AVAILABLE_IN_1_10
-void  clutter_evdev_reclaim_devices (void);
+CLUTTER_AVAILABLE_IN_1_18
+void  clutter_evdev_set_paused (gboolean paused);
 
 /**
  * ClutterPointerConstrainCallback:


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