[PATCH 1/2] window: Fix sending button events when there's no grab

Kristian Høgsberg krh at bitplanet.net
Tue Jan 24 07:47:49 PST 2012


On Mon, Jan 23, 2012 at 2:11 PM, Neil Roberts <neil at linux.intel.com> wrote:
> The code which sends the button events was checking whether there is a
> focus widget with a button handler but then always sending the button
> event to the grab widget. If the grab widget is different from the
> focus widget at this point then it will check the wrong widget for a
> button handler and potentially crash. It is also possible for there to
> be no grab widget here in the following situation:
>
> 1. Press and hold down the left mouse button
> 2. Press and hold down the right mouse button
> 3. Release the left mouse button
> 4. Release the right mouse button
>
> In this case the grab will be released at step 3 because the code only
> keeps track of the grab for one button. Then it will try to send the
> release event for the right mouse button to a NULL widget so it will
> crash.

Yup, good fix, thanks
Kristian

> ---
>  clients/window.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/clients/window.c b/clients/window.c
> index fe7508d..1356c75 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -1527,12 +1527,12 @@ input_handle_button(void *data,
>        if (input->focus_widget && input->grab == NULL && state)
>                input_grab(input, input->focus_widget, button);
>
> -       widget = input->focus_widget;
> +       widget = input->grab;
>        if (widget && widget->button_handler)
> -               (*input->grab->button_handler)(widget,
> -                                              input, time,
> -                                              button, state,
> -                                              input->grab->user_data);
> +               (*widget->button_handler)(widget,
> +                                         input, time,
> +                                         button, state,
> +                                         input->grab->user_data);
>
>        if (input->grab && input->grab_button == button && !state)
>                input_ungrab(input, time);
> --
> 1.7.3.16.g9464b
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list