about summary refs log tree commit diff
path: root/exwm-randr.el
diff options
context:
space:
mode:
Diffstat (limited to 'exwm-randr.el')
-rw-r--r--exwm-randr.el12
1 files changed, 7 insertions, 5 deletions
diff --git a/exwm-randr.el b/exwm-randr.el
index 85daff245d19..709469a44d0a 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -55,11 +55,11 @@
   "Normal hook run when the RandR module just refreshed.")
 
 (defvar exwm-workspace--fullscreen-frame-count)
-(defvar exwm-workspace-number)
 (defvar exwm-workspace--list)
 
-(declare-function exwm-workspace--update-workareas "exwm-workspace.el" ())
+(declare-function exwm-workspace--count "exwm-workspace.el")
 (declare-function exwm-workspace--set-fullscreen "exwm-workspace.el" (frame))
+(declare-function exwm-workspace--update-workareas "exwm-workspace.el" ())
 (declare-function exwm-workspace--set-desktop-geometry "exwm-workspace.el" ())
 
 (defun exwm-randr--refresh ()
@@ -97,7 +97,7 @@
       (when exwm-workspace--fullscreen-frame-count
         ;; Not all workspaces are fullscreen; reset this counter.
         (setq exwm-workspace--fullscreen-frame-count 0))
-      (dotimes (i exwm-workspace-number)
+      (dotimes (i (exwm-workspace--count))
         (let* ((output (plist-get exwm-randr-workspace-output-plist i))
                (geometry (lax-plist-get output-plist output))
                (frame (elt exwm-workspace--list i)))
@@ -154,10 +154,12 @@
                            ;;            xcb:randr:NotifyMask:OutputProperty
                            ;;            xcb:randr:NotifyMask:CrtcChange))
                            ))
-        (xcb:flush exwm--connection)))))
+        (xcb:flush exwm--connection)
+        (add-hook 'exwm-workspace-list-change-hook #'exwm-randr--refresh)))))
 
 (defun exwm-randr--exit ()
-  "Exit the RandR module.")
+  "Exit the RandR module."
+  (remove-hook 'exwm-workspace-list-change-hook #'exwm-randr--refresh))
 
 (defun exwm-randr-enable ()
   "Enable RandR support for EXWM."