Merge branch 'matthiasc/for-main' into 'main'

wayland: Tweak cursor sizing code

See merge request GNOME/gtk!7244
This commit is contained in:
Matthias Clasen
2024-05-11 03:40:53 +00:00
2 changed files with 43 additions and 39 deletions

7
NEWS
View File

@@ -6,6 +6,7 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
* CSS:
- Support the :root selector
- Support variables and custom properties
* Icontheme:
- Make symbolic svg loading more efficient
@@ -14,19 +15,22 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
* Accessibility:
- Make the gtk-demo sidebar search more accessible
- Stop emitting focus events
- Realize child contexts when necessary
* GDK:
- Support XDG_ACTIVATION_TOKEN
- dmabuf: Be more defensive when importing unknown formats to GL
- dmabuf: Use narrow range for YUV
- vulkan: Recreate swapchains when necessary or beneficial
* GSK:
- Improve logging for GDK_DEBUG=offload
- Improve logging for GSK_DEBUG=renderer
- gpu: Warn about inefficient texture import
- gpu: Handle tiny offscreens correctly
- gpu: Handle tiny offscreens correctly
- vulkan: Add profiler marks in various places
- vulkan: Fix a problem with imported dmabufs showing up black
- cairo: Speed up mask nodes, since we use them for symbolic icons
* Wayland:
- Use wl_compositor version 6
@@ -46,6 +50,7 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
* Translation updates:
Korean
Portuguese
Turkish

View File

@@ -165,25 +165,29 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
double *scale)
{
GdkTexture *texture;
int desired_scale_factor;
desired_scale_factor = (int) ceil (desired_scale);
if (gdk_cursor_get_name (cursor))
{
struct wl_cursor *c;
int scale_factor;
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
goto none;
{
*hotspot_x = *hotspot_y = 0;
*width = *height = 0;
*scale = 1;
return NULL;
}
scale_factor = (int) ceil (desired_scale);
c = gdk_wayland_cursor_load_for_name (display,
_gdk_wayland_display_get_cursor_theme (display),
desired_scale_factor,
display->cursor_theme,
scale_factor,
gdk_cursor_get_name (cursor));
if (c && c->image_count > 0)
{
struct wl_cursor_image *image;
int cursor_scale;
if (image_index >= c->image_count)
{
@@ -195,23 +199,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
image = c->images[image_index];
cursor_scale = desired_scale_factor;
if ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
*width = display->cursor_theme_size;
*height = display->cursor_theme_size;
*scale = image->width / (double) *width;
*hotspot_x = image->hotspot_x / scale_factor;
*hotspot_y = image->hotspot_y / scale_factor;
if (*scale != scale_factor && !use_viewporter)
{
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
"multiple of scale (%d)", image->width, image->height,
cursor_scale);
cursor_scale = 1;
g_warning (G_STRLOC " cursor image size (%d) not an integer "
"multiple of theme size (%d)", image->width, *width);
*width = image->width;
*height = image->height;
*hotspot_x = image->hotspot_x;
*hotspot_y = image->hotspot_y;
*scale = 1;
}
*hotspot_x = image->hotspot_x / cursor_scale;
*hotspot_y = image->hotspot_y / cursor_scale;
*width = image->width / cursor_scale;
*height = image->height / cursor_scale;
*scale = cursor_scale;
return wl_cursor_image_get_buffer (image);
}
}
@@ -257,7 +261,7 @@ from_texture:
else
{
if (!use_viewporter)
*scale = desired_scale_factor;
*scale = ceil (desired_scale);
else
*scale = desired_scale;
@@ -294,28 +298,23 @@ from_texture:
}
if (gdk_cursor_get_fallback (cursor))
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
{
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
}
else
{
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
goto from_texture;
}
none:
*hotspot_x = 0;
*hotspot_y = 0;
*width = 0;
*height = 0;
*scale = 1;
return NULL;
g_assert_not_reached ();
}
guint