From 1f37601850bc9502ce6f0f9ed8e2d2f39c893387 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 9 May 2012 11:43:11 -0400 Subject: [PATCH] compositor: Move pointer motion clipping to its own function --- src/compositor.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 50e0a77..f9e2499 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1558,17 +1558,17 @@ static void weston_input_update_drag_surface(struct wl_input_device *input_device, int dx, int dy); -WL_EXPORT void -notify_motion(struct wl_input_device *device, uint32_t time, GLfloat x, GLfloat y) +static void +clip_pointer_motion(struct weston_compositor *ec, + GLfloat *fx, GLfloat *fy) { struct weston_output *output; - const struct wl_pointer_grab_interface *interface; - struct weston_input_device *wd = (struct weston_input_device *) device; - struct weston_compositor *ec = wd->compositor; + int32_t x, y; int x_valid = 0, y_valid = 0; int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; - weston_compositor_activity(ec); + x = *fx; + y = *fy; wl_list_for_each(output, &ec->output_list, link) { if (output->x <= x && x < output->x + output->current->width) @@ -1602,6 +1602,22 @@ notify_motion(struct wl_input_device *device, uint32_t time, GLfloat x, GLfloat y = max_y; } + *fx = x; + *fy = y; +} + +WL_EXPORT void +notify_motion(struct wl_input_device *device, uint32_t time, GLfloat x, GLfloat y) +{ + const struct wl_pointer_grab_interface *interface; + struct weston_input_device *wd = (struct weston_input_device *) device; + struct weston_compositor *ec = wd->compositor; + struct weston_output *output; + + weston_compositor_activity(ec); + + clip_pointer_motion(ec, &x, &y); + weston_input_update_drag_surface(device, x - device->x, y - device->y); -- 2.7.4