Hello Bill, You are right, thus I dug into the git history and I found that the grab is mostly to confine the cursor into the X11 window. For reference, the git commit id [1] and the related bug [2].
Since I do not want introduce a regression, I think the minor improvement is valid. Best regards. [1] 7330862f9e25d513cfcc49358b7187524a9e1940 [2] https://bugs.freedesktop.org/show_bug.cgi?id=53558 On 13/05/2016 18:35, Bill Spitzak wrote: > 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. > > > On Fri, May 13, 2016 at 4:34 AM, Benoit Gschwind <[email protected] > <mailto:[email protected]>> wrote: > > In current compositor-x11, the mouse buttons are grabbed and ungrabbed > manually that may produce weird cases like starting a grab while the > buttons are already released, due to asynchronous X11 events > dispatching. > > The patch avoid the issue by using the better passive button grab, that > automatically grab buttons as soon as they occur. The passive grab > include an automatic ungrab when all mouse button are released. > > This probably fix some mysterious bugs. > > Signed-off-by: Benoit Gschwind <[email protected] > <mailto:[email protected]>> > --- > src/compositor-x11.c | 27 +++++++++++++-------------- > 1 file changed, 13 insertions(+), 14 deletions(-) > > diff --git a/src/compositor-x11.c b/src/compositor-x11.c > index 5b76dba..ae155d1 100644 > --- a/src/compositor-x11.c > +++ b/src/compositor-x11.c > @@ -882,6 +882,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) > @@ -1052,20 +1065,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); > > -- > 2.7.3 > > _______________________________________________ > wayland-devel mailing list > [email protected] > <mailto:[email protected]> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel > > _______________________________________________ wayland-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/wayland-devel
