about summary refs log tree commit diff
path: root/exwm-workspace.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-02-19T09·12+0800
committerChris Feng <chris.w.feng@gmail.com>2016-02-19T09·12+0800
commitfc589b899b71e88e48931de41ea1df760f9c1edd (patch)
treedbe6814fba5e46262b1809d8331f39220ed47c52 /exwm-workspace.el
parentbfd43feb494a8a7675f3a882ea5ebeaa91fb3f82 (diff)
Fix system tray issues after updating workspaces
* exwm-workspace.el (exwm-workspace-switch-hook): New hook run by
`exwm-workspace-switch'.
* exwm-randr.el (exwm-randr-refresh-hook): New hook run by
`exwm-randr--refresh'.
* exwm-systemtray.el (exwm-systemtray--on-randr-refresh)
(exwm-systemtray--on-workspace-switch, exwm-systemtray--init): Update the
system tray in `exwm-randr-refresh-hook' and `exwm-workspace-switch-hook'.

* exwm-layout.el (exwm-layout--set-frame-fullscreen):
* exwm-workspace.el (exwm-workspace--post-init): Wait until all workspace
frames are set fullscreen.

* exwm-workspace.el (exwm-workspace--current-width)
(exwm-workspace--current-height): New functions for retrieving the width
and height of the current workspace.
* exwm-layout.el (exwm-layout-set-fullscreen):
* exwm-manage.el (exwm-manage--manage-window)
(exwm-manage--on-ConfigureRequest):
* exwm-systemtray.el (exwm-systemtray--refresh, exwm-systemtray--init):
* exwm-workspace.le (exwm-workspace--resize-minibuffer-frame)
(exwm-workspace--on-ConfigureNotify): Switch to
`exwm-workspace--current-width' and `exwm-workspace--current-height'.

* exwm-core.el:
* exwm-floating.el:
* exwm-floating.el:
* exwm-input.el:
* exwm-layout.el:
* exwm-manage.el:
* exwm-randr.el:
* exwm-systemtray.el:
* exwm-workspace.el:
* exwm.el:
Clean up loading file.  Set/Unset some functions as commands.

* README.md: Add intro to system tray.
Diffstat (limited to 'exwm-workspace.el')
-rw-r--r--exwm-workspace.el46
1 files changed, 35 insertions, 11 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index e9bab305e321..99e3b5510ea5 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -62,7 +62,6 @@
 (defvar exwm-workspace--switch-history-outdated nil
   "Non-nil to indicate `exwm-workspace--switch-history' is outdated.")
 
-;;;###autoload
 (defun exwm-workspace--update-switch-history ()
   "Update the history for switching workspace to reflect the latest status."
   (when exwm-workspace--switch-history-outdated
@@ -109,6 +108,22 @@ Value nil means to use the default position which is fixed at bottom, while
   "Timer for auto-hiding echo area.")
 
 ;;;###autoload
+(defun exwm-workspace--current-width ()
+  "Return the width of current workspace."
+  (let ((geometry (frame-parameter exwm-workspace--current 'exwm-geometry)))
+    (if geometry
+        (slot-value geometry 'width)
+      (x-display-pixel-width))))
+
+;;;###autoload
+(defun exwm-workspace--current-height ()
+  "Return the height of current workspace."
+  (let ((geometry (frame-parameter exwm-workspace--current 'exwm-geometry)))
+    (if geometry
+        (slot-value geometry 'height)
+      (x-display-pixel-height))))
+
+;;;###autoload
 (defun exwm-workspace--minibuffer-own-frame-p ()
   "Reports whether the minibuffer is displayed in its own frame."
   (memq exwm-workspace-minibuffer-position '(top bottom)))
@@ -122,9 +137,9 @@ workspace frame."
   (cl-assert (exwm-workspace--minibuffer-own-frame-p))
   (let ((y (if (eq exwm-workspace-minibuffer-position 'top)
                0
-             (- (or height (frame-pixel-height exwm-workspace--current))
+             (- (or height (exwm-workspace--current-height))
                 (frame-pixel-height exwm-workspace--minibuffer))))
-        (width (or width (frame-pixel-width exwm-workspace--current)))
+        (width (or width (exwm-workspace--current-width)))
         (container (frame-parameter exwm-workspace--minibuffer
                                     'exwm-container)))
     (xcb:+request exwm--connection
@@ -206,6 +221,8 @@ The optional FORCE option is for internal use only."
         (xcb:flush exwm--connection))
       (run-hooks 'exwm-workspace-switch-hook))))
 
+(declare-function exwm-layout--hide "exwm-layout.el" (id))
+
 ;;;###autoload
 (defun exwm-workspace-move-window (index &optional id)
   "Move window ID to workspace INDEX."
@@ -266,6 +283,7 @@ The optional FORCE option is for internal use only."
                              (exwm--id->buffer id)))))
     (setq exwm-workspace--switch-history-outdated t)))
 
+;;;###autoload
 (defun exwm-workspace-switch-to-buffer ()
   "Make the current Emacs window display another buffer."
   (interactive)
@@ -348,10 +366,10 @@ The optional FORCE option is for internal use only."
                 window)
         (when (and (floatp max-mini-window-height)
                    (> height (* max-mini-window-height
-                                (frame-pixel-height exwm-workspace--current))))
+                                (exwm-workspace--current-height))))
           (setq height (floor
                         (* max-mini-window-height
-                           (frame-pixel-height exwm-workspace--current))))
+                           (exwm-workspace--current-height))))
           (xcb:+request exwm--connection
               (make-instance 'xcb:ConfigureWindow
                              :window window
@@ -361,7 +379,7 @@ The optional FORCE option is for internal use only."
             (setq value-mask xcb:ConfigWindow:Height
                   y 0)
           (setq value-mask (logior xcb:ConfigWindow:Y xcb:ConfigWindow:Height)
-                y (- (frame-pixel-height exwm-workspace--current) height)))
+                y (- (exwm-workspace--current-height) height)))
         (xcb:+request exwm--connection
             (make-instance 'xcb:ConfigureWindow
                            :window (frame-parameter exwm-workspace--minibuffer
@@ -457,6 +475,8 @@ This functions is modified from `display-buffer-reuse-window' and
     (cancel-timer exwm-workspace--display-echo-area-timer)
     (setq exwm-workspace--display-echo-area-timer nil)))
 
+(declare-function exwm-manage--unmanage-window "exwm-manage.el")
+
 (defun exwm-workspace--confirm-kill-emacs (prompt)
   "Confirm before exiting Emacs."
   (when (pcase (length exwm--id-buffer-alist)
@@ -611,13 +631,17 @@ This functions is modified from `display-buffer-reuse-window' and
   ;; Switch to the first workspace
   (exwm-workspace-switch 0 t))
 
+(defvar exwm-layout--fullscreen-frame-count)
+
 (defun exwm-workspace--post-init ()
   "The second stage in the initialization of the workspace module."
-  ;; Delay making the workspaces fullscreen until Emacs becomes idle
-  (run-with-idle-timer 0 nil
-                       (lambda ()
-                         (dolist (i exwm-workspace--list)
-                           (set-frame-parameter i 'fullscreen 'fullboth)))))
+  ;; Make the workspaces fullscreen.
+  (dolist (i exwm-workspace--list)
+    (set-frame-parameter i 'fullscreen 'fullboth))
+  ;; Wait until all workspace frames are resized.
+  (with-timeout (1)
+    (while (< exwm-layout--fullscreen-frame-count exwm-workspace-number)
+      (accept-process-output nil 0.1))))