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-12T10·35+0800
committerChris Feng <chris.w.feng@gmail.com>2016-07-12T10·35+0800
commit650ed0013c3fac9e88328086d1f4a029f4fb7221 (patch)
treee737fa39af0a669502fa9fd93fdc7083ea519968 /exwm.el
parent0863f4149062089abdadd0dd795ad17d0e73da03 (diff)
Add initial support for dock (panel) applications
* exwm-layout.el (exwm-layout--fullscreen-frame-count)
(exwm-layout--set-frame-fullscreen): Moved to workspace module.
* exwm-workspace.el (exwm-workspace--fullscreen-frame-count)
(exwm-workspace--set-fullscreen):
Moved from layout module.

* exwm-manage.el (exwm-manage--manage-window):
Update struts for dock applications.
* exwm-workspace.el (exwm-workspace--strut)
(exwm-workspace--strut-is-partial): New variables for storing struts.
(exwm-workspace--resize-minibuffer-frame)
(exwm-workspace--on-ConfigureNotify): Take struts into consideration.
* exwm.el (exwm--update-strut-legacy, exwm--update-strut-partial)
(exwm--update-strut): New functions for updating _NET_WM_STRUT
or _NET_WM_STRUT_PARTIAL.
(exwm--on-PropertyNotify): Update struts on corresponding event.
(exwm--init-icccm-ewmh): Declare _NET_WM_STRUT
and _NET_WM_STRUT_PARTIAL as supported.

* exwm-workspace.el (exwm-workspace--update-workareas):
Dedicated function for updating _NET_WORKAREA.
* exwm-randr.el (exwm-randr--refresh):
* exwm-workspace.el (exwm-workspace--init):
Use `exwm-workspace--update-workareas'.
* exwm.el (exwm--init-icccm-ewmh): Do not set _NET_WORKAREA here.
Diffstat (limited to 'exwm.el')
-rw-r--r--exwm.el63
1 files changed, 49 insertions, 14 deletions
diff --git a/exwm.el b/exwm.el
index 3748da2049e0..3b068786a13c 100644
--- a/exwm.el
+++ b/exwm.el
@@ -236,6 +236,46 @@
                                ;; Default to normal state
                                xcb:icccm:WM_STATE:NormalState)))))))
 
+(defun exwm--update-strut-legacy (id)
+  "Update _NET_WM_STRUT."
+  (unless exwm-workspace--strut-is-partial
+    (let ((reply (xcb:+request-unchecked+reply exwm--connection
+                     (make-instance 'xcb:ewmh:get-_NET_WM_STRUT
+                                    :window id))))
+      (setq exwm-workspace--strut (when reply (slot-value reply 'value)))
+      ;; Update workspaces.
+      (dolist (f exwm-workspace--list)
+        (exwm-workspace--set-fullscreen f))
+      ;; Resize the minibuffer frame.
+      (when (exwm-workspace--minibuffer-own-frame-p)
+        (exwm-workspace--resize-minibuffer-frame))
+      ;; Update _NET_WORKAREA.
+      (exwm-workspace--update-workareas))))
+
+(defun exwm--update-strut-partial (id)
+  "Update _NET_WM_STRUT_PARTIAL."
+  (let ((reply (xcb:+request-unchecked+reply exwm--connection
+                   (make-instance 'xcb:ewmh:get-_NET_WM_STRUT_PARTIAL
+                                  :window id))))
+    (setq exwm-workspace--strut (when reply (slot-value reply 'value)))
+    (if (not exwm-workspace--strut)
+        (setq exwm-workspace--strut-is-partial nil)
+      (setq exwm-workspace--strut (substring exwm-workspace--strut 0 4))
+      (setq exwm-workspace--strut-is-partial t))
+    ;; Update workspaces.
+    (dolist (f exwm-workspace--list)
+      (exwm-workspace--set-fullscreen f))
+    ;; Resize the minibuffer frame.
+    (when (exwm-workspace--minibuffer-own-frame-p)
+      (exwm-workspace--resize-minibuffer-frame))
+    ;; Update _NET_WORKAREA.
+    (exwm-workspace--update-workareas)))
+
+(defun exwm--update-strut (id)
+  "Update _NET_WM_STRUT_PARTIAL or _NET_WM_STRUT."
+  (exwm--update-strut-partial id)
+  (exwm--update-strut-legacy id))
+
 (defun exwm--on-PropertyNotify (data _synthetic)
   "Handle PropertyNotify event."
   (let ((obj (make-instance 'xcb:PropertyNotify))
@@ -245,7 +285,12 @@
           atom (slot-value obj 'atom)
           exwm-input--timestamp (slot-value obj 'time))
     (setq buffer (exwm--id->buffer id))
-    (when (buffer-live-p buffer)
+    (if (not (buffer-live-p buffer))
+        ;; Properties of unmanaged X windows.
+        (cond ((= atom xcb:Atom:_NET_WM_STRUT)
+               (exwm--update-strut-legacy id))
+              ((= atom xcb:Atom:_NET_WM_STRUT_PARTIAL)
+               (exwm--update-strut-partial id)))
       (with-current-buffer buffer
         (cond ((= atom xcb:Atom:_NET_WM_WINDOW_TYPE)
                (exwm--update-window-type id t))
@@ -326,7 +371,7 @@
                    (= action xcb:ewmh:_NET_WM_STATE_ADD))
           (dolist (f exwm-workspace--list)
             (when (equal (frame-parameter f 'exwm-outer-id) id)
-              (exwm-layout--set-frame-fullscreen f)
+              (exwm-workspace--set-fullscreen f)
               (xcb:+request
                   exwm--connection
                   (make-instance 'xcb:ewmh:set-_NET_WM_STATE
@@ -410,6 +455,8 @@
                                    xcb:Atom:_NET_REQUEST_FRAME_EXTENTS
                                    xcb:Atom:_NET_FRAME_EXTENTS
                                    xcb:Atom:_NET_WM_NAME
+                                   xcb:Atom:_NET_WM_STRUT
+                                   xcb:Atom:_NET_WM_STRUT_PARTIAL
                                    ;;
                                    xcb:Atom:_NET_WM_WINDOW_TYPE
                                    xcb:Atom:_NET_WM_WINDOW_TYPE_TOOLBAR
@@ -458,18 +505,6 @@
       (make-instance 'xcb:ewmh:set-_NET_DESKTOP_VIEWPORT
                      :window exwm--root
                      :data (make-vector (* 2 exwm-workspace-number) 0)))
-  ;; Set _NET_WORKAREA (with minibuffer excluded)
-  (let* ((workareas
-          (vector 0 0 (x-display-pixel-width)
-                  (- (x-display-pixel-height)
-                     (if (exwm-workspace--minibuffer-own-frame-p)
-                         0
-                       (window-pixel-height (minibuffer-window))))))
-         (workareas (mapconcat (lambda (_) workareas)
-                               (make-list exwm-workspace-number 0) [])))
-    (xcb:+request exwm--connection
-        (make-instance 'xcb:ewmh:set-_NET_WORKAREA
-                       :window exwm--root :data workareas)))
   (xcb:flush exwm--connection))
 
 (defvar exwm-init-hook nil