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'.
This commit is contained in:
Chris Feng 2017-02-24 23:05:43 +08:00
parent 0ae1e7327e
commit f299ca5ed7
2 changed files with 20 additions and 3 deletions

View file

@ -304,6 +304,9 @@ You shall use the default value if using auto-hide minibuffer.")
:event (xcb:marshal obj exwm-systemtray--connection)))) :event (xcb:marshal obj exwm-systemtray--connection))))
(xcb:flush exwm-systemtray--connection)) (xcb:flush exwm-systemtray--connection))
(defvar exwm-workspace--workareas)
(defvar exwm-workspace-current-index)
(defun exwm-systemtray--on-workspace-switch () (defun exwm-systemtray--on-workspace-switch ()
"Reparent/Refresh the system tray in `exwm-workspace-switch-hook'." "Reparent/Refresh the system tray in `exwm-workspace-switch-hook'."
(unless (exwm-workspace--minibuffer-own-frame-p) (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 (frame-parameter exwm-workspace--current
'window-id)) 'window-id))
:x 0 :x 0
:y (- (exwm-workspace--current-height) :y (- (elt (elt exwm-workspace--workareas
exwm-workspace-current-index)
3)
exwm-systemtray-height)))) exwm-systemtray-height))))
(exwm-systemtray--refresh)) (exwm-systemtray--refresh))
@ -325,10 +330,15 @@ You shall use the default value if using auto-hide minibuffer.")
(make-instance 'xcb:ConfigureWindow (make-instance 'xcb:ConfigureWindow
:window exwm-systemtray--embedder :window exwm-systemtray--embedder
:value-mask xcb:ConfigWindow:Y :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-height))))
(exwm-systemtray--refresh)) (exwm-systemtray--refresh))
(defalias 'exwm-systemtray--on-struts-update
#'exwm-systemtray--on-randr-refresh)
(defvar xcb:Atom:_NET_SYSTEM_TRAY_S0) (defvar xcb:Atom:_NET_SYSTEM_TRAY_S0)
(defvar exwm-workspace--minibuffer) (defvar exwm-workspace--minibuffer)
@ -459,6 +469,8 @@ You shall use the default value if using auto-hide minibuffer.")
#'exwm-systemtray--on-KeyPress)) #'exwm-systemtray--on-KeyPress))
;; Add hook to move/reparent the embedder. ;; Add hook to move/reparent the embedder.
(add-hook 'exwm-workspace-switch-hook #'exwm-systemtray--on-workspace-switch) (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) (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--on-randr-refresh)))
@ -472,6 +484,8 @@ You shall use the default value if using auto-hide minibuffer.")
exwm-systemtray--embedder nil) exwm-systemtray--embedder nil)
(remove-hook 'exwm-workspace-switch-hook (remove-hook 'exwm-workspace-switch-hook
#'exwm-systemtray--on-workspace-switch) #'exwm-systemtray--on-workspace-switch)
(remove-hook 'exwm-workspace--update-workareas-hook
#'exwm-systemtray--on-struts-update)
(when (boundp 'exwm-randr-refresh-hook) (when (boundp 'exwm-randr-refresh-hook)
(remove-hook 'exwm-randr-refresh-hook (remove-hook 'exwm-randr-refresh-hook
#'exwm-systemtray--on-randr-refresh)))) #'exwm-systemtray--on-randr-refresh))))

View file

@ -247,6 +247,8 @@ Value nil means to use the default position which is fixed at bottom, while
(append exwm-workspace--struts (list struts*)))))))))) (append exwm-workspace--struts (list struts*))))))))))
(defvar exwm-workspace--workareas nil "Workareas (struts excluded).") (defvar exwm-workspace--workareas nil "Workareas (struts excluded).")
(defvar exwm-workspace--update-workareas-hook nil
"Normal hook run when workareas get updated.")
(defun exwm-workspace--update-workareas () (defun exwm-workspace--update-workareas ()
"Update `exwm-workspace--workareas'." "Update `exwm-workspace--workareas'."
@ -309,7 +311,8 @@ Value nil means to use the default position which is fixed at bottom, while
(cl-incf (aref w 3) delta)))))) (cl-incf (aref w 3) delta))))))
;; Save the result. ;; Save the result.
(setq exwm-workspace--workareas workareas) (setq exwm-workspace--workareas workareas)
(xcb:flush exwm--connection))) (xcb:flush exwm--connection))
(run-hooks 'exwm-workspace--update-workareas-hook))
(defvar exwm-workspace--fullscreen-frame-count 0 (defvar exwm-workspace--fullscreen-frame-count 0
"Count the fullscreen workspace frames.") "Count the fullscreen workspace frames.")