[PATCH weston] weston-resizor: Don't add new frame callbacks every click
Derek Foreman
derekf at osg.samsung.com
Fri Mar 24 17:39:41 UTC 2017
Sorry, I forgot about this for a while.
On 17/02/17 10:31 PM, Jonas Ã…dahl wrote:
> On Wed, Feb 08, 2017 at 03:05:54PM -0600, Derek Foreman wrote:
>> The frame callback added on button click re-adds itself when done,
>> so adding a new one every click resulted in an ever increasing
>> number of callbacks.
>>
>> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
>> ---
>> clients/resizor.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/clients/resizor.c b/clients/resizor.c
>> index 5d342e1f..600452ad 100644
>> --- a/clients/resizor.c
>> +++ b/clients/resizor.c
>> @@ -53,6 +53,7 @@ struct resizor {
>> struct spring height;
>> struct wl_callback *frame_callback;
>> bool pointer_locked;
>> + bool locked_frame_callback_registered;
>> struct input *locked_input;
>> float pointer_x;
>> float pointer_y;
>> @@ -330,11 +331,15 @@ button_handler(struct widget *widget,
>> handle_pointer_unlocked);
>> resizor->locked_input = input;
>>
>> + if (resizor->locked_frame_callback_registered)
>> + return;
>> +
>> surface = window_get_wl_surface(resizor->window);
>> callback = wl_surface_frame(surface);
>> wl_callback_add_listener(callback,
>> &locked_pointer_frame_listener,
>> resizor);
>> + resizor->locked_frame_callback_registered = true;
>
> Won't this mean that we can only initiate the resize once?
No, because once we add the frame callback it continues to re-add itself
every time it runs.
> The second
> time we click, the locked_frame_callback_registered will still be true,
> and we won't add the frame listener.
Right, that was the intent, this prevents the problem where clicking
again adds another frame callback that continues to re-add itself
forever as well.
> Instead what we could do is probably to check the result of
> window_lock_pointer(), if it succeeded, continue with setting
> resizor->locked_input. Before trying to lock, check if we already have a
> locked_input, and if so, skip locking and adding the frame callback.
> Would also mean we need to clean up the locked_input on button-release
> and on unlocked (though seems weston-resizer crashes when unlocked by
> the compositor and not by itself).
I'll gladly review and test such a patch. Should I add a ticket in
bugzilla so this bug isn't forgotten?
Thanks,
Derek
>
> Jonas
>
>> } else if (button == BTN_LEFT &&
>> state == WL_POINTER_BUTTON_STATE_RELEASED) {
>> input_set_pointer_image(input, CURSOR_LEFT_PTR);
>> --
>> 2.11.0
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list