53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
|
;;; widget/clickable-container.fnl --- Clickable container
|
||
|
|
||
|
;;; Commentary:
|
||
|
;; From https://github.com/PapyElGringo/material-awesome/blob/57116136a904560e8626b673370d2130b40dc62a/widgets/clickable-container.lua
|
||
|
|
||
|
;;; Code:
|
||
|
|
||
|
(local wibox (require :wibox))
|
||
|
(local naughty (require :naughty))
|
||
|
(local awful (require :awful))
|
||
|
|
||
|
;;;
|
||
|
;; Functions
|
||
|
|
||
|
(fn build [widget]
|
||
|
(let [container (wibox.container.background widget)]
|
||
|
(var old-cursor {})
|
||
|
(var old-wibox {})
|
||
|
|
||
|
(: container :connect_signal
|
||
|
:mouse::enter
|
||
|
(lambda []
|
||
|
(let [cw _G.mouse.current_wibox]
|
||
|
(tset container :bg "#ffffff11")
|
||
|
;; Hm, no idea how to get the wibox from this signal's arguments...
|
||
|
(when cw
|
||
|
(set old-cursor cw.cursor)
|
||
|
(set old-wibox cw)
|
||
|
(tset cw :cursor :hand1)))))
|
||
|
|
||
|
(: container :connect_signal
|
||
|
:mouse::leave
|
||
|
(lambda []
|
||
|
(tset container :bg "#ffffff00")
|
||
|
(when old-wibox
|
||
|
(tset old-wibox :cursor old-cursor)
|
||
|
(set old-wibox nil))))
|
||
|
|
||
|
(: container :connect_signal
|
||
|
:button::press
|
||
|
(lambda []
|
||
|
(tset container :bg "#ffffff22")))
|
||
|
|
||
|
(: container :connect_signal
|
||
|
:button::release
|
||
|
(lambda []
|
||
|
(tset container :bg "#ffffff11")))
|
||
|
|
||
|
container))
|
||
|
|
||
|
build
|
||
|
;;; widget/clickable-container.fnl ends here
|