Ticket #3895: 0001-keygrabber-Handle-XI2-key-events.patch

File 0001-keygrabber-Handle-XI2-key-events.patch, 1.5 KB (added by erikos, 8 years ago)

keygrabber: Handle XI2 key events (toolkit-gtk3)

  • src/sugar3/sugar-key-grabber.c

    From b1425a6bb248d4f54fa2b0986fc14791b1345b55 Mon Sep 17 00:00:00 2001
    From: Carlos Garnacho <carlos@lanedo.com>
    Date: Thu, 13 Dec 2012 15:20:29 +0100
    Subject: [PATCH toolkit-gtk3] keygrabber: Handle XI2 key events
    
    XInput2 events are coerced by active grabs on the alt-tab handling
    code in sugar shell, even if the keygrabber itself does core events.
    ---
     src/sugar3/sugar-key-grabber.c | 20 ++++++++++++++++++++
     1 file changed, 20 insertions(+)
    
    diff --git a/src/sugar3/sugar-key-grabber.c b/src/sugar3/sugar-key-grabber.c
    index 74a0a95..a4c0096 100644
    a b  
    1919
    2020#include <X11/X.h>
    2121#include <X11/Xlib.h>
     22#include <X11/extensions/XInput2.h>
    2223#include <gdk/gdk.h>
    2324#include <gdk/gdkx.h>
    2425
    filter_events(GdkXEvent *xevent, GdkEvent *event, gpointer data) 
    138139                        return GDK_FILTER_REMOVE;
    139140        }
    140141
     142        if (xev->type == GenericEvent) {
     143                XIDeviceEvent *ev;
     144                int return_value = FALSE;
     145
     146                ev = (XIDeviceEvent *) ((XGenericEventCookie *) xev)->data;
     147
     148                if (ev->evtype == XI_KeyPress) {
     149                        g_signal_emit (grabber, signals[KEY_PRESSED], 0,
     150                                       ev->detail, ev->mods.effective, ev->time, &return_value);
     151                } else if (ev->evtype == XI_KeyRelease) {
     152                        g_signal_emit (grabber, signals[KEY_RELEASED], 0,
     153                                       ev->detail, ev->mods.effective, ev->time, &return_value);
     154                }
     155
     156                if (return_value)
     157                        return GDK_FILTER_REMOVE;
     158        }
     159
     160
    141161        return GDK_FILTER_CONTINUE;
    142162}
    143163