[mutter/wip/wayland-2: 5/5] wayland: add input device handling too



commit f898273a65ae84aa79fc7c376f6354225a0e05fc
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Mon Jul 15 18:39:32 2013 +0200

    wayland: add input device handling too
    
    Use the new hook in clutter-evdev to ask weston-launch for the
    FDs of the input devices we need.

 src/wayland/meta-wayland.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index effda25..0be9c3c 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -24,6 +24,7 @@
 #include <clutter/clutter.h>
 #include <clutter/wayland/clutter-wayland-compositor.h>
 #include <clutter/wayland/clutter-wayland-surface.h>
+#include <clutter/evdev/clutter-evdev.h>
 
 #include <glib.h>
 #include <sys/time.h>
@@ -1756,6 +1757,8 @@ on_our_vt_enter (MetaTTY               *tty,
       g_warning ("Failed to become DRM master: %s", error->message);
       g_error_free (error);
     }
+
+  clutter_evdev_reclaim_devices ();
 }
 
 static void
@@ -1772,7 +1775,19 @@ on_our_vt_leave (MetaTTY               *tty,
       g_error_free (error);
     }
 
-  /* FIXME: we must release input devices as well! */
+  clutter_evdev_release_devices ();
+}
+
+static int
+on_evdev_device_open (const char  *path,
+                     int          flags,
+                     gpointer     user_data,
+                     GError     **error)
+{
+  MetaWaylandCompositor *compositor = user_data;
+
+  return meta_weston_launch_open_input_device (compositor->weston_launch,
+                                              path, flags, error);
 }
 
 void
@@ -1783,6 +1798,7 @@ meta_wayland_init (void)
   ClutterBackend *backend;
   CoglContext *cogl_context;
   CoglRenderer *cogl_renderer;
+  int weston_launch_fd;
 
   memset (compositor, 0, sizeof (MetaWaylandCompositor));
 
@@ -1819,6 +1835,13 @@ meta_wayland_init (void)
 
   clutter_wayland_set_compositor_display (compositor->wayland_display);
 
+  /* We need to set this before clutter_init(), so we do it unconditionally.
+     It doesn't harm anyway to do it under X11 */
+  weston_launch_fd = env_get_fd ("WESTON_LAUNCHER_SOCK");
+  if (weston_launch_fd >= 0)
+    compositor->weston_launch = g_socket_new_from_fd (weston_launch_fd, NULL);
+  clutter_evdev_set_open_callback (on_evdev_device_open, compositor);
+
   if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
     g_error ("Failed to initialize Clutter");
 
@@ -1834,12 +1857,6 @@ meta_wayland_init (void)
   if (compositor->drm_fd >= 0)
     {
       /* Running on bare metal, let's initalize DRM master and VT handling */
-      int weston_launch_fd;
-
-      weston_launch_fd = env_get_fd ("WESTON_LAUNCHER_SOCK");
-      if (weston_launch_fd >= 0)
-       compositor->weston_launch = g_socket_new_from_fd (weston_launch_fd, NULL);
-
       compositor->tty = meta_tty_new ();
       if (compositor->tty)
        {


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