[PATCH weston] input: send the pressed keys to the focused client when running a key binding

Giulio Camuffo giuliocamuffo at gmail.com
Fri Nov 21 12:01:44 PST 2014


---
 src/bindings.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/bindings.c b/src/bindings.c
index 5e24725..0beca6d 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -262,6 +262,7 @@ weston_compositor_run_key_binding(struct weston_compositor *compositor,
 				  enum wl_keyboard_key_state state)
 {
 	struct weston_binding *b, *tmp;
+	struct weston_surface *focus;
 
 	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
 		return;
@@ -273,8 +274,17 @@ weston_compositor_run_key_binding(struct weston_compositor *compositor,
 	wl_list_for_each_safe(b, tmp, &compositor->key_binding_list, link) {
 		if (b->key == key && b->modifier == seat->modifier_state) {
 			weston_key_binding_handler_t handler = b->handler;
+			focus = seat->keyboard->focus;
 			handler(seat, time, key, b->data);
 
+			/* If the focus didn't change, and hence it didn't receive
+			 * a wl_keyboard.enter event with the pressed keys,
+			 * send a wl_keyboard.leave/enter pair */
+			if (focus && seat->keyboard->focus == focus) {
+				weston_keyboard_set_focus(seat->keyboard, NULL);
+				weston_keyboard_set_focus(seat->keyboard, focus);
+			}
+
 			/* If this was a key binding and it didn't
 			 * install a keyboard grab, install one now to
 			 * swallow the key release. */
-- 
2.1.3



More information about the wayland-devel mailing list