diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c index aa310316c..6dac285ba 100644 --- a/src/backends/meta-cursor-sprite-xcursor.c +++ b/src/backends/meta-cursor-sprite-xcursor.c @@ -247,9 +247,11 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor) if (meta_is_wayland_compositor ()) { - hotspot_x = ((int) (xc_image->xhot / sprite_xcursor->theme_scale) * + hotspot_x = ((int) roundf ((float) xc_image->xhot / + sprite_xcursor->theme_scale) * sprite_xcursor->theme_scale); - hotspot_y = ((int) (xc_image->yhot / sprite_xcursor->theme_scale) * + hotspot_y = ((int) roundf ((float) xc_image->yhot / + sprite_xcursor->theme_scale) * sprite_xcursor->theme_scale); } else @@ -273,6 +275,25 @@ meta_cursor_sprite_xcursor_set_theme_scale (MetaCursorSpriteXcursor *sprite_xcur sprite_xcursor->theme_scale = theme_scale; } +void +meta_cursor_sprite_xcursor_get_scaled_image_size (MetaCursorSpriteXcursor *sprite_xcursor, + int *width, + int *height) +{ + XcursorImage *current_image; + int theme_size; + int image_size; + float effective_theme_scale; + + current_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor); + theme_size = meta_prefs_get_cursor_size (); + image_size = current_image->size; + effective_theme_scale = (float) theme_size / image_size; + + *width = (int) ceilf (current_image->width * effective_theme_scale); + *height = (int) ceilf (current_image->width * effective_theme_scale); +} + static gboolean meta_cursor_sprite_xcursor_is_animated (MetaCursorSprite *sprite) { diff --git a/src/backends/meta-cursor-sprite-xcursor.h b/src/backends/meta-cursor-sprite-xcursor.h index 33f112ba2..3721b0fbe 100644 --- a/src/backends/meta-cursor-sprite-xcursor.h +++ b/src/backends/meta-cursor-sprite-xcursor.h @@ -38,6 +38,10 @@ MetaCursor meta_cursor_sprite_xcursor_get_cursor (MetaCursorSpriteXcursor *sprit XcursorImage * meta_cursor_sprite_xcursor_get_current_image (MetaCursorSpriteXcursor *sprite_xcursor); +void meta_cursor_sprite_xcursor_get_scaled_image_size (MetaCursorSpriteXcursor *sprite_xcursor, + int *width, + int *height); + META_EXPORT_TEST const char * meta_cursor_get_name (MetaCursor cursor); diff --git a/src/core/display.c b/src/core/display.c index 960d071da..2c02dc824 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1697,12 +1697,19 @@ root_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor, if (best_scale != 0.0f) { float ceiled_scale; + int cursor_width, cursor_height; ceiled_scale = ceilf (best_scale); meta_cursor_sprite_xcursor_set_theme_scale (sprite_xcursor, (int) ceiled_scale); - meta_cursor_sprite_set_texture_scale (cursor_sprite, - 1.0f / ceiled_scale); + + meta_cursor_sprite_realize_texture (cursor_sprite); + meta_cursor_sprite_xcursor_get_scaled_image_size (sprite_xcursor, + &cursor_width, + &cursor_height); + meta_cursor_sprite_set_viewport_dst_size (cursor_sprite, + cursor_width, + cursor_height); } } else