about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFran Ley <fran.ley@mailfence.com>2023-03-07T00·46-0800
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2023-06-09T00·00+0000
commit4970d6ad4ef7c9cff92cbfb90a9ec379a61cd5e7 (patch)
treedd1051a727510ed89f8265f155a25e2627a8a60d
parentb62d5e79b0c1799f2cd941b4cec5bf8492cb322c (diff)
More selectively ignore top and bottom struts
For the case of vertical columns of workareas, top and bottom struts
should only apply to workareas containing the respective edge of the
strut offset.

To simplify, imagine three monitors arranged vertically and one
workarea per display:

  +-------+
  |   1   | 2000x1000 px
  +-------+
  |   2   | 2000x1000 px
  +-------+
  |   3   | 2000x1000 px
  +-------+

In sexp form: ((0 0 2000 1000) (0 1000 2000 1000) (0 2000 2000 1000))
where each element represents a workarea as x, y, width, height

And example struts of the form (offset-type offset (x-start x-end))
a.) (top 42 (0 2000))
b.) (top 1042 (0 2000))
c.) (top 2042 (0 2000))
d.) (bottom 42 (0 2000))
e.) (bottom 1042 (0 2000))
f.) (bottom 2042 (0 2000))

Workareas adjusted for struts before this change:
a.) ((0 42 2000 958) (0 1000 2000 1000) (0 2000 2000 1000))
b.) ((0 1042 2000 -42) (0 1042 2000 958) (0 2000 2000 1000))
c.) ((0 2042 2000 -1042) (0 2042 2000 -42) (0 2042 2000 958))
d.) ((0 0 2000 1000) (0 1000 2000 1000) (0 2000 2000 902))
e.) ((0 0 2000 1000) (0 1000 2000 902) (0 2000 2000 -98))
f.) ((0 0 2000 902) (0 1000 2000 -98) (0 2000 2000 -1098))

Note that a. and d. are sensible, while b., c., e., and f. are quite
user unfriendly.

After this change, the same adjusted workareas are:
a.) no change
b.) ((0 0 2000 1000) (0 1042 2000 958) (0 2000 2000 1000))
c.) ((0 0 2000 1000) (0 1000 2000 1000) (0 2042 2000 958))
d.) no change
e.) ((0 0 2000 1000) (0 1000 2000 902) (0 2000 2000 1000))
f.) ((0 0 2000 902) (0 1000 2000 1000) (0 2000 2000 1000))

The intent is to allow dock type windows such as typical status bars
to occupy space in a workarea on any of a set of vertically arranged
displays without occluding the other workareas due to the limitations
of the X spec regarding strut offsets.

Note that this behaviour conflicts with EWMH 1.3:

> Struts MUST be specified in root window coordinates, that is,
they are *not* relative to the edges of any view port or Xinerama
monitor.

but is accepted by multiple WMs.  See:

- https://blog.martin-graesslin.com/blog/2016/08/panels-on-shared-screen-edges/
- https://mail.gnome.org/archives/wm-spec-list/2009-November/msg00005.html
- https://gitlab.freedesktop.org/xdg/xdg-specs/-/merge_requests/22

* exwm-workspace.el (exwm-workspace--update-workareas): Assume
vertical struts apply from the monitor boundary when they cross
them.

Copyright-paperwork-exempt: yes
-rw-r--r--exwm-workspace.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 06217a7769..1f60e80c63 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -377,7 +377,9 @@ NIL if FRAME is not a workspace"
                       (or (not position)
                           (< (max (aref position 0) (aref w 0))
                              (min (aref position 1)
-                                  (+ (aref w 0) (aref w 2))))))
+                                  (+ (aref w 0) (aref w 2)))))
+                      (< width (+ (aref w 1) (aref w 3)))
+                      (> width (aref w 1)))
              (cl-incf (aref w 3) delta)
              (setf (aref w 1) width)))
           (`bottom
@@ -386,7 +388,10 @@ NIL if FRAME is not a workspace"
                       (or (not position)
                           (< (max (aref position 0) (aref w 0))
                              (min (aref position 1)
-                                  (+ (aref w 0) (aref w 2))))))
+                                  (+ (aref w 0) (aref w 2)))))
+                      (< (- root-height width)
+                         (+ (aref w 1) (aref w 3)))
+                      (> (- root-height width) (aref w 1)))
              (cl-incf (aref w 3) delta))))))
     ;; Save the result.
     (setq exwm-workspace--workareas workareas)