From 0dcc9fdc17773eb9154c43081e82c5bfb728e30e Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 11 Mar 2022 20:11:57 +0800 Subject: [PATCH] Fix initial values of scroll bar foreground and background on GTK 3 * 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 | 8 ------- src/xfns.c | 65 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index f488b0ff752..fd32dc15bf2 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -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. */ diff --git a/src/xfns.c b/src/xfns.c index 65f3b5097c3..a1d6fd29df9 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -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); -- 2.39.2