commit c22ad427821c72d179d957e292d2b8dbf6c79340
parent 65451401706ebc379a285ce8c900e1c5e36dc807
Author: Michael Forney <mforney@mforney.org>
Date: Wed, 26 Feb 2014 19:37:30 -0800
input: Use common press structure
Diffstat:
6 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/libswc/input.h b/libswc/input.h
@@ -77,5 +77,15 @@ void input_focus_set(struct input_focus * input_focus,
/* }}} */
+/* Key/button handling {{{ */
+
+struct press
+{
+ uint32_t value;
+ uint32_t serial;
+};
+
+/* }}} */
+
#endif
diff --git a/libswc/pointer.c b/libswc/pointer.c
@@ -336,14 +336,13 @@ struct wl_resource * pointer_bind(struct pointer * pointer,
return client_resource;
}
-struct button_press * pointer_get_button_press(struct pointer * pointer,
- uint32_t serial)
+struct button * pointer_get_button(struct pointer * pointer, uint32_t serial)
{
- struct button_press * button;
+ struct button * button;
wl_array_for_each(button, &pointer->buttons)
{
- if (button->serial == serial)
+ if (button->press.serial == serial)
return button;
}
@@ -354,7 +353,7 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time,
uint32_t value, uint32_t state)
{
struct pointer_handler * handler;
- struct button_press * button;
+ struct button * button;
uint32_t serial;
serial = wl_display_next_serial(swc.display);
@@ -363,7 +362,7 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time,
{
wl_array_for_each(button, &pointer->buttons)
{
- if (button->value == value)
+ if (button->press.value == value)
{
swc_array_remove(&pointer->buttons, button, sizeof *button);
@@ -384,8 +383,8 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time,
if (handler->button && handler->button(handler, time, value, state))
{
button = wl_array_add(&pointer->buttons, sizeof *button);
- button->value = value;
- button->serial = serial;
+ button->press.value = value;
+ button->press.serial = serial;
button->handler = handler;
break;
}
diff --git a/libswc/pointer.h b/libswc/pointer.h
@@ -31,10 +31,9 @@
#include <wayland-server.h>
#include <pixman.h>
-struct button_press
+struct button
{
- uint32_t value;
- uint32_t serial;
+ struct press press;
struct pointer_handler * handler;
};
@@ -85,8 +84,7 @@ void pointer_set_focus(struct pointer * pointer, struct compositor_view * view);
void pointer_set_region(struct pointer * pointer, pixman_region32_t * region);
void pointer_set_cursor(struct pointer * pointer, uint32_t id);
-struct button_press * pointer_get_button_press(struct pointer * pointer,
- uint32_t serial);
+struct button * pointer_get_button(struct pointer * pointer, uint32_t serial);
struct wl_resource * pointer_bind(struct pointer * pointer,
struct wl_client * client, uint32_t id);
diff --git a/libswc/shell_surface.c b/libswc/shell_surface.c
@@ -52,9 +52,9 @@ static void move(struct wl_client * client, struct wl_resource * resource,
struct wl_resource * seat_resource, uint32_t serial)
{
struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
- struct button_press * button;
+ struct button * button;
- if (!(button = pointer_get_button_press(swc.seat->pointer, serial)))
+ if (!(button = pointer_get_button(swc.seat->pointer, serial)))
return;
window_begin_interactive_move(&shell_surface->window, button);
@@ -65,9 +65,9 @@ static void resize(struct wl_client * client, struct wl_resource * resource,
uint32_t edges)
{
struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
- struct button_press * button;
+ struct button * button;
- if (!(button = pointer_get_button_press(swc.seat->pointer, serial)))
+ if (!(button = pointer_get_button(swc.seat->pointer, serial)))
return;
window_begin_interactive_resize(&shell_surface->window, edges, button);
diff --git a/libswc/window.c b/libswc/window.c
@@ -114,7 +114,7 @@ void swc_window_set_border(struct swc_window * window,
static inline void window_begin_interaction
(struct window * window, struct window_pointer_interaction * interaction,
- struct button_press * button)
+ struct button * button)
{
if (button)
{
@@ -128,7 +128,7 @@ static inline void window_begin_interaction
}
void window_begin_interactive_move(struct window * window,
- struct button_press * button)
+ struct button * button)
{
struct swc_rectangle * geometry = &window->view->base.geometry;
int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
@@ -140,7 +140,7 @@ void window_begin_interactive_move(struct window * window,
}
void window_begin_interactive_resize(struct window * window, uint32_t edges,
- struct button_press * button)
+ struct button * button)
{
window_begin_interaction(window, &window->resize.interaction, button);
diff --git a/libswc/window.h b/libswc/window.h
@@ -79,10 +79,10 @@ void window_set_state(struct window * window, uint32_t state);
void window_set_parent(struct window * window, struct window * parent);
void window_begin_interactive_move(struct window * window,
- struct button_press * button);
+ struct button * button);
void window_begin_interactive_resize(struct window * window, uint32_t edges,
- struct button_press * button);
+ struct button * button);
#endif