mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
dnd 2
This commit is contained in:
parent
308cccc72c
commit
7947bcb0b0
@ -35,13 +35,21 @@
|
|||||||
|
|
||||||
#include "meta-stage.h"
|
#include "meta-stage.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CoglTexture *texture;
|
||||||
|
MetaRectangle current_rect;
|
||||||
|
gboolean handled_by_backend;
|
||||||
|
} MetaCursorLayer;
|
||||||
|
|
||||||
struct _MetaCursorRendererPrivate
|
struct _MetaCursorRendererPrivate
|
||||||
{
|
{
|
||||||
int current_x, current_y;
|
int current_x, current_y;
|
||||||
MetaRectangle current_rect;
|
|
||||||
|
MetaCursorLayer core_layer;
|
||||||
|
MetaCursorLayer dnd_layer;
|
||||||
|
|
||||||
MetaCursorReference *displayed_cursor;
|
MetaCursorReference *displayed_cursor;
|
||||||
gboolean handled_by_backend;
|
|
||||||
};
|
};
|
||||||
typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate;
|
typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate;
|
||||||
|
|
||||||
@ -53,18 +61,14 @@ queue_redraw (MetaCursorRenderer *renderer)
|
|||||||
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
ClutterActor *stage = meta_backend_get_stage (backend);
|
ClutterActor *stage = meta_backend_get_stage (backend);
|
||||||
CoglTexture *texture;
|
|
||||||
|
|
||||||
/* During early initialization, we can have no stage */
|
/* During early initialization, we can have no stage */
|
||||||
if (!stage)
|
if (!stage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (priv->displayed_cursor && !priv->handled_by_backend)
|
if (priv->core_layer.texture && !priv->core_layer.handled_by_backend)
|
||||||
texture = meta_cursor_reference_get_cogl_texture (priv->displayed_cursor, NULL, NULL);
|
meta_stage_set_cursor (META_STAGE (stage), layer->texture, &priv->current_rect);
|
||||||
else
|
meta_stage_set_dnd_surface (META_STAGE (stage),
|
||||||
texture = NULL;
|
|
||||||
|
|
||||||
meta_stage_set_cursor (META_STAGE (stage), texture, &priv->current_rect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -84,15 +88,45 @@ meta_cursor_renderer_init (MetaCursorRenderer *renderer)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_layer (MetaCursorRenderer *renderer,
|
||||||
|
MetaCursorLayer *layer,
|
||||||
|
CoglTexture *texture,
|
||||||
|
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.width = cogl_texture_get_width (layer->texture);
|
||||||
|
layer->current_rect.height = cogl_texture_get_height (layer->texture);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
layer->current_rect.x = 0;
|
||||||
|
layer->current_rect.y = 0;
|
||||||
|
layer->current_rect.width = 0;
|
||||||
|
layer->current_rect.height = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_cursor (MetaCursorRenderer *renderer)
|
update_cursor (MetaCursorRenderer *renderer)
|
||||||
{
|
{
|
||||||
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
||||||
gboolean handled_by_backend;
|
gboolean handled_by_backend;
|
||||||
gboolean should_redraw = FALSE;
|
gboolean should_redraw = FALSE;
|
||||||
|
CoglTexture *texture;
|
||||||
|
int hot_x, hot_y;
|
||||||
|
|
||||||
if (priv->displayed_cursor)
|
if (priv->displayed_cursor)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
int offset_x, offset_y;
|
int offset_x, offset_y;
|
||||||
|
|
||||||
@ -102,15 +136,20 @@ update_cursor (MetaCursorRenderer *renderer)
|
|||||||
priv->current_rect.y = priv->current_y + offset_y;
|
priv->current_rect.y = priv->current_y + offset_y;
|
||||||
priv->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (texture));
|
priv->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (texture));
|
||||||
priv->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (texture));
|
priv->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (texture));
|
||||||
|
=======
|
||||||
|
texture = meta_cursor_reference_get_cogl_texture (priv->displayed_cursor, &hot_x, &hot_y);
|
||||||
|
>>>>>>> 75e7834... dnd 2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
priv->current_rect.x = 0;
|
texture = NULL;
|
||||||
priv->current_rect.y = 0;
|
hot_x = 0;
|
||||||
priv->current_rect.width = 0;
|
hot_y = 0;
|
||||||
priv->current_rect.height = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_layer (renderer, &priv->core_layer, texture, hot_x, hot_y);
|
||||||
|
update_layer (renderer, &priv->
|
||||||
|
|
||||||
handled_by_backend = META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer);
|
handled_by_backend = META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer);
|
||||||
if (handled_by_backend != priv->handled_by_backend)
|
if (handled_by_backend != priv->handled_by_backend)
|
||||||
{
|
{
|
||||||
@ -144,6 +183,17 @@ meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
|
|||||||
update_cursor (renderer);
|
update_cursor (renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_cursor_renderer_set_dnd_surface (MetaCursorRenderer *renderer,
|
||||||
|
CoglTexture *texture,
|
||||||
|
int offset_x,
|
||||||
|
int offset_y)
|
||||||
|
{
|
||||||
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
||||||
|
|
||||||
|
update_layer (renderer, &priv->dnd_layer,
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
||||||
int x, int y)
|
int x, int y)
|
||||||
@ -171,5 +221,5 @@ meta_cursor_renderer_get_rect (MetaCursorRenderer *renderer)
|
|||||||
{
|
{
|
||||||
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
||||||
|
|
||||||
return &priv->current_rect;
|
return &priv->core_layer.current_rect;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user