[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/exwm 8e2da00 05/19: Add helper for counting number of w
From: |
Chris Feng |
Subject: |
[elpa] externals/exwm 8e2da00 05/19: Add helper for counting number of workspaces |
Date: |
Tue, 19 Jul 2016 03:07:07 +0000 (UTC) |
branch: externals/exwm
commit 8e2da00b6e7e530a53b584184dc94b9366ae7c69
Author: Adrián Medraño Calvo <address@hidden>
Commit: Adrián Medraño Calvo <address@hidden>
Add helper for counting number of workspaces
* exwm-workspace.el (exwm-workspace--count): New function.
* exwm-randr.el (exwm-randr--refresh):
* exwm-workspace.el (exwm-workspace--switch-map)
(exwm-workspace--update-switch-history, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--init)
(exwm-workspace--post-init): Use it.
---
exwm-randr.el | 6 +++---
exwm-workspace.el | 29 +++++++++++++++++------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/exwm-randr.el b/exwm-randr.el
index 85daff2..ac3341d 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -55,11 +55,11 @@
"Normal hook run when the RandR module just refreshed.")
(defvar exwm-workspace--fullscreen-frame-count)
-(defvar exwm-workspace-number)
(defvar exwm-workspace--list)
-(declare-function exwm-workspace--update-workareas "exwm-workspace.el" ())
+(declare-function exwm-workspace--count "exwm-workspace.el")
(declare-function exwm-workspace--set-fullscreen "exwm-workspace.el" (frame))
+(declare-function exwm-workspace--update-workareas "exwm-workspace.el" ())
(declare-function exwm-workspace--set-desktop-geometry "exwm-workspace.el" ())
(defun exwm-randr--refresh ()
@@ -97,7 +97,7 @@
(when exwm-workspace--fullscreen-frame-count
;; Not all workspaces are fullscreen; reset this counter.
(setq exwm-workspace--fullscreen-frame-count 0))
- (dotimes (i exwm-workspace-number)
+ (dotimes (i (exwm-workspace--count))
(let* ((output (plist-get exwm-randr-workspace-output-plist i))
(geometry (lax-plist-get output-plist output))
(frame (elt exwm-workspace--list i)))
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 641f3f2..a3f4c2e 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -36,6 +36,10 @@
NIL if FRAME is not a workspace"
(cl-position frame exwm-workspace--list))
+(defsubst exwm-workspace--count ()
+ "Retrieve total number of workspaces."
+ (length exwm-workspace--list))
+
(defvar exwm-workspace--switch-map
(let ((map (make-sparse-keymap)))
(define-key map [t] (lambda () (interactive)))
@@ -43,13 +47,13 @@ NIL if FRAME is not a workspace"
(define-key map (int-to-string i)
`(lambda ()
(interactive)
- (when (< ,i exwm-workspace-number)
+ (when (< ,i (exwm-workspace--count))
(goto-history-element ,(1+ i))
(exit-minibuffer)))))
(define-key map "\C-a" (lambda () (interactive) (goto-history-element 1)))
(define-key map "\C-e" (lambda ()
(interactive)
- (goto-history-element exwm-workspace-number)))
+ (goto-history-element (exwm-workspace--count))))
(define-key map "\C-g" #'abort-recursive-edit)
(define-key map "\C-]" #'abort-recursive-edit)
(define-key map "\C-j" #'exit-minibuffer)
@@ -73,8 +77,9 @@ NIL if FRAME is not a workspace"
"Update the history for switching workspace to reflect the latest status."
(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)))
+ (let* ((num (exwm-workspace--count))
+ (sequence (number-sequence 0 (1- num)))
+ (not-empty (make-vector num nil)))
(dolist (i exwm--id-buffer-alist)
(with-current-buffer (cdr i)
(when exwm--frame
@@ -185,7 +190,7 @@ Value nil means to use the default position which is fixed
at bottom, while
(list (vector x y width height))))))
;; Fall back to use the screen size.
(let ((workarea (vector 0 0 root-width root-height)))
- (setq workareas (make-list exwm-workspace-number workarea))))
+ (setq workareas (make-list (exwm-workspace--count) workarea))))
;; Exclude areas occupied by struts.
(dolist (struts exwm-workspace--struts)
(setq edge (aref struts 0)
@@ -305,7 +310,7 @@ The optional FORCE option is for internal use only."
. ,(1+ exwm-workspace-current-index)))))
(cl-position idx exwm-workspace--switch-history :test #'equal)))))
(when index
- (unless (and (<= 0 index) (< index exwm-workspace-number))
+ (unless (and (<= 0 index) (< index (exwm-workspace--count)))
(user-error "[EXWM] Workspace index out of range: %d" index))
(when (or force (/= exwm-workspace-current-index index))
(let* ((frame (elt exwm-workspace--list index))
@@ -412,7 +417,7 @@ The optional FORCE option is for internal use only."
. ,(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))
+ (unless (and (<= 0 index) (< index (exwm-workspace--count)))
(user-error "[EXWM] Workspace index out of range: %d" index))
(with-current-buffer (exwm--id->buffer id)
(let ((frame (elt exwm-workspace--list index)))
@@ -827,12 +832,12 @@ applied to all subsequently created X frames."
;; Initialize workspaces with minibuffers.
(progn
(setq exwm-workspace--list (frame-list))
- (when (< 1 (length exwm-workspace--list))
+ (when (< 1 (exwm-workspace--count))
;; Exclude the initial frame.
(dolist (i exwm-workspace--list)
(unless (frame-parameter i 'window-id)
(setq exwm-workspace--list (delq i exwm-workspace--list))))
- (cl-assert (= 1 (length exwm-workspace--list)))
+ (cl-assert (= 1 (exwm-workspace--count)))
(setq exwm-workspace--client
(frame-parameter (car exwm-workspace--list) 'client))
(let ((f (car exwm-workspace--list)))
@@ -975,14 +980,14 @@ applied to all subsequently created X frames."
;; Set _NET_NUMBER_OF_DESKTOPS (it's currently fixed).
(xcb:+request exwm--connection
(make-instance 'xcb:ewmh:set-_NET_NUMBER_OF_DESKTOPS
- :window exwm--root :data exwm-workspace-number))
+ :window exwm--root :data (exwm-workspace--count)))
;; Set _NET_DESKTOP_GEOMETRY.
(exwm-workspace--set-desktop-geometry)
;; Set _NET_DESKTOP_VIEWPORT (we don't support large desktop).
(xcb:+request exwm--connection
(make-instance 'xcb:ewmh:set-_NET_DESKTOP_VIEWPORT
:window exwm--root
- :data (make-vector (* 2 exwm-workspace-number) 0)))
+ :data (make-vector (* 2 (exwm-workspace--count)) 0)))
;; Update and set _NET_WORKAREA.
(exwm-workspace--update-workareas)
;; Set _NET_VIRTUAL_ROOTS (it's currently fixed.)
@@ -1022,7 +1027,7 @@ applied to all subsequently created X frames."
(set-frame-parameter i 'fullscreen 'fullboth))
;; Wait until all workspace frames are resized.
(with-timeout (1)
- (while (< exwm-workspace--fullscreen-frame-count exwm-workspace-number)
+ (while (< exwm-workspace--fullscreen-frame-count (exwm-workspace--count))
(accept-process-output nil 0.1)))
(setq exwm-workspace--fullscreen-frame-count nil))
- [elpa] externals/exwm updated (c22f356 -> b409d87), Chris Feng, 2016/07/18
- [elpa] externals/exwm ed6a18a 04/19: Add `exwm-workspace--position' helper, Chris Feng, 2016/07/18
- [elpa] externals/exwm f4b8cc4 11/19: Support moving workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm 9018545 06/19: New function exwm-workspace--workspace-p, Chris Feng, 2016/07/18
- [elpa] externals/exwm cd1372e 03/19: Apply minibuffer in own frame configuration to created frames, Chris Feng, 2016/07/18
- [elpa] externals/exwm d0797d0 13/19: Remove `exwm-worspace-number', Chris Feng, 2016/07/18
- [elpa] externals/exwm 18fc95d 01/19: Minor cleanup, Chris Feng, 2016/07/18
- [elpa] externals/exwm 983fd46 02/19: Add missing declarations, Chris Feng, 2016/07/18
- [elpa] externals/exwm 35e1655 07/19: Move defvars to the top, Chris Feng, 2016/07/18
- [elpa] externals/exwm e491118 10/19: Support swapping workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm 8e2da00 05/19: Add helper for counting number of workspaces,
Chris Feng <=
- [elpa] externals/exwm 2de2d42 09/19: Factor out prompt for workspace, Chris Feng, 2016/07/18
- [elpa] externals/exwm b51f3e6 18/19: Mention dynamic workspace in various places, Chris Feng, 2016/07/18
- [elpa] externals/exwm 2ebeec1 17/19: Adapt dynamic workspace for RandR module, Chris Feng, 2016/07/18
- [elpa] externals/exwm 4c9afc2 16/19: Adapt dynamic workspace for floating module, Chris Feng, 2016/07/18
- [elpa] externals/exwm 622618a 15/19: Improve the handling of workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm 73d890a 14/19: Fix various minor issues, Chris Feng, 2016/07/18
- [elpa] externals/exwm 07120a0 08/19: Work with workspace frames instead of indices, Chris Feng, 2016/07/18
- [elpa] externals/exwm 0fbc725 12/19: Support adding and removing workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm b409d87 19/19: Merge branch 'medranocalvo/dynamic-workspaces' into externals/exwm, Chris Feng, 2016/07/18