[PATCH weston 02/17] input: Pass axis events through pointer grab interfaces

Jonas Ådahl jadahl at gmail.com
Tue Dec 2 05:49:10 PST 2014


Don't only send motions and buttons but also axis events through the
pointer grab interface.

Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 desktop-shell/exposay.c |  7 +++++++
 desktop-shell/shell.c   | 24 ++++++++++++++++++++++++
 src/compositor.h        |  2 ++
 src/data-device.c       |  7 +++++++
 src/input.c             | 21 +++++++++++++++------
 5 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 4b65cbd..dc3fee0 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -378,6 +378,12 @@ exposay_button(struct weston_pointer_grab *grab, uint32_t time, uint32_t button,
 }
 
 static void
+exposay_axis(struct weston_pointer_grab *grab,
+	     uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+}
+
+static void
 exposay_pointer_grab_cancel(struct weston_pointer_grab *grab)
 {
 	struct desktop_shell *shell =
@@ -390,6 +396,7 @@ static const struct weston_pointer_grab_interface exposay_ptr_grab = {
 	exposay_focus,
 	exposay_motion,
 	exposay_button,
+	exposay_axis,
 	exposay_pointer_grab_cancel,
 };
 
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 9e8d45a..8fc6a48 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1621,6 +1621,12 @@ noop_grab_focus(struct weston_pointer_grab *grab)
 }
 
 static void
+noop_grab_axis(struct weston_pointer_grab *grab,
+	       uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+}
+
+static void
 constrain_position(struct weston_move_grab *move, int *cx, int *cy)
 {
 	struct shell_surface *shsurf = move->base.shsurf;
@@ -1699,6 +1705,7 @@ static const struct weston_pointer_grab_interface move_grab_interface = {
 	noop_grab_focus,
 	move_grab_motion,
 	move_grab_button,
+	noop_grab_axis,
 	move_grab_cancel,
 };
 
@@ -1854,6 +1861,7 @@ static const struct weston_pointer_grab_interface resize_grab_interface = {
 	noop_grab_focus,
 	resize_grab_motion,
 	resize_grab_button,
+	noop_grab_axis,
 	resize_grab_cancel,
 };
 
@@ -2016,6 +2024,7 @@ static const struct weston_pointer_grab_interface busy_cursor_grab_interface = {
 	busy_cursor_grab_focus,
 	busy_cursor_grab_motion,
 	busy_cursor_grab_button,
+	noop_grab_axis,
 	busy_cursor_grab_cancel,
 };
 
@@ -3110,6 +3119,19 @@ popup_grab_button(struct weston_pointer_grab *grab,
 }
 
 static void
+popup_grab_axis(struct weston_pointer_grab *grab,
+		uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+	struct weston_pointer *pointer = grab->pointer;
+	struct wl_resource *resource;
+	struct wl_list *resource_list;
+
+	resource_list = &pointer->focus_resource_list;
+	wl_resource_for_each(resource, resource_list)
+		wl_pointer_send_axis(resource, time, axis, value);
+}
+
+static void
 popup_grab_cancel(struct weston_pointer_grab *grab)
 {
 	popup_grab_end(grab->pointer);
@@ -3119,6 +3141,7 @@ static const struct weston_pointer_grab_interface popup_grab_interface = {
 	popup_grab_focus,
 	popup_grab_motion,
 	popup_grab_button,
+	popup_grab_axis,
 	popup_grab_cancel,
 };
 
@@ -4730,6 +4753,7 @@ static const struct weston_pointer_grab_interface rotate_grab_interface = {
 	noop_grab_focus,
 	rotate_grab_motion,
 	rotate_grab_button,
+	noop_grab_axis,
 	rotate_grab_cancel,
 };
 
diff --git a/src/compositor.h b/src/compositor.h
index 2bec183..ef1bc0f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -243,6 +243,8 @@ struct weston_pointer_grab_interface {
 		       wl_fixed_t x, wl_fixed_t y);
 	void (*button)(struct weston_pointer_grab *grab,
 		       uint32_t time, uint32_t button, uint32_t state);
+	void (*axis)(struct weston_pointer_grab *grab,
+		     uint32_t time, uint32_t axis, wl_fixed_t value);
 	void (*cancel)(struct weston_pointer_grab *grab);
 };
 
diff --git a/src/data-device.c b/src/data-device.c
index d28325d..b26ad3e 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -392,6 +392,12 @@ drag_grab_button(struct weston_pointer_grab *grab,
 }
 
 static void
+drag_grab_axis(struct weston_pointer_grab *grab,
+	       uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+}
+
+static void
 drag_grab_cancel(struct weston_pointer_grab *grab)
 {
 	struct weston_pointer_drag *drag =
@@ -407,6 +413,7 @@ static const struct weston_pointer_grab_interface pointer_drag_grab_interface =
 	drag_grab_focus,
 	drag_grab_motion,
 	drag_grab_button,
+	drag_grab_axis,
 	drag_grab_cancel,
 };
 
diff --git a/src/input.c b/src/input.c
index 15ff6ed..f40d44a 100644
--- a/src/input.c
+++ b/src/input.c
@@ -218,6 +218,19 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
 }
 
 static void
+default_grab_pointer_axis(struct weston_pointer_grab *grab,
+			  uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+	struct weston_pointer *pointer = grab->pointer;
+	struct wl_resource *resource;
+	struct wl_list *resource_list;
+
+	resource_list = &pointer->focus_resource_list;
+	wl_resource_for_each(resource, resource_list)
+		wl_pointer_send_axis(resource, time, axis, value);
+}
+
+static void
 default_grab_pointer_cancel(struct weston_pointer_grab *grab)
 {
 }
@@ -227,6 +240,7 @@ static const struct weston_pointer_grab_interface
 	default_grab_pointer_focus,
 	default_grab_pointer_motion,
 	default_grab_pointer_button,
+	default_grab_pointer_axis,
 	default_grab_pointer_cancel,
 };
 
@@ -1046,8 +1060,6 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
 {
 	struct weston_compositor *compositor = seat->compositor;
 	struct weston_pointer *pointer = seat->pointer;
-	struct wl_resource *resource;
-	struct wl_list *resource_list;
 
 	weston_compositor_wake(compositor);
 
@@ -1058,10 +1070,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
 						   time, axis, value))
 		return;
 
-	resource_list = &pointer->focus_resource_list;
-	wl_resource_for_each(resource, resource_list)
-		wl_pointer_send_axis(resource, time, axis,
-				     value);
+	pointer->grab->interface->axis(pointer->grab, time, axis, value);
 }
 
 WL_EXPORT int
-- 
1.8.5.1



More information about the wayland-devel mailing list