[mutter/wip/wayland-stacking: 10/13] wayland: Add a hack to give focus to Wayland clients on mouse clicks



commit 6f1ce3aeb90d4abf0c86e6a52876e60cdc531794
Author: Neil Roberts <neil linux intel com>
Date:   Mon Jan 23 16:00:58 2012 +0000

    wayland: Add a hack to give focus to Wayland clients on mouse clicks
    
    The rest of the Mutter code doesn't really know about surfaces from
    Wayland clients so nothing will give them keyboard focus. This adds a
    temporary hack to give them keyboard focus whenever a button press
    event is sent to a surface with no corresponding X id.

 src/wayland/meta-wayland.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index afc85b7..bfe4343 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -1191,6 +1191,26 @@ event_cb (ClutterActor *stage,
   if (device->pointer_focus == NULL)
     meta_wayland_stage_set_default_cursor (META_WAYLAND_STAGE (stage));
 
+  /* HACK: for now, the surfaces from Wayland clients aren't
+     integrated into Mutter's stacking and Mutter won't give them
+     focus on mouse clicks. As a hack to work around this we can just
+     give them input focus on mouse clicks so we can at least test the
+     keyboard support */
+  if (event->type == CLUTTER_BUTTON_PRESS)
+    {
+      MetaWaylandSurface *surface = (MetaWaylandSurface *) device->current;
+
+      /* Only focus surfaces that wouldn't be handled by the
+         corresponding X events */
+      if (surface && surface->xid == 0)
+        {
+          wl_input_device_set_keyboard_focus (device,
+                                              (struct wl_surface *) surface,
+                                              event->any.time);
+          wl_data_device_set_keyboard_focus (device);
+        }
+    }
+
   display = meta_get_display ();
   if (!display)
     return FALSE;



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