diff options
author | Victor Kareh <[email protected]> | 2017-08-14 06:31:10 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-08-18 09:17:31 +0200 |
commit | 841f6cc41ab3389d12912dbcb166744ab3eab688 (patch) | |
tree | 9b414cb82d34e7724148eb4340f9af51505a7ed1 | |
parent | 71950df523c575922a2d83ba54a7009c10c3895b (diff) | |
download | marco-841f6cc41ab3389d12912dbcb166744ab3eab688.tar.bz2 marco-841f6cc41ab3389d12912dbcb166744ab3eab688.tar.xz |
Fix synthetic keybinding/button-grab window (#342)
* Determine focused window when processing synthetic events
When a client is passively grabbing keybindings that it does not need,
it sends them up for other clients to process.
Often in this situation, the event contains the wrong window (either
root, for global keybindings, or the original client itself). This means
that Marco will attempt to process the event for the wrong window.
This is not an issue for global keybindings within Marco, as the focused
window does not matter. However, for shortcuts that operate directly on
specific windows, the event gets lost.
This change addresses this by determining what the currently-focused
window is, regardless of which client forwarded the event.
* Determine window under pointer when processing synthetic events
When a client is passively grabbing mouse clicks that it does not need,
it sends them up for other clients to process.
Often in this situation, the event contains the wrong window (either
root, for global keybindings, or the original client itself). This means
that Marco will attempt to process the event for the wrong window.
This change addresses this by determining what the current window under
the mouse pointer is, regardless of which client forwarded the event.
* Remove unused development data
-rw-r--r-- | src/core/display.c | 14 | ||||
-rw-r--r-- | src/core/keybindings.c | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/display.c b/src/core/display.c index 7b3ec502..e247ed33 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1779,6 +1779,20 @@ static gboolean event_callback(XEvent* event, gpointer data) meta_display_process_key_event (display, window, event); break; case ButtonPress: + /* Use window under pointer when processing synthetic events from another client */ + if (window == NULL && event->xbutton.send_event) + { + int x, y, root_x, root_y; + Window root, child; + guint mask; + XQueryPointer (display->xdisplay, + event->xany.window, + &root, &child, + &root_x, &root_y, + &x, &y, + &mask); + window = meta_display_lookup_x_window (display, child); + } if ((window && grab_op_is_mouse (display->grab_op) && display->grab_button != (int) event->xbutton.button && diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 271cf885..09283399 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -1306,6 +1306,14 @@ meta_display_process_key_event (MetaDisplay *display, meta_ui_window_is_widget (screen->ui, event->xany.window)) return; + /* Use focused window when processing synthetic events from another client */ + if (window == NULL && event->xkey.send_event) { + Window focus = None; + int ret_to = RevertToPointerRoot; + XGetInputFocus (display->xdisplay, &focus, &ret_to); + window = meta_display_lookup_x_window (display, focus); + } + /* window may be NULL */ #ifdef HAVE_XKB |