display: Only process keyboard mapping events for the core X keyboard

The X server sends a XkbNewKeyboardNotify event for each keyboard
device when a new keyboard description is loaded. These days a typical
computer has several keyboard devices, e.g. xinput on this laptop
lists 8. Since the work we do on these events is relatively expensive
and we are only really interested in changes to the virtual core
keyboard we can skip other devices' events to cut on needless work.

https://bugzilla.gnome.org/show_bug.cgi?id=674859
This commit is contained in:
Rui Matos 2012-04-26 11:43:52 +02:00
parent 859ea1457d
commit 4cf461fffa

View File

@ -74,6 +74,9 @@
#include <string.h>
#include <unistd.h>
/* This is set in stone and also hard-coded in GDK. */
#define VIRTUAL_CORE_KEYBOARD_ID 3
#define GRAB_OP_IS_WINDOW_SWITCH(g) \
(g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL || \
g == META_GRAB_OP_KEYBOARD_TABBING_DOCK || \
@ -2813,7 +2816,8 @@ event_callback (XEvent *event,
break;
case XkbNewKeyboardNotify:
case XkbMapNotify:
meta_display_process_mapping_event (display, event);
if (xkb_ev->device == VIRTUAL_CORE_KEYBOARD_ID)
meta_display_process_mapping_event (display, event);
break;
}
}