diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2018-03-02T17·00+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2018-03-02T17·00+0800 |
commit | e141ee684763d93cba02022d76274aeaaba407e5 (patch) | |
tree | 4155646b4cbfa0279a0712d6e1597f5d839b5296 | |
parent | 0d1a32312409a6196724d9a69035ea9f7137ed24 (diff) |
Add various per-application configurations
* exwm-manage.el (exwm-manage-configurations): Add options for fullscreen mode and floating & tiling mode-line formats. (exwm-manage--manage-window): Add support for configuring line-mode/char-mode, prefix keys, simulation keys and fullscreen mode. * exwm-floating.el (exwm-floating--set-floating): Add support for configuring the geometry, mode-line format and border width of a floating X window. (exwm-floating--unset-floating): Add support for configuring the mode-line format of a tiling X window.
-rw-r--r-- | exwm-floating.el | 69 | ||||
-rw-r--r-- | exwm-manage.el | 23 |
2 files changed, 78 insertions, 14 deletions
diff --git a/exwm-floating.el b/exwm-floating.el index 5a2c61e878d1..f9b1402fe7d0 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -176,7 +176,32 @@ This is also used by X window containers.") (when (= 0 height) (setq height (/ height* 2))) ;; Make sure at least half of the window is visible (unless (< y* (+ y (/ height 2)) (+ y* height*)) - (setq y (+ y* (/ (- height* height) 2)))))) + (setq y (+ y* (/ (- height* height) 2))))) + ;; The geometry can be overridden by user options. + (let ((x** (plist-get exwm--configurations 'x)) + (y** (plist-get exwm--configurations 'y)) + (width** (plist-get exwm--configurations 'width)) + (height** (plist-get exwm--configurations 'height))) + (if (integerp x**) + (setq x (+ x* x**)) + (when (and (floatp x**) + (>= 1 x** 0)) + (setq x (+ x* (round (* x** width*)))))) + (if (integerp y**) + (setq y (+ y* y**)) + (when (and (floatp y**) + (>= 1 y** 0)) + (setq y (+ y* (round (* y** height*)))))) + (if (integerp width**) + (setq width width**) + (when (and (floatp width**) + (> 1 width** 0)) + (setq width (max 1 (round (* width** width*)))))) + (if (integerp height**) + (setq height height**) + (when (and (floatp height**) + (> 1 height** 0)) + (setq height (max 1 (round (* height** height*)))))))) (exwm--set-geometry id x y nil nil) (xcb:flush exwm--connection) (exwm--log "Floating geometry (corrected): %dx%d%+d%+d" width height x y) @@ -189,13 +214,23 @@ This is also used by X window containers.") (frame-width (+ width (- (frame-pixel-width frame) (- (elt edges 2) (elt edges 0))))) (frame-height (+ height (- (frame-pixel-height frame) - (- (elt edges 3) (elt edges 1)))))) - ;; Check `exwm--mwm-hints-decorations'. - (unless exwm--mwm-hints-decorations - (setq frame-height (- frame-height (window-mode-line-height - (frame-root-window frame))) - exwm--mode-line-format mode-line-format - mode-line-format nil)) + (- (elt edges 3) (elt edges 1))))) + (floating-mode-line (plist-get exwm--configurations + 'floating-mode-line))) + (if floating-mode-line + (setq exwm--mode-line-format (or exwm--mode-line-format + mode-line-format) + mode-line-format floating-mode-line) + (if (and (not (plist-member exwm--configurations 'floating-mode-line)) + exwm--mwm-hints-decorations) + (when exwm--mode-line-format + (setq mode-line-format exwm--mode-line-format)) + ;; The mode-line need to be hidden in floating mode. + (setq frame-height (- frame-height (window-mode-line-height + (frame-root-window frame))) + exwm--mode-line-format (or exwm--mode-line-format + mode-line-format) + mode-line-format nil))) (set-frame-size frame frame-width frame-height t) ;; Create the frame container as the parent of the frame. (xcb:+request exwm--connection @@ -207,7 +242,14 @@ This is also used by X window containers.") :y (- y (elt edges 1)) :width width :height height - :border-width exwm-floating-border-width + :border-width + (with-current-buffer (exwm--id->buffer id) + (let ((border-witdh (plist-get exwm--configurations + 'border-width))) + (if (and (integerp border-witdh) + (>= border-witdh 0)) + border-witdh + exwm-floating-border-width))) :class xcb:WindowClass:InputOutput :visual 0 :value-mask (logior xcb:CW:BackPixmap @@ -326,7 +368,14 @@ This is also used by X window containers.") (delete-frame exwm--floating-frame)))) (with-current-buffer buffer (setq window-size-fixed nil - exwm--floating-frame nil)) + exwm--floating-frame nil) + (if (not (plist-member exwm--configurations 'tiling-mode-line)) + (when exwm--mode-line-format + (setq mode-line-format exwm--mode-line-format)) + (setq exwm--mode-line-format (or exwm--mode-line-format + mode-line-format) + mode-line-format (plist-get exwm--configurations + 'tiling-mode-line)))) ;; Only show X windows in normal state. (unless (exwm-layout--iconic-state-p) (pop-to-buffer-same-window buffer))) diff --git a/exwm-manage.el b/exwm-manage.el index 3954d3ea24ef..00914475f1d2 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -60,6 +60,9 @@ You can still make the X windows floating afterwards." (const :tag "Width" width) (const :tag "Height" height) (const :tag "Border width" border-width) + (const :tag "Fullscreen" fullscreen) + (const :tag "Floating mode-line" floating-mode-line) + (const :tag "Tiling mode-line" tiling-mode-line) (const :tag "Char-mode" char-mode) (const :tag "Prefix keys" prefix-keys) (const :tag "Simulation keys" simulation-keys) @@ -83,6 +86,7 @@ You can still make the X windows floating afterwards." (defvar exwm-manage--ping-lock nil "Non-nil indicates EXWM is pinging a window.") +(defvar exwm-input-prefix-keys) (defvar exwm-workspace--current) (defvar exwm-workspace--id-struts-alist) (defvar exwm-workspace--list) @@ -101,6 +105,7 @@ You can still make the X windows floating afterwards." (declare-function exwm-floating--set-floating "exwm-floating.el" (id)) (declare-function exwm-floating--unset-floating "exwm-floating.el" (id)) (declare-function exwm-input-grab-keyboard "exwm-input.el") +(declare-function exwm-input-set-local-simulation-keys "exwm-input.el") (declare-function exwm-layout--iconic-state-p "exwm-layout.el" (&optional id)) (declare-function exwm-workspace--count "exwm-workspace.el" ()) (declare-function exwm-workspace--position "exwm-workspace.el" (frame)) @@ -295,14 +300,24 @@ You can still make the X windows floating afterwards." exwm-window-type))) (exwm-floating--set-floating id) (exwm-floating--unset-floating id))) - (exwm-input-grab-keyboard id) + (if (plist-get exwm--configurations 'char-mode) + (exwm-input-release-keyboard id) + (exwm-input-grab-keyboard id)) + (let ((simulation-keys (plist-get exwm--configurations 'simulation-keys)) + (prefix-keys (plist-get exwm--configurations 'prefix-keys))) + (with-current-buffer (exwm--id->buffer id) + (when simulation-keys + (exwm-input-set-local-simulation-keys simulation-keys)) + (when prefix-keys + (setq-local exwm-input-prefix-keys prefix-keys)))) (setq exwm-workspace--switch-history-outdated t) (exwm--update-desktop id) (exwm-manage--update-ewmh-state id) (with-current-buffer (exwm--id->buffer id) - (when (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state) - (setq exwm--ewmh-state - (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (when (or (plist-get exwm--configurations 'fullscreen) + (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (setq exwm--ewmh-state (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN + exwm--ewmh-state)) (exwm-layout-set-fullscreen id)) (run-hooks 'exwm-manage-finish-hook))))) |