summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-02-18 22:34:13 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-02-18 22:34:13 +1100
commit0b771cbd1bfccdcbf4cbaabfed13eece4a2e8929 (patch)
treeb425f18696b5e17db585a90c39f1b3e7b1959c5c /src/widgets
parentbar: transparent + more round (diff)
downloadcaelestia-shell-0b771cbd1bfccdcbf4cbaabfed13eece4a2e8929.tar.gz
caelestia-shell-0b771cbd1bfccdcbf4cbaabfed13eece4a2e8929.tar.bz2
caelestia-shell-0b771cbd1bfccdcbf4cbaabfed13eece4a2e8929.zip
bar: vertical mode
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/popupwindow.ts22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/widgets/popupwindow.ts b/src/widgets/popupwindow.ts
index ffed396..2ba49fc 100644
--- a/src/widgets/popupwindow.ts
+++ b/src/widgets/popupwindow.ts
@@ -1,5 +1,6 @@
import { Binding, register } from "astal";
import { App, Astal, Gdk, Widget } from "astal/gtk3";
+import { bar } from "config";
import AstalHyprland from "gi://AstalHyprland?version=0.1";
const extendProp = <T>(
@@ -29,19 +30,30 @@ export default class PopupWindow extends Widget.Window {
popup_at_widget(widget: JSX.Element, event: Gdk.Event | Astal.ClickEvent) {
const { width, height } = widget.get_allocation();
- const mWidth = AstalHyprland.get_default().get_focused_monitor().get_width();
+ const { width: mWidth, height: mHeight } = AstalHyprland.get_default().get_focused_monitor();
const pWidth = this.get_preferred_width()[1];
+ const pHeight = this.get_preferred_height()[1];
const [, x, y] = event instanceof Gdk.Event ? event.get_coords() : [null, event.x, event.y];
const { x: cx, y: cy } = AstalHyprland.get_default().get_cursor_position();
- let marginLeft = cx + ((width - pWidth) / 2 - x);
- if (marginLeft < 0) marginLeft = 0;
- else if (marginLeft + pWidth > mWidth) marginLeft = mWidth - pWidth;
+ let marginLeft = 0;
+ let marginTop = 0;
+ if (bar.vertical) {
+ marginLeft = cx + (width - x);
+ marginTop = cy + ((height - pHeight) / 2 - y);
+ if (marginTop < 0) marginTop = 0;
+ else if (marginTop + pHeight > mHeight) marginTop = mHeight - pHeight;
+ } else {
+ marginLeft = cx + ((width - pWidth) / 2 - x);
+ if (marginLeft < 0) marginLeft = 0;
+ else if (marginLeft + pWidth > mWidth) marginLeft = mWidth - pWidth;
+ marginTop = cy + (height - y);
+ }
this.anchor = Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT;
this.exclusivity = Astal.Exclusivity.IGNORE;
this.marginLeft = marginLeft;
- this.marginTop = cy + (height - y);
+ this.marginTop = marginTop;
this.show();
}