[gnome-settings-daemon] keyboard: Trigger input source switching on key press for Caps Lock
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] keyboard: Trigger input source switching on key press for Caps Lock
- Date: Thu, 15 Nov 2012 13:50:51 +0000 (UTC)
commit ef29fcf8223a0f9293c2a9c8af6a27fba6e2e7af
Author: Rui Matos <tiagomatos gmail com>
Date: Thu Nov 15 11:02:46 2012 +0100
keyboard: Trigger input source switching on key press for Caps Lock
We usually only trigger the switch on key release because we don't
want to prevent applications from getting e.g. Ctrl+Shift+E if the
shortcut is Ctrl+Shift.
But, for shortcuts including Caps Lock we can trigger the switch on
key press since applications don't usually include Caps Lock in their
own shortcuts and this allows us to:
1) be more responsive;
2) trigger the switch even if the user is typing quickly and thus we
are getting other key events;
3) reduce the time window during which the lock mask is active in the
server.
https://bugzilla.gnome.org/show_bug.cgi?id=688350
plugins/keyboard/gsd-input-sources-switcher.c | 47 +++++++++++++-----------
1 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/plugins/keyboard/gsd-input-sources-switcher.c b/plugins/keyboard/gsd-input-sources-switcher.c
index b48f37e..e35ce6f 100644
--- a/plugins/keyboard/gsd-input-sources-switcher.c
+++ b/plugins/keyboard/gsd-input-sources-switcher.c
@@ -43,7 +43,6 @@ static guint n_keys = 0;
static guint master_keyboard_id = 0;
static gboolean includes_caps = FALSE;
-static Time caps_press_time = 0;
static void
do_switch (void)
@@ -432,23 +431,32 @@ filter (XEvent *xevent,
{
if (xiev->evtype == XI_KeyPress)
{
- XIAllowEvents (xev->display,
- xev->deviceid,
- XISyncDevice,
- xev->time);
- XIGrabButton (xev->display,
- XIAllMasterDevices,
- XIAnyButton,
- xev->root,
- None,
- XIGrabModeSync,
- XIGrabModeSync,
- False,
- &evmask,
- 1,
- &mods);
if (includes_caps)
- caps_press_time = xev->time;
+ {
+ do_switch ();
+ XIUngrabDevice (xev->display,
+ master_keyboard_id,
+ xev->time);
+ XkbLockModifiers (xev->display, XkbUseCoreKbd, LockMask, 0);
+ }
+ else
+ {
+ XIAllowEvents (xev->display,
+ xev->deviceid,
+ XISyncDevice,
+ xev->time);
+ XIGrabButton (xev->display,
+ XIAllMasterDevices,
+ XIAnyButton,
+ xev->root,
+ None,
+ XIGrabModeSync,
+ XIGrabModeSync,
+ False,
+ &evmask,
+ 1,
+ &mods);
+ }
}
else
{
@@ -462,11 +470,6 @@ filter (XEvent *xevent,
xev->root,
1,
&mods);
- if (includes_caps && caps_press_time < xev->time)
- {
- XkbLockModifiers (xev->display, XkbUseCoreKbd, LockMask, 0);
- caps_press_time = xev->time;
- }
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]