mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-30 14:38:00 +01:00
Add initial support for per-application configurations
* exwm-core.el (exwm--configurations): New buffer-local variable recording the configurations of an X window. * exwm-manage.el (exwm-manage-configurations): New user option as the per-application configurations. (exwm-manage--get-configurations): New function for fetching the configurations of this X window. (exwm-manage--manage-window): Fetch the configurations and check if the X window should be floating/tiling.
This commit is contained in:
parent
98c8fd4bc5
commit
dbc06b50ff
2 changed files with 44 additions and 7 deletions
|
@ -130,6 +130,7 @@ least SECS seconds later."
|
||||||
|
|
||||||
;; Internal variables
|
;; Internal variables
|
||||||
(defvar-local exwm--id nil) ;window ID
|
(defvar-local exwm--id nil) ;window ID
|
||||||
|
(defvar-local exwm--configurations nil) ;initial configurations.
|
||||||
(defvar-local exwm--frame nil) ;workspace frame
|
(defvar-local exwm--frame nil) ;workspace frame
|
||||||
(defvar-local exwm--floating-frame nil) ;floating frame
|
(defvar-local exwm--floating-frame nil) ;floating frame
|
||||||
(defvar-local exwm--mode-line-format nil) ;save mode-line-format
|
(defvar-local exwm--mode-line-format nil) ;save mode-line-format
|
||||||
|
|
|
@ -47,6 +47,26 @@ You can still make the X windows floating afterwards."
|
||||||
"Seconds to wait before killing a client."
|
"Seconds to wait before killing a client."
|
||||||
:type 'integer)
|
:type 'integer)
|
||||||
|
|
||||||
|
(defcustom exwm-manage-configurations nil
|
||||||
|
"Per-application configurations."
|
||||||
|
:type '(alist :key-type (sexp :tag "Matching criterion" nil)
|
||||||
|
:value-type
|
||||||
|
(plist :tag "Configurations"
|
||||||
|
:key-type
|
||||||
|
(choice
|
||||||
|
(const :tag "Floating" floating)
|
||||||
|
(const :tag "X" x)
|
||||||
|
(const :tag "Y" y)
|
||||||
|
(const :tag "Width" width)
|
||||||
|
(const :tag "Height" height)
|
||||||
|
(const :tag "Border width" border-width)
|
||||||
|
(const :tag "Char-mode" char-mode)
|
||||||
|
(const :tag "Prefix keys" prefix-keys)
|
||||||
|
(const :tag "Simulation keys" simulation-keys)
|
||||||
|
;; For forward compatibility.
|
||||||
|
(other))
|
||||||
|
:value-type (sexp :tag "Value" nil))))
|
||||||
|
|
||||||
;; FIXME: Make the following values as small as possible.
|
;; FIXME: Make the following values as small as possible.
|
||||||
(defconst exwm-manage--height-delta-min 5)
|
(defconst exwm-manage--height-delta-min 5)
|
||||||
(defconst exwm-manage--width-delta-min 5)
|
(defconst exwm-manage--width-delta-min 5)
|
||||||
|
@ -140,6 +160,14 @@ You can still make the X windows floating afterwards."
|
||||||
:window exwm--root
|
:window exwm--root
|
||||||
:data (vconcat (mapcar #'car exwm--id-buffer-alist)))))
|
:data (vconcat (mapcar #'car exwm--id-buffer-alist)))))
|
||||||
|
|
||||||
|
(cl-defun exwm-manage--get-configurations ()
|
||||||
|
"Retrieve configurations for this buffer."
|
||||||
|
(when (derived-mode-p 'exwm-mode)
|
||||||
|
(dolist (i exwm-manage-configurations)
|
||||||
|
(save-current-buffer
|
||||||
|
(when (eval (car i))
|
||||||
|
(cl-return-from exwm-manage--get-configurations (cdr i)))))))
|
||||||
|
|
||||||
(defun exwm-manage--manage-window (id)
|
(defun exwm-manage--manage-window (id)
|
||||||
"Manage window ID."
|
"Manage window ID."
|
||||||
(exwm--log "Try to manage #x%x" id)
|
(exwm--log "Try to manage #x%x" id)
|
||||||
|
@ -169,6 +197,7 @@ You can still make the X windows floating afterwards."
|
||||||
(exwm--update-hints id)
|
(exwm--update-hints id)
|
||||||
(exwm-manage--update-geometry id)
|
(exwm-manage--update-geometry id)
|
||||||
(exwm-manage--update-mwm-hints id)
|
(exwm-manage--update-mwm-hints id)
|
||||||
|
(setq exwm--configurations (exwm-manage--get-configurations))
|
||||||
;; No need to manage (please check OverrideRedirect outside)
|
;; No need to manage (please check OverrideRedirect outside)
|
||||||
(when (or
|
(when (or
|
||||||
(not
|
(not
|
||||||
|
@ -252,13 +281,20 @@ You can still make the X windows floating afterwards."
|
||||||
(xcb:flush exwm--connection)
|
(xcb:flush exwm--connection)
|
||||||
(exwm--update-title id)
|
(exwm--update-title id)
|
||||||
(exwm--update-protocols id)
|
(exwm--update-protocols id)
|
||||||
(if (and (not exwm-manage-force-tiling)
|
(if (plist-member exwm--configurations 'floating)
|
||||||
(or exwm-transient-for exwm--fixed-size
|
;; User has specified whether it should be floating.
|
||||||
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY exwm-window-type)
|
(if (plist-get exwm--configurations 'floating)
|
||||||
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
|
(exwm-floating--set-floating id)
|
||||||
exwm-window-type)))
|
(exwm-floating--unset-floating id))
|
||||||
(exwm-floating--set-floating id)
|
;; Try to determine if it should be floating.
|
||||||
(exwm-floating--unset-floating id))
|
(if (and (not exwm-manage-force-tiling)
|
||||||
|
(or exwm-transient-for exwm--fixed-size
|
||||||
|
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
|
||||||
|
exwm-window-type)
|
||||||
|
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
|
||||||
|
exwm-window-type)))
|
||||||
|
(exwm-floating--set-floating id)
|
||||||
|
(exwm-floating--unset-floating id)))
|
||||||
(exwm-input-grab-keyboard id)
|
(exwm-input-grab-keyboard id)
|
||||||
(setq exwm-workspace--switch-history-outdated t)
|
(setq exwm-workspace--switch-history-outdated t)
|
||||||
(exwm--update-desktop id)
|
(exwm--update-desktop id)
|
||||||
|
|
Loading…
Reference in a new issue