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

View File

@@ -94,12 +94,12 @@ update_cursor (MetaCursorRenderer *renderer)
if (priv->displayed_cursor) if (priv->displayed_cursor)
{ {
CoglTexture *texture; 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.x = priv->current_x + offset_x;
priv->current_rect.y = priv->current_y - hot_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));
} }

View File

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

View File

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

View File

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

View File

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