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

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

[elpa] externals/exwm 4255f07 64/64: On-demand update exwm-workspace--sw


From: Chris Feng
Subject: [elpa] externals/exwm 4255f07 64/64: On-demand update exwm-workspace--switch-history
Date: Thu, 17 Sep 2015 23:18:13 +0000

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

    On-demand update exwm-workspace--switch-history
    
    * exwm-workspace.el (exwm-workspace--switch-history-outdated)
      (exwm-workspace--update-switch-history, exwm-workspace-switch)
      (exwm-workspace-move-window):
    * exwm.el (exwm--update-hints, exwm--on-ClientMessage):
    * exwm-floating.el (exwm-floating--set-floating):
    * exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window):
      Update exwm-workspace--switch-history only when it's used.
---
 exwm-floating.el  |    2 +-
 exwm-manage.el    |    4 +-
 exwm-workspace.el |   75 +++++++++++++++++++++++++++++-----------------------
 exwm.el           |    4 +-
 4 files changed, 47 insertions(+), 38 deletions(-)

diff --git a/exwm-floating.el b/exwm-floating.el
index 12390b0..346f02e 100644
--- a/exwm-floating.el
+++ b/exwm-floating.el
@@ -94,7 +94,7 @@
     (let ((idx (cl-position original-frame exwm-workspace--list)))
       (when (/= idx exwm-workspace-current-index)
         (set-frame-parameter original-frame 'exwm--urgency t)
-        (exwm-workspace--update-switch-history)))
+        (setq exwm-workspace--switch-history-outdated t)))
     ;; Fix illegal parameters
     ;; FIXME: check normal hints restrictions
     (let* ((display-width (frame-pixel-width original-frame))
diff --git a/exwm-manage.el b/exwm-manage.el
index 2636c01..3e3c848 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -145,7 +145,7 @@ corresponding buffer.")
           (exwm-floating--set-floating id)
         (exwm-floating--unset-floating id))
       (exwm-input-grab-keyboard id)
-      (exwm-workspace--update-switch-history)
+      (setq exwm-workspace--switch-history-outdated t)
       (with-current-buffer (exwm--id->buffer id)
         (run-hooks 'exwm-manage-finish-hook)))))
 
@@ -161,7 +161,7 @@ corresponding buffer.")
     (xcb:flush exwm--connection)
     (when (buffer-live-p buffer)
       (with-current-buffer buffer
-        (exwm-workspace--update-switch-history)
+        (setq exwm-workspace--switch-history-outdated t)
         ;;
         (when withdraw-only
           ;; Reparent back to root
diff --git a/exwm-workspace.el b/exwm-workspace.el
index fcc42e2..a6f21b2 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -63,33 +63,39 @@
 
 (defvar exwm-workspace--switch-history nil
   "History for `read-from-minibuffer' to interactively switch workspace.")
+;;;###autoload
+(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."
-  (let ((sequence (number-sequence 0 (1- exwm-workspace-number)))
-        (not-empty (make-vector exwm-workspace-number nil)))
-    (dolist (i exwm--id-buffer-alist)
-      (with-current-buffer (cdr i)
-        (when exwm--frame
-          (setf (aref not-empty (cl-position exwm--frame exwm-workspace--list))
-                t))))
-    (setq exwm-workspace--switch-history
-          (mapcar
-           (lambda (i)
-             (mapconcat
-              (lambda (j)
-                (format (if (= i j) "[%s]" " %s ")
-                        (propertize
-                         (int-to-string j)
-                         'face
-                         (cond ((frame-parameter (elt exwm-workspace--list j)
-                                                 'exwm--urgency)
-                                '(:foreground "orange"))
-                               ((aref not-empty j) '(:foreground "green"))
-                               (t nil)))))
-              sequence ""))
-           sequence))))
+  (when exwm-workspace--switch-history-outdated
+    (setq exwm-workspace--switch-history-outdated nil)
+    (let ((sequence (number-sequence 0 (1- exwm-workspace-number)))
+          (not-empty (make-vector exwm-workspace-number nil)))
+      (dolist (i exwm--id-buffer-alist)
+        (with-current-buffer (cdr i)
+          (when exwm--frame
+            (setf (aref not-empty
+                        (cl-position exwm--frame exwm-workspace--list))
+                  t))))
+      (setq exwm-workspace--switch-history
+            (mapcar
+             (lambda (i)
+               (mapconcat
+                (lambda (j)
+                  (format (if (= i j) "[%s]" " %s ")
+                          (propertize
+                           (int-to-string j)
+                           'face
+                           (cond ((frame-parameter (elt exwm-workspace--list j)
+                                                   'exwm--urgency)
+                                  '(:foreground "orange"))
+                                 ((aref not-empty j) '(:foreground "green"))
+                                 (t nil)))))
+                sequence ""))
+             sequence)))))
 
 (defvar exwm-workspace--current nil "Current active workspace.")
 (defvar exwm-workspace-current-index 0 "Index of current active workspace.")
@@ -103,6 +109,7 @@ The optional FORCE option is for internal use only."
   (interactive
    (list
     (unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
+      (exwm-workspace--update-switch-history)
       (let* ((history-add-new-input nil) ;prevent modifying history
              (idx (read-from-minibuffer
                    "Workspace: " (elt exwm-workspace--switch-history
@@ -144,7 +151,7 @@ The optional FORCE option is for internal use only."
         ;; Update demands attention flag
         (set-frame-parameter frame 'exwm--urgency nil)
         ;; Update switch workspace history
-        (exwm-workspace--update-switch-history)
+        (setq exwm-workspace--switch-history-outdated t)
         (exwm--make-emacs-idle-for 0.1) ;FIXME
         ;; Update _NET_CURRENT_DESKTOP
         (xcb:+request exwm--connection
@@ -165,14 +172,16 @@ The optional FORCE option is for internal use only."
   "Move window ID to workspace INDEX."
   (interactive
    (list
-    (let* ((history-add-new-input nil)  ;prevent modifying history
-           (idx (read-from-minibuffer
-                 "Workspace: " (elt exwm-workspace--switch-history
-                                    exwm-workspace-current-index)
-                 exwm-workspace--switch-map nil
-                 `(exwm-workspace--switch-history
-                   . ,(1+ exwm-workspace-current-index)))))
-      (cl-position idx exwm-workspace--switch-history :test #'equal))))
+    (progn
+      (exwm-workspace--update-switch-history)
+      (let* ((history-add-new-input nil)  ;prevent modifying history
+             (idx (read-from-minibuffer
+                   "Workspace: " (elt exwm-workspace--switch-history
+                                      exwm-workspace-current-index)
+                   exwm-workspace--switch-map nil
+                   `(exwm-workspace--switch-history
+                     . ,(1+ exwm-workspace-current-index)))))
+        (cl-position idx exwm-workspace--switch-history :test #'equal)))))
   (unless id (setq id (exwm--buffer->id (window-buffer))))
   (unless (and (<= 0 index) (< index exwm-workspace-number))
     (user-error "[EXWM] Workspace index out of range: %d" index))
@@ -213,7 +222,7 @@ The optional FORCE option is for internal use only."
           (xcb:flush exwm--connection)
           (set-window-buffer (frame-selected-window frame)
                              (exwm--id->buffer id)))))
-    (exwm-workspace--update-switch-history)))
+    (setq exwm-workspace--switch-history-outdated t)))
 
 (defun exwm-workspace-switch-to-buffer ()
   "Make the current Emacs window display another buffer."
diff --git a/exwm.el b/exwm.el
index 9311af1..d2a0ecf 100644
--- a/exwm.el
+++ b/exwm.el
@@ -230,7 +230,7 @@
                      (not (eq exwm--frame exwm-workspace--current)))
             (unless (frame-parameter exwm--frame 'exwm--urgency)
               (set-frame-parameter exwm--frame 'exwm--urgency t)
-              (exwm-workspace--update-switch-history))))))))
+              (setq exwm-workspace--switch-history-outdated t))))))))
 
 ;;;###autoload
 (defun exwm--update-protocols (id &optional force)
@@ -389,7 +389,7 @@
                 (let ((idx (cl-position exwm--frame exwm-workspace--list)))
                   (unless (= idx exwm-workspace-current-index)
                     (set-frame-parameter exwm--frame 'exwm--urgency t)
-                    (exwm-workspace--update-switch-history))))
+                    (setq exwm-workspace--switch-history-outdated t))))
               ;; xcb:ewmh:_NET_WM_STATE_REMOVE?
               ;; xcb:ewmh:_NET_WM_STATE_TOGGLE?
               )



reply via email to

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