From 1c42b4f3c8196d516ba08b46970f296f755b1aea Mon Sep 17 00:00:00 2001 From: Lemmy Date: Tue, 27 Jan 2026 09:36:46 -0500 Subject: [PATCH] bar: added extra mouse areas in the corner that activate the closest widget. --- Modules/Bar/Bar.qml | 64 ++++++++++++++++++++++++++++++++++++++ Services/UI/BarService.qml | 15 ++++----- 2 files changed, 72 insertions(+), 7 deletions(-) diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 93fab1807..7338bbeec 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -27,6 +27,34 @@ Item { }); } + // Hot corner: trigger click on first widget in a section + function triggerFirstWidgetInSection(sectionName: string) { + var widgets = BarService.getWidgetsBySection(sectionName, screen?.name); + for (var i = 0; i < widgets.length; i++) { + var widget = widgets[i]; + if (widget && widget.visible && widget.widgetId !== "Spacer") { + if (typeof widget.clicked === "function") { + widget.clicked(); + } + return; + } + } + } + + // Hot corner: trigger click on last widget in a section + function triggerLastWidgetInSection(sectionName: string) { + var widgets = BarService.getWidgetsBySection(sectionName, screen?.name); + for (var i = widgets.length - 1; i >= 0; i--) { + var widget = widgets[i]; + if (widget && widget.visible && widget.widgetId !== "Spacer") { + if (typeof widget.clicked === "function") { + widget.clicked(); + } + return; + } + } + } + // Expose bar region for click-through mask readonly property var barRegion: barContentLoader.item?.children[0] || null @@ -220,6 +248,24 @@ Item { anchors.fill: parent clip: true + // Top edge hot corner - triggers first widget in left (top) section + MouseArea { + width: parent.width + height: Style.marginM + x: 0 + y: 0 + onClicked: root.triggerFirstWidgetInSection("left") + } + + // Bottom edge hot corner - triggers last widget in right (bottom) section + MouseArea { + width: parent.width + height: Style.marginM + x: 0 + anchors.bottom: parent.bottom + onClicked: root.triggerLastWidgetInSection("right") + } + // Top section (left widgets) ColumnLayout { x: Style.pixelAlignCenter(parent.width, width) @@ -306,6 +352,24 @@ Item { anchors.fill: parent clip: true + // Left edge hot corner - triggers first widget in left section + MouseArea { + width: Style.marginS + height: parent.height + x: 0 + y: 0 + onClicked: root.triggerFirstWidgetInSection("left") + } + + // Right edge hot corner - triggers last widget in right section + MouseArea { + width: Style.marginS + height: parent.height + anchors.right: parent.right + y: 0 + onClicked: root.triggerLastWidgetInSection("right") + } + // Left Section RowLayout { id: leftSection diff --git a/Services/UI/BarService.qml b/Services/UI/BarService.qml index 3da9ab385..dda7cd3fd 100644 --- a/Services/UI/BarService.qml +++ b/Services/UI/BarService.qml @@ -151,7 +151,7 @@ Singleton { // Get all widgets in a specific section function getWidgetsBySection(section, screenName = null) { - var widgets = []; + var widgetEntries = []; for (var key in widgetInstances) { var widget = widgetInstances[key]; @@ -159,19 +159,20 @@ Singleton { continue; if (widget.section === section) { if (!screenName || widget.screenName === screenName) { - widgets.push(widget.instance); + widgetEntries.push(widget); } } } // Sort by index to maintain order - widgets.sort(function (a, b) { - var aWidget = getWidgetWithMetadata(a.widgetId, a.screen?.name, a.section); - var bWidget = getWidgetWithMetadata(b.widgetId, b.screen?.name, b.section); - return (aWidget?.index || 0) - (bWidget?.index || 0); + widgetEntries.sort(function (a, b) { + return (a.index || 0) - (b.index || 0); }); - return widgets; + // Return just the instances + return widgetEntries.map(function (w) { + return w.instance; + }); } // Get all registered widgets (for debugging)