From 1a172f3297369a72865232c382abfc14281102a4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 23 Jul 2010 13:24:34 +1000 Subject: [PATCH] xkb: if the button isn't down, don't fake an event. 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 Reviewed-by: Keith Packard --- xkb/xkbActions.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index c36dba0b5..59c7fc5e5 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1410,6 +1410,7 @@ void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button) { DeviceIntPtr ptr; + 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. @@ -1427,6 +1428,10 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button) else return; + down = button_is_down(ptr, button, BUTTON_PROCESSED); + if (press == down) + return; + InjectPointerKeyEvents(dev, press ? ButtonPress : ButtonRelease, button, 0, 0, NULL); }