[PATCH 3/3] XWayland: Use FocusIn events for keyboard enter

Daniel Stone daniels at collabora.com
Mon Nov 24 14:17:34 PST 2014


wl_keyboard::enter is the equivalent of FocusIn + KeymapNotify: it
notifies us that the surface/window has now received the focus, and
provides us a set of keys which are currently down.

We should use these keys to update the current state, but not to send
any events to clients.

Signed-off-by: Daniel Stone <daniels at collabora.com>
Tested-by: Giulio Camuffo <giuliocamuffo at gmail.com>
---
 hw/xwayland/xwayland-input.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index b8c543c..c6a9c43 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -397,7 +397,7 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
     wl_array_copy(&xwl_seat->keys, keys);
     valuator_mask_zero(&mask);
     wl_array_for_each(k, &xwl_seat->keys)
-        QueueKeyboardEvents(xwl_seat->keyboard, KeyPress, *k + 8, &mask);
+        QueueKeyboardEvents(xwl_seat->keyboard, KeymapNotify, *k + 8, &mask);
 }
 
 static void
@@ -410,6 +410,11 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
 
     xwl_seat->xwl_screen->serial = serial;
 
+    /* Unlike keyboard_handle_enter() above, this time we _do_ want to trigger
+     * full release, as we don't know how long we'll be out of focus for.
+     * Notify clients that the keys have been released, disable autorepeat,
+     * etc. */
+
     valuator_mask_zero(&mask);
     wl_array_for_each(k, &xwl_seat->keys)
         QueueKeyboardEvents(xwl_seat->keyboard, KeyRelease, *k + 8, &mask);
-- 
2.1.0



More information about the xorg-devel mailing list