emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/exwm e8bc512 2/2: Fix workspace switch issues


From: Chris Feng
Subject: [elpa] externals/exwm e8bc512 2/2: Fix workspace switch issues
Date: Sun, 25 Oct 2015 06:58:51 +0000

branch: externals/exwm
commit e8bc51280dba18dc394e15dd544e70ad27176f82
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Fix workspace switch issues
    
    * exwm-core.el (exwm--make-emacs-idle-for): Removed.
    * exwm-workspace.el (exwm-workspace--switch-count): New variable.
      (exwm-workspace-switch): Increase exwm-workspace--switch-count when
      necessary; Remove the call to exwm--make-emacs-idle-for.
      (exwm-workspace--on-focus-in): Consume exwm-workspace--switch-count.
    
    * exwm-workspace.el (exwm-workspace--on-focus-in): Close active minibuffer.
---
 exwm-core.el      |    4 ----
 exwm-workspace.el |   12 ++++++++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/exwm-core.el b/exwm-core.el
index 1ac8678..ec70347 100644
--- a/exwm-core.el
+++ b/exwm-core.el
@@ -38,10 +38,6 @@
   (when exwm-debug-on
     `(message (concat "[EXWM] " ,format-string) ,@args)))
 
-(defun exwm--make-emacs-idle-for (seconds)
-  "Put Emacs in idle state for SECONDS seconds."
-  (with-timeout (seconds) (read-event)))
-
 (defvar exwm--connection nil "X connection.")
 (defvar exwm--root nil "Root window.")
 (defvar exwm--id-buffer-alist nil "Alist of (<X window ID> . <Emacs buffer>).")
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 0813c89..641ba7e 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -100,6 +100,10 @@
 (defvar exwm-workspace-current-index 0 "Index of current active workspace.")
 (defvar exwm-workspace-show-all-buffers nil
   "Non-nil to show buffers on other workspaces.")
+(defvar exwm-workspace--switch-count 0
+  "`exwm-workspace-switch' execution counts.
+
+Consumed by `exwm-workspace--on-focus-in.'")
 
 ;;;###autoload
 (defun exwm-workspace-switch (index &optional force)
@@ -125,6 +129,7 @@ The optional FORCE option is for internal use only."
       (let ((frame (elt exwm-workspace--list index)))
         (setq exwm-workspace--current frame
               exwm-workspace-current-index index)
+        (unless force (cl-incf exwm-workspace--switch-count))
         (select-frame-set-input-focus frame)
         ;; Move mouse when necessary
         (let ((position (mouse-pixel-position))
@@ -154,7 +159,6 @@ The optional FORCE option is for internal use only."
         (set-frame-parameter frame 'exwm--urgency nil)
         ;; Update switch workspace history
         (setq exwm-workspace--switch-history-outdated t)
-        (exwm--make-emacs-idle-for 0.1) ;FIXME
         ;; Update _NET_CURRENT_DESKTOP
         (xcb:+request exwm--connection
             (make-instance 'xcb:ewmh:set-_NET_CURRENT_DESKTOP
@@ -165,9 +169,13 @@ The optional FORCE option is for internal use only."
   "Fix unexpected frame switch."
   (let ((index (cl-position (selected-frame) exwm-workspace--list)))
     (exwm--log "Focus on workspace %s" index)
+    ;; Close the (possible) active minibuffer
+    (when (active-minibuffer-window) (abort-recursive-edit))
     (when (and index (/= index exwm-workspace-current-index))
       (exwm--log "Workspace was switched unexpectedly")
-      (exwm-workspace-switch index))))
+      (if (< 0 exwm-workspace--switch-count)
+          (cl-decf exwm-workspace--switch-count)
+        (exwm-workspace-switch index)))))
 
 ;;;###autoload
 (defun exwm-workspace-move-window (index &optional id)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]