compositor: Move pointer motion clipping to its own function

This commit is contained in:
Kristian Høgsberg 2012-05-09 11:43:11 -04:00
parent c39aa5afca
commit 1f37601850
1 changed files with 22 additions and 6 deletions

View File

@ -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);