Skip to content

Commit e39be76

Browse files
committed
Merge pull request #2690: decouple widget click from sort state
Resolve conflict by adopting upstream openWidgetPopout() abstraction with tabIndex: 1 (CPU) and tabIndex: 3 (GPU) routing. Preserve async race condition fix in PopoutService (Connections on Loader.Ready instead of Qt.callLater) and toggle->show delegation in ProcessListModal.
2 parents b447e16 + 2e60b85 commit e39be76

5 files changed

Lines changed: 54 additions & 13 deletions

File tree

quickshell/Modals/ProcessListModal.qml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ FloatingWindow {
1313

1414
property bool disablePopupTransparency: true
1515
property int currentTab: 0
16+
// Number of tabs in the tab bar — derived from the tab model array.
17+
// Using array literal length (4) as a constant property; matches the
18+
// inline Repeater model so the bound stays correct if tabs are added.
19+
readonly property int tabCount: 4
20+
readonly property int maxTabIndex: tabCount - 1
1621
property string searchText: ""
1722
property string expandedPid: ""
1823
property string processFilter: "all"
@@ -21,11 +26,25 @@ FloatingWindow {
2126

2227
signal closingModal
2328

24-
function show() {
29+
function clampTab(tabIndex) {
30+
if (tabIndex === undefined || tabIndex === null)
31+
return currentTab;
32+
return Math.max(0, Math.min(maxTabIndex, tabIndex));
33+
}
34+
35+
function show(tabIndex) {
2536
if (!DgopService.dgopAvailable) {
2637
log.warn("dgop is not available");
2738
return;
2839
}
40+
currentTab = clampTab(tabIndex);
41+
// Restore sort state when navigating to Performance tab (tab 1).
42+
// CpuMonitor and RamMonitor call setSortBy themselves; routing here
43+
// from a thermal widget should also set the sort so the data is
44+
// pre-sorted for the tab being opened.
45+
if (currentTab === 1) {
46+
DgopService.setSortBy("cpu");
47+
}
2948
visible = true;
3049
}
3150

@@ -35,12 +54,18 @@ FloatingWindow {
3554
processContextMenu.close();
3655
}
3756

38-
function toggle() {
57+
function toggle(tabIndex) {
3958
if (!DgopService.dgopAvailable) {
4059
log.warn("dgop is not available");
4160
return;
4261
}
43-
visible = !visible;
62+
// If already visible on the target tab, just hide.
63+
// Otherwise delegate to show() which handles clampTab, sort state, and visibility.
64+
if (visible && currentTab === clampTab(tabIndex)) {
65+
hide();
66+
return;
67+
}
68+
show(tabIndex);
4469
}
4570

4671
function focusOrToggle() {
@@ -78,11 +103,11 @@ FloatingWindow {
78103
}
79104

80105
function nextTab() {
81-
currentTab = (currentTab + 1) % 4;
106+
currentTab = (currentTab + 1) % tabCount;
82107
}
83108

84109
function previousTab() {
85-
currentTab = (currentTab - 1 + 4) % 4;
110+
currentTab = (currentTab - 1 + tabCount) % tabCount;
86111
}
87112

88113
objectName: "processListModal"

quickshell/Modules/DankBar/DankBarContent.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ Item {
12851285
widgetItem: cpuTempWidget,
12861286
section: topBarContent.getWidgetSection(parent) || "right",
12871287
triggerSource: "cpu_temp",
1288+
tabIndex: 1,
12881289
mode: "click"
12891290
});
12901291
}
@@ -1309,6 +1310,7 @@ Item {
13091310
widgetItem: gpuTempWidget,
13101311
section: topBarContent.getWidgetSection(parent) || "right",
13111312
triggerSource: "gpu_temp",
1313+
tabIndex: 3,
13121314
mode: "click"
13131315
});
13141316
}

quickshell/Modules/DankBar/Widgets/CpuTemperature.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ BasePill {
133133
acceptedButtons: Qt.LeftButton
134134
onPressed: mouse => {
135135
root.triggerRipple(this, mouse.x, mouse.y);
136-
DgopService.setSortBy("cpu");
137136
cpuTempClicked();
138137
}
139138
}

quickshell/Modules/DankBar/Widgets/GpuTemperature.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ BasePill {
201201
acceptedButtons: Qt.LeftButton
202202
onPressed: mouse => {
203203
root.triggerRipple(this, mouse.x, mouse.y);
204-
DgopService.setSortBy("cpu");
205204
gpuTempClicked();
206205
}
207206
}

quickshell/Services/PopoutService.qml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Singleton {
3939
property var powerMenuModal: null
4040
property var processListModal: null
4141
property var processListModalLoader: null
42+
// Pending tab index for async Loader path — consumed by Connections when modal loads
43+
property int pendingProcessTab: -1
4244
property var colorPickerModal: null
4345
property var notificationModal: null
4446
property var wifiPasswordModal: null
@@ -759,12 +761,12 @@ Singleton {
759761
}
760762
}
761763

762-
function showProcessListModal() {
764+
function showProcessListModal(tabIndex) {
763765
if (processListModal) {
764-
processListModal.show();
766+
processListModal.show(tabIndex);
765767
} else if (processListModalLoader) {
768+
pendingProcessTab = (tabIndex !== undefined && tabIndex !== null) ? tabIndex : -1;
766769
processListModalLoader.active = true;
767-
Qt.callLater(() => processListModal?.show());
768770
}
769771
}
770772

@@ -779,12 +781,26 @@ Singleton {
779781
}
780782
}
781783

782-
function toggleProcessListModal() {
784+
function toggleProcessListModal(tabIndex) {
783785
if (processListModal) {
784-
processListModal.toggle();
786+
processListModal.toggle(tabIndex);
785787
} else if (processListModalLoader) {
788+
pendingProcessTab = (tabIndex !== undefined && tabIndex !== null) ? tabIndex : -1;
786789
processListModalLoader.active = true;
787-
Qt.callLater(() => processListModal?.show());
790+
}
791+
}
792+
793+
// Reactive async path: when Loader finishes loading, show modal at pending tab.
794+
// Avoids Qt.callLater race condition where the lambda fires before modal is ready.
795+
Connections {
796+
target: processListModalLoader
797+
function onStatusChanged() {
798+
if (!processListModalLoader)
799+
return;
800+
if (processListModalLoader.status === Loader.Ready && pendingProcessTab !== -1) {
801+
processListModal?.show(pendingProcessTab);
802+
pendingProcessTab = -1;
803+
}
788804
}
789805
}
790806

0 commit comments

Comments
 (0)