mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-27 06:48:00 +01:00
exwm-xsettings: Use color-dark-p from Compat
This commit is contained in:
parent
87c429561f
commit
841ead8141
1 changed files with 1 additions and 15 deletions
|
@ -129,20 +129,6 @@ These settings take precedence over `exwm-xsettings-theme' and
|
|||
:initialize #'custom-initialize-default
|
||||
:set #'exwm-xsettings--custom-set)
|
||||
|
||||
(defalias 'exwm-xsettings--color-dark-p
|
||||
(if (eval-when-compile (< emacs-major-version 29))
|
||||
;; Borrowed from Emacs 29.
|
||||
(lambda (rgb)
|
||||
"Whether RGB is more readable against white than black."
|
||||
(unless (<= 0 (apply #'min rgb) (apply #'max rgb) 1)
|
||||
(error "RGB components %S not in [0,1]" rgb))
|
||||
(let* ((r (expt (nth 0 rgb) 2.2))
|
||||
(g (expt (nth 1 rgb) 2.2))
|
||||
(b (expt (nth 2 rgb) 2.2))
|
||||
(y (+ (* r 0.2126) (* g 0.7152) (* b 0.0722))))
|
||||
(< y 0.325)))
|
||||
'color-dark-p))
|
||||
|
||||
(defun exwm-xsettings--pick-theme (theme)
|
||||
"Pick a light or dark theme from the given THEME.
|
||||
If THEME is a string, it's returned directly.
|
||||
|
@ -151,7 +137,7 @@ the default face's background color."
|
|||
(pcase theme
|
||||
((cl-type string) theme)
|
||||
(`(,(cl-type string) . ,(cl-type string))
|
||||
(if (exwm-xsettings--color-dark-p (color-name-to-rgb (face-background 'default)))
|
||||
(if (color-dark-p (color-name-to-rgb (face-background 'default)))
|
||||
(cdr theme) (car theme)))
|
||||
(_ (error "Expected theme to be a string or a pair of strings"))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue