]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix initial values of scroll bar foreground and background on GTK 3
authorPo Lu <luangruo@yahoo.com>
Fri, 11 Mar 2022 12:11:57 +0000 (20:11 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 11 Mar 2022 12:26:31 +0000 (20:26 +0800)
* src/gtkutil.c (xg_create_frame_widgets): Stop creating
scrollbar stylesheet providers.
* src/xfns.c (Fx_create_frame): Create scroll bar stylesheet
providers here instead.
(x_set_scroll_bar_background):
(x_set_scroll_bar_foreground): Ignore tooltip frames.

src/gtkutil.c
src/xfns.c

index f488b0ff7521a46d47ca2f587ca80242420deb3e..fd32dc15bf26e9da376898a4b36f37c1bf094eca 100644 (file)
@@ -1631,14 +1631,6 @@ xg_create_frame_widgets (struct frame *f)
                     G_CALLBACK (delete_cb), f);
 #endif
 
-#if defined HAVE_GTK3 && !defined HAVE_PGTK
-  /* On PGTK this is done in Fx_create_frame.  */
-  FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider
-    = gtk_css_provider_new ();
-  FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider
-    = gtk_css_provider_new ();
-#endif
-
   /* Convert our geometry parameters into a geometry string
      and specify it.
      GTK will itself handle calculating the real position this way.  */
index 65f3b5097c34db462c7c4ac65fcd0056b2c682b9..a1d6fd29df9cd678f56898f0ef8f589736f0e018 100644 (file)
@@ -1970,22 +1970,25 @@ x_set_scroll_bar_foreground (struct frame *f, Lisp_Object value, Lisp_Object old
     }
 
 #ifdef HAVE_GTK3
-  if (pixel != -1)
+  if (!FRAME_TOOLTIP_P (f))
     {
-      color.pixel = pixel;
+      if (pixel != -1)
+       {
+         color.pixel = pixel;
 
-      XQueryColor (FRAME_X_DISPLAY (f),
-                  FRAME_X_COLORMAP (f),
-                  &color);
+         XQueryColor (FRAME_X_DISPLAY (f),
+                      FRAME_X_COLORMAP (f),
+                      &color);
 
-      sprintf (css, "scrollbar slider { background-color: #%02x%02x%02x; }",
-              color.red >> 8, color.green >> 8, color.blue >> 8);
-      gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider,
-                                      css, -1, NULL);
+         sprintf (css, "scrollbar slider { background-color: #%02x%02x%02x; }",
+                  color.red >> 8, color.green >> 8, color.blue >> 8);
+         gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider,
+                                          css, -1, NULL);
+       }
+      else
+       gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider,
+                                        "", -1, NULL);
     }
-  else
-    gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider,
-                                    "", -1, NULL);
 #endif
 }
 
@@ -2040,22 +2043,25 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old
     }
 
 #ifdef HAVE_GTK3
-  if (pixel != -1)
-    {
-      color.pixel = pixel;
+    if (!FRAME_TOOLTIP_P (f))
+      {
+       if (pixel != -1)
+         {
+           color.pixel = pixel;
 
-      XQueryColor (FRAME_X_DISPLAY (f),
-                  FRAME_X_COLORMAP (f),
-                  &color);
+           XQueryColor (FRAME_X_DISPLAY (f),
+                        FRAME_X_COLORMAP (f),
+                        &color);
 
-      sprintf (css, "scrollbar trough { background-color: #%02x%02x%02x; }",
-              color.red >> 8, color.green >> 8, color.blue >> 8);
-      gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider,
-                                      css, -1, NULL);
-    }
-  else
-    gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider,
-                                    "", -1, NULL);
+           sprintf (css, "scrollbar trough { background-color: #%02x%02x%02x; }",
+                    color.red >> 8, color.green >> 8, color.blue >> 8);
+           gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider,
+                                            css, -1, NULL);
+         }
+       else
+         gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider,
+                                          "", -1, NULL);
+      }
 #endif
 }
 
@@ -4759,6 +4765,13 @@ This function is an internal primitive--use `make-frame' instead.  */)
   gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
                          NULL, NULL, RES_TYPE_BOOLEAN);
 
+#ifdef HAVE_GTK3
+  FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider
+    = gtk_css_provider_new ();
+  FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider
+    = gtk_css_provider_new ();
+#endif
+
   x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground,
                                        "scrollBarForeground",
                                        "ScrollBarForeground", true);