emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 94e59f80b7: Check if WM support for NET_WM_USER_TIME_WINDOW chang


From: Po Lu
Subject: master 94e59f80b7: Check if WM support for NET_WM_USER_TIME_WINDOW changed during updates
Date: Thu, 24 Feb 2022 07:03:02 -0500 (EST)

branch: master
commit 94e59f80b758ed3e3ff083d44a843273342ec054
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Check if WM support for NET_WM_USER_TIME_WINDOW changed during updates
    
    * src/xterm.c (x_display_set_last_user_time): Update the user
    time window if window manager support changed.
    
    * src/xterm.h (struct x_display_info): New field
    `last_user_check_time'.
---
 src/xterm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/xterm.h |  6 ++++--
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 66b5dce73c..54b00455a1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2588,6 +2588,7 @@ x_display_set_last_user_time (struct x_display_info 
*dpyinfo, Time time)
 {
 #ifndef USE_GTK
   struct frame *focus_frame = dpyinfo->x_focus_frame;
+  struct x_output *output;
 #endif
 
 #ifdef ENABLE_CHECKING
@@ -2596,6 +2597,56 @@ x_display_set_last_user_time (struct x_display_info 
*dpyinfo, Time time)
   dpyinfo->last_user_time = time;
 
 #ifndef USE_GTK
+  if (focus_frame
+      && (dpyinfo->last_user_time
+         > (dpyinfo->last_user_check_time + 2000)))
+    {
+      output = FRAME_X_OUTPUT (focus_frame);
+
+      if (!x_wm_supports (focus_frame,
+                         dpyinfo->Xatom_net_wm_user_time_window))
+       {
+         if (output->user_time_window == None)
+           output->user_time_window = FRAME_OUTER_WINDOW (focus_frame);
+         else if (output->user_time_window != FRAME_OUTER_WINDOW (focus_frame))
+           {
+             XDestroyWindow (dpyinfo->display,
+                             output->user_time_window);
+             XDeleteProperty (dpyinfo->display,
+                              FRAME_OUTER_WINDOW (focus_frame),
+                              dpyinfo->Xatom_net_wm_user_time_window);
+             output->user_time_window = FRAME_OUTER_WINDOW (focus_frame);
+           }
+       }
+      else
+       {
+         if (output->user_time_window == FRAME_OUTER_WINDOW (focus_frame)
+             || output->user_time_window == None)
+           {
+             XSetWindowAttributes attrs;
+             memset (&attrs, 0, sizeof attrs);
+
+             output->user_time_window
+               = XCreateWindow (dpyinfo->display,
+                                FRAME_X_WINDOW (focus_frame),
+                                -1, -1, 1, 1, 0, 0, InputOnly,
+                                CopyFromParent, 0, &attrs);
+
+             XDeleteProperty (dpyinfo->display,
+                              FRAME_OUTER_WINDOW (focus_frame),
+                              dpyinfo->Xatom_net_wm_user_time);
+             XChangeProperty (dpyinfo->display,
+                              FRAME_OUTER_WINDOW (focus_frame),
+                              dpyinfo->Xatom_net_wm_user_time_window,
+                              XA_WINDOW, 32, PropModeReplace,
+                              (unsigned char *) &output->user_time_window,
+                              1);
+           }
+       }
+
+      dpyinfo->last_user_check_time = time;
+    }
+
   if (focus_frame)
     {
       while (FRAME_PARENT_FRAME (focus_frame))
diff --git a/src/xterm.h b/src/xterm.h
index ae9300f783..a41eb43d64 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -459,8 +459,10 @@ struct x_display_info
   /* The scroll bar in which the last X motion event occurred.  */
   struct scroll_bar *last_mouse_scroll_bar;
 
-  /* Time of last user interaction as returned in X events on this display.  */
-  Time last_user_time;
+  /* Time of last user interaction as returned in X events on this
+     display, and time where WM support for `_NET_WM_USER_TIME_WINDOW'
+     was last checked.  */
+  Time last_user_time, last_user_check_time;
 
   /* Position where the mouse was last time we reported a motion.
      This is a position on last_mouse_motion_frame.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]