emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a24f710395: Don't use the Gtk region face


From: Lars Ingebrigtsen
Subject: master a24f710395: Don't use the Gtk region face
Date: Sat, 23 Jul 2022 04:52:45 -0400 (EDT)

branch: master
commit a24f710395f9777cb9f8b000300e5e9c892d7794
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Don't use the Gtk region face
    
    * lisp/faces.el (region): Don't use the Gtk region face, because
    it produces low contrast combinations (bug#46493).
    * src/gtkutil.h:
    * src/gtkutil.c (xg_check_special_colors): Remove.
    
    * src/xfns.c (x_defined_color):
    * src/pgtkterm.c (pgtk_defined_color): Don't call.
---
 etc/NEWS       |  7 +++++
 lisp/faces.el  |  3 ---
 src/gtkutil.c  | 82 ----------------------------------------------------------
 src/gtkutil.h  |  3 ---
 src/pgtkterm.c |  4 +--
 src/xfns.c     |  6 +----
 6 files changed, 9 insertions(+), 96 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 666699e8c6..780dbfa51e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -166,6 +166,13 @@ of 'user-emacs-directory'.
 
 * Incompatible changes in Emacs 29.1
 
+---
+*** The Gtk selection face is no longer used for the region.
+The combination of a Gtk-controlled background and a foreground colour
+controlled by the internal Emacs machinery led to low-contrast faces
+in common default setups.  Emacs now uses the same 'region' face on
+Gtk and non-Gtk setups.
+
 ** Dired
 
 ---
diff --git a/lisp/faces.el b/lisp/faces.el
index f04ea9115e..b2589c5c06 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2502,9 +2502,6 @@ default."
 (defface region
   '((((class color) (min-colors 88) (background dark))
      :background "blue3" :extend t)
-    (((class color) (min-colors 88) (background light) (type gtk))
-     :distant-foreground "gtk_selection_fg_color"
-     :background "gtk_selection_bg_color" :extend t)
     (((class color) (min-colors 88) (background light) (type ns))
      :distant-foreground "ns_selection_fg_color"
      :background "ns_selection_bg_color" :extend t)
diff --git a/src/gtkutil.c b/src/gtkutil.c
index a6bba096a4..87f166bf54 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -727,88 +727,6 @@ get_utf8_string (const char *str)
   return utf8_str;
 }
 
-/* Check for special colors used in face spec for region face.
-   The colors are fetched from the Gtk+ theme.
-   Return true if color was found, false if not.  */
-
-bool
-xg_check_special_colors (struct frame *f,
-                         const char *color_name,
-                         Emacs_Color *color)
-{
-  bool success_p;
-  bool get_bg;
-  bool get_fg;
-#ifdef HAVE_GTK3
-  GtkStyleContext *gsty;
-  GdkRGBA col;
-  char buf[sizeof "rgb://rrrr/gggg/bbbb"];
-  int state;
-  GdkRGBA *c;
-  unsigned short r, g, b;
-#else
-  GtkStyle *gsty;
-  GdkColor *grgb;
-#endif
-
-  get_bg = !strcmp ("gtk_selection_bg_color", color_name);
-  get_fg = !get_bg && !strcmp ("gtk_selection_fg_color", color_name);
-  success_p = false;
-
-#ifdef HAVE_PGTK
-  while (FRAME_PARENT_FRAME (f))
-    f = FRAME_PARENT_FRAME (f);
-#endif
-
-  if (!FRAME_GTK_WIDGET (f) || !(get_bg || get_fg))
-    return success_p;
-
-  block_input ();
-#ifdef HAVE_GTK3
-  gsty = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
-  state = GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED;
-
-  if (get_fg)
-    gtk_style_context_get_color (gsty, state, &col);
-  else
-    {
-      /* FIXME: Retrieving the background color is deprecated in
-        GTK+ 3.16.  New versions of GTK+ don't use the concept of a
-        single background color any more, so we shouldn't query for
-        it.  */
-      gtk_style_context_get (gsty, state,
-                            GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
-                            NULL);
-      col = *c;
-      gdk_rgba_free (c);
-    }
-
-  r = col.red * 65535;
-  g = col.green * 65535;
-  b = col.blue * 65535;
-#ifndef HAVE_PGTK
-  sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b);
-  success_p = x_parse_color (f, buf, color) != 0;
-#else
-  sprintf (buf, "#%04x%04x%04x", r, g, b);
-  success_p = pgtk_parse_color (f, buf, color) != 0;
-#endif
-#else
-  gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f));
-  grgb = (get_bg ? &gsty->bg[GTK_STATE_SELECTED]
-         : &gsty->fg[GTK_STATE_SELECTED]);
-
-  color->red = grgb->red;
-  color->green = grgb->green;
-  color->blue = grgb->blue;
-  color->pixel = grgb->pixel;
-  success_p = 1;
-#endif
-  unblock_input ();
-  return success_p;
-}
-
-
 
 /***********************************************************************
                               Tooltips
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 190d662831..32b1fedbaa 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -179,9 +179,6 @@ extern GdkCursor * xg_create_default_cursor (GdkDisplay 
*gdpy);
 extern bool xg_create_frame_widgets (struct frame *f);
 extern void xg_free_frame_widgets (struct frame *f);
 extern void xg_set_background_color (struct frame *f, unsigned long bg);
-extern bool xg_check_special_colors (struct frame *f,
-                                    const char *color_name,
-                                    Emacs_Color *color);
 #ifdef HAVE_PGTK
 extern void xg_create_frame_outer_widgets (struct frame *f);
 #endif
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index b283cef7cd..54e70255f4 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -6913,9 +6913,7 @@ pgtk_defined_color (struct frame *f, const char *name,
   int r;
 
   block_input ();
-  r = xg_check_special_colors (f, name, color_def);
-  if (!r)
-    r = pgtk_parse_color (f, name, color_def);
+  r = pgtk_parse_color (f, name, color_def);
   unblock_input ();
   return r;
 }
diff --git a/src/xfns.c b/src/xfns.c
index ce867c1619..7d394bd4f5 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -670,11 +670,7 @@ x_defined_color (struct frame *f, const char *color_name,
   Colormap cmap = FRAME_X_COLORMAP (f);
 
   block_input ();
-#ifdef USE_GTK
-  success_p = xg_check_special_colors (f, color_name, color);
-#endif
-  if (!success_p)
-    success_p = x_parse_color (f, color_name, color) != 0;
+  success_p = x_parse_color (f, color_name, color) != 0;
   if (success_p && alloc_p)
     success_p = x_alloc_nearest_color (f, cmap, color);
   unblock_input ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]