diff options
Diffstat (limited to 'third_party/exwm/exwm-layout.el')
-rw-r--r-- | third_party/exwm/exwm-layout.el | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/third_party/exwm/exwm-layout.el b/third_party/exwm/exwm-layout.el index 9173a1c049..8649c11ffd 100644 --- a/third_party/exwm/exwm-layout.el +++ b/third_party/exwm/exwm-layout.el @@ -1,6 +1,6 @@ ;;; exwm-layout.el --- Layout Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2015-2021 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng <chris.w.feng@gmail.com> @@ -29,7 +29,6 @@ (defgroup exwm-layout nil "Layout." - :version "25.3" :group 'exwm) (defcustom exwm-layout-auto-iconify t @@ -57,8 +56,7 @@ (declare-function exwm-input--grab-keyboard "exwm-input.el") (declare-function exwm-input-grab-keyboard "exwm-input.el") (declare-function exwm-workspace--active-p "exwm-workspace.el" (frame)) -(declare-function exwm-workspace--client-p "exwm-workspace.el" - (&optional frame)) +(declare-function exwm-workspace--get-geometry "exwm-workspace.el" (frame)) (declare-function exwm-workspace--minibuffer-own-frame-p "exwm-workspace.el") (declare-function exwm-workspace--workspace-p "exwm-workspace.el" (workspace)) @@ -66,7 +64,7 @@ (frame-or-index &optional id)) (defun exwm-layout--set-state (id state) - "Set WM_STATE." + "Set WM_STATE of X window ID to STATE." (exwm--log "id=#x%x" id) (xcb:+request exwm--connection (make-instance 'xcb:icccm:set-WM_STATE @@ -75,24 +73,28 @@ (setq exwm-state state))) (defun exwm-layout--iconic-state-p (&optional id) + "Check whether X window ID is in iconic state." (= xcb:icccm:WM_STATE:IconicState (if id (buffer-local-value 'exwm-state (exwm--id->buffer id)) exwm-state))) -(defun exwm-layout--set-ewmh-state (xwin) - "Set _NET_WM_STATE." - (with-current-buffer (exwm--id->buffer xwin) +(defun exwm-layout--set-ewmh-state (id) + "Set _NET_WM_STATE of X window ID to the value of variable `exwm--ewmh-state'." + (with-current-buffer (exwm--id->buffer id) (xcb:+request exwm--connection (make-instance 'xcb:ewmh:set-_NET_WM_STATE :window exwm--id :data exwm--ewmh-state)))) (defun exwm-layout--fullscreen-p () + "Check whether current `exwm-mode' buffer is in fullscreen state." (when (derived-mode-p 'exwm-mode) (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))) (defun exwm-layout--auto-iconify () + "Helper function to iconify unused X windows. +See variable `exwm-layout-auto-iconify'." (when (and exwm-layout-auto-iconify (not exwm-transient-for)) (let ((xwin exwm--id) @@ -154,7 +156,8 @@ (with-current-buffer (exwm--id->buffer id) (unless (or (exwm-layout--iconic-state-p) (and exwm--floating-frame - (eq 4294967295. exwm--desktop))) + exwm--desktop + (= 4294967295. exwm--desktop))) (exwm--log "Hide #x%x" id) (when exwm--floating-frame (let* ((container (frame-parameter exwm--floating-frame @@ -212,7 +215,7 @@ ;;;###autoload (cl-defun exwm-layout-unset-fullscreen (&optional id) - "Restore window from fullscreen state." + "Restore X window ID from fullscreen state." (interactive) (exwm--log "id=#x%x" (or id 0)) (unless (and (or id (derived-mode-p 'exwm-mode)) @@ -243,7 +246,7 @@ ;;;###autoload (cl-defun exwm-layout-toggle-fullscreen (&optional id) - "Toggle fullscreen mode." + "Toggle fullscreen mode of X window ID." (interactive (list (exwm--buffer->id (window-buffer)))) (exwm--log "id=#x%x" (or id 0)) (unless (or id (derived-mode-p 'exwm-mode)) @@ -300,7 +303,8 @@ selected by `other-buffer'." clients clients-floating)))))) (defun exwm-layout--refresh (&optional frame) - "Refresh layout." + "Refresh layout of FRAME. +If FRAME is nil, refresh layout of selected frame." ;; `window-size-change-functions' sets this argument while ;; `window-configuration-change-hook' makes the frame selected. (unless frame @@ -405,22 +409,29 @@ selected by `other-buffer'." (defun exwm-layout--on-minibuffer-setup () "Refresh layout when minibuffer grows." (exwm--log) - (unless (exwm-workspace--client-p) - (exwm--defer 0 (lambda () - (when (< 1 (window-height (minibuffer-window))) - (exwm-layout--refresh)))))) + ;; Only when active minibuffer's frame is an EXWM frame. + (let* ((mini-window (active-minibuffer-window)) + (frame (window-frame mini-window))) + (when (exwm-workspace--workspace-p frame) + (exwm--defer 0 (lambda () + (when (< 1 (window-height mini-window)) + (exwm-layout--refresh frame))))))) (defun exwm-layout--on-echo-area-change (&optional dirty) - "Run when message arrives or in `echo-area-clear-hook' to refresh layout." - (when (and (current-message) - (not (exwm-workspace--client-p)) - (or (cl-position ?\n (current-message)) - (> (length (current-message)) - (frame-width exwm-workspace--current)))) - (exwm--log) - (if dirty - (exwm-layout--refresh) - (exwm--defer 0 #'exwm-layout--refresh)))) + "Run when message arrives or in `echo-area-clear-hook' to refresh layout. +If DIRTY is non-nil, refresh layout immediately." + (let ((frame (window-frame (active-minibuffer-window))) + (msg (current-message))) + ;; Check whether the frame where current window's minibuffer resides (not + ;; current window's frame for floating windows!) must be adjusted. + (when (and msg + (exwm-workspace--workspace-p frame) + (or (cl-position ?\n msg) + (> (length msg) (frame-width frame)))) + (exwm--log) + (if dirty + (exwm-layout--refresh exwm-workspace--current) + (exwm--defer 0 #'exwm-layout--refresh exwm-workspace--current))))) ;;;###autoload (defun exwm-layout-enlarge-window (delta &optional horizontal) |