<div dir="ltr">Does the x11 compositor have to do this at all? It owns that window so it gets automatic grabs. This is for one client to eat the events being passed to another client.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 4:34 AM, Benoit Gschwind <span dir="ltr"><<a href="mailto:gschwind@gnu-log.net" target="_blank">gschwind@gnu-log.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In current compositor-x11, the mouse buttons are grabbed and ungrabbed<br>
manually that may produce weird cases like starting a grab while the<br>
buttons are already released, due to asynchronous X11 events dispatching.<br>
<br>
The patch avoid the issue by using the better passive button grab, that<br>
automatically grab buttons as soon as they occur. The passive grab<br>
include an automatic ungrab when all mouse button are released.<br>
<br>
This probably fix some mysterious bugs.<br>
<br>
Signed-off-by: Benoit Gschwind <<a href="mailto:gschwind@gnu-log.net">gschwind@gnu-log.net</a>><br>
---<br>
 src/compositor-x11.c | 27 +++++++++++++--------------<br>
 1 file changed, 13 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/src/compositor-x11.c b/src/compositor-x11.c<br>
index 5b76dba..ae155d1 100644<br>
--- a/src/compositor-x11.c<br>
+++ b/src/compositor-x11.c<br>
@@ -882,6 +882,19 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,<br>
<br>
        x11_output_set_wm_protocols(b, output);<br>
<br>
+       /* Automatically grab and ungrab mouse buttons */<br>
+       xcb_grab_button(b->conn, 0, output->window,<br>
+                       XCB_EVENT_MASK_BUTTON_PRESS |<br>
+                       XCB_EVENT_MASK_BUTTON_RELEASE |<br>
+                       XCB_EVENT_MASK_POINTER_MOTION |<br>
+                       XCB_EVENT_MASK_ENTER_WINDOW |<br>
+                       XCB_EVENT_MASK_LEAVE_WINDOW,<br>
+                       XCB_GRAB_MODE_ASYNC,<br>
+                       XCB_GRAB_MODE_ASYNC,<br>
+                       output->window, XCB_CURSOR_NONE,<br>
+                       XCB_BUTTON_INDEX_ANY,<br>
+                       XCB_MOD_MASK_ANY);<br>
+<br>
        xcb_map_window(b->conn, output->window);<br>
<br>
        if (fullscreen)<br>
@@ -1052,20 +1065,6 @@ x11_backend_deliver_button_event(struct x11_backend *b,<br>
        if (!output)<br>
                return;<br>
<br>
-       if (is_button_pressed)<br>
-               xcb_grab_pointer(b->conn, 0, output->window,<br>
-                                XCB_EVENT_MASK_BUTTON_PRESS |<br>
-                                XCB_EVENT_MASK_BUTTON_RELEASE |<br>
-                                XCB_EVENT_MASK_POINTER_MOTION |<br>
-                                XCB_EVENT_MASK_ENTER_WINDOW |<br>
-                                XCB_EVENT_MASK_LEAVE_WINDOW,<br>
-                                XCB_GRAB_MODE_ASYNC,<br>
-                                XCB_GRAB_MODE_ASYNC,<br>
-                                output->window, XCB_CURSOR_NONE,<br>
-                                button_event->time);<br>
-       else<br>
-               xcb_ungrab_pointer(b->conn, button_event->time);<br>
-<br>
        if (!b->has_xkb)<br>
                update_xkb_state_from_core(b, button_event->state);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.7.3<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div>