[weston,v3,3/3] compositor-x11: remove manual mouse button grab/ungrab

Submitted by Benoit Gschwind on June 30, 2016, 6:54 p.m.

Details

Message ID 1467312893-1733-4-git-send-email-gschwind@gnu-log.net
State New
Headers show

Not browsing as part of any series.

Patch hide | download patch | download mbox

diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index b6acccd..5d063b5 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -892,6 +892,19 @@  x11_backend_create_output(struct x11_backend *b, int x, int y,
 
 	x11_output_set_wm_protocols(b, output);
 
+	/* Automatically grab and ungrab mouse buttons */
+	xcb_grab_button(b->conn, 0, output->window,
+			XCB_EVENT_MASK_BUTTON_PRESS |
+			XCB_EVENT_MASK_BUTTON_RELEASE |
+			XCB_EVENT_MASK_POINTER_MOTION |
+			XCB_EVENT_MASK_ENTER_WINDOW |
+			XCB_EVENT_MASK_LEAVE_WINDOW,
+			XCB_GRAB_MODE_ASYNC,
+			XCB_GRAB_MODE_ASYNC,
+			output->window, XCB_CURSOR_NONE,
+			XCB_BUTTON_INDEX_ANY,
+			XCB_MOD_MASK_ANY);
+
 	xcb_map_window(b->conn, output->window);
 
 	if (fullscreen)
@@ -1063,20 +1076,6 @@  x11_backend_deliver_button_event(struct x11_backend *b,
 	if (!output)
 		return;
 
-	if (is_button_pressed)
-		xcb_grab_pointer(b->conn, 0, output->window,
-				 XCB_EVENT_MASK_BUTTON_PRESS |
-				 XCB_EVENT_MASK_BUTTON_RELEASE |
-				 XCB_EVENT_MASK_POINTER_MOTION |
-				 XCB_EVENT_MASK_ENTER_WINDOW |
-				 XCB_EVENT_MASK_LEAVE_WINDOW,
-				 XCB_GRAB_MODE_ASYNC,
-				 XCB_GRAB_MODE_ASYNC,
-				 output->window, XCB_CURSOR_NONE,
-				 button_event->time);
-	else
-		xcb_ungrab_pointer(b->conn, button_event->time);
-
 	if (!b->has_xkb)
 		update_xkb_state_from_core(b, button_event->state);