Support setting system tray background color to current workspace's
* exwm-systemtray.el (exwm-systemtray-background-color): Add support for using current workspace's background color as system tray background color. (exwm-systemtray--refresh-background-color): New function to set the background color upon theme changes or workspace switches. (exwm-systemtray--on-workspace-switch) (exwm-systemtray--on-theme-change): Use it. (exwm-systemtray--init): React to theme changes.
This commit is contained in:
parent
b8d621041a
commit
07b9b2ccf8
1 changed files with 27 additions and 7 deletions
|
@ -75,7 +75,7 @@ You shall use the default value if using auto-hide minibuffer."
|
||||||
|
|
||||||
(defcustom exwm-systemtray-background-color
|
(defcustom exwm-systemtray-background-color
|
||||||
(if (exwm-systemtray--transparency-supported-p)
|
(if (exwm-systemtray--transparency-supported-p)
|
||||||
"black"
|
'workspace-background
|
||||||
'transparent)
|
'transparent)
|
||||||
"Background color of systemtray.
|
"Background color of systemtray.
|
||||||
This should be a color, the symbol `workspace-background' for the background
|
This should be a color, the symbol `workspace-background' for the background
|
||||||
|
@ -85,16 +85,17 @@ background.
|
||||||
Transparent background is not yet supported when Emacs uses 32-bit depth
|
Transparent background is not yet supported when Emacs uses 32-bit depth
|
||||||
visual, as reported by `x-display-planes'. The X resource \"Emacs.visualClass:
|
visual, as reported by `x-display-planes'. The X resource \"Emacs.visualClass:
|
||||||
TrueColor-24\" can be used to force Emacs to use 24-bit depth."
|
TrueColor-24\" can be used to force Emacs to use 24-bit depth."
|
||||||
:type '(choice (const :tag "Transparent" 'transparent)
|
:type '(choice (const :tag "Transparent" transparent)
|
||||||
(color))
|
(const :tag "Frame background" workspace-background)
|
||||||
|
(color :tag "Color"))
|
||||||
:initialize #'custom-initialize-default
|
:initialize #'custom-initialize-default
|
||||||
:set (lambda (symbol value)
|
:set (lambda (symbol value)
|
||||||
(when (and (eq value 'transparent)
|
(when (and (eq value 'transparent)
|
||||||
(not (exwm-systemtray--transparency-supported-p)))
|
(not (exwm-systemtray--transparency-supported-p)))
|
||||||
(display-warning 'exwm-systemtray
|
(display-warning 'exwm-systemtray
|
||||||
"Transparent background is not supported yet when \
|
"Transparent background is not supported yet when \
|
||||||
using 32-bit depth. Using black instead.")
|
using 32-bit depth. Using `workspace-background' instead.")
|
||||||
(setq value "black"))
|
(setq value 'workspace-background))
|
||||||
(set-default symbol value)
|
(set-default symbol value)
|
||||||
(when (and exwm-systemtray--connection
|
(when (and exwm-systemtray--connection
|
||||||
exwm-systemtray--embedder-window)
|
exwm-systemtray--embedder-window)
|
||||||
|
@ -256,6 +257,12 @@ using 32-bit depth. Using black instead.")
|
||||||
:window exwm-systemtray--embedder-window))))
|
:window exwm-systemtray--embedder-window))))
|
||||||
(xcb:flush exwm-systemtray--connection))
|
(xcb:flush exwm-systemtray--connection))
|
||||||
|
|
||||||
|
(defun exwm-systemtray--refresh-background-color ()
|
||||||
|
"Refresh background color after theme change or workspace switch."
|
||||||
|
;; Only `workspace-background' is dependent on current theme and workspace.
|
||||||
|
(when (eq 'workspace-background exwm-systemtray-background-color)
|
||||||
|
(exwm-systemtray--set-background-color)))
|
||||||
|
|
||||||
(defun exwm-systemtray--set-background-color ()
|
(defun exwm-systemtray--set-background-color ()
|
||||||
"Change the background color of the embedder.
|
"Change the background color of the embedder.
|
||||||
The color is set according to `exwm-systemtray-background-color'.
|
The color is set according to `exwm-systemtray-background-color'.
|
||||||
|
@ -268,8 +275,11 @@ window; unmap & map are necessary for the background color to take effect."
|
||||||
((transparent nil) ; nil means transparent as well
|
((transparent nil) ; nil means transparent as well
|
||||||
(if (exwm-systemtray--transparency-supported-p)
|
(if (exwm-systemtray--transparency-supported-p)
|
||||||
nil
|
nil
|
||||||
(message "%s" "[EXWM] system tray does not support transparent background; using black instead")
|
(message "%s" "[EXWM] system tray does not support \
|
||||||
"black"))
|
`transparent' background; using `workspace-background' instead")
|
||||||
|
(face-background 'default exwm-workspace--current)))
|
||||||
|
(workspace-background
|
||||||
|
(face-background 'default exwm-workspace--current))
|
||||||
(t exwm-systemtray-background-color)))
|
(t exwm-systemtray-background-color)))
|
||||||
(background-pixel (exwm--color->pixel color)))
|
(background-pixel (exwm--color->pixel color)))
|
||||||
(xcb:+request exwm-systemtray--connection
|
(xcb:+request exwm-systemtray--connection
|
||||||
|
@ -437,8 +447,13 @@ indicate how to support actual transparency."
|
||||||
3)
|
3)
|
||||||
exwm-workspace--frame-y-offset
|
exwm-workspace--frame-y-offset
|
||||||
exwm-systemtray-height))))
|
exwm-systemtray-height))))
|
||||||
|
(exwm-systemtray--refresh-background-color)
|
||||||
(exwm-systemtray--refresh))
|
(exwm-systemtray--refresh))
|
||||||
|
|
||||||
|
(defun exwm-systemtray--on-theme-change ()
|
||||||
|
"Refresh system tray upon theme change."
|
||||||
|
(exwm-systemtray--refresh-background-color))
|
||||||
|
|
||||||
(defun exwm-systemtray--refresh-all ()
|
(defun exwm-systemtray--refresh-all ()
|
||||||
"Reposition/Refresh the system tray."
|
"Reposition/Refresh the system tray."
|
||||||
(exwm--log)
|
(exwm--log)
|
||||||
|
@ -608,6 +623,9 @@ indicate how to support actual transparency."
|
||||||
(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
|
(add-hook 'exwm-workspace--update-workareas-hook
|
||||||
#'exwm-systemtray--refresh-all)
|
#'exwm-systemtray--refresh-all)
|
||||||
|
;; Add hook to update background colors.
|
||||||
|
(add-hook 'enable-theme-functions #'exwm-systemtray--on-theme-change)
|
||||||
|
(add-hook 'disable-theme-functions #'exwm-systemtray--on-theme-change)
|
||||||
(add-hook 'menu-bar-mode-hook #'exwm-systemtray--refresh-all)
|
(add-hook 'menu-bar-mode-hook #'exwm-systemtray--refresh-all)
|
||||||
(add-hook 'tool-bar-mode-hook #'exwm-systemtray--refresh-all)
|
(add-hook 'tool-bar-mode-hook #'exwm-systemtray--refresh-all)
|
||||||
(when (boundp 'exwm-randr-refresh-hook)
|
(when (boundp 'exwm-randr-refresh-hook)
|
||||||
|
@ -642,6 +660,8 @@ indicate how to support actual transparency."
|
||||||
#'exwm-systemtray--on-workspace-switch)
|
#'exwm-systemtray--on-workspace-switch)
|
||||||
(remove-hook 'exwm-workspace--update-workareas-hook
|
(remove-hook 'exwm-workspace--update-workareas-hook
|
||||||
#'exwm-systemtray--refresh-all)
|
#'exwm-systemtray--refresh-all)
|
||||||
|
(remove-hook 'enable-theme-functions #'exwm-systemtray--on-theme-change)
|
||||||
|
(remove-hook 'disable-theme-functions #'exwm-systemtray--on-theme-change)
|
||||||
(remove-hook 'menu-bar-mode-hook #'exwm-systemtray--refresh-all)
|
(remove-hook 'menu-bar-mode-hook #'exwm-systemtray--refresh-all)
|
||||||
(remove-hook 'tool-bar-mode-hook #'exwm-systemtray--refresh-all)
|
(remove-hook 'tool-bar-mode-hook #'exwm-systemtray--refresh-all)
|
||||||
(when (boundp 'exwm-randr-refresh-hook)
|
(when (boundp 'exwm-randr-refresh-hook)
|
||||||
|
|
Loading…
Reference in a new issue