about summary refs log tree commit diff
path: root/exwm-systemtray.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2019-09-14T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2019-09-14T00·00+0000
commitf167bc979c76edb43bc63cffebec095601446477 (patch)
tree6e8ecd6c1030c9f98f9b6996be3a87bab86c3dd0 /exwm-systemtray.el
parenteb49e57f762ab47e874c821c12e0b641d3dd9d8e (diff)
Replace `frame-geometry'
* exwm-workspace.el (exwm-workspace--frame-y-offset)
exwm-workspace--window-y-offset, exwm-workspace--update-offsets): New
variables & function for the calculation of Emacs frame offsets, as
`frame-geometry' is not available in Emacs 24.
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--do-moveresize):
* exwm-layout.el (exwm-layout--show):
* exwm-systemtray.el (exwm-systemtray--on-workspace-switch)
(exwm-systemtray--on-randr-refresh, exwm-systemtray--init): Use them.

* exwm-systemtray.el (exwm-systemtray--refresh-all): Renamed from
`exwm-systemtray--on-randr-refresh'.
(exwm-systemtray--init, exwm-systemtray--exit): Use it.

* exwm-floating.el (exwm-floating--stop-moveresize): Send a
ConfigureNotify event to floating frame to update its position (seems
required by Emacs 24).
Diffstat (limited to 'exwm-systemtray.el')
-rw-r--r--exwm-systemtray.el83
1 files changed, 42 insertions, 41 deletions
diff --git a/exwm-systemtray.el b/exwm-systemtray.el
index a095bfa8de..35010ee341 100644
--- a/exwm-systemtray.el
+++ b/exwm-systemtray.el
@@ -331,42 +331,37 @@ You shall use the default value if using auto-hide minibuffer."
   "Reparent/Refresh the system tray in `exwm-workspace-switch-hook'."
   (exwm--log)
   (unless (exwm-workspace--minibuffer-own-frame-p)
-    (let ((geometry (frame-geometry exwm-workspace--current)))
-      (xcb:+request exwm-systemtray--connection
-          (make-instance 'xcb:ReparentWindow
-                         :window exwm-systemtray--embedder-window
-                         :parent (string-to-number
-                                  (frame-parameter exwm-workspace--current
-                                                   'window-id))
-                         :x 0
-                         :y (- (elt (elt exwm-workspace--workareas
-                                         exwm-workspace-current-index)
-                                    3)
-                               (or (cddr (assq 'menu-bar-size geometry)) 0)
-                               (or (cddr (assq 'tool-bar-size geometry)) 0)
-                               exwm-systemtray-height)))))
+    (exwm-workspace--update-offsets)
+    (xcb:+request exwm-systemtray--connection
+        (make-instance 'xcb:ReparentWindow
+                       :window exwm-systemtray--embedder-window
+                       :parent (string-to-number
+                                (frame-parameter exwm-workspace--current
+                                                 'window-id))
+                       :x 0
+                       :y (- (elt (elt exwm-workspace--workareas
+                                       exwm-workspace-current-index)
+                                  3)
+                             exwm-workspace--frame-y-offset
+                             exwm-systemtray-height))))
   (exwm-systemtray--refresh))
 
-(defun exwm-systemtray--on-randr-refresh ()
-  "Reposition/Refresh the system tray in `exwm-randr-refresh-hook'."
+(defun exwm-systemtray--refresh-all ()
+  "Reposition/Refresh the system tray."
   (exwm--log)
   (unless (exwm-workspace--minibuffer-own-frame-p)
-    (let ((geometry (frame-geometry exwm-workspace--current)))
-      (xcb:+request exwm-systemtray--connection
-          (make-instance 'xcb:ConfigureWindow
-                         :window exwm-systemtray--embedder-window
-                         :value-mask xcb:ConfigWindow:Y
-                         :y (- (elt (elt exwm-workspace--workareas
-                                         exwm-workspace-current-index)
-                                    3)
-                               (or (cddr (assq 'menu-bar-size geometry)) 0)
-                               (or (cddr (assq 'tool-bar-size geometry)) 0)
-                               exwm-systemtray-height)))))
+    (exwm-workspace--update-offsets)
+    (xcb:+request exwm-systemtray--connection
+        (make-instance 'xcb:ConfigureWindow
+                       :window exwm-systemtray--embedder-window
+                       :value-mask xcb:ConfigWindow:Y
+                       :y (- (elt (elt exwm-workspace--workareas
+                                       exwm-workspace-current-index)
+                                  3)
+                             exwm-workspace--frame-y-offset
+                             exwm-systemtray-height))))
   (exwm-systemtray--refresh))
 
-(defalias 'exwm-systemtray--on-struts-update
-  #'exwm-systemtray--on-randr-refresh)
-
 (cl-defun exwm-systemtray--init ()
   "Initialize system tray module."
   (exwm--log)
@@ -452,11 +447,14 @@ You shall use the default value if using auto-hide minibuffer."
                     (- (line-pixel-height) exwm-systemtray-height)
                   ;; Vertically centered.
                   (/ (- (line-pixel-height) exwm-systemtray-height) 2)))
-      (let ((workarea (elt exwm-workspace--workareas
-                           exwm-workspace-current-index)))
-        (setq frame exwm-workspace--current
-              ;; Bottom aligned.
-              y (- (aref workarea 3) exwm-systemtray-height))))
+      (exwm-workspace--update-offsets)
+      (setq frame exwm-workspace--current
+            ;; Bottom aligned.
+            y (- (elt (elt exwm-workspace--workareas
+                           exwm-workspace-current-index)
+                      3)
+                 exwm-workspace--frame-y-offset
+                 exwm-systemtray-height)))
     (setq parent (string-to-number (frame-parameter frame 'window-id))
           depth (slot-value (xcb:+request-unchecked+reply
                                 exwm-systemtray--connection
@@ -501,12 +499,14 @@ You shall use the default value if using auto-hide minibuffer."
   ;; 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)
+            #'exwm-systemtray--refresh-all)
+  (add-hook 'menu-bar-mode-hook #'exwm-systemtray--refresh-all)
+  (add-hook 'tool-bar-mode-hook #'exwm-systemtray--refresh-all)
   (when (boundp 'exwm-randr-refresh-hook)
-    (add-hook 'exwm-randr-refresh-hook #'exwm-systemtray--on-randr-refresh))
+    (add-hook 'exwm-randr-refresh-hook #'exwm-systemtray--refresh-all))
   ;; The struts can be updated already.
   (when exwm-workspace--workareas
-    (exwm-systemtray--on-struts-update)))
+    (exwm-systemtray--refresh-all)))
 
 (defun exwm-systemtray--exit ()
   "Exit the systemtray module."
@@ -532,10 +532,11 @@ You shall use the default value if using auto-hide minibuffer."
     (remove-hook 'exwm-workspace-switch-hook
                  #'exwm-systemtray--on-workspace-switch)
     (remove-hook 'exwm-workspace--update-workareas-hook
-                 #'exwm-systemtray--on-struts-update)
+                 #'exwm-systemtray--refresh-all)
+    (remove-hook 'menu-bar-mode-hook #'exwm-systemtray--refresh-all)
+    (remove-hook 'tool-bar-mode-hook #'exwm-systemtray--refresh-all)
     (when (boundp 'exwm-randr-refresh-hook)
-      (remove-hook 'exwm-randr-refresh-hook
-                   #'exwm-systemtray--on-randr-refresh))))
+      (remove-hook 'exwm-randr-refresh-hook #'exwm-systemtray--refresh-all))))
 
 (defun exwm-systemtray-enable ()
   "Enable system tray support for EXWM."