[gtk/matthiasc/for-master: 3/3] textutil: Do a little better on retro X servers
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 3/3] textutil: Do a little better on retro X servers
- Date: Sat, 8 Aug 2020 22:10:54 +0000 (UTC)
commit f9c6f6806afb2f34a446f0ea354063049f68d6ce
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 8 18:06:12 2020 -0400
textutil: Do a little better on retro X servers
When running on a non-composited, non-rgba X server
(such as Xnest), force the drag icons for text selections
to have a background, so we don't end up with black
text on black background.
Fixes: #3048
gtk/gtktextutil.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 6110046084..c55e86d1d5 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -108,10 +108,12 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
GtkCssStyle *style;
GtkSnapshot *snapshot;
PangoContext *context;
- PangoLayout *layout;
+ PangoLayout *layout;
GdkPaintable *paintable;
- int layout_width;
+ int layout_width;
+ int layout_height;
const GdkRGBA *color;
+ GdkDisplay *display;
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (text != NULL, NULL);
@@ -133,6 +135,24 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
color = gtk_css_color_value_get_rgba (style->core->color);
+ display = gtk_widget_get_display (widget);
+
+ if (!gdk_display_is_rgba (display) ||
+ !gdk_display_is_composited (display))
+ {
+ GtkWidget *bg_widget;
+
+ if (GTK_IS_TEXT (widget))
+ bg_widget = gtk_widget_get_parent (widget);
+ else
+ bg_widget = widget;
+ pango_layout_get_size (layout, &layout_width, &layout_height);
+ gtk_snapshot_render_background (snapshot,
+ gtk_widget_get_style_context (bg_widget),
+ 0, 0, layout_width / PANGO_SCALE,
+ layout_height / PANGO_SCALE);
+ }
+
gtk_snapshot_append_layout (snapshot, layout, color);
paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);
@@ -194,6 +214,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
GtkTextAttributes *style;
PangoContext *ltr_context, *rtl_context;
GtkTextIter iter;
+ GdkDisplay *display;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
@@ -251,6 +272,16 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
snapshot = gtk_snapshot_new ();
+ display = gtk_widget_get_display (widget);
+
+ if (!gdk_display_is_rgba (display) ||
+ !gdk_display_is_composited (display))
+ {
+ gtk_snapshot_render_background (snapshot,
+ gtk_widget_get_style_context (widget),
+ 0, 0, layout_width, layout_height);
+ }
+
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height },
1.0);
g_object_unref (layout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]