aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-07-09 08:05:30 +0800
committerPo Lu2022-07-09 08:05:30 +0800
commitee5814178503c327f703e03f372f792fa1689632 (patch)
treeddc66cd6896d1a2c1c4c651139b7d26abaa02a0c /src
parent0508d7c4d6637d63a823b66e9f87ab54c2e73b09 (diff)
downloademacs-ee5814178503c327f703e03f372f792fa1689632.tar.gz
emacs-ee5814178503c327f703e03f372f792fa1689632.zip
Speed up querying for window manager support
* src/xterm.c (handle_one_xevent): Clear net_supported_window if it is destroyed. (x_get_wm_check_window): New function. (x_wm_supports_1): First try net_supported_window. If it still exists, don't ask for _NET_SUPPORTING_WM_CHECK.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c76
1 files changed, 56 insertions, 20 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 23a784ade89..1afb8adcfee 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -19215,6 +19215,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19215 goto OTHER; 19215 goto OTHER;
19216 19216
19217 case DestroyNotify: 19217 case DestroyNotify:
19218 if (event->xdestroywindow.window
19219 == dpyinfo->net_supported_window)
19220 dpyinfo->net_supported_window = None;
19221
19218 xft_settings_event (dpyinfo, event); 19222 xft_settings_event (dpyinfo, event);
19219 break; 19223 break;
19220 19224
@@ -24076,6 +24080,36 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity)
24076 unblock_input (); 24080 unblock_input ();
24077} 24081}
24078 24082
24083static Window
24084x_get_wm_check_window (struct x_display_info *dpyinfo)
24085{
24086 Window result;
24087 unsigned char *tmp_data = NULL;
24088 int rc, actual_format;
24089 unsigned long actual_size, bytes_remaining;
24090 Atom actual_type;
24091
24092 rc = XGetWindowProperty (dpyinfo->display, dpyinfo->root_window,
24093 dpyinfo->Xatom_net_supporting_wm_check,
24094 0, 1, False, XA_WINDOW, &actual_type,
24095 &actual_format, &actual_size,
24096 &bytes_remaining, &tmp_data);
24097
24098 if (rc != Success || actual_type != XA_WINDOW
24099 || actual_format != 32 || actual_size != 1)
24100 {
24101 if (tmp_data)
24102 XFree (tmp_data);
24103
24104 return None;
24105 }
24106
24107 result = *(Window *) tmp_data;
24108 XFree (tmp_data);
24109
24110 return result;
24111}
24112
24079/* Return true if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED 24113/* Return true if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED
24080 on the root window for frame F contains ATOMNAME. 24114 on the root window for frame F contains ATOMNAME.
24081 This is how a WM check shall be done according to the Window Manager 24115 This is how a WM check shall be done according to the Window Manager
@@ -24099,30 +24133,32 @@ x_wm_supports_1 (struct x_display_info *dpyinfo, Atom want_atom)
24099 block_input (); 24133 block_input ();
24100 24134
24101 x_catch_errors (dpy); 24135 x_catch_errors (dpy);
24102 rc = XGetWindowProperty (dpy, target_window,
24103 dpyinfo->Xatom_net_supporting_wm_check,
24104 0, max_len, False, target_type,
24105 &actual_type, &actual_format, &actual_size,
24106 &bytes_remaining, &tmp_data);
24107 24136
24108 if (rc != Success || actual_type != XA_WINDOW || x_had_errors_p (dpy)) 24137 wmcheck_window = dpyinfo->net_supported_window;
24109 {
24110 if (tmp_data) XFree (tmp_data);
24111 x_uncatch_errors ();
24112 unblock_input ();
24113 return false;
24114 }
24115 24138
24116 wmcheck_window = *(Window *) tmp_data; 24139 if (wmcheck_window == None)
24117 XFree (tmp_data); 24140 wmcheck_window = x_get_wm_check_window (dpyinfo);
24118 24141
24119 /* Check if window exists. */ 24142 if (!x_special_window_exists_p (dpyinfo, wmcheck_window))
24120 XSelectInput (dpy, wmcheck_window, StructureNotifyMask);
24121 if (x_had_errors_p (dpy))
24122 { 24143 {
24123 x_uncatch_errors_after_check (); 24144 if (dpyinfo->net_supported_window != None)
24124 unblock_input (); 24145 {
24125 return false; 24146 dpyinfo->net_supported_window = None;
24147 wmcheck_window = x_get_wm_check_window (dpyinfo);
24148
24149 if (!x_special_window_exists_p (dpyinfo, wmcheck_window))
24150 {
24151 x_uncatch_errors ();
24152 unblock_input ();
24153 return false;
24154 }
24155 }
24156 else
24157 {
24158 x_uncatch_errors ();
24159 unblock_input ();
24160 return false;
24161 }
24126 } 24162 }
24127 24163
24128 if (dpyinfo->net_supported_window != wmcheck_window) 24164 if (dpyinfo->net_supported_window != wmcheck_window)