display: Fix cursor sprite sizes with fractional scales
This makes the cursor size match the expectation given by the theme size. It also means the sprite size now matches GTK4 provided cursor surfaces using wp_viewport. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
This commit is contained in:
parent
8fc1bddf3b
commit
f77d8e2a12
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user