This commit is contained in:
Jasper St. Pierre 2014-08-21 17:57:28 -04:00
parent 9688a0d7bc
commit 074946ac0b
6 changed files with 36 additions and 31 deletions

View File

@ -30,7 +30,7 @@
typedef struct {
CoglTexture2D *texture;
struct gbm_bo *bo;
int hot_x, hot_y;
int offset_x, offset_y;
} MetaCursorImage;
struct _MetaCursorReference {
@ -41,11 +41,11 @@ struct _MetaCursorReference {
};
CoglTexture *meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
int *hot_x,
int *hot_y);
int *offset_x,
int *offset_y);
struct gbm_bo *meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
int *hot_x,
int *hot_y);
int *offset_x,
int *offset_y);
#endif /* META_CURSOR_PRIVATE_H */

View File

@ -94,12 +94,12 @@ update_cursor (MetaCursorRenderer *renderer)
if (priv->displayed_cursor)
{
CoglTexture *texture;
int hot_x, hot_y;
int offset_x, offset_y;
texture = meta_cursor_reference_get_cogl_texture (priv->displayed_cursor, &hot_x, &hot_y);
texture = meta_cursor_reference_get_cogl_texture (priv->displayed_cursor, &offset_x, &offset_y);
priv->current_rect.x = priv->current_x - hot_x;
priv->current_rect.y = priv->current_y - hot_y;
priv->current_rect.x = priv->current_x + offset_x;
priv->current_rect.y = priv->current_y + offset_y;
priv->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (texture));
priv->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (texture));
}

View File

@ -310,6 +310,7 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
int *y)
{
MetaCursorReference *cursor;
int offset_x, offset_y;
g_return_if_fail (META_IS_CURSOR_TRACKER (tracker));
@ -324,14 +325,19 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
}
if (cursor)
meta_cursor_reference_get_cogl_texture (cursor, x, y);
{
meta_cursor_reference_get_cogl_texture (cursor, &offset_x, &offset_y);
}
else
{
if (x)
*x = 0;
if (y)
*y = 0;
offset_x = 0;
offset_y = 0;
}
if (x)
*x = -offset_x;
if (y)
*y = -offset_y;
}
void

View File

@ -352,25 +352,25 @@ meta_cursor_reference_from_buffer (struct wl_resource *buffer,
CoglTexture *
meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
int *hot_x,
int *hot_y)
int *offset_x,
int *offset_y)
{
if (hot_x)
*hot_x = cursor->image.hot_x;
if (hot_y)
*hot_y = cursor->image.hot_y;
if (offset_x)
*offset_x = cursor->image.offset_x;
if (offset_y)
*offset_y = cursor->image.offset_y;
return COGL_TEXTURE (cursor->image.texture);
}
struct gbm_bo *
meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
int *hot_x,
int *hot_y)
int *offset_x,
int *offset_y)
{
if (hot_x)
*hot_x = cursor->image.hot_x;
if (hot_y)
*hot_y = cursor->image.hot_y;
if (offset_x)
*offset_x = cursor->image.offset_x;
if (offset_y)
*offset_y = cursor->image.offset_y;
return cursor->image.bo;
}

View File

@ -34,8 +34,7 @@ MetaCursorReference * meta_cursor_reference_from_theme (MetaCursor cur
#ifdef HAVE_WAYLAND
#include <wayland-server.h>
MetaCursorReference * meta_cursor_reference_from_buffer (struct wl_resource *buffer,
int hot_x,
int hot_y);
int offset_x, int offset_y);
#endif
MetaCursor meta_cursor_reference_get_meta_cursor (MetaCursorReference *cursor);

View File

@ -72,16 +72,16 @@ set_crtc_cursor (MetaCursorRendererNative *native,
struct gbm_bo *bo;
union gbm_bo_handle handle;
int width, height;
int hot_x, hot_y;
int offset_x, offset_y;
bo = meta_cursor_reference_get_gbm_bo (cursor, &hot_x, &hot_y);
bo = meta_cursor_reference_get_gbm_bo (cursor, &offset_x, &offset_y);
handle = gbm_bo_get_handle (bo);
width = gbm_bo_get_width (bo);
height = gbm_bo_get_height (bo);
drmModeSetCursor2 (priv->drm_fd, crtc->crtc_id, handle.u32,
width, height, hot_x, hot_y);
width, height, -offset_x, -offset_y);
}
else
{