Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion quickshell/Modules/DankBar/Widgets/FocusedApp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BasePill {
property int availableWidth: 400
readonly property int maxNormalWidth: 456
readonly property int maxCompactWidth: 288
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
property Toplevel activeWindow: null
property var activeDesktopEntry: null
property bool isHovered: mouseArea.containsMouse
property bool isAutoHideBar: false
Expand All @@ -38,10 +38,44 @@ BasePill {
return 0;
}

function updateActiveWindow() {
const active = ToplevelManager.activeToplevel;

if (!active) {
// Only clear if our tracked window is no longer alive
if (activeWindow) {
const alive = ToplevelManager.toplevels?.values;
if (alive && !Array.from(alive).some(t => t === activeWindow))
activeWindow = null;
}
return;
}

if (!parentScreen || CompositorService.filterCurrentDisplay([active], parentScreen?.name)?.length > 0) {
activeWindow = active;
}
// else: active window is on a different screen so keep the previous value
}

Component.onCompleted: {
updateActiveWindow();
updateDesktopEntry();
}

Connections {
target: ToplevelManager
function onActiveToplevelChanged() {
root.updateActiveWindow();
}
}

Connections {
target: CompositorService
function onToplevelsChanged() {
root.updateActiveWindow();
}
}

Connections {
target: DesktopEntries
function onApplicationsChanged() {
Expand Down
Loading