summaryrefslogtreecommitdiff
path: root/src/data-device.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2013-05-07 22:53:43 -0400
committerKristian Høgsberg <krh@bitplanet.net>2013-05-07 22:57:15 -0400
commitaad8099c2f9970264779e43148ec2da8e4152d4c (patch)
treeaf02222c950d6809f41a1644b5c4b5a9eb0b5dbd /src/data-device.c
parent415f30cc08708ea06573f75ac4b4941303161fdc (diff)
downloadweston-aad8099c2f9970264779e43148ec2da8e4152d4c.tar.gz
data-device: Update drag icon position from configure and motion handlers
We can now update the drag icon position directly from the configure handler or the grab motion handler, and no longer need weston_seat_update_drag_surface().
Diffstat (limited to 'src/data-device.c')
-rw-r--r--src/data-device.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/src/data-device.c b/src/data-device.c
index 8b2c7cf4..ee17f76d 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -167,6 +167,7 @@ drag_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_
{
struct weston_seat *seat = es->configure_private;
struct wl_list *list;
+ float fx, fy;
if (!weston_surface_is_mapped(es) && es->buffer_ref.buffer) {
if (seat->sprite && weston_surface_is_mapped(seat->sprite))
@@ -179,9 +180,12 @@ drag_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_
empty_region(&es->pending.input);
}
- weston_surface_configure(es,
- es->geometry.x + sx, es->geometry.y + sy,
- width, height);
+ seat->drag_dx += sx;
+ seat->drag_dy += sy;
+
+ fx = wl_fixed_to_double(seat->pointer->x) + seat->drag_dx;
+ fy = wl_fixed_to_double(seat->pointer->y) + seat->drag_dy;
+ weston_surface_configure(es, fx, fy, width, height);
}
static int
@@ -196,10 +200,8 @@ device_setup_new_drag_surface(struct weston_seat *seat,
}
seat->drag_surface = surface;
-
- weston_surface_set_position(seat->drag_surface,
- wl_fixed_to_double(seat->pointer->x),
- wl_fixed_to_double(seat->pointer->y));
+ seat->drag_dx = 0;
+ seat->drag_dy = 0;
surface->configure = drag_surface_configure;
surface->configure_private = seat;
@@ -222,29 +224,6 @@ device_release_drag_surface(struct weston_seat *seat)
seat->drag_surface = NULL;
}
-void
-weston_seat_update_drag_surface(struct weston_seat *seat, int dx, int dy)
-{
- if (!seat->drag_surface)
- return;
-
- if (!dx && !dy)
- return;
-
- weston_surface_set_position(seat->drag_surface,
- seat->drag_surface->geometry.x + wl_fixed_to_double(dx),
- seat->drag_surface->geometry.y + wl_fixed_to_double(dy));
-}
-
-void
-weston_compositor_update_drag_surfaces(struct weston_compositor *compositor)
-{
- struct weston_seat *seat;
-
- wl_list_for_each(seat, &compositor->seat_list, link)
- weston_seat_update_drag_surface(seat, 0, 0);
-}
-
static void
destroy_drag_focus(struct wl_listener *listener, void *data)
{
@@ -307,6 +286,14 @@ drag_grab_motion(struct weston_pointer_grab *grab,
{
struct weston_seat *seat =
container_of(grab, struct weston_seat, drag_grab);
+ float fx, fy;
+
+ if (seat->drag_surface) {
+ fx = wl_fixed_to_double(seat->pointer->x) + seat->drag_dx;
+ fy = wl_fixed_to_double(seat->pointer->y) + seat->drag_dy;
+ weston_surface_set_position(seat->drag_surface, fx, fy);
+ weston_surface_schedule_repaint(seat->drag_surface);
+ }
if (seat->drag_focus_resource)
wl_data_device_send_motion(seat->drag_focus_resource,
@@ -316,10 +303,8 @@ drag_grab_motion(struct weston_pointer_grab *grab,
static void
data_device_end_drag_grab(struct weston_seat *seat)
{
- if (seat->drag_surface) {
+ if (seat->drag_surface)
device_release_drag_surface(seat);
- weston_seat_update_drag_surface(seat, 0, 0);
- }
drag_grab_focus(&seat->drag_grab, NULL,
wl_fixed_from_int(0), wl_fixed_from_int(0));
@@ -408,7 +393,6 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
if (icon_resource) {
if (!device_setup_new_drag_surface(seat, icon_resource->data))
return;
- weston_seat_update_drag_surface(seat, 0, 0);
}
weston_pointer_set_focus(seat->pointer, NULL,