about summary refs log tree commit diff
path: root/exwm-systemtray.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2017-02-24T15·05+0800
committerChris Feng <chris.w.feng@gmail.com>2017-02-24T15·13+0800
commitf299ca5ed7056842aa59e9978061bca650316a71 (patch)
tree3aadb06fdc9fddd89c8697ae0525622df3720377 /exwm-systemtray.el
parent0ae1e7327ea900ad1b35ce145db63cb0837251de (diff)
Fix systemtray position
* exwm-workspace.el (exwm-workspace--update-workareas-hook): New hook
run when workareas get updated.
(exwm-workspace--update-workareas): Run the hook.
* exwm-systemtray.el (exwm-systemtray--on-workspace-switch)
(exwm-systemtray--on-randr-refresh): Take struts into account when
calculating the position for systemtray.
(exwm-systemtray--on-struts-update): Alias of
`exwm-systemtray--on-randr-refresh'.
(exwm-systemtray--init, exwm-systemtray--exit): Manipulate
`exwm-workspace--update-workareas-hook'.
Diffstat (limited to 'exwm-systemtray.el')
-rw-r--r--exwm-systemtray.el18
1 files changed, 16 insertions, 2 deletions
diff --git a/exwm-systemtray.el b/exwm-systemtray.el
index 60a2e3b3de..82a2ccdbf2 100644
--- a/exwm-systemtray.el
+++ b/exwm-systemtray.el
@@ -304,6 +304,9 @@ You shall use the default value if using auto-hide minibuffer.")
                        :event (xcb:marshal obj exwm-systemtray--connection))))
   (xcb:flush exwm-systemtray--connection))
 
+(defvar exwm-workspace--workareas)
+(defvar exwm-workspace-current-index)
+
 (defun exwm-systemtray--on-workspace-switch ()
   "Reparent/Refresh the system tray in `exwm-workspace-switch-hook'."
   (unless (exwm-workspace--minibuffer-own-frame-p)
@@ -314,7 +317,9 @@ You shall use the default value if using auto-hide minibuffer.")
                                 (frame-parameter exwm-workspace--current
                                                  'window-id))
                        :x 0
-                       :y (- (exwm-workspace--current-height)
+                       :y (- (elt (elt exwm-workspace--workareas
+                                       exwm-workspace-current-index)
+                                  3)
                              exwm-systemtray-height))))
   (exwm-systemtray--refresh))
 
@@ -325,10 +330,15 @@ You shall use the default value if using auto-hide minibuffer.")
         (make-instance 'xcb:ConfigureWindow
                        :window exwm-systemtray--embedder
                        :value-mask xcb:ConfigWindow:Y
-                       :y (- (exwm-workspace--current-height)
+                       :y (- (elt (elt exwm-workspace--workareas
+                                       exwm-workspace-current-index)
+                                  3)
                              exwm-systemtray-height))))
   (exwm-systemtray--refresh))
 
+(defalias 'exwm-systemtray--on-struts-update
+  #'exwm-systemtray--on-randr-refresh)
+
 (defvar xcb:Atom:_NET_SYSTEM_TRAY_S0)
 (defvar exwm-workspace--minibuffer)
 
@@ -459,6 +469,8 @@ You shall use the default value if using auto-hide minibuffer.")
                 #'exwm-systemtray--on-KeyPress))
   ;; Add hook to move/reparent the embedder.
   (add-hook 'exwm-workspace-switch-hook #'exwm-systemtray--on-workspace-switch)
+  (add-hook 'exwm-workspace--update-workareas-hook
+            #'exwm-systemtray--on-struts-update)
   (when (boundp 'exwm-randr-refresh-hook)
     (add-hook 'exwm-randr-refresh-hook #'exwm-systemtray--on-randr-refresh)))
 
@@ -472,6 +484,8 @@ You shall use the default value if using auto-hide minibuffer.")
           exwm-systemtray--embedder nil)
     (remove-hook 'exwm-workspace-switch-hook
                  #'exwm-systemtray--on-workspace-switch)
+    (remove-hook 'exwm-workspace--update-workareas-hook
+                 #'exwm-systemtray--on-struts-update)
     (when (boundp 'exwm-randr-refresh-hook)
       (remove-hook 'exwm-randr-refresh-hook
                    #'exwm-systemtray--on-randr-refresh))))