Floating windows by default (pinentry, ...); pointer warp; clear other tags on main tag switch
This commit is contained in:
37
main.janet
37
main.janet
@@ -141,7 +141,7 @@
|
||||
(defn handle-event [event]
|
||||
(match event
|
||||
[: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))
|
||||
[:app-id app-id] (put window :app-id app-id)
|
||||
[:parent parent] (put window :parent (if parent (:get-user-data parent)))
|
||||
@@ -229,6 +229,10 @@
|
||||
(put seat :focused nil))
|
||||
: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]
|
||||
(when (window :new)
|
||||
(:use-ssd (window :obj))
|
||||
@@ -239,11 +243,12 @@
|
||||
(:propose-dimensions (window :obj) 0 0))
|
||||
(do
|
||||
(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))
|
||||
(each seat (wm :seats) (seat/focus seat window))))
|
||||
(when-let [rule ((config :appid-rules) (window :app-id))]
|
||||
(rule window)))
|
||||
(rule window))
|
||||
(callback :new-window window))
|
||||
|
||||
(match (window :fullscreen-requested)
|
||||
[:enter] (window/enter-fullscreen window)
|
||||
@@ -333,10 +338,12 @@
|
||||
(layout/main (length windows) W H))
|
||||
|
||||
(each window (filter |($ :float) (output/windows output))
|
||||
(let [t (+ Y (/ H 4))
|
||||
l (+ X (/ W 4))
|
||||
h (/ H 2)
|
||||
w (/ W 2)]
|
||||
(callback :layout-floating window)
|
||||
(let [[min-w max-w min-h max-h] (or (window :dimensions-bounds) [(/ W 2) (/ W 2) (/ H 2) (/ H 2)])
|
||||
h (if (< 10 min-h) min-h (/ H 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/propose-dimensions window w h)
|
||||
(:place-top (window :node)))))
|
||||
@@ -344,7 +351,8 @@
|
||||
(defn output/set-main-tag [output tag]
|
||||
(map |(when (= ($ :tag-main) tag) (put $ :tag-main nil)) (wm :outputs))
|
||||
(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]
|
||||
(if (has-value? (output :tags-other) tag)
|
||||
@@ -482,7 +490,8 @@
|
||||
outputs (wm :outputs)
|
||||
new-output (action/target-in current-output outputs dir)]
|
||||
(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]
|
||||
(def f (cond
|
||||
@@ -618,12 +627,14 @@
|
||||
|
||||
|
||||
(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)
|
||||
"vesktop" (rule/tag :d)
|
||||
"io.github.alainm23.planify" (rule/tag :j)
|
||||
"floating-terminal" (rule/pulldown)
|
||||
"floating-repl" (rule/pulldown)})
|
||||
"floating-repl" (rule/pulldown)
|
||||
"steam" (rule/float false)})
|
||||
|
||||
|
||||
(defn startup []
|
||||
@@ -636,14 +647,10 @@
|
||||
(spawn "io.github.alainm23.planify"))
|
||||
|
||||
# TODO: layout flexibility
|
||||
# TODO: fix waybar complaining about <
|
||||
# TODO: fullscreen oddities with games: debug (warframe, novadrift, portal)
|
||||
# TODO: firefox focus weirdness
|
||||
# TODO: double fullscreen
|
||||
# TODO: floating windows (WF launcher, discord launch screen, pinentry, ...)
|
||||
# TODO: swaylock hibernate acquire
|
||||
# TODO: actually do idle lock
|
||||
# TODO: mouse warp on switch output
|
||||
# TODO: swaylock hibernate acquire outputs
|
||||
|
||||
(defn configure-keymap []
|
||||
(def ctx (xkbcommon/context/new))
|
||||
|
||||
Reference in New Issue
Block a user