From 5e56abd8775a0fb832c7842dc16f8cdb084ad362 Mon Sep 17 00:00:00 2001 From: mx Date: Sat, 14 Nov 2026 15:00:05 +0100 Subject: [PATCH] Open the launcher inside the notch in notch mode The launcher now works like a notification there: the notch pill widens at its own height, the clock and now playing keep the left end, and a search field with the top matches as a row of icons fills the right. Enter launches the highlighted match, Tab and arrows move along the row, Escape clears then closes, and a click elsewhere closes it. The bar window takes the keyboard while it is open. Clipboard history and emoji still open the launcher window, which now only shows for those modes. NotchGlance moves to components so the launcher and notch can share it without importing each other. Co-Authored-By: Claude Opus 5.5 --- quickshell/bar/Bar.qml | 10 + .../{notch => components}/NotchGlance.qml | 0 quickshell/core/ShellState.qml | 3 + quickshell/launcher/Launcher.qml | 68 ++--- quickshell/launcher/NotchSearch.qml | 233 ++++++++++++++++++ quickshell/launcher/qmldir | 1 + quickshell/notch/NotchPill.qml | 38 ++- 7 files changed, 321 insertions(+), 32 deletions(-) rename quickshell/{notch => components}/NotchGlance.qml (100%) create mode 100644 quickshell/launcher/NotchSearch.qml diff --git a/quickshell/bar/Bar.qml b/quickshell/bar/Bar.qml index 43482fd..00fe43e 100644 --- a/quickshell/bar/Bar.qml +++ b/quickshell/bar/Bar.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Shapes import Quickshell +import Quickshell.Hyprland import Quickshell.Wayland import "../components" import "../notch" @@ -33,6 +34,15 @@ PanelWindow { exclusionMode: ExclusionMode.Normal exclusiveZone: BarDrawers.bottom WlrLayershell.namespace: "glassMxrph-bar" + // The notch's search takes the keyboard while it is open on this screen; + // a click anywhere else closes it. + readonly property bool searching: notch && ShellState.notchSearch && ScreenService.current(ShellState.launcherScreen) === screen + WlrLayershell.keyboardFocus: searching ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + HyprlandFocusGrab { + windows: [root] + active: root.searching + onCleared: ShellState.launcherOpen = false + } Component.onCompleted: TrayService.registerBar(root) Component.onDestruction: TrayService.unregisterBar(root) GlassPanel { diff --git a/quickshell/notch/NotchGlance.qml b/quickshell/components/NotchGlance.qml similarity index 100% rename from quickshell/notch/NotchGlance.qml rename to quickshell/components/NotchGlance.qml diff --git a/quickshell/core/ShellState.qml b/quickshell/core/ShellState.qml index c0683b3..c3727ff 100644 --- a/quickshell/core/ShellState.qml +++ b/quickshell/core/ShellState.qml @@ -129,6 +129,9 @@ Singleton { // "emoji" is the Emoji Picker. // Changing it on an open launcher switches in place. property string launcherMode: "apps" + // Notch mode searches apps in the notch pill itself, the way a notification + // widens it; clipboard history and emoji still open the launcher window. + readonly property bool notchSearch: notchMode && launcherOpen && launcherMode === "apps" function activeScreen() { return ScreenService.active; } diff --git a/quickshell/launcher/Launcher.qml b/quickshell/launcher/Launcher.qml index 81e1b2d..997970e 100644 --- a/quickshell/launcher/Launcher.qml +++ b/quickshell/launcher/Launcher.qml @@ -8,7 +8,7 @@ import "../components" import "../services" import "../theme" import "../core" -import "../notch" + // Spotlight-style launcher: opens as a single search bar in the upper third. // Typing shows ranked results below it; the magnifying glass (or ↓ in an @@ -29,12 +29,12 @@ PanelWindow { left: true right: true } - visible: ShellState.launcherOpen || panel.opacity > 0.01 || (notch && progress > 0.001) + visible: root.open || panel.opacity > 0.01 || (notch && progress > 0.001) color: Theme.transparent exclusionMode: ExclusionMode.Ignore WlrLayershell.namespace: "glassMxrph-launcher" WlrLayershell.layer: WlrLayer.Overlay - WlrLayershell.keyboardFocus: ShellState.launcherOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + WlrLayershell.keyboardFocus: root.open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None readonly property var options: ConfigService.ready ? ConfigService.data.launcher : ({ width: 680, maxResults: 50, @@ -55,13 +55,13 @@ PanelWindow { description: entry.genericName || entry.comment || entry.id, entry: entry })) - readonly property var clipboardResults: clipboardMode && ShellState.launcherOpen ? ClipboardService.filter(query).map(e => ({ + readonly property var clipboardResults: clipboardMode && root.open ? ClipboardService.filter(query).map(e => ({ id: e.id, title: e.text.replace(/\s+/g, " ").trim(), description: "", clip: e })) : [] - readonly property var emojiResults: emojiMode && ShellState.launcherOpen ? EmojiService.filter(query).map(e => ({ + readonly property var emojiResults: emojiMode && root.open ? EmojiService.filter(query).map(e => ({ id: e.emoji, title: e.name, description: "", @@ -83,26 +83,29 @@ PanelWindow { // Notch mode: the launcher drops out of the notch at the top edge. The // panel's top corners sit above the screen and concave ears join it there. readonly property bool notch: ShellState.notchMode + // Notch mode searches apps inside the notch itself (NotchSearch); this + // window only opens there for clipboard history and emoji. + readonly property bool open: ShellState.launcherOpen && !ShellState.notchSearch // Notch mode morphs the collapsed notch into the launcher, as the notch // panel does: solid shape throughout, width leading the height a little, // contents fading in once it is mostly open and out first. - property real progress: ShellState.launcherOpen ? 1 : 0 + property real progress: root.open ? 1 : 0 Behavior on progress { enabled: root.notch NumberAnimation { id: morph - duration: ShellState.launcherOpen ? Theme.notchOpenDuration * 2 : Theme.notchCloseDuration * 1.3 + duration: root.open ? Theme.notchOpenDuration * 2 : Theme.notchCloseDuration * 1.3 easing.type: Easing.BezierSpline - easing.bezierCurve: ShellState.launcherOpen ? [0.2, 0, 0, 1, 1, 1] : [0.3, 0, 0.8, 0.15, 1, 1] + easing.bezierCurve: root.open ? [0.2, 0, 0, 1, 1, 1] : [0.3, 0, 0.8, 0.15, 1, 1] } } - readonly property bool settled: ShellState.launcherOpen && !morph.running + readonly property bool settled: root.open && !morph.running readonly property real wp: Math.min(1, progress * 1.15) readonly property real contentOpacity: Math.max(0, Math.min(1, (progress - 0.55) / 0.4)) // Open height, held while closing so clearing the results does not jump it. property real heldHeight: barHeight + bodyHeight Binding on heldHeight { - when: ShellState.launcherOpen + when: root.open value: root.barHeight + root.bodyHeight restoreMode: Binding.RestoreNone } @@ -135,7 +138,7 @@ PanelWindow { running: root.notch && root.visible && root.drawnFrames < 3 onTriggered: root.drawnFrames++ } - readonly property bool covering: visible && drawnFrames >= 3 && (ShellState.launcherOpen || progress > 0.02) + readonly property bool covering: visible && drawnFrames >= 3 && (root.open || progress > 0.02) Timer { id: unsnap interval: 120 @@ -180,6 +183,19 @@ PanelWindow { else launchError = ApplicationsService.error; } + // Fresh state each time the window opens. + function reset() { + if (!open) + return; + search.text = ""; + browsing = false; + launchError = ""; + selectedIndex = 0; + ClipboardService.refresh(); + if (emojiMode) + EmojiService.load(); + Qt.callLater(() => search.forceActiveFocus()); + } function toggleBrowse() { if (clipboardMode || emojiMode) { ShellState.launcherMode = "apps"; @@ -202,21 +218,15 @@ PanelWindow { Connections { target: ShellState function onLauncherOpenChanged() { - if (ShellState.launcherOpen) { - search.text = ""; - root.browsing = false; - root.launchError = ""; - root.selectedIndex = 0; - ClipboardService.refresh(); - if (root.emojiMode) - EmojiService.load(); - Qt.callLater(() => search.forceActiveFocus()); - } + root.reset(); + } + function onNotchSearchChanged() { + root.reset(); } function onLauncherModeChanged() { if (root.emojiMode) EmojiService.load(); - if (!ShellState.launcherOpen) + if (!root.open) return; root.snapping = true; unsnap.restart(); @@ -229,13 +239,13 @@ PanelWindow { } AppSearch { id: apps - enabled: ShellState.launcherOpen && root.showList && !root.commandMode + enabled: root.open && root.showList && !root.commandMode query: search.text limit: root.options.maxResults } CommandSearch { id: commands - enabled: ShellState.launcherOpen && root.commandMode + enabled: root.open && root.commandMode query: search.text limit: root.options.maxResults } @@ -326,10 +336,10 @@ PanelWindow { ear: BarDrawers.ear radius: panel.radius // Docked colour; the open fill only if the launcher follows "glassy when open". - fillColor: ShellState.launcherOpen ? Theme.notchLauncherFill : Theme.notchFill + fillColor: root.open ? Theme.notchLauncherFill : Theme.notchFill Behavior on fillColor { ColorAnimation { - duration: ShellState.launcherOpen ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration) + duration: root.open ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration) } } } @@ -355,14 +365,14 @@ PanelWindow { x: Math.round((root.width - width) / 2) y: root.notch ? 0 : Math.round(root.height * 0.22) // Notch mode grows out of the collapsed notch and shrinks back into it. - width: root.notch ? ShellState.notchPillWidth + (root.targetWidth - ShellState.notchPillWidth) * root.wp : ShellState.launcherOpen ? root.targetWidth : Math.min(320, root.targetWidth) + width: root.notch ? ShellState.notchPillWidth + (root.targetWidth - ShellState.notchPillWidth) * root.wp : root.open ? root.targetWidth : Math.min(320, root.targetWidth) height: root.notch ? BarDrawers.bottom + (root.heldHeight - BarDrawers.bottom) * root.progress : root.barHeight + root.bodyHeight color: root.notch ? Theme.transparent : Qt.alpha(Theme.surface, surfaceOpacity) border.width: root.notch ? 0 : 1 plain: root.notch radius: Math.min(Theme.radius + 6, root.barHeight / 2) - opacity: root.notch ? root.contentOpacity : ShellState.launcherOpen ? 1 : 0 - scale: ShellState.launcherOpen || root.notch ? 1 : 1 - 0.04 * Theme.intensity + opacity: root.notch ? root.contentOpacity : root.open ? 1 : 0 + scale: root.open || root.notch ? 1 : 1 - 0.04 * Theme.intensity clip: true Behavior on width { enabled: !root.notch diff --git a/quickshell/launcher/NotchSearch.qml b/quickshell/launcher/NotchSearch.qml new file mode 100644 index 0000000..e8fafca --- /dev/null +++ b/quickshell/launcher/NotchSearch.qml @@ -0,0 +1,233 @@ +pragma ComponentBehavior: Bound +import QtQuick +import "../core" +import "../services" +import "../theme" + +// The launcher in notch mode: a search field and a row of top matches inside +// the widened notch, the way a notification shows there. Enter launches the +// highlighted match, Tab and the arrow keys move along the row, Escape clears +// and then closes. Clipboard history and emoji open the launcher window. +Item { + id: root + property bool active: false + readonly property string query: input.text.trim() + readonly property bool commandMode: query.startsWith(">") + readonly property int maxShown: 6 + readonly property var results: (commandMode ? commands.results : apps.results).slice(0, maxShown) + property int selectedIndex: 0 + property string launchError: "" + readonly property var selected: results[selectedIndex] || null + onResultsChanged: selectedIndex = 0 + onActiveChanged: { + input.text = ""; + launchError = ""; + selectedIndex = 0; + if (active) + Qt.callLater(() => input.forceActiveFocus()); + } + + AppSearch { + id: apps + enabled: root.active && root.query !== "" && !root.commandMode + query: root.query + limit: root.maxShown + } + CommandSearch { + id: commands + enabled: root.active && root.commandMode + query: root.query + limit: root.maxShown + } + function select(offset) { + if (results.length) + selectedIndex = (selectedIndex + offset + results.length) % results.length; + } + function activate(index) { + const result = results[index]; + if (!result) + return; + if (result.command) { + const command = CommandRegistry.commands.find(c => c.id === result.id); + if (!command || !command.stay) + ShellState.launcherOpen = false; + CommandRegistry.execute(result.id); + } else if (ApplicationsService.launch(result.entry, null)) + ShellState.launcherOpen = false; + else + launchError = ApplicationsService.error; + } + + // Swallows clicks so they reach the field, not the pill behind it. + MouseArea { + anchors.fill: parent + onClicked: input.forceActiveFocus() + } + Text { + id: glass + x: 14 + anchors.verticalCenter: parent.verticalCenter + text: Icons.available ? "󰍉" : "⌕" + font.family: Icons.available ? Icons.family : "" + font.pixelSize: 17 + color: Theme.textSecondary + } + // Typed text, then the highlighted match's name in grey after it. + Item { + id: field + anchors.left: glass.right + anchors.leftMargin: 10 + anchors.right: strip.left + anchors.rightMargin: 12 + anchors.verticalCenter: parent.verticalCenter + height: 24 + clip: true + TextInput { + id: input + objectName: "notchSearchInput" + anchors.verticalCenter: parent.verticalCenter + width: Math.max(1, Math.min(contentWidth + 2, field.width)) + color: Theme.text + selectionColor: Theme.accent + selectedTextColor: Theme.text + font.pixelSize: 15 + maximumLength: 256 + onTextEdited: root.launchError = "" + Keys.onEscapePressed: { + if (text !== "") + clear(); + else + ShellState.launcherOpen = false; + } + Keys.onTabPressed: root.select(1) + Keys.onBacktabPressed: root.select(-1) + Keys.onDownPressed: root.select(1) + Keys.onUpPressed: root.select(-1) + Keys.onRightPressed: event => { + if (cursorPosition === text.length && root.results.length) + root.select(1); + else + event.accepted = false; + } + Keys.onLeftPressed: event => { + if (cursorPosition === text.length && root.selectedIndex > 0) + root.select(-1); + else + event.accepted = false; + } + Keys.onReturnPressed: root.activate(root.selectedIndex) + Keys.onEnterPressed: root.activate(root.selectedIndex) + } + Text { + anchors.verticalCenter: parent.verticalCenter + x: input.text === "" ? 0 : input.width + 8 + width: Math.max(0, field.width - x) + elide: Text.ElideRight + font.pixelSize: 15 + color: root.launchError ? Theme.urgent : Theme.textSecondary + text: root.launchError ? root.launchError : input.text === "" ? "Search apps" : root.selected ? "— " + root.selected.title : "No matches" + } + } + // Top matches; the highlighted one launches on Enter. + Row { + id: strip + anchors.right: modes.left + anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + spacing: 4 + Repeater { + model: root.results + Rectangle { + id: tile + required property var modelData + required property int index + readonly property bool current: index === root.selectedIndex + width: 34 + height: 34 + radius: 10 + color: current ? Qt.alpha(Theme.accent, 0.35) : tileArea.containsMouse ? Theme.hover : Theme.transparent + border.width: current ? 1 : 0 + border.color: Qt.alpha(Theme.accent, 0.8) + Accessible.role: Accessible.Button + Accessible.name: modelData.title + Image { + id: tileIcon + anchors.centerIn: parent + width: 24 + height: 24 + source: tile.modelData.entry ? ApplicationsService.icon(tile.modelData.entry) : "" + sourceSize: Qt.size(48, 48) + asynchronous: true + smooth: true + mipmap: true + } + Text { + anchors.centerIn: parent + visible: tileIcon.status !== Image.Ready + text: tile.modelData.command ? (Icons.available ? "󰒓" : ">") : tile.modelData.title.charAt(0).toUpperCase() + font.family: Icons.available ? Icons.family : "" + font.pixelSize: 15 + color: Theme.text + } + MouseArea { + id: tileArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onEntered: root.selectedIndex = tile.index + onClicked: root.activate(tile.index) + } + } + } + } + // Clipboard history and emoji open the full launcher window. + Row { + id: modes + anchors.right: parent.right + anchors.rightMargin: 12 + anchors.verticalCenter: parent.verticalCenter + spacing: 4 + Repeater { + model: [ + { + mode: "clipboard", + glyph: "󰅌", + fallback: "C", + name: "Clipboard history" + }, + { + mode: "emoji", + glyph: "󰞅", + fallback: ":)", + name: "Emoji" + } + ] + Rectangle { + id: mode + required property var modelData + width: 28 + height: 28 + radius: 14 + color: modeArea.containsMouse ? Theme.hover : Theme.fill + border.width: 1 + border.color: Theme.hairline + Accessible.role: Accessible.Button + Accessible.name: modelData.name + Text { + anchors.centerIn: parent + text: Icons.available ? mode.modelData.glyph : mode.modelData.fallback + font.family: Icons.available ? Icons.family : "" + font.pixelSize: 14 + color: Theme.text + } + MouseArea { + id: modeArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: ShellState.openLauncher(mode.modelData.mode) + } + } + } + } +} diff --git a/quickshell/launcher/qmldir b/quickshell/launcher/qmldir index 98b5dfc..0c81257 100644 --- a/quickshell/launcher/qmldir +++ b/quickshell/launcher/qmldir @@ -3,3 +3,4 @@ singleton LauncherState 1.0 LauncherState.qml AppSearch 1.0 AppSearch.qml CommandSearch 1.0 CommandSearch.qml Launcher 1.0 Launcher.qml +NotchSearch 1.0 NotchSearch.qml diff --git a/quickshell/notch/NotchPill.qml b/quickshell/notch/NotchPill.qml index 9395aaa..7d07e6c 100644 --- a/quickshell/notch/NotchPill.qml +++ b/quickshell/notch/NotchPill.qml @@ -2,13 +2,15 @@ pragma ComponentBehavior: Bound import QtQuick import "../components" import "../core" +import "../launcher" import "../services" import "../theme" // The collapsed notch: a glass island hanging from the screen's top edge with // concave ears, showing the time, plus cover art and a small visualizer while // audio plays. Clicking it opens the notch panel. A new notification widens -// it: the clock and media keep the left end, the banner takes the right. +// it: the clock and media keep the left end, the banner takes the right. The +// launcher opens the same way, with the search where the banner would be. Item { id: root property var barScreen @@ -24,11 +26,13 @@ Item { if (latest) notice = latest; } - readonly property bool showing: !!latest && owner && visible + readonly property bool searching: ShellState.notchSearch && ScreenService.current(ShellState.launcherScreen) === barScreen && visible + readonly property bool showing: !!latest && owner && visible && !searching // Holds the last banner while the notch closes around it. property var notice: null readonly property int noticeWidth: 340 - readonly property real bodyWidth: ShellState.notchPillWidth + (showing ? noticeWidth : 0) + readonly property int searchWidth: 520 + readonly property real bodyWidth: ShellState.notchPillWidth + (searching ? searchWidth : showing ? noticeWidth : 0) implicitWidth: bodyWidth + 2 * BarDrawers.ear implicitHeight: BarDrawers.bottom Behavior on implicitWidth { @@ -203,6 +207,34 @@ Item { } } } + Item { + objectName: "notchSearch" + x: lead.x + lead.width + width: Math.max(0, root.width - BarDrawers.ear - x) + height: root.height + clip: true + opacity: root.searching ? 1 : 0 + visible: width > 1 && opacity > 0 + Behavior on opacity { + NumberAnimation { + duration: root.searching ? Theme.notchDuration * 1.6 : Theme.notchDuration * 0.6 + easing.type: Easing.OutCubic + } + } + Rectangle { + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + width: 1 + height: parent.height * 0.5 + color: Theme.hairline + } + // Laid out at full width so it does not reflow while the notch grows. + NotchSearch { + width: root.searchWidth + height: parent.height + active: root.searching + } + } // 0 (critical) stays until dismissed. Each banner's time counts from its // arrival, so older ones revealed by an expiry leave on schedule; hovering // restarts the full time.