Mouse events are released after the OSD is hidden. (#39)

* Fixes #38 - Fixed an issue that would cause the OSD to block mouse events even when invisible.

* Replace Overlay with a temporary workaround since Overlay can't be resized.

* Fix visible toggle being stuck on initial retoggle.
This commit is contained in:
Jas Singh
2024-07-29 23:03:17 -07:00
committed by GitHub
parent faa434405c
commit 49a25e8741

View File

@@ -23,6 +23,21 @@ hyprland.active.connect("changed", () => {
const DELAY = 2500; const DELAY = 2500;
let count = 0
const handleReveal = (self: any, property: string) => {
if (!enable.value) {
return;
}
self[property] = true
count++
Utils.timeout(DELAY, () => {
count--
if (count === 0)
self[property] = false
})
}
const getPosition = (pos: OSDAnchor): ("top" | "bottom" | "left" | "right")[] => { const getPosition = (pos: OSDAnchor): ("top" | "bottom" | "left" | "right")[] => {
const positionMap: { [key: string]: ("top" | "bottom" | "left" | "right")[] } = { const positionMap: { [key: string]: ("top" | "bottom" | "left" | "right")[] } = {
"top": ["top"], "top": ["top"],
@@ -38,31 +53,20 @@ const getPosition = (pos: OSDAnchor): ("top" | "bottom" | "left" | "right")[] =>
return positionMap[pos]; return positionMap[pos];
} }
const renderOSD = () => { const renderOSD = () => {
let count = 0
const handleReveal = (self: any) => {
self.reveal_child = true
count++
Utils.timeout(DELAY, () => {
count--
if (count === 0)
self.reveal_child = false
})
}
return Widget.Revealer({ return Widget.Revealer({
transition: "crossfade", transition: "crossfade",
reveal_child: false, reveal_child: false,
setup: self => { setup: self => {
self.hook(brightness, () => { self.hook(brightness, () => {
handleReveal(self); handleReveal(self, "reveal_child");
}, "notify::screen") }, "notify::screen")
self.hook(brightness, () => { self.hook(brightness, () => {
handleReveal(self); handleReveal(self, "reveal_child");
}, "notify::kbd") }, "notify::kbd")
self.hook(audio.speaker, () => { self.hook(audio.speaker, () => {
handleReveal(self); handleReveal(self, "reveal_child");
}) })
}, },
@@ -100,7 +104,6 @@ export default () => Widget.Window({
return mon; return mon;
}), }),
name: `indicator`, name: `indicator`,
visible: enable.bind("value"),
class_name: "indicator", class_name: "indicator",
layer: "overlay", layer: "overlay",
anchor: location.bind("value").as(v => getPosition(v)), anchor: location.bind("value").as(v => getPosition(v)),
@@ -110,4 +113,19 @@ export default () => Widget.Window({
expand: true, expand: true,
child: renderOSD(), child: renderOSD(),
}), }),
setup: self => {
self.hook(enable, () => {
handleReveal(self, "visible");
})
self.hook(brightness, () => {
handleReveal(self, "visible");
}, "notify::screen")
self.hook(brightness, () => {
handleReveal(self, "visible");
}, "notify::kbd")
self.hook(audio.speaker, () => {
handleReveal(self, "visible");
})
},
}) })