diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2018-03-04T04·23+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2018-03-04T04·29+0800 |
commit | 46fe764634ff4fa0eff7ea87c3b96209a05c89be (patch) | |
tree | 3cd4e040f3b3b463638a6cdefcf0a1ca3496369e | |
parent | 277377c718429555f75a88a85f336d80f3716dce (diff) |
Fix fullscreen mode after switching workspace and back
* exwm-layout.el (exwm-layout--show): Always set an X window in fullscreen mode the size in fullscreen. (exwm-layout-unset-fullscreen): Leave the fullscreen mode first. * exwm-layout.el (exwm-layout--fullscreen-p): New function telling whether the current buffer is in fullscreen mode. (exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen) (exwm-layout-toggle-fullscreen): * exwm-manage.el (exwm-manage--manage-window) (exwm-manage--on-ConfigureRequest): * exwm-workspace.el (exwm-workspace-switch, exwm-workspace-swap) (exwm-workspace-move): * exwm.el (exwm-reset, exwm--on-ClientMessage): Use it.
-rw-r--r-- | exwm-layout.el | 24 | ||||
-rw-r--r-- | exwm-manage.el | 7 | ||||
-rw-r--r-- | exwm-workspace.el | 7 | ||||
-rw-r--r-- | exwm.el | 14 |
4 files changed, 32 insertions, 20 deletions
diff --git a/exwm-layout.el b/exwm-layout.el index 5a01f900323d..998556bc896f 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -69,6 +69,10 @@ (buffer-local-value 'exwm-state (exwm--id->buffer id)) exwm-state))) +(defun exwm-layout--fullscreen-p () + (when (derived-mode-p 'exwm-mode) + (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))) + (defun exwm-layout--show (id &optional window) "Show window ID exactly fit in the Emacs window WINDOW." (exwm--log "Show #x%x in %s" id window) @@ -92,6 +96,16 @@ (exwm--set-geometry (frame-parameter exwm--floating-frame 'exwm-container) frame-x frame-y frame-width frame-height)) + (when (exwm-layout--fullscreen-p) + (with-slots ((x* x) + (y* y) + (width* width) + (height* height)) + (exwm-workspace--get-geometry exwm--frame) + (setq x x* + y y* + width width* + height height*))) (exwm--set-geometry id x y width height) (xcb:+request exwm--connection (make-instance 'xcb:MapWindow :window id)) (exwm-layout--set-state id xcb:icccm:WM_STATE:NormalState))) @@ -131,7 +145,7 @@ "Make window ID fullscreen." (interactive) (unless (and (or id (derived-mode-p 'exwm-mode)) - (not (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))) + (not (exwm-layout--fullscreen-p))) (cl-return-from 'exwm-layout-set-fullscreen)) (with-current-buffer (if id (exwm--id->buffer id) (window-buffer)) ;; Expand the X window to fill the whole screen. @@ -158,9 +172,11 @@ "Restore window from fullscreen state." (interactive) (unless (and (or id (derived-mode-p 'exwm-mode)) - (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (exwm-layout--fullscreen-p)) (cl-return-from 'exwm-layout-unset-fullscreen)) (with-current-buffer (if id (exwm--id->buffer id) (window-buffer)) + (setq exwm--ewmh-state + (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) (if exwm--floating-frame (exwm-layout--show exwm--id (frame-root-window exwm--floating-frame)) (xcb:+request exwm--connection @@ -176,8 +192,6 @@ (xcb:+request exwm--connection (make-instance 'xcb:ewmh:set-_NET_WM_STATE :window exwm--id :data [])) (xcb:flush exwm--connection) - (setq exwm--ewmh-state - (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) (call-interactively #'exwm-input-grab-keyboard))) ;;;###autoload @@ -188,7 +202,7 @@ (cl-return-from 'exwm-layout-toggle-fullscreen)) (when id (with-current-buffer (exwm--id->buffer id) - (if (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state) + (if (exwm-layout--fullscreen-p) (exwm-reset) (exwm-layout-set-fullscreen id))))) diff --git a/exwm-manage.el b/exwm-manage.el index 94aefd8c555f..b5c3f58dfdde 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -109,6 +109,7 @@ You can still make the X windows floating afterwards." (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--fullscreen-p "exwm-layout.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)) @@ -318,7 +319,7 @@ You can still make the X windows floating afterwards." (exwm-manage--update-ewmh-state id) (with-current-buffer (exwm--id->buffer id) (when (or (plist-get exwm--configurations 'fullscreen) - (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (exwm-layout--fullscreen-p)) (setq exwm--ewmh-state (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) (exwm-layout-set-fullscreen id)) @@ -533,7 +534,7 @@ border-width: %d; sibling: #x%x; stack-mode: %d" border-width sibling stack-mode) (if (and (setq buffer (exwm--id->buffer window)) (with-current-buffer buffer - (or (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state) + (or (exwm-layout--fullscreen-p) ;; Make sure it's a floating X window wanting to resize ;; itself. (or (not exwm--floating-frame) @@ -559,7 +560,7 @@ border-width: %d; sibling: #x%x; stack-mode: %d" ;; Send client message for managed windows (with-current-buffer buffer (setq edges - (if (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state) + (if (exwm-layout--fullscreen-p) (with-slots (x y width height) (exwm-workspace--get-geometry exwm--frame) (list x y width height)) diff --git a/exwm-workspace.el b/exwm-workspace.el index 0651b575d8b4..deb6a653575a 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -128,6 +128,7 @@ Please manually run the hook `exwm-workspace-list-change-hook' afterwards.") (defvar exwm-manage--desktop) (declare-function exwm--exit "exwm.el") (declare-function exwm-input--on-buffer-list-update "exwm-input.el" ()) +(declare-function exwm-layout--fullscreen-p "exwm-layout.el" ()) (declare-function exwm-layout--hide "exwm-layout.el" (id)) (declare-function exwm-layout--other-buffer-predicate "exwm-layout.el" (buffer)) @@ -504,7 +505,7 @@ for internal use only." ((null current-prefix-arg) (unless (and (eq major-mode 'exwm-mode) ;; The prompt is invisible in fullscreen mode. - (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (exwm-layout--fullscreen-p)) (let ((exwm-workspace--prompt-add-allowed t) (exwm-workspace--prompt-delete-allowed t)) (exwm-workspace--prompt-for-workspace "Switch to [+/-]: ")))) @@ -631,7 +632,7 @@ Passing a workspace frame as the first option is for internal use only." (interactive (unless (and (eq major-mode 'exwm-mode) ;; The prompt is invisible in fullscreen mode. - (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (exwm-layout--fullscreen-p)) (let (w1 w2) (let ((exwm-workspace--prompt-add-allowed t) (exwm-workspace--prompt-delete-allowed t)) @@ -671,7 +672,7 @@ before it." ((null current-prefix-arg) (unless (and (eq major-mode 'exwm-mode) ;; The prompt is invisible in fullscreen mode. - (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)) + (exwm-layout--fullscreen-p)) (list exwm-workspace--current (exwm-workspace--position (exwm-workspace--prompt-for-workspace "Move workspace to: "))))) diff --git a/exwm.el b/exwm.el index ed251f30adfc..0387426ffc68 100644 --- a/exwm.el +++ b/exwm.el @@ -110,7 +110,7 @@ (interactive) (with-current-buffer (window-buffer) (when (eq major-mode 'exwm-mode) - (when (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state) + (when (exwm-layout--fullscreen-p) (exwm-layout-unset-fullscreen)) ;; Force refresh (exwm-layout--refresh) @@ -484,8 +484,7 @@ exwm--connection (make-instance 'xcb:ewmh:set-_NET_WM_STATE :window id - :data (vector - xcb:Atom:_NET_WM_STATE_FULLSCREEN))) + :data (vector xcb:Atom:_NET_WM_STATE_FULLSCREEN))) (xcb:flush exwm--connection)) (when buffer ;ensure it's managed (with-current-buffer buffer @@ -493,17 +492,14 @@ (when (or (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN props) (memq xcb:Atom:_NET_WM_STATE_ABOVE props)) (cond ((= action xcb:ewmh:_NET_WM_STATE_ADD) - (unless (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN - exwm--ewmh-state) + (unless (exwm-layout--fullscreen-p) (exwm-layout-set-fullscreen id)) (push xcb:Atom:_NET_WM_STATE_FULLSCREEN props-new)) ((= action xcb:ewmh:_NET_WM_STATE_REMOVE) - (when (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN - exwm--ewmh-state) + (when (exwm-layout--fullscreen-p) (exwm-layout-unset-fullscreen id))) ((= action xcb:ewmh:_NET_WM_STATE_TOGGLE) - (if (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN - exwm--ewmh-state) + (if (exwm-layout--fullscreen-p) (exwm-layout-unset-fullscreen id) (exwm-layout-set-fullscreen id) (push xcb:Atom:_NET_WM_STATE_FULLSCREEN props-new))))) |