2022-07-12 23:06:16 +00:00
|
|
|
;; -*- mode: Fennel;
|
|
|
|
|
2022-05-05 22:38:39 +00:00
|
|
|
(local { : view } (require :fennel))
|
|
|
|
|
2022-07-03 10:16:37 +00:00
|
|
|
(local texture (require :texture))
|
2022-07-03 13:03:35 +00:00
|
|
|
(local matrix (require :matrix))
|
2022-07-01 21:28:41 +00:00
|
|
|
(local socket-repl (require :socket-repl))
|
2022-05-05 22:38:39 +00:00
|
|
|
|
2022-07-03 22:36:17 +00:00
|
|
|
(local app-state
|
|
|
|
{
|
|
|
|
:in-overview false
|
|
|
|
:focus-view nil
|
|
|
|
:views []
|
|
|
|
})
|
|
|
|
|
2022-07-01 21:28:41 +00:00
|
|
|
(let [repl-socket-name
|
|
|
|
(..
|
|
|
|
(: (os.getenv "XDG_RUNTIME_DIR") :gsub "/$" "")
|
|
|
|
"/kiwmi-repl."
|
|
|
|
(os.getenv "WAYLAND_DISPLAY")
|
|
|
|
".socket"
|
|
|
|
)]
|
|
|
|
(socket-repl.start repl-socket-name))
|
2022-05-08 21:38:44 +00:00
|
|
|
|
2022-07-01 22:09:00 +00:00
|
|
|
(fn resize-wayland-backend [output]
|
|
|
|
(when (string.find (output:name) "^WL-")
|
|
|
|
(output:set_mode 360 720 0)))
|
2022-05-08 21:38:44 +00:00
|
|
|
|
2022-07-03 14:36:48 +00:00
|
|
|
(fn kill-window []
|
|
|
|
(print "DIE")
|
|
|
|
true)
|
|
|
|
|
|
|
|
(fn launch []
|
|
|
|
(print "WHOOSH")
|
|
|
|
true)
|
|
|
|
|
2022-07-03 22:36:17 +00:00
|
|
|
(fn show-overview []
|
|
|
|
(let [facets 64
|
|
|
|
angle (/ (* 2 math.pi) facets)
|
|
|
|
scale 0.6
|
|
|
|
y-offset (+ (* 1 680)
|
|
|
|
(/ (* 360 facets) (* 2 math.pi)))
|
|
|
|
]
|
|
|
|
(each [i view (ipairs app-state.views)]
|
|
|
|
(doto view
|
|
|
|
(: :set_matrix
|
|
|
|
(-> matrix.identity
|
|
|
|
(matrix.scale scale scale)
|
|
|
|
(matrix.translate (* 2 180) (+ y-offset))
|
|
|
|
(matrix.rotate (/ (* (- i 2
|
|
|
|
) angle) 1))
|
|
|
|
(matrix.translate (* -2 180) (- y-offset))
|
|
|
|
(matrix.translate 120 150)
|
|
|
|
))
|
|
|
|
(: :show)))))
|
|
|
|
|
|
|
|
|
|
|
|
(fn hide-overview []
|
|
|
|
(each [k view (pairs app-state.views)]
|
|
|
|
(view:set_matrix matrix.identity)
|
|
|
|
(if (= (view:id) (app-state.focus-view:id))
|
|
|
|
(doto view
|
|
|
|
(: :show)
|
|
|
|
(: :focus))
|
|
|
|
(view:hide))))
|
|
|
|
|
2022-07-03 14:36:48 +00:00
|
|
|
(fn carousel []
|
2022-07-03 22:36:17 +00:00
|
|
|
(let [was app-state.in-overview]
|
|
|
|
(if was
|
|
|
|
(hide-overview)
|
|
|
|
(show-overview))
|
|
|
|
(: (kiwmi:active_output) :redraw)
|
|
|
|
(tset app-state :in-overview (not was))))
|
2022-07-03 14:36:48 +00:00
|
|
|
|
|
|
|
(fn placements [output]
|
|
|
|
(let [(width height) (output:size)
|
|
|
|
bar-height (/ height 15)]
|
|
|
|
{
|
|
|
|
|
|
|
|
:application {
|
|
|
|
:x 0
|
|
|
|
:y 0
|
|
|
|
:w width
|
|
|
|
:h (- height (* bar-height 1.1))
|
|
|
|
}
|
|
|
|
:bar {
|
|
|
|
:x 0
|
|
|
|
:y (- height (* bar-height 1.1))
|
|
|
|
:w width
|
|
|
|
:h (* bar-height 1.1)
|
|
|
|
}
|
|
|
|
:kill {
|
|
|
|
:x (- (* width 0.25) (/ bar-height 2))
|
|
|
|
:y (- height bar-height)
|
|
|
|
:w bar-height
|
|
|
|
:h bar-height
|
|
|
|
:on-press kill-window
|
|
|
|
}
|
|
|
|
:launch {
|
|
|
|
:x (- (* width 0.5) (/ bar-height 2))
|
|
|
|
:y (- height bar-height)
|
|
|
|
:w bar-height
|
|
|
|
:h bar-height
|
|
|
|
:on-press launch
|
|
|
|
}
|
|
|
|
:overview {
|
|
|
|
:x (- (* width 0.75) (/ bar-height 2))
|
|
|
|
:y (- height bar-height)
|
|
|
|
:w bar-height
|
|
|
|
:h bar-height
|
|
|
|
:on-press carousel
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
|
2022-07-07 11:17:46 +00:00
|
|
|
(fn choose-view-at [x y]
|
|
|
|
(let [view (kiwmi:view_at x y)]
|
|
|
|
(tset app-state :focus-view view)
|
|
|
|
(tset app-state :in-overview false)
|
|
|
|
(hide-overview)
|
|
|
|
true))
|
|
|
|
|
|
|
|
(let [cursor (kiwmi:cursor)]
|
|
|
|
(cursor:on "button_up"
|
|
|
|
(fn [button-id]
|
|
|
|
(when app-state.in-overview
|
|
|
|
(let [geom (placements (kiwmi:active_output))
|
|
|
|
(x y) (cursor:pos)]
|
|
|
|
(if (< y geom.application.h)
|
|
|
|
(choose-view-at x y)
|
|
|
|
false))))))
|
|
|
|
|
2022-05-05 22:38:39 +00:00
|
|
|
(kiwmi:on
|
|
|
|
"output"
|
|
|
|
(fn [output]
|
2022-07-03 13:57:57 +00:00
|
|
|
(resize-wayland-backend output)
|
|
|
|
(let [(width height) (output:size)
|
2022-07-01 22:08:15 +00:00
|
|
|
r (output:renderer)
|
2022-07-03 10:16:37 +00:00
|
|
|
kill (texture.from-file r "close-window.png")
|
|
|
|
launch (texture.from-file r "launcher.png")
|
2022-07-03 22:17:39 +00:00
|
|
|
overview (texture.from-file r "carousel.png")]
|
2022-05-05 22:38:39 +00:00
|
|
|
(output:on "render"
|
|
|
|
(fn [{: output : renderer}]
|
2022-07-03 14:36:48 +00:00
|
|
|
(let [buttons (placements output)]
|
|
|
|
(renderer:draw_rect :#77000077
|
|
|
|
buttons.bar.x buttons.bar.y
|
|
|
|
buttons.bar.w buttons.bar.h)
|
2022-05-08 21:38:44 +00:00
|
|
|
(renderer:draw_texture
|
|
|
|
kill
|
2022-07-03 13:03:35 +00:00
|
|
|
matrix.identity
|
2022-07-03 14:36:48 +00:00
|
|
|
buttons.kill.x buttons.kill.y
|
2022-05-08 21:38:44 +00:00
|
|
|
0.7)
|
|
|
|
(renderer:draw_texture
|
2022-07-03 13:03:35 +00:00
|
|
|
launch
|
|
|
|
matrix.identity
|
2022-07-03 14:36:48 +00:00
|
|
|
buttons.launch.x buttons.launch.y
|
2022-05-08 21:38:44 +00:00
|
|
|
0.7)
|
|
|
|
(renderer:draw_texture
|
2022-07-03 22:17:39 +00:00
|
|
|
overview
|
2022-07-03 13:03:35 +00:00
|
|
|
matrix.identity
|
2022-07-03 14:36:48 +00:00
|
|
|
buttons.overview.x buttons.overview.y
|
2022-05-08 21:38:44 +00:00
|
|
|
0.7)))))))
|
|
|
|
|
2022-05-08 21:48:44 +00:00
|
|
|
|
|
|
|
(let [cursor (kiwmi:cursor)]
|
|
|
|
(cursor:on "button_down"
|
|
|
|
(fn [button]
|
|
|
|
(let [(x y) (cursor:pos)]
|
2022-07-03 14:36:48 +00:00
|
|
|
(each [name attribs (pairs (placements (kiwmi:active_output)))]
|
|
|
|
(if (and
|
|
|
|
(<= attribs.x x)
|
|
|
|
(< x (+ attribs.x attribs.w))
|
|
|
|
(<= attribs.y y)
|
|
|
|
(< y (+ attribs.y attribs.h)))
|
|
|
|
(if attribs.on-press (attribs.on-press))))))))
|
2022-05-05 22:38:39 +00:00
|
|
|
|
2022-04-26 21:13:51 +00:00
|
|
|
(kiwmi:on "view"
|
|
|
|
(fn [view]
|
2022-07-03 14:36:48 +00:00
|
|
|
(let [geom (placements (kiwmi:active_output))]
|
|
|
|
(view:resize geom.application.w geom.application.h)
|
|
|
|
(view:move geom.application.x geom.application.y))
|
2022-04-26 21:13:51 +00:00
|
|
|
(view:focus)
|
|
|
|
(view:show)
|
2022-07-03 22:36:17 +00:00
|
|
|
(tset app-state :focus-view view)
|
|
|
|
(table.insert app-state.views view)
|
2022-04-26 21:13:51 +00:00
|
|
|
(view:on "request_move" #(view:imove))
|
|
|
|
(view:on "request_resize" (fn [ev] (view:iresize ev.edges)))))
|
2022-04-26 20:14:46 +00:00
|
|
|
|
2022-04-26 21:13:37 +00:00
|
|
|
|
|
|
|
;(kiwmi:spawn "swaybg -c '#ff00ff'")
|
|
|
|
(kiwmi:spawn "lua -l fennelrun modeline.fnl")
|
2022-04-26 22:01:30 +00:00
|
|
|
(kiwmi:spawn "lua -l fennelrun saturn/main.fnl")
|
2022-04-27 09:07:33 +00:00
|
|
|
(kiwmi:spawn "lua -l fennelrun crier/crier.fnl")
|
2022-04-27 12:26:54 +00:00
|
|
|
(kiwmi:spawn "lua -l fennelrun just/just.fnl")
|
2022-04-27 09:07:33 +00:00
|
|
|
;(kiwmi:spawn "foot")
|
2022-07-12 23:06:16 +00:00
|
|
|
|
|
|
|
;; Local Variables:
|
|
|
|
;; inferior-lisp-program: "eufonctl"
|
|
|
|
;; End:
|