about summary refs log tree commit diff
path: root/exwm.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-07-19T03·01+0800
committerChris Feng <chris.w.feng@gmail.com>2016-07-19T03·01+0800
commitb409d873b6d1372dd7ba01155f7a03fb8de6e053 (patch)
tree35fe2782e1c77ca7d5c1f5110d7dee920e143ba9 /exwm.el
parentc22f35620f0db3e86f4b0678a29dc3eee48df4d9 (diff)
parentb51f3e65f15385da70b659ef093230913429572b (diff)
Merge branch 'medranocalvo/dynamic-workspaces' into externals/exwm
Diffstat (limited to 'exwm.el')
-rw-r--r--exwm.el29
1 files changed, 20 insertions, 9 deletions
diff --git a/exwm.el b/exwm.el
index 814104a86dd2..b6bc164e54ef 100644
--- a/exwm.el
+++ b/exwm.el
@@ -28,14 +28,15 @@
 
 ;; Overview
 ;; --------
-;; EXWM (Emacs X Window Manager) is a full-featured tiling X window manager for
-;; Emacs built on top of XELB.  It features:
+;; EXWM (Emacs X Window Manager) is a full-featured tiling X window manager
+;; for Emacs built on top of [XELB](https://github.com/ch11ng/xelb).
+;; It features:
 ;; + Fully keyboard-driven operations
 ;; + Hybrid layout modes (tiling & stacking)
-;; + Workspace support
+;; + Dynamic workspace support
 ;; + ICCCM/EWMH compliance
-;; ++ (Optional) RandR (multi-monitor) support
-;; ++ (Optional) system tray
+;; + (Optional) RandR (multi-monitor) support
+;; + (Optional) Builtin system tray
 
 ;; Installation & configuration
 ;; ----------------------------
@@ -325,6 +326,17 @@
           id (slot-value obj 'window)
           data (slot-value (slot-value obj 'data) 'data32))
     (cond
+     ;; _NET_NUMBER_OF_DESKTOPS.
+     ((= type xcb:Atom:_NET_NUMBER_OF_DESKTOPS)
+      (let ((current (exwm-workspace--count))
+            (requested (elt data 0)))
+        ;; Only allow increasing/decreasing the workspace number by 1.
+        (cond
+         ((< current requested)
+          (make-frame))
+         ((and (> current requested)
+               (> current 1))
+          (delete-frame (car (last exwm-workspace--list)))))))
      ;; _NET_CURRENT_DESKTOP.
      ((= type xcb:Atom:_NET_CURRENT_DESKTOP)
       (exwm-workspace-switch (elt data 0)))
@@ -438,10 +450,9 @@
             ;; FIXME: check (may require other properties set)
             (when (memq xcb:Atom:_NET_WM_STATE_DEMANDS_ATTENTION props)
               (when (= action xcb:ewmh:_NET_WM_STATE_ADD)
-                (let ((idx (cl-position exwm--frame exwm-workspace--list)))
-                  (unless (= idx exwm-workspace-current-index)
-                    (set-frame-parameter exwm--frame 'exwm--urgency t)
-                    (setq exwm-workspace--switch-history-outdated t))))
+                (unless (eq exwm--frame exwm-workspace--current)
+                  (set-frame-parameter exwm--frame 'exwm--urgency t)
+                  (setq exwm-workspace--switch-history-outdated t)))
               ;; xcb:ewmh:_NET_WM_STATE_REMOVE?
               ;; xcb:ewmh:_NET_WM_STATE_TOGGLE?
               )