[PATCH weston 2/5] zoom: use the new pointer motion signal to move the zoom frame.

Giulio Camuffo giuliocamuffo at gmail.com
Thu Nov 14 14:42:51 PST 2013


---
 src/compositor.h |  3 +++
 src/input.c      |  8 --------
 src/shell.c      |  3 +--
 src/zoom.c       | 27 +++++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index 624d475..95928a4 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -155,6 +155,7 @@ struct weston_output_zoom {
 	struct weston_fixed_point from;
 	struct weston_fixed_point to;
 	struct weston_fixed_point current;
+	struct wl_listener motion_listener;
 };
 
 /* bit compatible with drm definitions. */
@@ -1148,6 +1149,8 @@ weston_output_init_zoom(struct weston_output *output);
 void
 weston_output_update_zoom(struct weston_output *output);
 void
+weston_output_activate_zoom(struct weston_output *output);
+void
 weston_output_update_matrix(struct weston_output *output);
 void
 weston_output_move(struct weston_output *output, int x, int y);
diff --git a/src/input.c b/src/input.c
index e6b070d..f1cf938 100644
--- a/src/input.c
+++ b/src/input.c
@@ -712,9 +712,7 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t
 static void
 move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
 {
-	struct weston_compositor *ec = seat->compositor;
 	struct weston_pointer *pointer = seat->pointer;
-	struct weston_output *output;
 	int32_t ix, iy;
 
 	weston_pointer_clamp (pointer, &x, &y);
@@ -725,12 +723,6 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
 	ix = wl_fixed_to_int(x);
 	iy = wl_fixed_to_int(y);
 
-	wl_list_for_each(output, &ec->output_list, link)
-		if (output->zoom.active &&
-		    pixman_region32_contains_point(&output->region,
-						   ix, iy, NULL))
-			weston_output_update_zoom(output);
-
 	if (pointer->sprite) {
 		weston_view_set_position(pointer->sprite,
 					 ix - pointer->hotspot_x,
diff --git a/src/shell.c b/src/shell.c
index 9a9127b..cbb741a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3052,8 +3052,7 @@ do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
 			else if (output->zoom.level > output->zoom.max_level)
 				output->zoom.level = output->zoom.max_level;
 			else if (!output->zoom.active) {
-				output->zoom.active = 1;
-				output->disable_planes++;
+				weston_output_activate_zoom(output);
 			}
 
 			output->zoom.spring_z.target = output->zoom.level;
diff --git a/src/zoom.c b/src/zoom.c
index 962ed6d..622c0d7 100644
--- a/src/zoom.c
+++ b/src/zoom.c
@@ -45,6 +45,7 @@ weston_zoom_frame_z(struct weston_animation *animation,
 		if (output->zoom.active && output->zoom.level <= 0.0) {
 			output->zoom.active = 0;
 			output->disable_planes--;
+			wl_list_remove(&output->zoom.motion_listener.link);
 		}
 		output->zoom.spring_z.current = output->zoom.level;
 		wl_list_remove(&animation->link);
@@ -236,6 +237,31 @@ weston_output_update_zoom(struct weston_output *output)
 	weston_output_update_zoom_transform(output);
 }
 
+static void
+motion(struct wl_listener *listener, void *data)
+{
+	struct weston_output_zoom *zoom =
+		container_of(listener, struct weston_output_zoom, motion_listener);
+	struct weston_output *output =
+		container_of(zoom, struct weston_output, zoom);
+
+	weston_output_update_zoom(output);
+}
+
+WL_EXPORT void
+weston_output_activate_zoom(struct weston_output *output)
+{
+	struct weston_seat *seat = weston_zoom_pick_seat(output->compositor);
+
+	if (output->zoom.active)
+		return;
+
+	output->zoom.active = 1;
+	output->disable_planes++;
+	wl_signal_add(&seat->pointer->motion_signal,
+		      &output->zoom.motion_listener);
+}
+
 WL_EXPORT void
 weston_output_init_zoom(struct weston_output *output)
 {
@@ -253,4 +279,5 @@ weston_output_init_zoom(struct weston_output *output)
 	output->zoom.spring_xy.friction = 1000;
 	output->zoom.animation_xy.frame = weston_zoom_frame_xy;
 	wl_list_init(&output->zoom.animation_xy.link);
+	output->zoom.motion_listener.notify = motion;
 }
-- 
1.8.4.2



More information about the wayland-devel mailing list