about summary refs log tree commit diff
path: root/exwm-layout.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-02-06T04·59+0800
committerChris Feng <chris.w.feng@gmail.com>2016-02-06T04·59+0800
commit0e4055d3392537cd4138181b9c615fa03053add8 (patch)
treecf9642d140b82a8c8d401dd01e26145fd7f060ea /exwm-layout.el
parent2d42fee327f92b01444718cfc83ce5f00716fa33 (diff)
Add auto-hiding minibuffer support
* exwm-floating.el (exwm-floating--set-floating): Take auto-hiding
minibuffer into account when calculating available height.
(exwm-floating--unset-floating): Restack the container to avoid further
restacking.
* exwm-input.el (exwm-input--update-focus): Use more accurate restacking.
(exwm-input--on-minibuffer-setup): Replaced by
`exwm-layout--on-minibuffer-setup' and `exwm-workspace--on-minibuffer-setup'.
(exwm-input-command-whitelist, exwm-input--during-command)
(exwm-input--on-KeyPress-line-mode): The functionality of
`exwm-input-command-whitelist' is replaced by `exwm-input--during-command',
which can automatically tell whether functions like `read-event' are being
called.
(exwm-input--init): Add/remove corresponding hooks.
* exwm-layout.el (exwm-layout--on-minibuffer-setup): Also set input focus.
(exwm-layout--on-echo-area-change): New function for refreshing layout when
the size of echo area changes.
(exwm-layout--init): Track size changes for fixed minibuffer and echo area.
* exwm-manage.el (exwm-manage--on-ConfigureRequest): Never grant restacking
requests initiated by other clients.
* exwm-workspace.el (exwm-workspace--minibuffer): New variable for the
auto-hiding minibuffer.
(exwm-workspace-minibuffer-position): For setting the position of the
auto-hiding minibuffer.
(exwm-workspace-display-echo-area-timeout): Seconds before echo area
auto-hides.
(exwm-workspace--display-echo-area-timer): The corresponding timer.
(exwm-workspace-switch): Configure the auto-hiding minibuffer when
switching workspace.
(exwm-workspace--update-minibuffer): New function for adjusting the height
of the auto-hiding minibuffer.
(exwm-workspace--on-ConfigureNotify): New function for configuring the
container of the auto-hiding minibuffer.
(exwm-workspace--display-buffer): New function for forcing
`minibuffer-completion-help' to use the workspace frame.
(exwm-workspace--show-minibuffer, exwm-workspace--hide-minibuffer):
New functions for showing/hiding the auto-hiding minibuffer (container).
(exwm-workspace--on-minibuffer-setup, exwm-workspace--on-minibuffer-exit):
New functions called when the auto-hiding minibuffer entered/exists.
(exwm-workspace--on-echo-area-dirty, exwm-workspace--on-echo-area-clear):
New functions when the auto-hiding echo area is ready to show/hide.
(exwm-workspace--init): Set up the auto-hiding minibuffer and workspace
frames.  Track sizes changes for auto-hiding minibuffer and echo area.
No need to set OverrideRedirect on workspace frames.
* exwm.el (exwm--init-icccm-ewmh): Correct the value of _NET_WORKAREA.
Diffstat (limited to 'exwm-layout.el')
-rw-r--r--exwm-layout.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/exwm-layout.el b/exwm-layout.el
index a290876bb3..316bf62a74 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -279,10 +279,20 @@
   "Refresh layout when minibuffer grows."
   (run-with-idle-timer 0.01 nil         ;FIXME
                        (lambda ()
-                         (when (and (< 1 (window-height (minibuffer-window)))
-                                    (not (and (eq major-mode 'exwm-mode)
-                                              exwm--floating-frame)))
-                           (exwm-layout--refresh)))))
+                         (when (< 1 (window-height (minibuffer-window)))
+                           (exwm-layout--refresh))))
+  ;; Set input focus on the Emacs frame
+  (x-focus-frame (window-frame (minibuffer-selected-window))))
+
+(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)
+             (or (cl-position ?\n (current-message))
+                 (> (length (current-message))
+                    (frame-width exwm-workspace--current))))
+    (if dirty
+        (exwm-layout--refresh)
+      (run-with-idle-timer 0.01 nil #'exwm-layout--refresh)))) ;FIXME
 
 (defun exwm-layout-enlarge-window (delta &optional horizontal)
   "Make the selected window DELTA pixels taller.
@@ -383,8 +393,11 @@ See also `exwm-layout-enlarge-window'."
   "Initialize layout module."
   ;; Auto refresh layout
   (add-hook 'window-configuration-change-hook #'exwm-layout--refresh)
-  ;; Refresh when minibuffer grows
-  (add-hook 'minibuffer-setup-hook #'exwm-layout--on-minibuffer-setup t))
+  (unless (memq exwm-workspace-minibuffer-position '(top bottom))
+    ;; Refresh when minibuffer grows
+    (add-hook 'minibuffer-setup-hook #'exwm-layout--on-minibuffer-setup t)
+    (run-with-idle-timer 0 t #'exwm-layout--on-echo-area-change t)
+    (add-hook 'echo-area-clear-hook #'exwm-layout--on-echo-area-change)))