aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services/stumpwm/config-gaps
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-07-27 23:01:42 -0700
committerGravatar Tom Willemse2023-08-29 22:26:42 -0700
commit1cb472dd975a5b69a94f50569c7bdec7256ed0eb (patch)
treebc48ba5a2fb7494e18814c646e675ad61f37c2f7 /oni/home/services/stumpwm/config-gaps
parenta6be36fcbb7a136d3e09a90a7cf55c82cafa9c98 (diff)
downloadnew-dotfiles-1cb472dd975a5b69a94f50569c7bdec7256ed0eb.tar.gz
new-dotfiles-1cb472dd975a5b69a94f50569c7bdec7256ed0eb.zip
Split stumpwm-gaps configuration into separate service
Diffstat (limited to 'oni/home/services/stumpwm/config-gaps')
-rw-r--r--oni/home/services/stumpwm/config-gaps68
1 files changed, 68 insertions, 0 deletions
diff --git a/oni/home/services/stumpwm/config-gaps b/oni/home/services/stumpwm/config-gaps
new file mode 100644
index 0000000..fa865d6
--- /dev/null
+++ b/oni/home/services/stumpwm/config-gaps
@@ -0,0 +1,68 @@
+;; -*- mode: lisp; -*-
+(in-package :stumpwm-user)
+
+(require 'swm-gaps)
+
+;;; Redefine this function again because for some reason on my system
+;;; `(frame-width ...)' returns a ratio, not an integer, which is not accepted
+;;; by `xlib:drawable-width'.
+(defun stumpwm::maximize-window (win)
+ "Redefined gaps aware maximize function."
+ (multiple-value-bind (x y wx wy width height border stick)
+ (stumpwm::geometry-hints win)
+
+ (let ((ox 0) (oy 0) (ow 0) (oh 0)
+ (frame (stumpwm::window-frame win)))
+ (if (swm-gaps::apply-gaps-p win)
+ (multiple-value-setq (ox oy ow oh) (swm-gaps::gaps-offsets win)))
+
+ ;; Only do width or height subtraction if result will be positive,
+ ;; otherwise stumpwm will crash. Also, only modify window dimensions
+ ;; if needed (i.e. window at least fills frame minus gap).
+ (when (and (< ow width)
+ (>= width (- (frame-width frame) ow)))
+ (setf width (- width ow)))
+ (when (and (< oh height)
+ (>= height (- (frame-height frame) oh)))
+ (setf height (- height oh)))
+
+ (setf x (+ x ox)
+ y (+ y oy))
+
+ ;; This is the only place a window's geometry should change
+ (set-window-geometry win :x wx :y wy :width width :height height :border-width 0)
+ (xlib:with-state ((window-parent win))
+ ;; FIXME: updating the border doesn't need to be run everytime
+ ;; the window is maximized, but only when the border style or
+ ;; window type changes. The overhead is probably minimal,
+ ;; though.
+ (setf (xlib:drawable-x (window-parent win)) x
+ (xlib:drawable-y (window-parent win)) y
+ (xlib:drawable-border-width (window-parent win)) border)
+ ;; the parent window should stick to the size of the window
+ ;; unless it isn't being maximized to fill the frame.
+ (if (or stick
+ (find *window-border-style* '(:tight :none)))
+ (setf (xlib:drawable-width (window-parent win)) (window-width win)
+ (xlib:drawable-height (window-parent win)) (window-height win))
+ (let ((frame (stumpwm::window-frame win)))
+ (setf (xlib:drawable-width (window-parent win)) (- (round (frame-width frame))
+ (* 2 (xlib:drawable-border-width (window-parent win)))
+ ow)
+ (xlib:drawable-height (window-parent win)) (- (stumpwm::frame-display-height (window-group win) frame)
+ (* 2 (xlib:drawable-border-width (window-parent win)))
+ oh))))
+ ;; update the "extents"
+ (xlib:change-property (window-xwin win) :_NET_FRAME_EXTENTS
+ (list wx
+ (- (xlib:drawable-width (window-parent win)) width wx)
+ wy
+ (- (xlib:drawable-height (window-parent win)) height wy))
+ :cardinal 32))
+ (update-configuration win))))
+
+(setf swm-gaps:*head-gaps-size* 0)
+(setf swm-gaps:*inner-gaps-size* 15)
+(setf swm-gaps:*outer-gaps-size* 15)
+
+(swm-gaps:toggle-gaps-on)