[mutter/wip/dnd-surface2: 8/18] detach dnd surface and pointer
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/dnd-surface2: 8/18] detach dnd surface and pointer
- Date: Tue, 30 Sep 2014 15:32:08 +0000 (UTC)
commit 1dbc9e868f19c8ee311e8a463e67c16f4f682c5e
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Sep 29 12:38:01 2014 +0200
detach dnd surface and pointer
src/backends/meta-cursor-renderer.c | 35 +++++++++++++++++----------
src/backends/meta-cursor-renderer.h | 2 +
src/backends/meta-cursor-tracker-private.h | 3 ++
src/backends/meta-cursor-tracker.c | 11 ++++++++
src/wayland/meta-wayland-data-device.c | 18 ++++++++++++-
5 files changed, 54 insertions(+), 15 deletions(-)
---
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index 502be11..18b5b45 100644
--- a/src/backends/meta-cursor-renderer.c
+++ b/src/backends/meta-cursor-renderer.c
@@ -39,12 +39,11 @@ typedef struct
{
CoglTexture *texture;
MetaRectangle current_rect;
+ int current_x, current_y;
} MetaCursorLayer;
struct _MetaCursorRendererPrivate
{
- int current_x, current_y;
-
MetaCursorLayer core_layer;
MetaCursorLayer dnd_layer;
@@ -107,14 +106,12 @@ update_layer (MetaCursorRenderer *renderer,
int offset_x,
int offset_y)
{
- MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
-
layer->texture = texture;
if (layer->texture)
{
- layer->current_rect.x = priv->current_x + offset_x;
- layer->current_rect.y = priv->current_y + offset_y;
+ layer->current_rect.x = layer->current_x + offset_x;
+ layer->current_rect.y = layer->current_y + offset_y;
layer->current_rect.width = cogl_texture_get_width (layer->texture);
layer->current_rect.height = cogl_texture_get_height (layer->texture);
}
@@ -170,11 +167,6 @@ update_cursor (MetaCursorRenderer *renderer)
}
update_layer (renderer, &priv->core_layer, texture, -hot_x, -hot_y);
-
- /* The DnD surface layer will also need updating position */
- update_layer (renderer, &priv->dnd_layer, priv->dnd_layer.texture,
- priv->dnd_surface_offset_x, priv->dnd_surface_offset_y);
-
emit_update_cursor (renderer, FALSE);
}
@@ -222,12 +214,29 @@ meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
g_assert (meta_is_wayland_compositor ());
- priv->current_x = x;
- priv->current_y = y;
+ priv->core_layer.current_x = x;
+ priv->core_layer.current_y = y;
update_cursor (renderer);
}
+void
+meta_cursor_renderer_set_dnd_surface_position (MetaCursorRenderer *renderer,
+ int x,
+ int y)
+{
+ MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
+
+ g_assert (meta_is_wayland_compositor ());
+
+ priv->dnd_layer.current_x = x;
+ priv->dnd_layer.current_y = y;
+
+ update_layer (renderer, &priv->dnd_layer, priv->dnd_layer.texture,
+ priv->dnd_surface_offset_x, priv->dnd_surface_offset_y);
+ emit_update_cursor (renderer, FALSE);
+}
+
MetaCursorReference *
meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
{
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
index ef6542a..fa45275 100644
--- a/src/backends/meta-cursor-renderer.h
+++ b/src/backends/meta-cursor-renderer.h
@@ -71,5 +71,7 @@ void meta_cursor_renderer_set_dnd_surface (MetaCursorRenderer *renderer,
CoglTexture *texture,
int offset_x,
int offset_y);
+void meta_cursor_renderer_set_dnd_surface_position (MetaCursorRenderer *renderer,
+ int x, int y);
#endif /* META_CURSOR_RENDERER_H */
diff --git a/src/backends/meta-cursor-tracker-private.h b/src/backends/meta-cursor-tracker-private.h
index d9246c6..ef97556 100644
--- a/src/backends/meta-cursor-tracker-private.h
+++ b/src/backends/meta-cursor-tracker-private.h
@@ -70,6 +70,9 @@ void meta_cursor_tracker_set_dnd_surface (MetaCursorTracker *tracker,
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
int new_x,
int new_y);
+void meta_cursor_tracker_update_dnd_surface_position (MetaCursorTracker *tracker,
+ int new_x,
+ int new_y);
MetaCursorReference * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 9719b85..549a934 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -380,6 +380,17 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
meta_cursor_renderer_set_position (tracker->renderer, new_x, new_y);
}
+void
+meta_cursor_tracker_update_dnd_surface_position (MetaCursorTracker *tracker,
+ int new_x,
+ int new_y)
+{
+ g_assert (meta_is_wayland_compositor ());
+
+ meta_cursor_renderer_set_dnd_surface_position (tracker->renderer,
+ new_x, new_y);
+}
+
static void
get_pointer_position_gdk (int *x,
int *y,
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 83673c0..6d56018 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -243,12 +243,23 @@ drag_grab_focus (MetaWaylandPointerGrab *grab,
}
static void
+drag_grab_update_dnd_surface_position (MetaWaylandDragGrab *drag_grab)
+{
+ MetaWaylandSeat *seat = drag_grab->seat;
+ ClutterPoint pos;
+
+ clutter_input_device_get_coords (seat->pointer.device, NULL, &pos);
+ meta_cursor_tracker_update_dnd_surface_position (seat->pointer.cursor_tracker,
+ (int) pos.x, (int) pos.y);
+}
+
+static void
drag_grab_update_dnd_surface (MetaWaylandDragGrab *drag_grab)
{
MetaWaylandSurface *surface = drag_grab->drag_surface;
MetaWaylandSeat *seat = drag_grab->seat;
- int offset_x = 0, offset_y = 0;
CoglTexture *texture = NULL;
+ int offset_x, offset_y;
if (surface)
{
@@ -258,6 +269,8 @@ drag_grab_update_dnd_surface (MetaWaylandDragGrab *drag_grab)
offset_x = surface->offset_x;
offset_y = surface->offset_y;
}
+ else
+ offset_x = offset_y = 0;
meta_cursor_tracker_set_dnd_surface (seat->pointer.cursor_tracker,
texture, offset_x, offset_y);
@@ -270,7 +283,7 @@ drag_grab_motion (MetaWaylandPointerGrab *grab,
MetaWaylandDragGrab *drag_grab = (MetaWaylandDragGrab*) grab;
wl_fixed_t sx, sy;
- drag_grab_update_dnd_surface (drag_grab);
+ drag_grab_update_dnd_surface_position (drag_grab);
if (drag_grab->drag_focus_data_device)
{
@@ -396,6 +409,7 @@ data_device_start_drag (struct wl_client *client,
meta_wayland_pointer_set_focus (&seat->pointer, NULL);
meta_wayland_pointer_start_grab (&seat->pointer, (MetaWaylandPointerGrab*)drag_grab);
+ drag_grab_update_dnd_surface_position (drag_grab);
drag_grab_update_dnd_surface (drag_grab);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]