detach dnd surface and pointer
This commit is contained in:
@@ -39,12 +39,11 @@ typedef struct
|
|||||||
{
|
{
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
MetaRectangle current_rect;
|
MetaRectangle current_rect;
|
||||||
|
int current_x, current_y;
|
||||||
} MetaCursorLayer;
|
} MetaCursorLayer;
|
||||||
|
|
||||||
struct _MetaCursorRendererPrivate
|
struct _MetaCursorRendererPrivate
|
||||||
{
|
{
|
||||||
int current_x, current_y;
|
|
||||||
|
|
||||||
MetaCursorLayer core_layer;
|
MetaCursorLayer core_layer;
|
||||||
MetaCursorLayer dnd_layer;
|
MetaCursorLayer dnd_layer;
|
||||||
|
|
||||||
@@ -107,14 +106,12 @@ update_layer (MetaCursorRenderer *renderer,
|
|||||||
int offset_x,
|
int offset_x,
|
||||||
int offset_y)
|
int offset_y)
|
||||||
{
|
{
|
||||||
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
|
||||||
|
|
||||||
layer->texture = texture;
|
layer->texture = texture;
|
||||||
|
|
||||||
if (layer->texture)
|
if (layer->texture)
|
||||||
{
|
{
|
||||||
layer->current_rect.x = priv->current_x + offset_x;
|
layer->current_rect.x = layer->current_x + offset_x;
|
||||||
layer->current_rect.y = priv->current_y + offset_y;
|
layer->current_rect.y = layer->current_y + offset_y;
|
||||||
layer->current_rect.width = cogl_texture_get_width (layer->texture);
|
layer->current_rect.width = cogl_texture_get_width (layer->texture);
|
||||||
layer->current_rect.height = cogl_texture_get_height (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);
|
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);
|
emit_update_cursor (renderer, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,12 +214,29 @@ meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
|||||||
|
|
||||||
g_assert (meta_is_wayland_compositor ());
|
g_assert (meta_is_wayland_compositor ());
|
||||||
|
|
||||||
priv->current_x = x;
|
priv->core_layer.current_x = x;
|
||||||
priv->current_y = y;
|
priv->core_layer.current_y = y;
|
||||||
|
|
||||||
update_cursor (renderer);
|
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 *
|
MetaCursorReference *
|
||||||
meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
|
meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
|
||||||
{
|
{
|
||||||
|
@@ -71,5 +71,7 @@ void meta_cursor_renderer_set_dnd_surface (MetaCursorRenderer *renderer,
|
|||||||
CoglTexture *texture,
|
CoglTexture *texture,
|
||||||
int offset_x,
|
int offset_x,
|
||||||
int offset_y);
|
int offset_y);
|
||||||
|
void meta_cursor_renderer_set_dnd_surface_position (MetaCursorRenderer *renderer,
|
||||||
|
int x, int y);
|
||||||
|
|
||||||
#endif /* META_CURSOR_RENDERER_H */
|
#endif /* META_CURSOR_RENDERER_H */
|
||||||
|
@@ -70,6 +70,9 @@ void meta_cursor_tracker_set_dnd_surface (MetaCursorTracker *tracker,
|
|||||||
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||||
int new_x,
|
int new_x,
|
||||||
int new_y);
|
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);
|
MetaCursorReference * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
|
||||||
|
|
||||||
|
@@ -380,6 +380,17 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
|||||||
meta_cursor_renderer_set_position (tracker->renderer, new_x, new_y);
|
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
|
static void
|
||||||
get_pointer_position_gdk (int *x,
|
get_pointer_position_gdk (int *x,
|
||||||
int *y,
|
int *y,
|
||||||
|
@@ -242,13 +242,24 @@ drag_grab_focus (MetaWaylandPointerGrab *grab,
|
|||||||
wl_resource_add_destroy_listener (data_device_resource, &drag_grab->drag_focus_listener);
|
wl_resource_add_destroy_listener (data_device_resource, &drag_grab->drag_focus_listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
drag_grab_update_dnd_surface (MetaWaylandDragGrab *drag_grab)
|
drag_grab_update_dnd_surface (MetaWaylandDragGrab *drag_grab)
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *surface = drag_grab->drag_surface;
|
MetaWaylandSurface *surface = drag_grab->drag_surface;
|
||||||
MetaWaylandSeat *seat = drag_grab->seat;
|
MetaWaylandSeat *seat = drag_grab->seat;
|
||||||
int offset_x = 0, offset_y = 0;
|
|
||||||
CoglTexture *texture = NULL;
|
CoglTexture *texture = NULL;
|
||||||
|
int offset_x, offset_y;
|
||||||
|
|
||||||
if (surface)
|
if (surface)
|
||||||
{
|
{
|
||||||
@@ -258,6 +269,8 @@ drag_grab_update_dnd_surface (MetaWaylandDragGrab *drag_grab)
|
|||||||
offset_x = surface->offset_x;
|
offset_x = surface->offset_x;
|
||||||
offset_y = surface->offset_y;
|
offset_y = surface->offset_y;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
offset_x = offset_y = 0;
|
||||||
|
|
||||||
meta_cursor_tracker_set_dnd_surface (seat->pointer.cursor_tracker,
|
meta_cursor_tracker_set_dnd_surface (seat->pointer.cursor_tracker,
|
||||||
texture, offset_x, offset_y);
|
texture, offset_x, offset_y);
|
||||||
@@ -270,7 +283,7 @@ drag_grab_motion (MetaWaylandPointerGrab *grab,
|
|||||||
MetaWaylandDragGrab *drag_grab = (MetaWaylandDragGrab*) grab;
|
MetaWaylandDragGrab *drag_grab = (MetaWaylandDragGrab*) grab;
|
||||||
wl_fixed_t sx, sy;
|
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)
|
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_set_focus (&seat->pointer, NULL);
|
||||||
meta_wayland_pointer_start_grab (&seat->pointer, (MetaWaylandPointerGrab*)drag_grab);
|
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);
|
drag_grab_update_dnd_surface (drag_grab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user