]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor cleanups to PGTK code
authorPo Lu <luangruo@yahoo.com>
Fri, 13 May 2022 08:32:10 +0000 (16:32 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 13 May 2022 08:32:10 +0000 (16:32 +0800)
* 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.

src/pgtkterm.c

index 4d6221d8034f6ea8684b82f9e4328b416d908ddf..98567be18cd089dab40f13fed371e6a02f3e91f2 100644 (file)
@@ -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;