Hide blocked frames (they are visible with a compositor)

* exwm-workspace.el (exwm-workspace--set-active): New function for
setting the 'exwm-active' frame parameter and show/hide frames BTW.
(exwm-workspace--active-p): New function checking whether a frame is
active.
(exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window):
* exwm-randr.el (exwm-randr--refresh): Use them.

* exwm-workspace.el (exwm-workspace-attach-minibuffer)
(exwm-workspace--show-minibuffer, exwm-workspace--hide-minibuffer):
Show/Hide the minibuffer frame.
This commit is contained in:
Chris Feng 2018-02-22 22:21:54 +08:00
parent 32b88f4bd0
commit 1b6272e458
2 changed files with 58 additions and 29 deletions

View file

@ -81,7 +81,10 @@ the first one in result being the primary output."
(defvar exwm-workspace--fullscreen-frame-count) (defvar exwm-workspace--fullscreen-frame-count)
(defvar exwm-workspace--list) (defvar exwm-workspace--list)
(declare-function exwm-workspace--active-p "exwm-workspace.el" (frame))
(declare-function exwm-workspace--count "exwm-workspace.el") (declare-function exwm-workspace--count "exwm-workspace.el")
(declare-function exwm-workspace--set-active "exwm-workspace.el"
(frame active))
(declare-function exwm-workspace--set-desktop-geometry "exwm-workspace.el" ()) (declare-function exwm-workspace--set-desktop-geometry "exwm-workspace.el" ())
(declare-function exwm-workspace--set-fullscreen "exwm-workspace.el" (frame)) (declare-function exwm-workspace--set-fullscreen "exwm-workspace.el" (frame))
(declare-function exwm-workspace--show-minibuffer "exwm-workspace.el" ()) (declare-function exwm-workspace--show-minibuffer "exwm-workspace.el" ())
@ -138,7 +141,9 @@ the first one in result being the primary output."
container-frame-alist)) container-frame-alist))
(set-frame-parameter frame 'exwm-randr-output output) (set-frame-parameter frame 'exwm-randr-output output)
(set-frame-parameter frame 'exwm-geometry geometry))) (set-frame-parameter frame 'exwm-geometry geometry)))
;; Update the 'exwm-active' frame parameter. ;; Update active/inactive workspaces.
(dolist (w exwm-workspace--list)
(exwm-workspace--set-active w nil))
(dolist (xwin (dolist (xwin
(reverse (reverse
(slot-value (xcb:+request-unchecked+reply exwm--connection (slot-value (xcb:+request-unchecked+reply exwm--connection
@ -149,8 +154,8 @@ the first one in result being the primary output."
(when output (when output
(setq container-output-alist (setq container-output-alist
(rassq-delete-all output container-output-alist)) (rassq-delete-all output container-output-alist))
(set-frame-parameter (cdr (assq xwin container-frame-alist)) (exwm-workspace--set-active (cdr (assq xwin container-frame-alist))
'exwm-active t)))) t))))
;; Update workareas. ;; Update workareas.
(exwm-workspace--update-workareas) (exwm-workspace--update-workareas)
;; Resize workspace. ;; Resize workspace.

View file

@ -369,6 +369,18 @@ NIL if FRAME is not a workspace"
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
(run-hooks 'exwm-workspace--update-workareas-hook)) (run-hooks 'exwm-workspace--update-workareas-hook))
(defun exwm-workspace--set-active (frame active)
"Make frame FRAME active on its output."
(set-frame-parameter frame 'exwm-active active)
(if active
(exwm-workspace--set-fullscreen frame)
(exwm--set-geometry (frame-parameter frame 'exwm-container) nil nil 1 1)
(xcb:flush exwm--connection)))
(defun exwm-workspace--active-p (frame)
"Return non-nil if FRAME is active"
(frame-parameter frame 'exwm-active))
(defun exwm-workspace--set-fullscreen (frame) (defun exwm-workspace--set-fullscreen (frame)
"Make frame FRAME fullscreen according to `exwm-workspace--workareas'." "Make frame FRAME fullscreen according to `exwm-workspace--workareas'."
(let ((workarea (elt exwm-workspace--workareas (let ((workarea (elt exwm-workspace--workareas
@ -383,7 +395,9 @@ NIL if FRAME is not a workspace"
(when (and (eq frame exwm-workspace--current) (when (and (eq frame exwm-workspace--current)
(exwm-workspace--minibuffer-own-frame-p)) (exwm-workspace--minibuffer-own-frame-p))
(exwm-workspace--resize-minibuffer-frame)) (exwm-workspace--resize-minibuffer-frame))
(exwm--set-geometry container x y width height) (if (exwm-workspace--active-p frame)
(exwm--set-geometry container x y width height)
(exwm--set-geometry container x y 1 1))
(exwm--set-geometry id nil nil width height) (exwm--set-geometry id nil nil width height)
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
;; This is only used for workspace initialization. ;; This is only used for workspace initialization.
@ -516,25 +530,25 @@ for internal use only."
;; Show/Hide X windows. ;; Show/Hide X windows.
(let ((output-old (frame-parameter old-frame 'exwm-randr-output)) (let ((output-old (frame-parameter old-frame 'exwm-randr-output))
(output-new (frame-parameter frame 'exwm-randr-output)) (output-new (frame-parameter frame 'exwm-randr-output))
(active-old (frame-parameter old-frame 'exwm-active)) (active-old (exwm-workspace--active-p old-frame))
(active-new (frame-parameter frame 'exwm-active)) (active-new (exwm-workspace--active-p frame))
workspaces-to-hide) workspaces-to-hide)
(cond (cond
((not active-old) ((not active-old)
(set-frame-parameter frame 'exwm-active t)) (exwm-workspace--set-active frame t))
((eq output-old output-new) ((eq output-old output-new)
(set-frame-parameter old-frame 'exwm-active nil) (exwm-workspace--set-active old-frame nil)
(set-frame-parameter frame 'exwm-active t) (exwm-workspace--set-active frame t)
(setq workspaces-to-hide (list old-frame))) (setq workspaces-to-hide (list old-frame)))
(active-new) (active-new)
(t (t
(dolist (w exwm-workspace--list) (dolist (w exwm-workspace--list)
(when (and (frame-parameter w 'exwm-active) (when (and (exwm-workspace--active-p w)
(eq output-new (eq output-new
(frame-parameter w 'exwm-randr-output))) (frame-parameter w 'exwm-randr-output)))
(set-frame-parameter w 'exwm-active nil) (exwm-workspace--set-active w nil)
(setq workspaces-to-hide (append workspaces-to-hide (list w))))) (setq workspaces-to-hide (append workspaces-to-hide (list w)))))
(set-frame-parameter frame 'exwm-active t))) (exwm-workspace--set-active frame t)))
(dolist (i exwm--id-buffer-alist) (dolist (i exwm--id-buffer-alist)
(with-current-buffer (cdr i) (with-current-buffer (cdr i)
(if (memq exwm--frame workspaces-to-hide) (if (memq exwm--frame workspaces-to-hide)
@ -737,7 +751,7 @@ INDEX must not exceed the current number of workspaces."
(exwm--id->buffer id)) (exwm--id->buffer id))
(if (eq frame exwm-workspace--current) (if (eq frame exwm-workspace--current)
(select-window (frame-selected-window frame)) (select-window (frame-selected-window frame))
(unless (frame-parameter frame 'exwm-active) (unless (exwm-workspace--active-p frame)
(exwm-layout--hide id)))) (exwm-layout--hide id))))
;; Floating. ;; Floating.
(setq container (frame-parameter exwm--floating-frame (setq container (frame-parameter exwm--floating-frame
@ -762,7 +776,7 @@ INDEX must not exceed the current number of workspaces."
(if (eq frame exwm-workspace--current) (if (eq frame exwm-workspace--current)
(select-window (frame-root-window exwm--floating-frame)) (select-window (frame-root-window exwm--floating-frame))
(select-window (frame-selected-window exwm-workspace--current)) (select-window (frame-selected-window exwm-workspace--current))
(unless (frame-parameter frame 'exwm-active) (unless (exwm-workspace--active-p frame)
(exwm-layout--hide id))) (exwm-layout--hide id)))
;; The frame needs to be recreated since it won't use the ;; The frame needs to be recreated since it won't use the
;; minibuffer on the new workspace. ;; minibuffer on the new workspace.
@ -823,7 +837,7 @@ INDEX must not exceed the current number of workspaces."
(if (eq frame exwm-workspace--current) (if (eq frame exwm-workspace--current)
(with-current-buffer (exwm--id->buffer id) (with-current-buffer (exwm--id->buffer id)
(select-window (frame-root-window exwm--floating-frame))) (select-window (frame-root-window exwm--floating-frame)))
(unless (frame-parameter frame 'exwm-active) (unless (exwm-workspace--active-p frame)
(exwm-layout--hide id))))) (exwm-layout--hide id)))))
;; Update the 'exwm-selected-window' frame parameter. ;; Update the 'exwm-selected-window' frame parameter.
(when (not (eq frame exwm-workspace--current)) (when (not (eq frame exwm-workspace--current))
@ -935,6 +949,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
(redisplay) ;FIXME. (redisplay) ;FIXME.
(setq exwm-workspace--attached-minibuffer-height (setq exwm-workspace--attached-minibuffer-height
(frame-pixel-height exwm-workspace--minibuffer)) (frame-pixel-height exwm-workspace--minibuffer))
(exwm-workspace--show-minibuffer)
(let ((container (frame-parameter exwm-workspace--minibuffer (let ((container (frame-parameter exwm-workspace--minibuffer
'exwm-container))) 'exwm-container)))
(push (cons container (push (cons container
@ -945,8 +960,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
(exwm-workspace--update-struts) (exwm-workspace--update-struts)
(exwm-workspace--update-workareas) (exwm-workspace--update-workareas)
(dolist (f exwm-workspace--list) (dolist (f exwm-workspace--list)
(exwm-workspace--set-fullscreen f)) (exwm-workspace--set-fullscreen f)))))
(exwm-workspace--show-minibuffer))))
;;;###autoload ;;;###autoload
(defun exwm-workspace-detach-minibuffer () (defun exwm-workspace-detach-minibuffer ()
@ -1050,6 +1064,12 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
(cancel-timer exwm-workspace--display-echo-area-timer) (cancel-timer exwm-workspace--display-echo-area-timer)
(setq exwm-workspace--display-echo-area-timer nil)) (setq exwm-workspace--display-echo-area-timer nil))
;; Show the minibuffer frame. ;; Show the minibuffer frame.
(unless (exwm-workspace--minibuffer-attached-p)
(exwm--set-geometry (frame-parameter exwm-workspace--minibuffer
'exwm-container)
nil nil
(frame-pixel-width exwm-workspace--minibuffer)
(frame-pixel-height exwm-workspace--minibuffer)))
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:ConfigureWindow (make-instance 'xcb:ConfigureWindow
:window (frame-parameter exwm-workspace--minibuffer :window (frame-parameter exwm-workspace--minibuffer
@ -1061,18 +1081,22 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
(defun exwm-workspace--hide-minibuffer () (defun exwm-workspace--hide-minibuffer ()
"Hide the minibuffer frame." "Hide the minibuffer frame."
;; Hide the minibuffer frame. ;; Hide the minibuffer frame.
(xcb:+request exwm--connection (if (exwm-workspace--minibuffer-attached-p)
(make-instance 'xcb:ConfigureWindow (xcb:+request exwm--connection
:window (frame-parameter exwm-workspace--minibuffer (make-instance 'xcb:ConfigureWindow
'exwm-container) :window (frame-parameter exwm-workspace--minibuffer
:value-mask (logior (if exwm-manage--desktop 'exwm-container)
xcb:ConfigWindow:Sibling :value-mask (logior (if exwm-manage--desktop
0) xcb:ConfigWindow:Sibling
xcb:ConfigWindow:StackMode) 0)
:sibling exwm-manage--desktop xcb:ConfigWindow:StackMode)
:stack-mode (if exwm-manage--desktop :sibling exwm-manage--desktop
xcb:StackMode:Above :stack-mode (if exwm-manage--desktop
xcb:StackMode:Below))) xcb:StackMode:Above
xcb:StackMode:Below)))
(exwm--set-geometry (frame-parameter exwm-workspace--minibuffer
'exwm-container)
nil nil 1 1))
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
(defun exwm-workspace--on-minibuffer-setup () (defun exwm-workspace--on-minibuffer-setup ()