Add support for 'managed' per-application configuration

* exwm-manage.el (exwm-manage-configurations): Add a new value type
'managed' to allow users to specify whether a certain X window should
be managed or not.
(exwm-manage--manage-window): Use it.
This commit is contained in:
Chris Feng 2018-11-18 00:00:00 +00:00
parent 882a628daa
commit dc3b86d1b8

View file

@ -70,6 +70,7 @@ You can still make the X windows floating afterwards."
(const :tag "Prefix keys" prefix-keys) (const :tag "Prefix keys" prefix-keys)
(const :tag "Simulation keys" simulation-keys) (const :tag "Simulation keys" simulation-keys)
(const :tag "Workspace" workspace) (const :tag "Workspace" workspace)
(const :tag "Managed" managed)
;; For forward compatibility. ;; For forward compatibility.
(other)) (other))
:value-type (sexp :tag "Value" nil)))) :value-type (sexp :tag "Value" nil))))
@ -214,14 +215,23 @@ 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)
;; No need to manage (please check OverrideRedirect outside) (setq exwm--configurations (exwm-manage--get-configurations))
(when (or ;; OverrideRedirect is not checked here.
(not (when (and
(or (not exwm-window-type) ;; The user has specified to manage it.
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY exwm-window-type) (not (plist-get exwm--configurations 'managed))
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG exwm-window-type) (or
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_NORMAL exwm-window-type))) ;; The user has specified not to manage it.
;; Check the _MOTIF_WM_HINTS property. (plist-member exwm--configurations 'managed)
;; This is not a type of X window we can manage.
(and exwm-window-type
(not (cl-intersection
exwm-window-type
(list xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
xcb:Atom:_NET_WM_WINDOW_TYPE_NORMAL))))
;; Check the _MOTIF_WM_HINTS property to not manage floating X
;; windows without decoration.
(and (not exwm--mwm-hints-decorations) (and (not exwm--mwm-hints-decorations)
(not exwm--hints-input) (not exwm--hints-input)
;; Floating windows only ;; Floating windows only
@ -229,7 +239,7 @@ You can still make the X windows floating afterwards."
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY (memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
exwm-window-type) exwm-window-type)
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
exwm-window-type)))) exwm-window-type)))))
(exwm--log "No need to manage #x%x" id) (exwm--log "No need to manage #x%x" id)
;; Update struts. ;; Update struts.
(when (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DOCK exwm-window-type) (when (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DOCK exwm-window-type)
@ -277,7 +287,6 @@ You can still make the X windows floating afterwards."
(let ((kill-buffer-query-functions nil)) (let ((kill-buffer-query-functions nil))
(kill-buffer (current-buffer))) (kill-buffer (current-buffer)))
(throw 'return 'ignored)) (throw 'return 'ignored))
(setq exwm--configurations (exwm-manage--get-configurations))
(let ((index (plist-get exwm--configurations 'workspace))) (let ((index (plist-get exwm--configurations 'workspace)))
(when (and index (< index (length exwm-workspace--list))) (when (and index (< index (length exwm-workspace--list)))
(setq exwm--frame (elt exwm-workspace--list index)))) (setq exwm--frame (elt exwm-workspace--list index))))