From 64e0b237fb26251246786a83be49656fecb8b7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?= Date: Tue, 20 Aug 2024 00:00:00 +0000 Subject: [PATCH] [DRAFT] Keep input mode when switching to fullscreen --- exwm-core.el | 2 ++ exwm-layout.el | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/exwm-core.el b/exwm-core.el index c8ec1e0..08b9553 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -256,6 +256,8 @@ If CONN is non-nil, use it instead of the value of the variable One of `line-mode' or `char-mode'.") (defvar-local exwm--input-mode 'line-mode "Actual input mode, i.e. whether mouse and keyboard are grabbed.") +(defvar-local exwm--fullscreen-previous-configuration nil + "Stores window configuration to restore when unsetting fullscreen.") ;; Properties (defvar-local exwm--desktop nil "_NET_WM_DESKTOP.") (defvar-local exwm-window-type nil "_NET_WM_WINDOW_TYPE.") diff --git a/exwm-layout.el b/exwm-layout.el index eb3977d..08a3bcd 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -209,10 +209,14 @@ See variable `exwm-layout-auto-iconify'." :stack-mode xcb:StackMode:Above)) (cl-pushnew xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state) (exwm-layout--set-ewmh-state exwm--id) + (unless exwm--floating-frame + ;; Store window configuration and leave the window of the buffer's window + ;; as the sole window. This makes commands such as `other-window` more + ;; intuitive. + (setq exwm--fullscreen-previous-configuration (current-window-configuration)) + (delete-other-windows)) (xcb:flush exwm--connection) - (set-window-dedicated-p (get-buffer-window) t) - (when (eq 'char-mode exwm--selected-input-mode) - (exwm-input--release-keyboard exwm--id)))) + (set-window-dedicated-p (get-buffer-window) t))) ;;;###autoload (cl-defun exwm-layout-unset-fullscreen (&optional id) @@ -230,6 +234,11 @@ See variable `exwm-layout-auto-iconify'." (exwm-layout--set-ewmh-state exwm--id) (if exwm--floating-frame (exwm-layout--show exwm--id (frame-root-window exwm--floating-frame)) + (when exwm--fullscreen-previous-configuration + ;; Restore the window configuration as it was before switching to + ;; fullscreen. + (set-window-configuration exwm--fullscreen-previous-configuration) + (setq exwm--fullscreen-previous-configuration nil)) (xcb:+request exwm--connection (make-instance 'xcb:ConfigureWindow :window exwm--id @@ -241,9 +250,7 @@ See variable `exwm-layout-auto-iconify'." (when window (exwm-layout--show exwm--id window)))) (xcb:flush exwm--connection) - (set-window-dedicated-p (get-buffer-window) nil) - (when (eq 'line-mode exwm--selected-input-mode) - (exwm-input--grab-keyboard exwm--id)))) + (set-window-dedicated-p (get-buffer-window) nil))) ;;;###autoload (defun exwm-layout-toggle-fullscreen (&optional id)