From d2457db2c3ad21a639db7176bc25eab9f76b0c49 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:59:33 +1100 Subject: osds: volume mute colour and show on mute --- modules/osds.tsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'modules') diff --git a/modules/osds.tsx b/modules/osds.tsx index 4ed291d..5b6af8f 100644 --- a/modules/osds.tsx +++ b/modules/osds.tsx @@ -42,7 +42,7 @@ const SliderOsd = ({ fillIcons?: boolean; monitor: Monitor; type: keyof typeof config; - windowSetup: (self: Widget.Window, hideAfterTimeout: () => void) => void; + windowSetup: (self: Widget.Window, show: () => void) => void; className?: string; initValue: number; drawAreaSetup: (self: Widget.DrawingArea, icon: Variable) => void; @@ -60,7 +60,10 @@ const SliderOsd = ({ time = timeout(config[type].hideDelay, () => self.hide()); }; self.connect("show", hideAfterTimeout); - windowSetup(self, hideAfterTimeout); + windowSetup(self, () => { + self.show(); + hideAfterTimeout(); + }); }} > @@ -75,6 +78,7 @@ const SliderOsd = ({ const icon = Variable(""); drawAreaSetup(self, icon); + self.hook(icon, () => self.queue_draw()); // Init size const styleContext = self.get_style_context(); @@ -123,7 +127,7 @@ const SliderOsd = ({ cr.arc(radius, height - radius, radius, halfPi, Math.PI); // Bottom left cr.fill(); - const fg = styleContext.get_color(Gtk.StateFlags.NORMAL); + const fg = pContext.get_background_color(Gtk.StateFlags.NORMAL); cr.setAntialias(cairo.Antialias.BEST); // Progress number, at top/right @@ -202,11 +206,9 @@ const Volume = ({ monitor, audio }: { monitor: Monitor; audio: AstalWp.Audio }) fillIcons monitor={monitor} type="volume" - windowSetup={(self, hideAfterTimeout) => { - self.hook(audio.defaultSpeaker, "notify::volume", () => { - self.show(); - hideAfterTimeout(); - }); + windowSetup={(self, show) => { + self.hook(audio.defaultSpeaker, "notify::volume", show); + self.hook(audio.defaultSpeaker, "notify::mute", show); }} className={audio.defaultSpeaker.mute ? "mute" : ""} initValue={audio.defaultSpeaker.volume} @@ -236,12 +238,7 @@ const Brightness = ({ monitor }: { monitor: Monitor }) => ( { - self.hook(monitor, "notify::brightness", () => { - self.show(); - hideAfterTimeout(); - }); - }} + windowSetup={(self, show) => self.hook(monitor, "notify::brightness", show)} initValue={monitor.brightness} drawAreaSetup={(self, icon) => { const update = () => { -- cgit v1.2.3-freya