Compare commits

..

2 Commits

Author SHA1 Message Date
bluepython508
6ec59c3be2 Floating windows by default (pinentry, ...); pointer warp; clear other tags on main tag switch 2026-02-19 09:08:14 +00:00
bluepython508
7c6abcaddb Change formatting for status display: <t 2026-02-16 22:05:57 +00:00

View File

@@ -141,7 +141,7 @@
(defn handle-event [event] (defn handle-event [event]
(match event (match event
[:closed] (put window :closed true) [:closed] (put window :closed true)
[:dimensions-hint min-w min-h max-w max-h] (put window :dimensions-bounds {:min-w min-w :max-w max-w :min-h min-h :max-h max-h}) [:dimensions-hint min-w min-h max-w max-h] (put window :dimensions-bounds [min-w max-w min-h max-h])
[:dimensions w h] (do (put window :w w) (put window :h h)) [:dimensions w h] (do (put window :w w) (put window :h h))
[:app-id app-id] (put window :app-id app-id) [:app-id app-id] (put window :app-id app-id)
[:parent parent] (put window :parent (if parent (:get-user-data parent))) [:parent parent] (put window :parent (if parent (:get-user-data parent)))
@@ -229,6 +229,10 @@
(put seat :focused nil)) (put seat :focused nil))
:none (focus-non-layer))) :none (focus-non-layer)))
(defn window/should-float [window]
(let [[min-w max-w min-h max-h] (or (window :dimensions-bounds) [0 1 0 1])]
(and (= min-w max-w) (= min-h max-h) (< 0 min-w) (< 0 min-h))))
(defn window/manage [window] (defn window/manage [window]
(when (window :new) (when (window :new)
(:use-ssd (window :obj)) (:use-ssd (window :obj))
@@ -239,11 +243,12 @@
(:propose-dimensions (window :obj) 0 0)) (:propose-dimensions (window :obj) 0 0))
(do (do
(def seat (first (wm :seats))) (def seat (first (wm :seats)))
(window/set-float window false) (window/set-float window (window/should-float window))
(window/move-output window (seat :focused-output)) (window/move-output window (seat :focused-output))
(each seat (wm :seats) (seat/focus seat window)))) (each seat (wm :seats) (seat/focus seat window))))
(when-let [rule ((config :appid-rules) (window :app-id))] (when-let [rule ((config :appid-rules) (window :app-id))]
(rule window))) (rule window))
(callback :new-window window))
(match (window :fullscreen-requested) (match (window :fullscreen-requested)
[:enter] (window/enter-fullscreen window) [:enter] (window/enter-fullscreen window)
@@ -333,10 +338,12 @@
(layout/main (length windows) W H)) (layout/main (length windows) W H))
(each window (filter |($ :float) (output/windows output)) (each window (filter |($ :float) (output/windows output))
(let [t (+ Y (/ H 4)) (callback :layout-floating window)
l (+ X (/ W 4)) (let [[min-w max-w min-h max-h] (or (window :dimensions-bounds) [(/ W 2) (/ W 2) (/ H 2) (/ H 2)])
h (/ H 2) h (if (< 10 min-h) min-h (/ H 2))
w (/ W 2)] w (if (< 10 min-w) min-w (/ W 2))
t (+ Y (/ H 2) (- (math/trunc (/ h 2))))
l (+ X (/ W 2) (- (math/trunc (/ w 2))))]
(window/set-position window l t) (window/set-position window l t)
(window/propose-dimensions window w h) (window/propose-dimensions window w h)
(:place-top (window :node))))) (:place-top (window :node)))))
@@ -344,7 +351,8 @@
(defn output/set-main-tag [output tag] (defn output/set-main-tag [output tag]
(map |(when (= ($ :tag-main) tag) (put $ :tag-main nil)) (wm :outputs)) (map |(when (= ($ :tag-main) tag) (put $ :tag-main nil)) (wm :outputs))
(put output :tag-main tag) (put output :tag-main tag)
(put output :tag-offload nil)) (put output :tag-offload nil)
(put output :tags-other nil))
(defn output/toggle-other-tag [output tag] (defn output/toggle-other-tag [output tag]
(if (has-value? (output :tags-other) tag) (if (has-value? (output :tags-other) tag)
@@ -442,11 +450,10 @@
(defn status-display [output] (defn status-display [output]
(def output (find |(= (get-in $ [:wl-output :name]) output) (wm :outputs))) (def output (find |(= (get-in $ [:wl-output :name]) output) (wm :outputs)))
(string (string
":" (output :tag-main) ":"
(case (output :tag-offload) (if (= (output :tag-offload) :comma) "<" "")
:comma "<" (output :tag-main)
:period ">" (if (= (output :tag-offload) :period) ">" "")
"")
" " " "
(string/join (map |(string ":" $) (filter keyword? (output :tags-other)))))) (string/join (map |(string ":" $) (filter keyword? (output :tags-other))))))
@@ -483,7 +490,8 @@
outputs (wm :outputs) outputs (wm :outputs)
new-output (action/target-in current-output outputs dir)] new-output (action/target-in current-output outputs dir)]
(seat/focus-output seat new-output) (seat/focus-output seat new-output)
(seat/focus seat (first (output/windows new-output)))))) (seat/focus seat (first (output/windows new-output)))
(:pointer-warp (seat :obj) (+ (new-output :x) (/ (new-output :w) 2)) (+ (new-output :y) (/ (new-output :h) 2))))))
(defn action/goto-tag [tag] (defn action/goto-tag [tag]
(def f (cond (def f (cond
@@ -619,12 +627,14 @@
(defn rule/tag [tag] (fn [window] (put window :tag tag))) (defn rule/tag [tag] (fn [window] (put window :tag tag)))
(defn rule/float [float] (fn [window] (put window :float float)))
(put config :appid-rules @{"thunderbird" (rule/tag :m) (put config :appid-rules @{"thunderbird" (rule/tag :m)
"vesktop" (rule/tag :d) "vesktop" (rule/tag :d)
"io.github.alainm23.planify" (rule/tag :j) "io.github.alainm23.planify" (rule/tag :j)
"floating-terminal" (rule/pulldown) "floating-terminal" (rule/pulldown)
"floating-repl" (rule/pulldown)}) "floating-repl" (rule/pulldown)
"steam" (rule/float false)})
(defn startup [] (defn startup []
@@ -637,14 +647,10 @@
(spawn "io.github.alainm23.planify")) (spawn "io.github.alainm23.planify"))
# TODO: layout flexibility # TODO: layout flexibility
# TODO: fix waybar complaining about <
# TODO: fullscreen oddities with games: debug (warframe, novadrift, portal) # TODO: fullscreen oddities with games: debug (warframe, novadrift, portal)
# TODO: firefox focus weirdness # TODO: firefox focus weirdness
# TODO: double fullscreen # TODO: double fullscreen
# TODO: floating windows (WF launcher, discord launch screen, pinentry, ...) # TODO: swaylock hibernate acquire outputs
# TODO: swaylock hibernate acquire
# TODO: actually do idle lock
# TODO: mouse warp on switch output
(defn configure-keymap [] (defn configure-keymap []
(def ctx (xkbcommon/context/new)) (def ctx (xkbcommon/context/new))