swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit ce14c7287b3a8e3c90ef2ecf153b08d975b299b2
parent 9eefeab29543f2dcf1da3fcd372a62cf7ea1f253
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 26 Feb 2014 20:07:07 -0800

pointer: Pass button press structure to pointer handler

Diffstat:
Mlibswc/pointer.c | 34++++++++++++++++++++--------------
Mlibswc/pointer.h | 2+-
Mlibswc/window.c | 6+++---
3 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/libswc/pointer.c b/libswc/pointer.c @@ -155,19 +155,18 @@ void pointer_set_cursor(struct pointer * pointer, uint32_t id) view_attach(&pointer->cursor.view, pointer->cursor.internal_buffer); } -static bool client_handle_button(struct pointer_handler * handler, - uint32_t time, uint32_t button, uint32_t state) +static bool client_handle_button + (struct pointer_handler * handler, uint32_t time, + struct press * press, uint32_t state) { struct pointer * pointer = CONTAINER_OF(handler, typeof(*pointer), client_handler); - uint32_t serial; if (!pointer->focus.resource) return false; - serial = wl_display_get_serial(swc.display); - wl_pointer_send_button(pointer->focus.resource, serial, time, - button, state); + wl_pointer_send_button(pointer->focus.resource, press->serial, time, + press->value, state); return true; } @@ -364,27 +363,34 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time, { if (button->press.value == value) { - swc_array_remove(&pointer->buttons, button, sizeof *button); - - if (button->handler->button) + if (button->handler) { + button->press.serial = serial; button->handler->button(button->handler, time, - value, state); + &button->press, state); } + swc_array_remove(&pointer->buttons, button, sizeof *button); break; } } } else { + button = wl_array_add(&pointer->buttons, sizeof *button); + + if (!button) + return; + + button->press.value = value; + button->press.serial = serial; + button->handler = NULL; + wl_list_for_each(handler, &pointer->handlers, link) { - if (handler->button && handler->button(handler, time, value, state)) + if (handler->button && handler->button(handler, time, + &button->press, state)) { - button = wl_array_add(&pointer->buttons, sizeof *button); - button->press.value = value; - button->press.serial = serial; button->handler = handler; break; } diff --git a/libswc/pointer.h b/libswc/pointer.h @@ -42,7 +42,7 @@ struct pointer_handler bool (* motion)(struct pointer_handler * handler, uint32_t time, wl_fixed_t x, wl_fixed_t y); bool (* button)(struct pointer_handler * handler, uint32_t time, - uint32_t button, uint32_t state); + struct press * press, uint32_t state); bool (* axis)(struct pointer_handler * handler, uint32_t time, enum wl_pointer_axis axis, wl_fixed_t amount); diff --git a/libswc/window.c b/libswc/window.c @@ -204,7 +204,7 @@ static bool resize_motion(struct pointer_handler * handler, uint32_t time, } static bool handle_button(struct pointer_handler * handler, uint32_t time, - uint32_t button, uint32_t state) + struct press * press, uint32_t state) { struct window_pointer_interaction * interaction = CONTAINER_OF(handler, typeof(*interaction), handler); @@ -215,8 +215,8 @@ static bool handle_button(struct pointer_handler * handler, uint32_t time, return false; } - interaction->original_handler->button - (interaction->original_handler, time, button, state); + interaction->original_handler->button(interaction->original_handler, time, + press, state); wl_list_remove(&handler->link); return true;