diff options
author | Victor Kareh <[email protected]> | 2018-03-07 06:41:17 -0500 |
---|---|---|
committer | monsta <[email protected]> | 2018-03-18 14:12:44 +0300 |
commit | 600082f15aabbc3c83e0b7a5552ed28df49ed4df (patch) | |
tree | a841b39be3b8884952039f5c7e95dac90cae5ac3 /plugins/media-keys | |
parent | 6e7cc4819759b44dca2516c3586b35dc3e6977e3 (diff) | |
download | mate-settings-daemon-600082f15aabbc3c83e0b7a5552ed28df49ed4df.tar.bz2 mate-settings-daemon-600082f15aabbc3c83e0b7a5552ed28df49ed4df.tar.xz |
Prevent media-keys bindings from swallowing modifier keys
This changes how the media-keys manager determines successful
key-bindings from KeyRelease to KeyPress so that it does not conflict
with third-party applications that want to use modifier keys as global
key-bindings. We've already done this change for general keybindings and
marco.
(port of d0368790c6deda728eb46337247bd0a9a844ac4b without deprecations fixes to 1.18 branch)
Diffstat (limited to 'plugins/media-keys')
-rw-r--r-- | plugins/media-keys/msd-media-keys-manager.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index 32d5d34..c581f80 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -1063,7 +1063,7 @@ acme_filter_events (GdkXEvent *xevent, int i; /* verify we have a key event */ - if (xev->type != KeyPress && xev->type != KeyRelease) { + if (xev->type != KeyPress) { return GDK_FILTER_CONTINUE; } @@ -1077,10 +1077,6 @@ acme_filter_events (GdkXEvent *xevent, return GDK_FILTER_CONTINUE; } break; - default: - if (xev->type != KeyRelease) { - return GDK_FILTER_CONTINUE; - } } manager->priv->current_screen = acme_get_screen_from_event (manager, xany); @@ -1100,9 +1096,15 @@ static gboolean start_media_keys_idle_cb (MsdMediaKeysManager *manager) { GSList *l; + GdkDisplay *dpy; + Display *xdpy; g_debug ("Starting media_keys manager"); mate_settings_profile_start (NULL); + + dpy = gdk_display_get_default (); + xdpy = GDK_DISPLAY_XDISPLAY (dpy); + manager->priv->volume_monitor = g_volume_monitor_get (); manager->priv->settings = g_settings_new (BINDING_SCHEMA); @@ -1111,14 +1113,28 @@ start_media_keys_idle_cb (MsdMediaKeysManager *manager) /* Start filtering the events */ for (l = manager->priv->screens; l != NULL; l = l->next) { + GdkWindow *window; + Window xwindow; + XWindowAttributes atts; + mate_settings_profile_start ("gdk_window_add_filter"); + window = gdk_screen_get_root_window (l->data); + xwindow = GDK_WINDOW_XID (window); + g_debug ("adding key filter for screen: %d", gdk_screen_get_number (l->data)); - gdk_window_add_filter (gdk_screen_get_root_window (l->data), + gdk_window_add_filter (window, (GdkFilterFunc)acme_filter_events, manager); + + gdk_error_trap_push (); + /* Add KeyPressMask to the currently reportable event masks */ + XGetWindowAttributes (xdpy, xwindow, &atts); + XSelectInput (xdpy, xwindow, atts.your_event_mask | KeyPressMask); + gdk_error_trap_pop_ignored (); + mate_settings_profile_end ("gdk_window_add_filter"); } |