From 9fdc0f08ce69ae0a41f75b10067c29492472f6a6 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 11 Feb 2022 13:44:42 +0800 Subject: [PATCH] Set _NET_WM_OPAQUE_REGION on non-GTK3 toolkits when using 32 bit visual * src/xfns.c (x_set_alpha_background): Set opaque region if opaque. * src/xterm.c (x_update_opaque_region): New parameter `configure'. All callers changed. (handle_one_xevent): Call `x_update_opaque_region' on configure events. --- src/xfns.c | 13 +++++++++++++ src/xterm.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/xfns.c b/src/xfns.c index 7d91f32ad4a..849fa72f39f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -730,6 +730,11 @@ x_set_wait_for_wm (struct frame *f, Lisp_Object new_value, Lisp_Object old_value static void x_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { +#ifndef HAVE_GTK3 + unsigned long opaque_region[] = {0, 0, FRAME_PIXEL_WIDTH (f), + FRAME_PIXEL_HEIGHT (f)}; +#endif + gui_set_alpha_background (f, arg, oldval); #ifdef USE_GTK @@ -749,6 +754,14 @@ x_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) XA_CARDINAL, 32, PropModeReplace, NULL, 0); } +#ifndef HAVE_GTK3 + else + XChangeProperty (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &opaque_region, 4); +#endif } static void diff --git a/src/xterm.c b/src/xterm.c index 66666229cd9..e7736f741a0 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -345,7 +345,7 @@ static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t); static void x_initialize (void); static bool x_get_current_wm_state (struct frame *, Window, int *, bool *); -static void x_update_opaque_region (struct frame *); +static void x_update_opaque_region (struct frame *, XEvent *); /* Flush display of frame F. */ @@ -366,7 +366,6 @@ x_flush (struct frame *f) static void x_drop_xrender_surfaces (struct frame *f) { - x_update_opaque_region (f); font_drop_xrender_surfaces (f); #ifdef HAVE_XRENDER @@ -440,14 +439,37 @@ record_event (char *locus, int type) #endif static void -x_update_opaque_region (struct frame *f) +x_update_opaque_region (struct frame *f, XEvent *configure) { +#ifndef HAVE_GTK3 + unsigned long opaque_region[] = {0, 0, + (configure + ? configure->xconfigure.width + : FRAME_PIXEL_WIDTH (f)), + (configure + ? configure->xconfigure.height + : FRAME_PIXEL_HEIGHT (f))}; +#endif + + if (!FRAME_DISPLAY_INFO (f)->alpha_bits) + return; + + block_input (); if (f->alpha_background < 1.0) XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, XA_CARDINAL, 32, PropModeReplace, NULL, 0); +#ifndef HAVE_GTK3 + else + XChangeProperty (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &opaque_region, 4); +#endif + unblock_input (); } @@ -9712,7 +9734,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, f->output_data.x->has_been_visible = true; } - x_update_opaque_region (f); + x_update_opaque_region (f, NULL); if (not_hidden && iconified) { @@ -10350,6 +10372,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_cr_update_surface_desired_size (any, configureEvent.xconfigure.width, configureEvent.xconfigure.height); + x_update_opaque_region (f, &configureEvent); #endif #ifdef USE_GTK if (!f @@ -10378,6 +10401,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_cr_update_surface_desired_size (f, configureEvent.xconfigure.width, configureEvent.xconfigure.height); #endif + x_update_opaque_region (f, &configureEvent); f = 0; } #endif -- 2.39.5