[PATCH weston v1 3/3] compositor-x11: remove manual mouse button grab/ungrab

Bill Spitzak spitzak at gmail.com
Fri May 13 16:35:30 UTC 2016


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 <gschwind at gnu-log.net>
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 <gschwind at gnu-log.net>
> ---
>  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
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160513/dc90e6e3/attachment.html>


More information about the wayland-devel mailing list