From: Po Lu Date: Fri, 13 May 2022 08:32:10 +0000 (+0800) Subject: Minor cleanups to PGTK code X-Git-Tag: emacs-29.0.90~1910^2~740 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1a6def02cd1ff50e611d23259d7129acc2165dda;p=emacs.git Minor cleanups to PGTK code * src/pgtkterm.c (pgtk_text_scaling_factor): Rename to `pgtk_get_text_scaling_factor', clean up coding style, and fix leak of GSettings object. (pgtk_term_init): Clean up coding style and fix scroll increments. --- diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 4d6221d8034..98567be18cd 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -6283,18 +6283,32 @@ same_x_server (const char *name1, const char *name2) #define GNOME_INTERFACE_SCHEMA "org.gnome.desktop.interface" -static gdouble pgtk_text_scaling_factor (void) +static gdouble +pgtk_get_text_scaling_factor (void) { - GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default (); + GSettingsSchemaSource *schema_source; + GSettingsSchema *schema; + GSettings *settings; + double factor; + + schema_source = g_settings_schema_source_get_default (); + if (schema_source != NULL) { - GSettingsSchema *schema = g_settings_schema_source_lookup (schema_source, - GNOME_INTERFACE_SCHEMA, true); - if (schema != NULL) + schema = g_settings_schema_source_lookup (schema_source, + GNOME_INTERFACE_SCHEMA, + true); + + if (schema) { g_settings_schema_unref (schema); - GSettings *set = g_settings_new (GNOME_INTERFACE_SCHEMA); - return g_settings_get_double (set, "text-scaling-factor"); + + settings = g_settings_new (GNOME_INTERFACE_SCHEMA); + factor = g_settings_get_double (settings, + "text-scaling-factor"); + + g_object_unref (settings); + return factor; } } return 1; @@ -6317,6 +6331,8 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) char *dpy_name; static void *handle = NULL; Lisp_Object lisp_dpy_name = Qnil; + GdkScreen *gscr; + gdouble dpi; block_input (); @@ -6468,20 +6484,20 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) reset_mouse_highlight (&dpyinfo->mouse_highlight); { - GdkScreen *gscr = gdk_display_get_default_screen (dpyinfo->gdpy); + gscr = gdk_display_get_default_screen (dpyinfo->gdpy); + dpi = gdk_screen_get_resolution (gscr); - gdouble dpi = gdk_screen_get_resolution (gscr); if (dpi < 0) - dpi = 96.0; + dpi = 96.0; - dpi *= pgtk_text_scaling_factor (); + dpi *= pgtk_get_text_scaling_factor (); dpyinfo->resx = dpi; dpyinfo->resy = dpi; } - /* smooth scroll setting */ - dpyinfo->scroll.x_per_char = 2; - dpyinfo->scroll.y_per_line = 2; + /* Set up scrolling increments. */ + dpyinfo->scroll.x_per_char = 1; + dpyinfo->scroll.y_per_line = 1; dpyinfo->connection = -1;