about summary refs log tree commit diff
path: root/exwm-workspace.el
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2016-07-17T12·00+0000
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2016-07-17T12·00+0000
commited6a18a697bc1eb8bf09a12c04ffa3200a5248cd (patch)
tree167924fdc0c66b19afc068288b2289eb7ccc1098 /exwm-workspace.el
parentcd1372eaec2521ea163c505b38d36b1f787d1944 (diff)
Add `exwm-workspace--position' helper
	* exwm-workspace.el (exwm-workspace--position): New function.
	* exwm-layout.el (exwm-layout--refresh):
	* exwm-input.el (exwm-input--on-ButtonPress):
	* exwm-workspace.el (exwm-workspace--update-switch-history):
	* exwm.el (exwm--on-ClientMessage, exwm-workspace--init): Use it.
Diffstat (limited to 'exwm-workspace.el')
-rw-r--r--exwm-workspace.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index b2138aa138..641f3f2f22 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -29,6 +29,13 @@
 
 (defvar exwm-workspace-number 4 "Number of workspaces (1 ~ 10).")
 (defvar exwm-workspace--list nil "List of all workspaces (Emacs frames).")
+
+(defsubst exwm-workspace--position (frame)
+  "Retrieve index of given FRAME in workspace list.
+
+NIL if FRAME is not a workspace"
+  (cl-position frame exwm-workspace--list))
+
 (defvar exwm-workspace--switch-map
   (let ((map (make-sparse-keymap)))
     (define-key map [t] (lambda () (interactive)))
@@ -72,7 +79,7 @@
         (with-current-buffer (cdr i)
           (when exwm--frame
             (setf (aref not-empty
-                        (cl-position exwm--frame exwm-workspace--list))
+                        (exwm-workspace--position exwm--frame))
                   t))))
       (setq exwm-workspace--switch-history
             (mapcar
@@ -948,13 +955,13 @@ applied to all subsequently created X frames."
                           :window workspace
                           :data
                           (format "EXWM workspace %d"
-                                  (cl-position i exwm-workspace--list))))
+                                  (exwm-workspace--position i))))
        (xcb:+request exwm--connection
            (make-instance 'xcb:ewmh:set-_NET_WM_NAME
                           :window container
                           :data
                           (format "EXWM workspace %d frame container"
-                                  (cl-position i exwm-workspace--list)))))
+                                  (exwm-workspace--position i)))))
       (xcb:+request exwm--connection
           (make-instance 'xcb:ReparentWindow
                          :window outer-id :parent container :x 0 :y 0))