diff --git a/quickshell/Modules/ProcessList/ProcessesView.qml b/quickshell/Modules/ProcessList/ProcessesView.qml index d0ef346e..69542648 100644 --- a/quickshell/Modules/ProcessList/ProcessesView.qml +++ b/quickshell/Modules/ProcessList/ProcessesView.qml @@ -105,7 +105,7 @@ Item { sortKey: "name" currentSort: DgopService.currentSort sortAscending: DgopService.sortAscending - onClicked: DgopService.setSortBy("name") + onClicked: DgopService.toggleSort("name") alignment: Text.AlignLeft } @@ -115,7 +115,7 @@ Item { sortKey: "cpu" currentSort: DgopService.currentSort sortAscending: DgopService.sortAscending - onClicked: DgopService.setSortBy("cpu") + onClicked: DgopService.toggleSort("cpu") } SortableHeader { @@ -124,7 +124,7 @@ Item { sortKey: "memory" currentSort: DgopService.currentSort sortAscending: DgopService.sortAscending - onClicked: DgopService.setSortBy("memory") + onClicked: DgopService.toggleSort("memory") } SortableHeader { @@ -133,7 +133,7 @@ Item { sortKey: "pid" currentSort: DgopService.currentSort sortAscending: DgopService.sortAscending - onClicked: DgopService.setSortBy("pid") + onClicked: DgopService.toggleSort("pid") } Item { diff --git a/quickshell/Services/DgopService.qml b/quickshell/Services/DgopService.qml index 04d3236a..8a31da49 100644 --- a/quickshell/Services/DgopService.qml +++ b/quickshell/Services/DgopService.qml @@ -569,10 +569,18 @@ Singleton { } function setSortBy(newSortBy) { - if (newSortBy === currentSort) { + if (newSortBy !== currentSort) { + currentSort = newSortBy; + sortAscending = false; + applySorting(); + } + } + + function toggleSort(column) { + if (column === currentSort) { sortAscending = !sortAscending; } else { - currentSort = newSortBy; + currentSort = column; sortAscending = false; } applySorting();