emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/exwm e689221: Only call exwm-randr-screen-change-hook o


From: Chris Feng
Subject: [elpa] externals/exwm e689221: Only call exwm-randr-screen-change-hook on new event sequence number
Date: Sun, 9 Dec 2018 07:40:05 -0500 (EST)

branch: externals/exwm
commit e6892216a6851307c822a71841ad2dc986facb77
Author: James Ferguson <address@hidden>
Commit: James Ferguson <address@hidden>

    Only call exwm-randr-screen-change-hook on new event sequence number
    
    Multiple event callbacks are triggered per physical monitor plug event.
    This de-duplicates the events triggering the running of the hook.
---
 exwm-randr.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/exwm-randr.el b/exwm-randr.el
index a0fe959..59b2912 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -95,6 +95,8 @@ corresponding monitors whenever the monitors are active.
 
 (defvar exwm-workspace--fullscreen-frame-count)
 (defvar exwm-workspace--list)
+(defvar exwm-randr--prev-screen-change-seqnum nil
+  "The most recent ScreenChangeNotify sequence number.")
 (declare-function exwm-workspace--count "exwm-workspace.el")
 (declare-function exwm-workspace--set-active "exwm-workspace.el"
                   (frame active))
@@ -193,12 +195,17 @@ corresponding monitors whenever the monitors are active.
 (define-obsolete-function-alias 'exwm-randr--refresh #'exwm-randr-refresh
   "27.1")
 
-(defun exwm-randr--on-ScreenChangeNotify (_data _synthetic)
+(defun exwm-randr--on-ScreenChangeNotify (data _synthetic)
   "Handle `ScreenChangeNotify' event.
 
 Run `exwm-randr-screen-change-hook' (usually user scripts to configure RandR)."
   (exwm--log)
-  (run-hooks 'exwm-randr-screen-change-hook))
+  (let ((evt (make-instance 'xcb:randr:ScreenChangeNotify)))
+    (xcb:unmarshal evt data)
+    (let ((seqnum (slot-value evt '~sequence)))
+      (unless (equal seqnum exwm-randr--prev-screen-change-seqnum)
+        (setq exwm-randr--prev-screen-change-seqnum seqnum)
+        (run-hooks 'exwm-randr-screen-change-hook)))))
 
 (defun exwm-randr--on-Notify (data _synthetic)
   "Handle `CrtcChangeNotify' and `OutputChangeNotify' events.



reply via email to

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