From dba1ed94c2e06b46da77a2aa80aa35e17b08fdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?= Date: Sun, 21 Oct 2018 12:00:00 +0000 Subject: [PATCH 1/2] Do away with `exwm-input--input-mode' * exwm-input.el (exwm-input--update-mode-line): Remove. (exwm-input--on-ButtonPress, exwm-input--on-KeyPress) (exwm-input--update-mode-line, exwm-input-toggle-keyboard): Use `exwm--input-mode' variable directly. --- exwm-input.el | 15 ++++----------- exwm-layout.el | 3 +-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index 6e8f6d8..78e74cd 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -411,7 +411,7 @@ ARGS are additional arguments to CALLBACK." (when window (select-window window)))) (with-current-buffer buffer (when (derived-mode-p 'exwm-mode) - (cl-case (exwm-input--current-input-mode) + (cl-case exwm--input-mode (line-mode (setq mode (exwm-input--on-ButtonPress-line-mode buffer button-event))) (char-mode @@ -427,7 +427,7 @@ ARGS are additional arguments to CALLBACK." (exwm--log "major-mode=%s buffer=%s" major-mode (buffer-name (current-buffer))) (if (derived-mode-p 'exwm-mode) - (cl-case (exwm-input--current-input-mode) + (cl-case exwm--input-mode (line-mode (exwm-input--on-KeyPress-line-mode obj data)) (char-mode @@ -688,17 +688,10 @@ The return value is used as event_mode to release the original button event." xcb:Allow:ReplayPointer) -(defun exwm-input--current-input-mode () - "Return current input mode. -The return value is one of the symbols \\='line-mode or \\=`char-mode. - -Current buffer must be an `exwm-mode' buffer." - exwm--input-mode) - (defun exwm-input--update-mode-line (id) "Update the propertized `mode-line-process' for window ID." (let (help-echo cmd mode) - (cl-case (exwm-input--current-input-mode) + (cl-case exwm--input-mode (line-mode (setq mode "line" help-echo "mouse-1: Switch to char-mode" @@ -784,7 +777,7 @@ Current buffer must be an `exwm-mode' buffer." (when id (exwm--log "id=#x%x" id) (with-current-buffer (exwm--id->buffer id) - (cl-case (exwm-input--current-input-mode) + (cl-case exwm--input-mode (line-mode (exwm-input-release-keyboard id)) (char-mode diff --git a/exwm-layout.el b/exwm-layout.el index 90988fa..fe394e2 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -45,7 +45,6 @@ (defvar exwm-layout--timer nil "Timer used to track echo area changes.") (defvar exwm-workspace--current) -(declare-function exwm-input--current-input-mode "exwm-input.el") (declare-function exwm-input--release-keyboard "exwm-input.el") (declare-function exwm-input--grab-keyboard "exwm-input.el") (declare-function exwm-input-grab-keyboard "exwm-input.el") @@ -200,7 +199,7 @@ (make-instance 'xcb:ewmh:set-_NET_WM_STATE :window exwm--id :data [])) (xcb:flush exwm--connection) (set-window-dedicated-p (get-buffer-window) nil) - (when (eq 'line-mode (exwm-input--current-input-mode)) + (when (eq 'line-mode exwm--input-mode) (exwm-input--grab-keyboard exwm--id)))) ;;;###autoload From eb91ee2c77787bbeb1df74f0237f5087d031217f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?= Date: Sun, 21 Oct 2018 12:00:00 +0000 Subject: [PATCH 2/2] Restore keyboard grabbing after exiting fullscreen Recover the difference between the input mode selected by the user and actual one, which might be transient. This was inadvertently removed in recent changes. * exwm-core.el (exwm--selected-input-mode): New variable. * exwm-input.el (exwm-input-grab-keyboard) (exwm-input-release-keyboard): Use it. * exwm-layout.el (exwm-layout-unset-fullscreen): Return to the selected input mode. --- exwm-core.el | 6 +++++- exwm-input.el | 2 ++ exwm-layout.el | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/exwm-core.el b/exwm-core.el index 612a26f..1f93949 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -158,7 +158,11 @@ least SECS seconds later." (defvar-local exwm--mode-line-format nil) ;save mode-line-format (defvar-local exwm--floating-frame-position nil) ;set when hidden. (defvar-local exwm--fixed-size nil) ;fixed size -(defvar-local exwm--input-mode 'line-mode) ;Keyboard grabbed. +(defvar-local exwm--selected-input-mode 'line-mode + "Input mode as selected by the user. +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.") ;; Properties (defvar-local exwm--desktop nil "_NET_WM_DESKTOP.") (defvar-local exwm-window-type nil "_NET_WM_WINDOW_TYPE.") diff --git a/exwm-input.el b/exwm-input.el index 78e74cd..c757b09 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -756,6 +756,7 @@ button event." (exwm--buffer->id (window-buffer))))) (when id (exwm--log "id=#x%x" id) + (setq exwm--selected-input-mode 'line-mode) (exwm-input--grab-keyboard id) (exwm-input--update-mode-line id))) @@ -766,6 +767,7 @@ button event." (exwm--buffer->id (window-buffer))))) (when id (exwm--log "id=#x%x" id) + (setq exwm--selected-input-mode 'char-mode) (exwm-input--release-keyboard id) (exwm-input--update-mode-line id))) diff --git a/exwm-layout.el b/exwm-layout.el index fe394e2..bee6901 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -199,7 +199,7 @@ (make-instance 'xcb:ewmh:set-_NET_WM_STATE :window exwm--id :data [])) (xcb:flush exwm--connection) (set-window-dedicated-p (get-buffer-window) nil) - (when (eq 'line-mode exwm--input-mode) + (when (eq 'line-mode exwm--selected-input-mode) (exwm-input--grab-keyboard exwm--id)))) ;;;###autoload