Skip to content
Open
Show file tree
Hide file tree
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
28 changes: 25 additions & 3 deletions shell/services/AppLibrary.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Item {
// it: the OSD shows with duration 0, so only closeLaunchFeedback() takes it
// down.
property bool launchOsdOpen: false
property bool launchOsdShowPending: false
property bool launchOsdCloseQueued: false
property string launchOsdMessage: ""

// Emitted whenever the visible application set may have changed: desktop
Expand Down Expand Up @@ -184,12 +186,20 @@ Item {
launchTimeout.restart()
}

function showLaunchOsd() {
root.launchOsdOpen = true
root.launchOsdShowPending = true
launchOsdShow.command = ["omarchy-shell", "osd", "show", JSON.stringify({ icon: "󱓞", message: root.launchOsdMessage, duration: 0 })]
launchOsdShow.running = true
}

function closeLaunchFeedback(serial) {
if (serial !== root.launchSerial) return
launchDelay.stop()
launchTimeout.stop()
if (root.launchOsdOpen) {
Quickshell.execDetached(["omarchy-shell", "osd", "close"])
if (root.launchOsdShowPending) root.launchOsdCloseQueued = true
else Quickshell.execDetached(["omarchy-shell", "osd", "close"])
root.launchOsdOpen = false
}
}
Expand Down Expand Up @@ -259,8 +269,7 @@ Item {
interval: 2000
onTriggered: {
if (root.toplevelCount() > root.launchToplevelCount || ToplevelManager.activeToplevel !== root.launchActiveToplevel) return
root.launchOsdOpen = true
Quickshell.execDetached(["omarchy-shell", "osd", "show", JSON.stringify({ icon: "󱓞", message: root.launchOsdMessage, duration: 0 })])
root.showLaunchOsd()
}
}

Expand All @@ -270,6 +279,19 @@ Item {
onTriggered: root.closeLaunchFeedback(root.launchSerial)
}

// Show and close are separate omarchy-shell calls. Close waits for show to
// finish, so a close cannot reach the OSD first and leave it open forever.
// launchOsdShowPending covers the gap before `running` turns true.
Process {
id: launchOsdShow
onExited: {
root.launchOsdShowPending = false
if (!root.launchOsdCloseQueued) return
root.launchOsdCloseQueued = false
Quickshell.execDetached(["omarchy-shell", "osd", "close"])
}
}

Connections {
target: DesktopEntries.applications
function onValuesChanged() {
Expand Down
33 changes: 33 additions & 0 deletions test/shell.d/fixtures/launch-osd-order/shell.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import QtQuick
import Quickshell
import Quickshell.Io
import "services"

// Shows the launch OSD and closes it in the same turn, while the stubbed
// `omarchy-shell osd show` is still running. Nothing runs in between, so window
// changes on the desktop cannot cancel the launch first. The test then checks
// that the close reached omarchy-shell after the show.
ShellRoot {
id: root

AppLibrary { id: appLibrary }

FileView {
id: resultFile
path: Quickshell.env("OMARCHY_QML_TEST_RESULT")
atomicWrites: true
}

Timer {
id: settle
interval: 1500
onTriggered: resultFile.setText(JSON.stringify({ ok: true }))
}

Component.onCompleted: {
appLibrary.beginLaunchFeedback("Test")
appLibrary.showLaunchOsd()
appLibrary.closeLaunchFeedback(appLibrary.launchSerial)
settle.start()
}
}
24 changes: 24 additions & 0 deletions test/shell.d/launch-osd-order-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

require_quickshell "launch OSD order test"

# A slow `osd show` must not let the following `osd close` overtake it: the
# launch OSD has no duration, so a close that lands first leaves it open.
qml_fixture_scratch
osd_log="$QML_FIXTURE_TMP/osd.log"
cat >"$QML_FIXTURE_TMP/bin/omarchy-shell" <<'SH'
#!/bin/bash
[[ $2 == "show" ]] && sleep 0.5
echo "$2" >>"$OSD_LOG"
SH
chmod +x "$QML_FIXTURE_TMP/bin/omarchy-shell"

OSD_LOG="$osd_log" run_qml_fixture launch-osd-order "launch OSD fixture runs" services Commons

[[ $(cat "$osd_log" 2>/dev/null | tr '\n' ' ') == "show close " ]] ||
fail "launch OSD close waits for show" "omarchy-shell calls: $(cat "$osd_log" 2>/dev/null | tr '\n' ' ')"
pass "launch OSD close waits for show"