summaryrefslogtreecommitdiff
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
parent415f30cc08708ea06573f75ac4b4941303161fdc (diff)
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().
-rw-r--r--src/compositor.c2
-rw-r--r--src/compositor.h5
-rw-r--r--src/data-device.c52
-rw-r--r--src/input.c2
4 files changed, 19 insertions, 42 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 4dba3a33..a810fd27 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1182,8 +1182,6 @@ weston_output_repaint(struct weston_output *output, uint32_t msecs)
struct wl_list frame_callback_list;
pixman_region32_t output_damage;
- weston_compositor_update_drag_surfaces(ec);
-
/* Rebuild the surface list and update surface transforms up front. */
wl_list_init(&ec->surface_list);
wl_list_init(&frame_callback_list);
diff --git a/src/compositor.h b/src/compositor.h
index 5a9349d9..45054f51 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -334,8 +334,6 @@ void
weston_seat_set_keyboard(struct weston_seat *seat, struct weston_keyboard *keyboard);
void
weston_seat_set_touch(struct weston_seat *seat, struct weston_touch *touch);
-void
-weston_seat_update_drag_surface(struct weston_seat *seat, int dx, int dy);
void
weston_pointer_init(struct weston_pointer *pointer);
@@ -474,6 +472,7 @@ struct weston_seat {
struct weston_pointer_grab drag_grab;
struct weston_surface *drag_surface;
struct wl_listener drag_surface_destroy_listener;
+ int32_t drag_dx, drag_dy;
uint32_t num_tp;
@@ -856,8 +855,6 @@ void
weston_compositor_offscreen(struct weston_compositor *compositor);
void
weston_compositor_sleep(struct weston_compositor *compositor);
-void
-weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);
struct weston_surface *
weston_compositor_pick_surface(struct weston_compositor *compositor,
wl_fixed_t x, wl_fixed_t y,
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,
diff --git a/src/input.c b/src/input.c
index 753b6796..1d8aee38 100644
--- a/src/input.c
+++ b/src/input.c
@@ -639,8 +639,6 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
clip_pointer_motion(seat, &x, &y);
- weston_seat_update_drag_surface(seat, x - pointer->x, y - pointer->y);
-
pointer->x = x;
pointer->y = y;