Panels relied on Hyprland sending every click to a layer with exclusive keyboard focus; it does not, so clicking another window or monitor left the Control Center, Dashboard, notch, Overview, Settings, wallpaper picker, launcher and plugin panels open. A shared OutsideClick holds a Hyprland focus grab while a panel is open and closes it when the grab is cleared. The bars count as inside, so a bar button still toggles its panel. The old catchers stay as a fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
5.9 KiB
QML
157 lines
5.9 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import "../components"
|
|
import "../theme"
|
|
import "../core"
|
|
|
|
// 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
|
|
// empty bar) browses every application as an icon grid; > lists commands.
|
|
// Clipboard mode (>clipboard, `glassmxrph clipboard`) lists cliphist history
|
|
// in the same bar, newest first, without closing the window to switch.
|
|
// Emoji mode (>emoji, `glassmxrph emoji`) shows a searchable emoji grid the
|
|
// same way; the selected emoji's name is the section label.
|
|
// The contents are LauncherView; in notch mode the notch hosts that instead
|
|
// and this window stays closed.
|
|
// Runtime selects the concrete Wayland layer implementation.
|
|
// qmllint disable uncreatable-type
|
|
PanelWindow {
|
|
// qmllint enable uncreatable-type
|
|
id: root
|
|
screen: ScreenService.current(ShellState.launcherScreen)
|
|
anchors {
|
|
top: true
|
|
bottom: true
|
|
left: true
|
|
right: true
|
|
}
|
|
readonly property bool open: ShellState.launcherOpen && !ShellState.notchMode
|
|
visible: open || panel.opacity > 0.01
|
|
color: Theme.transparent
|
|
exclusionMode: ExclusionMode.Ignore
|
|
WlrLayershell.namespace: "glassMxrph-launcher"
|
|
WlrLayershell.layer: WlrLayer.Overlay
|
|
WlrLayershell.keyboardFocus: open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
|
readonly property var options: view.options
|
|
// Room is kept for the mode pills on the right of the bar.
|
|
readonly property int pillSize: 48
|
|
readonly property real pillsWidth: 2 * pillSize + 2 * 10
|
|
readonly property real targetWidth: Math.min(options.width, root.width - 40 - 2 * pillsWidth)
|
|
function toggleBrowse() {
|
|
view.toggleBrowse();
|
|
}
|
|
Component.onCompleted: LauncherState.window = root
|
|
Component.onDestruction: LauncherState.window = null
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: ShellState.launcherOpen = false
|
|
}
|
|
// The window covers its screen; this catches clicks on other monitors.
|
|
OutsideClick {
|
|
window: root
|
|
active: root.open
|
|
onOutside: ShellState.launcherOpen = false
|
|
}
|
|
// Mode pills beside the search bar (macOS Spotlight style): each toggles
|
|
// its launcher mode; the active one is filled.
|
|
Row {
|
|
id: pills
|
|
objectName: "launcherPills"
|
|
x: panel.x + panel.width + 10
|
|
y: panel.y + (view.barHeight - root.pillSize) / 2
|
|
z: 1
|
|
spacing: 10
|
|
opacity: panel.opacity
|
|
scale: panel.scale
|
|
Repeater {
|
|
model: view.modes
|
|
GlassPanel {
|
|
id: pill
|
|
required property var modelData
|
|
readonly property bool active: ShellState.launcherMode === modelData.mode
|
|
objectName: "launcherPill-" + modelData.mode
|
|
width: root.pillSize
|
|
height: width
|
|
radius: width / 2
|
|
color: active ? Theme.accent : Qt.alpha(Theme.surface, Math.min(1, surfaceOpacity + (pillArea.containsMouse ? 0.18 : 0)))
|
|
border.color: Theme.border
|
|
Accessible.role: Accessible.Button
|
|
Accessible.name: modelData.label
|
|
scale: pillArea.pressed ? 0.92 : 1
|
|
Behavior on scale {
|
|
NumberAnimation {
|
|
duration: Theme.duration / 2
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback
|
|
font.family: Icons.available ? Icons.family : ""
|
|
font.pixelSize: 21
|
|
color: pill.active ? Theme.accentText : Theme.text
|
|
}
|
|
MouseArea {
|
|
id: pillArea
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onContainsMouseChanged: {
|
|
if (containsMouse)
|
|
view.pillHover = pill.modelData.label;
|
|
else if (view.pillHover === pill.modelData.label)
|
|
view.pillHover = "";
|
|
}
|
|
onClicked: view.toggleMode(pill.modelData.mode)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
GlassPanel {
|
|
id: panel
|
|
objectName: "launcherSurface"
|
|
x: Math.round((root.width - width) / 2)
|
|
y: Math.round(root.height * 0.22)
|
|
width: root.open ? root.targetWidth : Math.min(320, root.targetWidth)
|
|
height: view.barHeight + view.bodyHeight
|
|
color: Qt.alpha(Theme.surface, surfaceOpacity)
|
|
border.width: 1
|
|
radius: Math.min(Theme.radius + 6, view.barHeight / 2)
|
|
opacity: root.open ? 1 : 0
|
|
scale: root.open ? 1 : 1 - 0.04 * Theme.intensity
|
|
clip: true
|
|
Behavior on width {
|
|
NumberAnimation {
|
|
duration: Theme.duration
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
Behavior on height {
|
|
enabled: !view.snapping
|
|
NumberAnimation {
|
|
duration: Theme.duration
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
Behavior on opacity {
|
|
NumberAnimation {
|
|
duration: Theme.duration
|
|
}
|
|
}
|
|
Behavior on scale {
|
|
NumberAnimation {
|
|
duration: Theme.duration
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
LauncherView {
|
|
id: view
|
|
anchors.fill: parent
|
|
active: root.open
|
|
maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - root.height * 0.22)
|
|
}
|
|
}
|
|
}
|