[PATCH] dix: deliver attached slave device's keyboard events to the master's focus

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 15 22:23:45 PDT 2013


Tricky one.

The protocol spec specifically states:
- if the SD is attached to a master keyboard, it sends events to this
  keyboard's focus window (if applicable) and/or changes the modifier state
  of this keyboard.

Except that the actual behavior of the keyboard since 1.7 was that SDs have
a separate keyboard focus whether attached or not. That focus by default is
PointerRoot, unless set otherwise. So fixing this means we may actually
break applications - if there are any that use this, I don't actually know.

I'm actually contemplating changing the spec to reflect the server behavior
we've had since 1.7 than fixing this, but here's the patch anyway.

To make the behavior consistent we'd need to extend XISetFocus to return
BadDevice when trying to set a
---
 dix/events.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index ed3138d..825cb8b 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4039,13 +4039,17 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
 void
 DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
 {
-    DeviceIntPtr ptr;
-    WindowPtr focus = keybd->focus->win;
+    DeviceIntPtr ptr, kbd;
+    WindowPtr focus;
     BOOL sendCore = (IsMaster(keybd) && keybd->coreEvents);
     xEvent *core = NULL, *xE = NULL, *xi2 = NULL;
     int count, rc;
     int deliveries = 0;
 
+    kbd = GetMaster(keybd, KEYBOARD_OR_FLOAT);
+    BUG_RETURN(!kbd->focus);
+    focus = kbd->focus->win;
+
     if (focus == FollowKeyboardWin)
         focus = inputInfo.keyboard->focus->win;
     if (!focus)
-- 
1.8.2.1



More information about the xorg-devel mailing list