summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-05-09 11:43:11 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-05-09 11:43:11 -0400
commit1f37601850bc9502ce6f0f9ed8e2d2f39c893387 (patch)
tree11cfb8c4d3ebc93f4d5b180bc1bc4500f2727874
parentc39aa5afcacaf17297b5a168a179c7399521c7a4 (diff)
compositor: Move pointer motion clipping to its own function
-rw-r--r--src/compositor.c28
1 files 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);