aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-30 09:23:40 +0800
committerPo Lu2022-01-30 09:23:40 +0800
commit310bcda934a88f2c93e8b34b093853ce695c8d3b (patch)
tree1f34a467f619f2173adcff7b03cf4611db1637bd /src
parent391c1289e28ce11d5639a4d754ec36e7b26aa6ac (diff)
downloademacs-310bcda934a88f2c93e8b34b093853ce695c8d3b.tar.gz
emacs-310bcda934a88f2c93e8b34b093853ce695c8d3b.zip
Add support for ARGB visuals on non-Xt builds
* src/gtkutil.c (xg_create_frame_widgets): Enable RGBA visual on non-PGTK builds. * src/xfns.c (select_visual): Select 32-bit visuals on non-Xt builds. * src/xterm.c (x_draw_fringe_bitmap): (x_draw_image_glyph_string): Stop using DefaultDepthOfScreen. (x_query_colors): * src/xterm.h (x_make_truecolor_pixel): Make colors opaque on 32-bit visuals.
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/xfns.c4
-rw-r--r--src/xterm.c19
-rw-r--r--src/xterm.h7
4 files changed, 23 insertions, 9 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 067df216a4a..ef6270dbcf8 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1593,7 +1593,7 @@ xg_create_frame_widgets (struct frame *f)
1593 1593
1594 GdkScreen *screen = gtk_widget_get_screen (wtop); 1594 GdkScreen *screen = gtk_widget_get_screen (wtop);
1595 1595
1596#if !defined HAVE_PGTK && defined USE_CAIRO 1596#if !defined HAVE_PGTK
1597 if (FRAME_DISPLAY_INFO (f)->n_planes == 32) 1597 if (FRAME_DISPLAY_INFO (f)->n_planes == 32)
1598 { 1598 {
1599 GdkVisual *visual = gdk_screen_get_rgba_visual (screen); 1599 GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
diff --git a/src/xfns.c b/src/xfns.c
index b37ba139a22..7fe181fa3fd 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -6375,7 +6375,7 @@ select_visual (struct x_display_info *dpyinfo)
6375 6375
6376 vinfo_template.screen = XScreenNumberOfScreen (screen); 6376 vinfo_template.screen = XScreenNumberOfScreen (screen);
6377 6377
6378#if defined (USE_GTK) && defined (USE_CAIRO) 6378#if !defined USE_X_TOOLKIT
6379 /* First attempt to use 32-bit visual if available */ 6379 /* First attempt to use 32-bit visual if available */
6380 6380
6381 vinfo_template.depth = 32; 6381 vinfo_template.depth = 32;
@@ -6391,7 +6391,7 @@ select_visual (struct x_display_info *dpyinfo)
6391 return; 6391 return;
6392 } 6392 }
6393 6393
6394#endif /* USE_GTK && USE_CAIRO */ 6394#endif /* !USE_X_TOOLKIT */
6395 6395
6396 /* 32-bit visual not available, fallback to default visual */ 6396 /* 32-bit visual not available, fallback to default visual */
6397 dpyinfo->visual = DefaultVisualOfScreen (screen); 6397 dpyinfo->visual = DefaultVisualOfScreen (screen);
diff --git a/src/xterm.c b/src/xterm.c
index ab5fd46c4c0..209e99fc09c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1966,7 +1966,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
1966 Drawable drawable = FRAME_X_DRAWABLE (f); 1966 Drawable drawable = FRAME_X_DRAWABLE (f);
1967 char *bits; 1967 char *bits;
1968 Pixmap pixmap, clipmask = (Pixmap) 0; 1968 Pixmap pixmap, clipmask = (Pixmap) 0;
1969 int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); 1969 int depth = FRAME_DISPLAY_INFO (f)->n_planes;
1970 XGCValues gcv; 1970 XGCValues gcv;
1971 1971
1972 if (p->wd > 8) 1972 if (p->wd > 8)
@@ -2812,12 +2812,12 @@ void
2812x_query_colors (struct frame *f, XColor *colors, int ncolors) 2812x_query_colors (struct frame *f, XColor *colors, int ncolors)
2813{ 2813{
2814 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 2814 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
2815 int i;
2815 2816
2816 if (dpyinfo->red_bits > 0) 2817 if (dpyinfo->red_bits > 0)
2817 { 2818 {
2818 /* For TrueColor displays, we can decompose the RGB value 2819 /* For TrueColor displays, we can decompose the RGB value
2819 directly. */ 2820 directly. */
2820 int i;
2821 unsigned int rmult, gmult, bmult; 2821 unsigned int rmult, gmult, bmult;
2822 unsigned int rmask, gmask, bmask; 2822 unsigned int rmask, gmask, bmask;
2823 2823
@@ -2854,6 +2854,12 @@ x_query_colors (struct frame *f, XColor *colors, int ncolors)
2854 colors[i].green = (g * gmult) >> 16; 2854 colors[i].green = (g * gmult) >> 16;
2855 colors[i].blue = (b * bmult) >> 16; 2855 colors[i].blue = (b * bmult) >> 16;
2856 } 2856 }
2857
2858 if (FRAME_DISPLAY_INFO (f)->n_planes == 32)
2859 {
2860 for (i = 0; i < ncolors; ++i)
2861 colors[i].pixel |= ((unsigned long) 0xFF << 24);
2862 }
2857 return; 2863 return;
2858 } 2864 }
2859 2865
@@ -2871,6 +2877,12 @@ x_query_colors (struct frame *f, XColor *colors, int ncolors)
2871 } 2877 }
2872 2878
2873 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors); 2879 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors);
2880
2881 if (FRAME_DISPLAY_INFO (f)->n_planes == 32)
2882 {
2883 for (i = 0; i < ncolors; ++i)
2884 colors[i].pixel |= ((unsigned long) 0xFF << 24);
2885 }
2874} 2886}
2875 2887
2876/* Store F's background color into *BGCOLOR. */ 2888/* Store F's background color into *BGCOLOR. */
@@ -3924,8 +3936,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
3924 /* Create a pixmap as large as the glyph string. Fill it 3936 /* Create a pixmap as large as the glyph string. Fill it
3925 with the background color. Copy the image to it, using 3937 with the background color. Copy the image to it, using
3926 its mask. Copy the temporary pixmap to the display. */ 3938 its mask. Copy the temporary pixmap to the display. */
3927 Screen *screen = FRAME_X_SCREEN (s->f); 3939 int depth = FRAME_DISPLAY_INFO (s->f)->n_planes;
3928 int depth = DefaultDepthOfScreen (screen);
3929 3940
3930 /* Create a pixmap as large as the glyph string. */ 3941 /* Create a pixmap as large as the glyph string. */
3931 pixmap = XCreatePixmap (display, FRAME_X_DRAWABLE (s->f), 3942 pixmap = XCreatePixmap (display, FRAME_X_DRAWABLE (s->f),
diff --git a/src/xterm.h b/src/xterm.h
index 33887be52b0..aa5bd2caa19 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1270,7 +1270,7 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time t)
1270INLINE unsigned long 1270INLINE unsigned long
1271x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b) 1271x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
1272{ 1272{
1273 unsigned long pr, pg, pb; 1273 unsigned long pr, pg, pb, pa = 0;
1274 1274
1275 /* Scale down RGB values to the visual's bits per RGB, and shift 1275 /* Scale down RGB values to the visual's bits per RGB, and shift
1276 them to the right position in the pixel color. Note that the 1276 them to the right position in the pixel color. Note that the
@@ -1279,8 +1279,11 @@ x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
1279 pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset; 1279 pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
1280 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset; 1280 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset;
1281 1281
1282 if (dpyinfo->n_planes == 32)
1283 pa = ((unsigned long) 0xFF << 24);
1284
1282 /* Assemble the pixel color. */ 1285 /* Assemble the pixel color. */
1283 return pr | pg | pb; 1286 return pr | pg | pb | pa;
1284} 1287}
1285 1288
1286/* If display has an immutable color map, freeing colors is not 1289/* If display has an immutable color map, freeing colors is not