[PATCH] xkb: if the button isn't down, don't fake an event.

Peter Hutterer peter.hutterer at who-t.net
Thu Jul 22 20:26:46 PDT 2010


If the button we're about to fake isn't down (or up), don't fake a release
(or press) event for it. Behaviour is the same as before, this just saves
a few cycles.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---

 xkb/xkbActions.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 4fc2f27..e1763a4 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1376,6 +1376,7 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
     EventListPtr        events;
     int                 nevents, i;
     DeviceIntPtr        ptr, mpointer, lastSlave;
+    int                 down;
 
     /* If dev is a slave device, and the SD is attached, do nothing. If we'd
      * post through the attached master pointer we'd get duplicate events.
@@ -1401,6 +1402,10 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
     else
         return;
 
+    down = button_is_down(ptr, button, BUTTON_PROCESSED);
+    if (press == down)
+        return;
+
     events = InitEventList(GetMaximumEventsNum() + 1);
     OsBlockSignals();
     nevents = GetPointerEvents(events, ptr,
-- 
1.7.1


More information about the xorg-devel mailing list