From: "Håkon Flatval" <hkon20@hotmail.com>
To: Po Lu <luangruo@yahoo.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Sv: Sv: Sv: Support for background transparency
Date: Sat, 29 Jan 2022 01:01:23 +0100 [thread overview]
Message-ID: <PRAP251MB0688131736C3B37FB5EA8324CF229@PRAP251MB0688.EURP251.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <87ee4ukn5u.fsf@yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
> Well, it's not a prerequisite to installing your change, but could you
> please attach to that frozen Emacs process with gdb and print a
> backtrace?
I have attached the backtrace I got from attaching with gdb to the
frozen process. I also removed the `defined (USE_CAIRO)` part from
the preprocessor statement, so that cairo builds can now have 32-
bit visuals.
- Håkon
[-- Attachment #2: bt2 --]
[-- Type: application/octet-stream, Size: 6206 bytes --]
#0 0x00007fec29d680da in __futex_abstimed_wait_common64 () at /lib64/libpthread.so.0
#1 0x00007fec29d61c20 in pthread_cond_wait@@GLIBC_2.3.2 () at /lib64/libpthread.so.0
#2 0x00007fec2b4ea3b3 in _XReply () at /usr/lib64/libX11.so.6
#3 0x00007fec2b4e5bbb in XSync () at /usr/lib64/libX11.so.6
#4 0x00007fec2b4e5c5b in _XSyncFunction () at /usr/lib64/libX11.so.6
#5 0x00007fec2b5f62cb in XdbeDeallocateBackBufferName () at /usr/lib64/libXext.so.6
#6 0x0000556e68b90a8b in tear_down_x_back_buffer (f=0x556e69f8daa0) at xfns.c:3338
#7 0x0000556e68b84601 in x_free_frame_resources (f=0x556e69f8daa0) at xterm.c:14494
#8 0x0000556e68b84fb1 in x_destroy_window (f=0x556e69f8daa0) at xterm.c:14651
#9 0x0000556e68a5a714 in delete_frame (frame=0x556e69f8daa5, force=0xb700) at frame.c:2207
#10 0x0000556e68b80a64 in x_connection_closed
(dpy=0x556e69e21ab0, error_message=0x7ffc70c96110 "X protocol error: BadMatch (invalid parameter attributes) on protocol request 70", ioerror=false) at xterm.c:12549
#11 0x0000556e68b80cb0 in x_error_quitter (display=0x556e69e21ab0, event=0x7ffc70c962c0)
at xterm.c:12652
#12 0x0000556e68b80bfb in x_error_handler (display=0x556e69e21ab0, event=0x7ffc70c962c0)
at xterm.c:12625
#13 0x00007fec2b4ec5f4 in _XError () at /usr/lib64/libX11.so.6
#14 0x00007fec2b4e9337 in handle_error () at /usr/lib64/libX11.so.6
#15 0x00007fec2b4e93d5 in handle_response () at /usr/lib64/libX11.so.6
#16 0x00007fec2b4ea3cd in _XReply () at /usr/lib64/libX11.so.6
#17 0x00007fec2b4e5bbb in XSync () at /usr/lib64/libX11.so.6
#18 0x00007fec2b4e5c5b in _XSyncFunction () at /usr/lib64/libX11.so.6
#19 0x00007fec2b4cb05a in XFillRectangle () at /usr/lib64/libX11.so.6
#20 0x0000556e68d6d8c8 in display_menu
(mw=0x556e6a058350, level=0, just_compute_p=0 '\000', highlighted_pos=0x0, hit=0x0, hit_return=0x0) at xlwmenu.c:1207
#21 0x0000556e68d7063a in XlwMenuRedisplay (w=0x556e6a058350, ev=0x0, region=0x0)
at xlwmenu.c:2085
#22 0x0000556e68d7065f in xlwmenu_redisplay (w=0x556e6a058350) at xlwmenu.c:2095
#23 0x0000556e68b7c5ca in handle_one_xevent
(dpyinfo=0x556e69e321e0, event=0x7ffc70c96e50, finish=0x7ffc70c96e40, hold_quit=0x7ffc70c96f70) at xterm.c:9173
#24 0x0000556e68b7f2ad in XTread_socket (terminal=0x556e69df9cf0, hold_quit=0x7ffc70c96f70)
at xterm.c:11843
#25 0x0000556e68bc7ec0 in gobble_input () at keyboard.c:7113
#26 0x0000556e68bc83b2 in handle_async_input () at keyboard.c:7344
#27 0x0000556e68bc83d1 in process_pending_signals () at keyboard.c:7358
#28 0x0000556e68bc8411 in unblock_input_to (level=0) at keyboard.c:7373
#29 0x0000556e68bc8446 in totally_unblock_input () at keyboard.c:7401
#30 0x0000556e68b831f2 in x_wait_for_event (f=0x556e69f8daa0, eventtype=19) at xterm.c:13793
#31 0x0000556e68b84186 in x_make_frame_visible (f=0x556e69f8daa0) at xterm.c:14276
#32 0x0000556e68b8436c in x_make_frame_visible_invisible (f=0x556e69f8daa0, visible=true)
at xterm.c:14344
#33 0x0000556e68a5b767 in Fmake_frame_visible (frame=0x556e69f8daa5) at frame.c:2731
#34 0x0000556e68c825d3 in funcall_subr
(subr=0x556e69145f00 <Smake_frame_visible>, numargs=1, args=0x7ffc70c972f8)
at eval.c:3137
#35 0x0000556e68cd4eab in exec_byte_code
(bytestr=0x7fec26b83ff4, vector=0x7fec26b82fb5, maxdepth=0x2e, args_template=256, nargs=1, args=0x7ffc70c977c8) at bytecode.c:676
#36 0x0000556e68cd4e54 in exec_byte_code
(bytestr=0x7fec26b840b4, vector=0x7fec26b82f35, maxdepth=0xe, args_template=257, nargs=1, args=0x7ffc70c97ef8) at bytecode.c:671
#37 0x0000556e68c828af in fetch_and_exec_byte_code
(fun=0x7fec26b82ee5, args_template=257, nargs=1, args=0x7ffc70c97ef0) at eval.c:3187
#38 0x0000556e68c82c72 in funcall_lambda
(fun=0x7fec26b82ee5, nargs=1, arg_vector=0x7ffc70c97ef0) at eval.c:3268
#39 0x0000556e68c820ba in funcall_general
(fun=0x7fec26b82ee5, numargs=1, args=0x7ffc70c97ef0) at eval.c:3035
#40 0x0000556e68c82316 in Ffuncall (nargs=2, args=0x7ffc70c97ee8) at eval.c:3085
#41 0x0000556e68c80fed in Fapply (nargs=2, args=0x7ffc70c97ee8) at eval.c:2649
#42 0x0000556e68c824de in funcall_subr
(subr=0x556e69154100 <Sapply>, numargs=2, args=0x7ffc70c97ee8) at eval.c:3117
#43 0x0000556e68cd4eab in exec_byte_code
(bytestr=0x7fec267f73e4, vector=0x7fec267f7405, maxdepth=0x3a, args_template=128, nargs=1, args=0x7ffc70c98420) at bytecode.c:676
#44 0x0000556e68cd4e54 in exec_byte_code
(bytestr=0x7fec26a4cd9c, vector=0x7fec268454d5, maxdepth=0x3a, args_template=256, nargs=1, args=0x7ffc70c98900) at bytecode.c:671
#45 0x0000556e68cd4e54 in exec_byte_code
(bytestr=0x7fec269c00fc, vector=0x7fec269bfe35, maxdepth=0x1a, args_template=0, nargs=0, args=0x7ffc70c98dd8) at bytecode.c:671
#46 0x0000556e68cd4e54 in exec_byte_code
(bytestr=0x7fec269c3a24, vector=0x7fec269971ad, maxdepth=0x3a, args_template=0, nargs=0, args=0x7ffc70c992e0) at bytecode.c:671
#47 0x0000556e68cd4e54 in exec_byte_code
(bytestr=0x7fec269c5d7c, vector=0x7fec26996975, maxdepth=0x26, args_template=0, nargs=0, args=0x7ffc70c99870) at bytecode.c:671
#48 0x0000556e68c828af in fetch_and_exec_byte_code
(fun=0x7fec26996935, args_template=0, nargs=0, args=0x7ffc70c99870) at eval.c:3187
#49 0x0000556e68c82c72 in funcall_lambda
(fun=0x7fec26996935, nargs=0, arg_vector=0x7ffc70c99870) at eval.c:3268
#50 0x0000556e68c82a68 in apply_lambda (fun=0x7fec26996935, args=0x0, count=4) at eval.c:3212
#51 0x0000556e68c80b3e in eval_sub (form=0x7fec26ea7233) at eval.c:2571
#52 0x0000556e68c7ff2b in Feval (form=0x7fec26ea7233, lexical=0x0) at eval.c:2349
#53 0x0000556e68bb974f in top_level_2 () at keyboard.c:1146
#54 0x0000556e68c7e0e5 in internal_condition_case
(bfun=0x556e68bb972c <top_level_2>, handlers=0x90, hfun=0x556e68bb904b <cmd_error>)
at eval.c:1485
#55 0x0000556e68bb97a0 in top_level_1 (ignore=0x0) at keyboard.c:1154
#56 0x0000556e68c7d78c in internal_catch
(tag=0xef70, func=0x556e68bb9751 <top_level_1>, arg=0x0) at eval.c:1216
#57 0x0000556e68bb9677 in command_loop () at keyboard.c:1114
#58 0x0000556e68bb8bed in recursive_edit_1 () at keyboard.c:724
#59 0x0000556e68bb8d99 in Frecursive_edit () at keyboard.c:807
#60 0x0000556e68bb5220 in main (argc=4, argv=0x7ffc70c99de8) at emacs.c:2427
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: gdk-cairo-background-transparency-010.patch --]
[-- Type: text/x-patch, Size: 16141 bytes --]
diff --git a/doc/emacs/xresources.texi b/doc/emacs/xresources.texi
index ccf7e35eee..bb362ca3ea 100644
--- a/doc/emacs/xresources.texi
+++ b/doc/emacs/xresources.texi
@@ -149,6 +149,15 @@ Table of Resources
is the case.
@table @asis
+@item @code{alpha} (class @code{Alpha})
+Sets the @samp{alpha} frame parameter, determining frame transparency
+(@pxref{Frame Parameters,,, elisp, The Emacs Lisp Reference Manual}).
+
+@item @code{alphaBackground} (class @code{AlphaBackground})
+Sets the @samp{alpha-background} frame parameter, determining background
+transparency
+(@pxref{Frame Parameters,,, elisp, The Emacs Lisp Reference Manual}).
+
@item @code{background} (class @code{Background})
Background color (@pxref{Colors}).
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 2eeb8b7ed7..16748ac922 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -2433,6 +2433,16 @@ Font and Color Parameters
Some window systems do not support the @code{alpha} parameter for child
frames (@pxref{Child Frames}).
+
+@vindex alpha-background@r{, a frame parameter}
+@item alpha-background
+@cindex opacity, frame
+@cindex transparency, frame
+Sets the background transparency of the frame. Unlike the @code{alpha}
+frame parameter, this only controls the transparency of the background
+while keeping foreground elements such as text fully opaque. It
+should be an integer between 0 and 100, where 0 means
+completely transparent and 100 means completely opaque (default).
@end table
The following frame parameters are semi-obsolete in that they are
diff --git a/src/frame.c b/src/frame.c
index 8aaff949ba..c331cff32b 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3907,6 +3907,7 @@ DEFUN ("frame-scale-factor", Fframe_scale_factor, Sframe_scale_factor,
{"z-group", SYMBOL_INDEX (Qz_group)},
{"override-redirect", SYMBOL_INDEX (Qoverride_redirect)},
{"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs)},
+ {"alpha-background", SYMBOL_INDEX (Qalpha_background)},
#ifdef NS_IMPL_COCOA
{"ns-appearance", SYMBOL_INDEX (Qns_appearance)},
{"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar)},
@@ -5024,6 +5025,33 @@ gui_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
}
}
+void
+gui_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+{
+ double alpha = 1.0;
+
+ if (NILP (arg))
+ alpha = 1.0;
+ else if (FLOATP (arg))
+ {
+ alpha = XFLOAT_DATA (arg);
+ if (! (0 <= alpha && alpha <= 1.0))
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if (FIXNUMP (arg))
+ {
+ EMACS_INT ialpha = XFIXNUM (arg);
+ if (! (0 <= ialpha && ialpha <= 100))
+ args_out_of_range (make_fixnum (0), make_fixnum (100));
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, arg);
+
+ f->alpha_background = alpha;
+
+ SET_FRAME_GARBAGED (f);
+}
/**
* gui_set_no_special_glyphs:
@@ -6100,6 +6128,7 @@ syms_of_frame (void)
#endif
DEFSYM (Qalpha, "alpha");
+ DEFSYM (Qalpha_background, "alpha-background");
DEFSYM (Qauto_lower, "auto-lower");
DEFSYM (Qauto_raise, "auto-raise");
DEFSYM (Qborder_color, "border-color");
diff --git a/src/frame.h b/src/frame.h
index cb2f58e261..5d5f2122fb 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -637,6 +637,9 @@ #define EMACS_FRAME_H
Negative values mean not to change alpha. */
double alpha[2];
+ /* Background opacity */
+ double alpha_background;
+
/* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
frame parameter. 0 means don't do gamma correction. */
@@ -1669,6 +1672,7 @@ #define EMACS_CLASS "Emacs"
extern long gui_figure_window_size (struct frame *, Lisp_Object, bool, bool);
extern void gui_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_alpha_background (struct frame *, Lisp_Object, Lisp_Object);
extern void gui_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object);
extern void validate_x_resource_name (void);
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 98907bf022..8b8123c807 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1467,6 +1467,10 @@ xg_create_frame_widgets (struct frame *f)
}
wtop = gtk_window_new (type);
gtk_widget_add_events (wtop, GDK_ALL_EVENTS_MASK);
+
+ /* This prevents GTK from painting the window's background, which
+ would interfere with transparent background in some environments */
+ gtk_widget_set_app_paintable (wtop, TRUE);
#endif
/* gtk_window_set_has_resize_grip is a Gtk+ 3.0 function but Ubuntu
@@ -1587,6 +1591,15 @@ xg_create_frame_widgets (struct frame *f)
#endif
| GDK_VISIBILITY_NOTIFY_MASK);
+ GdkScreen *screen = gtk_widget_get_screen (wtop);
+
+ if (FRAME_DISPLAY_INFO (f)->n_planes == 32)
+ {
+ GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
+ gtk_widget_set_visual (wtop, visual);
+ gtk_widget_set_visual (wfixed, visual);
+ }
+
#ifndef HAVE_PGTK
/* Must realize the windows so the X window gets created. It is used
by callers of this function. */
@@ -1651,7 +1664,6 @@ xg_create_frame_widgets (struct frame *f)
#endif
{
- GdkScreen *screen = gtk_widget_get_screen (wtop);
GtkSettings *gs = gtk_settings_get_for_screen (screen);
/* Only connect this signal once per screen. */
if (! g_signal_handler_find (G_OBJECT (gs),
diff --git a/src/haikufns.c b/src/haikufns.c
index 58a2e1d464..0e0cffea72 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -830,6 +830,8 @@ #define ASSIGN_CURSOR(cursor, be_cursor) \
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qfullscreen, Qnil,
"fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
@@ -1043,6 +1045,8 @@ haiku_create_tip_frame (Lisp_Object parms)
"cursorType", "CursorType", RES_TYPE_SYMBOL);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
initial_setup_back_buffer (f);
@@ -2609,7 +2613,8 @@ DEFUN ("haiku-frame-restack", Fhaiku_frame_restack, Shaiku_frame_restack, 2, 3,
haiku_set_no_accept_focus,
NULL, /* set z group */
haiku_set_override_redirect,
- gui_set_no_special_glyphs
+ gui_set_no_special_glyphs,
+ gui_set_alpha_background,
};
void
diff --git a/src/nsfns.m b/src/nsfns.m
index 11132a294a..467e56ece4 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1004,6 +1004,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
ns_set_z_group,
0, /* x_set_override_redirect */
gui_set_no_special_glyphs,
+ gui_set_alpha_background,
#ifdef NS_IMPL_COCOA
ns_set_appearance,
ns_set_transparent_titlebar,
@@ -1436,6 +1437,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qfullscreen, Qnil,
"fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
diff --git a/src/pgtkfns.c b/src/pgtkfns.c
index 9c37c04810..5980b31d6e 100644
--- a/src/pgtkfns.c
+++ b/src/pgtkfns.c
@@ -1043,6 +1043,7 @@ frames (each of which corresponds to one page). Each frame should be
x_set_z_group,
x_set_override_redirect,
gui_set_no_special_glyphs,
+ gui_set_alpha_background,
};
@@ -1667,6 +1668,8 @@ #define INSTALL_CURSOR(FIELD, NAME) \
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
if (!NILP (parent_frame))
{
@@ -2936,6 +2939,8 @@ x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct
"cursorType", "CursorType", RES_TYPE_SYMBOL);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
/* Add `tooltip' frame parameter's default value. */
if (NILP (Fframe_parameter (frame, Qtooltip)))
diff --git a/src/w32fns.c b/src/w32fns.c
index 1ea685d194..009855602e 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6018,6 +6018,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
NULL, NULL, RES_TYPE_BOOLEAN);
gui_default_parameter (f, parameters, Qno_special_glyphs, Qnil,
NULL, NULL, RES_TYPE_BOOLEAN);
+ gui_default_parameter (f, parameters, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
/* Process alpha here (Bug#16619). On XP this fails with child
frames. For `no-focus-on-map' frames delay processing of alpha
@@ -6155,6 +6157,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
gui_default_parameter (f, parameters, Qz_group, Qnil,
NULL, NULL, RES_TYPE_SYMBOL);
+ gui_default_parameter (f, parameters, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
+
/* Make the window appear on the frame and enable display, unless
the caller says not to. However, with explicit parent, Emacs
cannot control visibility, so don't try. */
@@ -7089,6 +7094,8 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms)
/* Process alpha here (Bug#17344). */
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
/* Add `tooltip' frame parameter's default value. */
if (NILP (Fframe_parameter (frame, Qtooltip)))
@@ -10436,6 +10443,7 @@ w32_get_resource (const char *key, const char *name, LPDWORD lpdwtype)
w32_set_z_group,
0, /* x_set_override_redirect */
gui_set_no_special_glyphs,
+ gui_set_alpha_background,
};
void
diff --git a/src/xfns.c b/src/xfns.c
index faab1b1158..2f2e33fa69 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4598,6 +4598,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
if (!NILP (parent_frame))
{
@@ -6371,10 +6373,29 @@ select_visual (struct x_display_info *dpyinfo)
int n_visuals;
XVisualInfo *vinfo, vinfo_template;
- dpyinfo->visual = DefaultVisualOfScreen (screen);
+ vinfo_template.screen = XScreenNumberOfScreen (screen);
+
+#if defined (USE_GTK)
+ /* First attempt to use 32-bit visual if available */
+
+ vinfo_template.depth = 32;
+
+ vinfo = XGetVisualInfo (dpy, VisualScreenMask | VisualDepthMask,
+ &vinfo_template, &n_visuals);
+ if (n_visuals > 0)
+ {
+ dpyinfo->n_planes = vinfo->depth;
+ dpyinfo->visual = vinfo->visual;
+ XFree (vinfo);
+ return;
+ }
+
+#endif /* defined (USE_GTK) */
+
+ /* 32-bit visual not available, fallback to default visual */
+ dpyinfo->visual = DefaultVisualOfScreen (screen);
vinfo_template.visualid = XVisualIDFromVisual (dpyinfo->visual);
- vinfo_template.screen = XScreenNumberOfScreen (screen);
vinfo = XGetVisualInfo (dpy, VisualIDMask | VisualScreenMask,
&vinfo_template, &n_visuals);
if (n_visuals <= 0)
@@ -7232,6 +7253,8 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms)
"cursorType", "CursorType", RES_TYPE_SYMBOL);
gui_default_parameter (f, parms, Qalpha, Qnil,
"alpha", "Alpha", RES_TYPE_NUMBER);
+ gui_default_parameter (f, parms, Qalpha_background, Qnil,
+ "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
/* Add `tooltip' frame parameter's default value. */
if (NILP (Fframe_parameter (frame, Qtooltip)))
@@ -8560,6 +8583,7 @@ DEFUN ("x-gtk-debug", Fx_gtk_debug, Sx_gtk_debug, 1, 1, 0,
x_set_z_group,
x_set_override_redirect,
gui_set_no_special_glyphs,
+ gui_set_alpha_background,
};
void
diff --git a/src/xterm.c b/src/xterm.c
index 3f277c5b87..ab5fd46c4c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -874,12 +874,27 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc)
{
XGCValues xgcv;
XColor color;
+ unsigned int depth;
XGetGCValues (FRAME_X_DISPLAY (f), gc, GCBackground, &xgcv);
color.pixel = xgcv.background;
+
x_query_colors (f, &color, 1);
- cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
- color.green / 65535.0, color.blue / 65535.0);
+
+ depth = FRAME_DISPLAY_INFO (f)->n_planes;
+
+ if (f->alpha_background < 1.0 && depth == 32)
+ {
+ cairo_set_source_rgba (FRAME_CR_CONTEXT (f), color.red / 65535.0,
+ color.green / 65535.0, color.blue / 65535.0,
+ f->alpha_background);
+
+ cairo_set_operator (FRAME_CR_CONTEXT (f), CAIRO_OPERATOR_SOURCE);
+ }
+ else
+ cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
+ color.green / 65535.0, color.blue / 65535.0);
+
}
static const cairo_user_data_key_t xlib_surface_key, saved_drawable_key;
@@ -1318,6 +1333,29 @@ x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height)
#endif
}
+
+static void
+x_clear_rectangle (struct frame *f, GC gc, int x, int y, int width, int height)
+{
+#ifdef USE_CAIRO
+ cairo_t *cr;
+
+ cr = x_begin_cr_clip (f, gc);
+ x_set_cr_source_with_gc_background (f, gc);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_fill (cr);
+ x_end_cr_clip (f);
+#else
+ XGCValues xgcv;
+ Display *dpy = FRAME_X_DISPLAY (f);
+ XGetGCValues (dpy, gc, GCBackground | GCForeground, &xgcv);
+ XSetForeground (dpy, gc, xgcv.background);
+ XFillRectangle (dpy, FRAME_X_DRAWABLE (f),
+ gc, x, y, width, height);
+ XSetForeground (dpy, gc, xgcv.foreground);
+#endif
+}
+
static void
x_draw_rectangle (struct frame *f, GC gc, int x, int y, int width, int height)
{
@@ -1898,9 +1936,9 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
if (face->stipple)
XSetFillStyle (display, face->gc, FillOpaqueStippled);
else
- XSetForeground (display, face->gc, face->background);
+ XSetBackground (display, face->gc, face->background);
- x_fill_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny);
+ x_clear_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny);
if (!face->stipple)
XSetForeground (display, face->gc, face->foreground);
@@ -2201,12 +2239,7 @@ x_compute_glyph_string_overhangs (struct glyph_string *s)
static void
x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h)
{
- Display *display = FRAME_X_DISPLAY (s->f);
- XGCValues xgcv;
- XGetGCValues (display, s->gc, GCForeground | GCBackground, &xgcv);
- XSetForeground (display, s->gc, xgcv.background);
- x_fill_rectangle (s->f, s->gc, x, y, w, h);
- XSetForeground (display, s->gc, xgcv.foreground);
+ x_clear_rectangle (s->f, s->gc, x, y, w, h);
}
next prev parent reply other threads:[~2022-01-29 0:01 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 19:45 Support for background transparency Håkon Flatval
2021-11-04 20:06 ` Eli Zaretskii
2021-11-04 20:17 ` Lars Ingebrigtsen
2021-11-27 23:01 ` Håkon Flatval
2021-11-28 0:35 ` Sv: " arthur miller
2021-11-28 13:32 ` Lars Ingebrigtsen
2021-11-28 16:04 ` Arthur Miller
2021-11-28 20:33 ` Håkon Flatval
2021-11-29 2:56 ` Arthur Miller
2021-11-28 7:41 ` Eli Zaretskii
2021-11-28 7:47 ` Po Lu
2021-11-28 8:27 ` Eli Zaretskii
2021-12-01 18:54 ` Sv: " Håkon Flatval
2021-12-09 17:13 ` Håkon Flatval
2021-12-10 0:40 ` Lars Ingebrigtsen
2022-01-19 17:26 ` Sv: " Håkon Flatval
2022-01-20 0:52 ` Po Lu
2022-01-20 19:52 ` Sv: " Håkon Flatval
2022-01-21 0:59 ` Po Lu
2022-01-23 13:48 ` Håkon Flatval
2022-01-24 0:11 ` Po Lu
2022-01-25 17:53 ` Håkon Flatval
2022-01-26 1:00 ` Po Lu
2022-01-24 10:22 ` Po Lu
2022-01-25 19:47 ` Håkon Flatval
2022-01-25 19:37 ` Robert Pluim
2022-01-26 18:16 ` Håkon Flatval
2022-01-26 1:05 ` Po Lu
2022-01-26 11:11 ` Robert Pluim
2022-01-26 18:34 ` Håkon Flatval
2022-01-27 1:00 ` Po Lu
2022-01-29 0:01 ` Håkon Flatval [this message]
2022-01-29 1:08 ` Po Lu
2022-01-20 9:12 ` Robert Pluim
2022-01-23 21:43 ` Håkon Flatval
2022-01-24 9:14 ` Robert Pluim
2022-01-25 20:00 ` Håkon Flatval
2022-01-25 19:31 ` Robert Pluim
2022-01-29 10:26 ` Po Lu
2022-01-29 15:17 ` Håkon Flatval
2022-01-30 0:53 ` Po Lu
2021-11-28 13:41 ` Lars Ingebrigtsen
2021-11-28 15:05 ` Sv: " Håkon Flatval
2021-11-28 16:07 ` Gregor Zattler
2021-11-28 16:32 ` Lars Ingebrigtsen
2021-11-28 18:10 ` Jean Louis
2021-11-28 18:44 ` Sv: " Håkon Flatval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PRAP251MB0688131736C3B37FB5EA8324CF229@PRAP251MB0688.EURP251.PROD.OUTLOOK.COM \
--to=hkon20@hotmail.com \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).