bar: added extra mouse areas in the corner that activate the closest widget.

This commit is contained in:
Lemmy
2026-01-27 09:36:46 -05:00
parent 584584297e
commit 1c42b4f3c8
2 changed files with 72 additions and 7 deletions
+64
View File
@@ -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
+8 -7
View File
@@ -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)