From 8fab7d4b65cd16769d3ef48e44da3f8ed75582ed Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Mon, 31 Mar 2025 23:02:52 +1100
Subject: feat: fake screen rounding

---
 src/modules/bar.tsx | 121 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 69 insertions(+), 52 deletions(-)

(limited to 'src/modules/bar.tsx')

diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx
index 995d3a3..29f4f88 100644
--- a/src/modules/bar.tsx
+++ b/src/modules/bar.tsx
@@ -8,6 +8,7 @@ import { bindCurrentTime, osIcon } from "@/utils/system";
 import type { AstalWidget } from "@/utils/types";
 import { setupCustomTooltip } from "@/utils/widgets";
 import type PopupWindow from "@/widgets/popupwindow";
+import ScreenCorner from "@/widgets/screencorner";
 import { execAsync, Variable } from "astal";
 import Binding, { bind, kebabify } from "astal/binding";
 import { App, Astal, Gtk } from "astal/gtk3";
@@ -560,63 +561,79 @@ const bindWidget = (module: keyof typeof config.modules, Widget: () => JSX.Eleme
 const bindCompositeWidget = (module: keyof typeof config.modules, binding: Binding<JSX.Element>) =>
     bind(Variable.derive([config.modules[module].enabled, binding], (e, w) => (e ? w : <Dummy />)));
 
-export default ({ monitor }: { monitor: Monitor }) => {
+const Bar = ({ monitor }: { monitor: Monitor }) => {
     const className = Variable.derive(
         [bind(config.vertical), bind(config.style)],
         (v, s) => `bar ${v ? "vertical" : " horizontal"} ${s}`
     );
 
     return (
-        <window
-            namespace="caelestia-bar"
-            monitor={monitor.id}
-            anchor={bind(config.vertical).as(
-                v =>
-                    Astal.WindowAnchor.TOP |
-                    Astal.WindowAnchor.LEFT |
-                    (v ? Astal.WindowAnchor.BOTTOM : Astal.WindowAnchor.RIGHT)
-            )}
-            exclusivity={Astal.Exclusivity.EXCLUSIVE}
-        >
-            <centerbox vertical={bind(config.vertical)} className={bind(className)} onDestroy={() => className.drop()}>
-                <box vertical={bind(config.vertical)}>
-                    {bindWidget("osIcon", OSIcon)}
-                    {bindWidget("activeWindow", ActiveWindow)}
-                    {bindWidget("mediaPlaying", MediaPlaying)}
-                    <button
-                        expand
-                        onScroll={(_, event) =>
-                            event.delta_y > 0 ? (monitor.brightness -= 0.1) : (monitor.brightness += 0.1)
-                        }
-                    />
-                </box>
-                {bindWidget("workspaces", Workspaces)}
-                <box vertical={bind(config.vertical)}>
-                    <button
-                        expand
-                        onScroll={(_, event) => {
-                            const speaker = AstalWp.get_default()?.audio.defaultSpeaker;
-                            if (!speaker) return console.error("Unable to connect to WirePlumber.");
-                            speaker.mute = false;
-                            if (event.delta_y > 0) speaker.volume -= 0.1;
-                            else speaker.volume += 0.1;
-                        }}
-                    />
-                    {bindWidget("tray", Tray)}
-                    {bindWidget("statusIcons", StatusIcons)}
-                    {bindWidget("pkgUpdates", PkgUpdates)}
-                    {bindWidget("notifCount", NotifCount)}
-                    {bindCompositeWidget(
-                        "battery",
-                        bind(AstalBattery.get_default(), "isBattery").as(b => (b ? <Battery /> : <Dummy />))
-                    )}
-                    {bindCompositeWidget(
-                        "dateTime",
-                        bind(config.vertical).as(v => (v ? <DateTimeVertical /> : <DateTime />))
-                    )}
-                    {bindWidget("power", Power)}
-                </box>
-            </centerbox>
-        </window>
+        <centerbox vertical={bind(config.vertical)} className={bind(className)} onDestroy={() => className.drop()}>
+            <box vertical={bind(config.vertical)}>
+                {bindWidget("osIcon", OSIcon)}
+                {bindWidget("activeWindow", ActiveWindow)}
+                {bindWidget("mediaPlaying", MediaPlaying)}
+                <button
+                    expand
+                    onScroll={(_, event) =>
+                        event.delta_y > 0 ? (monitor.brightness -= 0.1) : (monitor.brightness += 0.1)
+                    }
+                />
+            </box>
+            {bindWidget("workspaces", Workspaces)}
+            <box vertical={bind(config.vertical)}>
+                <button
+                    expand
+                    onScroll={(_, event) => {
+                        const speaker = AstalWp.get_default()?.audio.defaultSpeaker;
+                        if (!speaker) return console.error("Unable to connect to WirePlumber.");
+                        speaker.mute = false;
+                        if (event.delta_y > 0) speaker.volume -= 0.1;
+                        else speaker.volume += 0.1;
+                    }}
+                />
+                {bindWidget("tray", Tray)}
+                {bindWidget("statusIcons", StatusIcons)}
+                {bindWidget("pkgUpdates", PkgUpdates)}
+                {bindWidget("notifCount", NotifCount)}
+                {bindCompositeWidget(
+                    "battery",
+                    bind(AstalBattery.get_default(), "isBattery").as(b => (b ? <Battery /> : <Dummy />))
+                )}
+                {bindCompositeWidget(
+                    "dateTime",
+                    bind(config.vertical).as(v => (v ? <DateTimeVertical /> : <DateTime />))
+                )}
+                {bindWidget("power", Power)}
+            </box>
+        </centerbox>
     );
 };
+
+export default ({ monitor }: { monitor: Monitor }) => (
+    <window
+        namespace="caelestia-bar"
+        monitor={monitor.id}
+        anchor={bind(config.vertical).as(
+            v =>
+                Astal.WindowAnchor.TOP |
+                Astal.WindowAnchor.LEFT |
+                (v ? Astal.WindowAnchor.BOTTOM : Astal.WindowAnchor.RIGHT)
+        )}
+        exclusivity={Astal.Exclusivity.EXCLUSIVE}
+    >
+        <overlay
+            passThrough
+            overlays={[
+                <ScreenCorner place="topleft" />,
+                <ScreenCorner
+                    halign={bind(config.vertical).as(v => (v ? undefined : Gtk.Align.END))}
+                    valign={bind(config.vertical).as(v => (v ? Gtk.Align.END : undefined))}
+                    place={bind(config.vertical).as(v => (v ? "bottomleft" : "topright"))}
+                />,
+            ]}
+        >
+            <Bar monitor={monitor} />
+        </overlay>
+    </window>
+);
-- 
cgit v1.2.3-freya

