Merge branch 'cursor-size' into 'main'

GtkSettings: Provide settings in logical pixels also on X11

Closes #5223 and #5230

See merge request GNOME/gtk!5172
This commit is contained in:
Matthias Clasen
2022-11-08 16:27:06 +00:00
2 changed files with 28 additions and 8 deletions

View File

@@ -281,27 +281,32 @@ gdk_x11_display_set_cursor_theme (GdkDisplay *display,
const int size)
{
#if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2
GdkX11Screen *x11_screen;
Display *xdisplay;
char *old_theme;
int real_size;
int old_size;
gpointer cursor, xcursor;
GHashTableIter iter;
g_return_if_fail (GDK_IS_DISPLAY (display));
x11_screen = gdk_x11_display_get_screen (display);
xdisplay = GDK_DISPLAY_XDISPLAY (display);
real_size = size * x11_screen->surface_scale;
old_theme = XcursorGetTheme (xdisplay);
old_size = XcursorGetDefaultSize (xdisplay);
if (old_size == size &&
if (old_size == real_size &&
(old_theme == theme ||
(old_theme && theme && strcmp (old_theme, theme) == 0)))
return;
XcursorSetTheme (xdisplay, theme);
if (size > 0)
XcursorSetDefaultSize (xdisplay, size);
if (real_size > 0)
XcursorSetDefaultSize (xdisplay, real_size);
if (GDK_X11_DISPLAY (display)->cursors == NULL)
return;

View File

@@ -457,16 +457,31 @@ read_settings (GdkX11Screen *x11_screen,
}
}
if (do_notify)
notify_changes (x11_screen, old_list);
if (old_list)
g_hash_table_unref (old_list);
g_value_init (&value, G_TYPE_INT);
if (!x11_screen->fixed_surface_scale &&
gdk_display_get_setting (display, "gdk-window-scaling-factor", &value))
_gdk_x11_screen_set_surface_scale (x11_screen, g_value_get_int (&value));
/* XSettings gives us the cursor theme size in physical pixel size,
* while we want logical pixel values instead.
*/
if (x11_screen->surface_scale > 1 &&
gdk_display_get_setting (display, "gtk-cursor-theme-size", &value))
{
int cursor_theme_size = g_value_get_int (&value);
copy = g_new0 (GValue, 1);
g_value_init (copy, G_TYPE_INT);
g_value_set_int (copy, cursor_theme_size / x11_screen->surface_scale);
g_hash_table_insert (x11_screen->xsettings,
(gpointer) "gtk-cursor-theme-size", copy);
}
if (do_notify)
notify_changes (x11_screen, old_list);
if (old_list)
g_hash_table_unref (old_list);
}
static Atom