mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Workspace: avoid a bleep of the indicator when switching window focus on the same workspace
+ Fix a bug where you could have two active windows indicator after the first switch.
This commit is contained in:
@@ -178,7 +178,7 @@ Item {
|
||||
}
|
||||
}
|
||||
function onActiveWindowChanged() {
|
||||
if (showApplications || showLabelsOnlyWhenOccupied) {
|
||||
if (showApplications) {
|
||||
refreshWorkspaces();
|
||||
}
|
||||
}
|
||||
@@ -450,7 +450,6 @@ Item {
|
||||
|
||||
return Qt.alpha(Color.mSecondary, 0.3);
|
||||
}
|
||||
scale: model.isActive ? 1.0 : 0.9
|
||||
z: 0
|
||||
|
||||
MouseArea {
|
||||
|
||||
@@ -285,9 +285,10 @@ Item {
|
||||
windows = toSortedWindowList(windowsList);
|
||||
windowListChanged();
|
||||
|
||||
// Find focused window index in the SORTED windows array
|
||||
focusedWindowIndex = -1;
|
||||
for (var i = 0; i < windowsList.length; i++) {
|
||||
if (windowsList[i].isFocused) {
|
||||
for (var i = 0; i < windows.length; i++) {
|
||||
if (windows[i].isFocused) {
|
||||
focusedWindowIndex = i;
|
||||
break;
|
||||
}
|
||||
@@ -301,6 +302,9 @@ Item {
|
||||
const existingIndex = windows.findIndex(w => w.id === windowData.id);
|
||||
const newWindow = getWindowData(windowData);
|
||||
|
||||
// Find the previously focused window ID before any modifications
|
||||
const previouslyFocusedId = focusedWindowIndex >= 0 && focusedWindowIndex < windows.length ? windows[focusedWindowIndex].id : null;
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
windows[existingIndex] = newWindow;
|
||||
} else {
|
||||
@@ -309,15 +313,16 @@ Item {
|
||||
windows = toSortedWindowList(windows);
|
||||
|
||||
if (newWindow.isFocused) {
|
||||
const oldFocusedIndex = focusedWindowIndex;
|
||||
focusedWindowIndex = windows.findIndex(w => w.id === windowData.id);
|
||||
|
||||
if (oldFocusedIndex !== focusedWindowIndex) {
|
||||
if (oldFocusedIndex >= 0 && oldFocusedIndex < windows.length) {
|
||||
windows[oldFocusedIndex].isFocused = false;
|
||||
// Clear focus on the previously focused window by ID (not index, since list was re-sorted)
|
||||
if (previouslyFocusedId !== null && previouslyFocusedId !== windowData.id) {
|
||||
const oldFocusedWindow = windows.find(w => w.id === previouslyFocusedId);
|
||||
if (oldFocusedWindow) {
|
||||
oldFocusedWindow.isFocused = false;
|
||||
}
|
||||
activeWindowChanged();
|
||||
}
|
||||
activeWindowChanged();
|
||||
}
|
||||
|
||||
windowListChanged();
|
||||
|
||||
Reference in New Issue
Block a user