Laucher: Fix wayland warning about focus surface stealing

This commit is contained in:
LemmyCook 2025-09-03 08:05:06 -04:00
parent 1599ee5682
commit 7548ffc191
2 changed files with 89 additions and 83 deletions

View file

@ -174,30 +174,40 @@ NPanel {
anchors.margins: Style.marginL * scaling anchors.margins: Style.marginL * scaling
spacing: Style.marginM * scaling spacing: Style.marginM * scaling
// Wrapper ensures the input stretches to full width under RowLayout FocusScope {
Item {
id: searchInputWrap id: searchInputWrap
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: Math.round(Style.barHeight * scaling) Layout.preferredHeight: Math.round(Style.barHeight * scaling)
// Search input // This FocusScope should get focus when panel opens
focus: true
NTextInput { NTextInput {
id: searchInput id: searchInput
anchors.fill: parent // The NTextInput fills the wrapper anchors.fill: parent
Layout.preferredHeight: Style.barHeight * scaling
// The input should have focus within the scope
focus: true
placeholderText: "Search entries... or use > for commands" placeholderText: "Search entries... or use > for commands"
text: searchText text: searchText
inputMaxWidth: Number.MAX_SAFE_INTEGER inputMaxWidth: Number.MAX_SAFE_INTEGER
function forceActiveFocus() { function forceActiveFocus() {
// First ensure the scope has focus
searchInputWrap.forceActiveFocus()
// Then focus the actual input
if (inputItem && inputItem.visible) {
inputItem.forceActiveFocus() inputItem.forceActiveFocus()
} }
}
Component.onCompleted: { Component.onCompleted: {
if (inputItem) {
inputItem.font.pointSize = Style.fontSizeL * scaling inputItem.font.pointSize = Style.fontSizeL * scaling
inputItem.verticalAlignment = TextInput.AlignVCenter inputItem.verticalAlignment = TextInput.AlignVCenter
} }
}
onTextChanged: searchText = text onTextChanged: searchText = text

View file

@ -31,25 +31,22 @@ QtObject {
// Return available commands when user types ">" // Return available commands when user types ">"
function commands() { function commands() {
return [ return [{
{ "name": ">clip",
name: ">clip", "description": "Search clipboard history",
description: "Search clipboard history", "icon": "content_paste",
icon: "content_paste", "onActivate": function () {
onActivate: function() {
launcher.setSearchText(">clip ") launcher.setSearchText(">clip ")
} }
}, }, {
{ "name": ">clip clear",
name: ">clip clear", "description": "Clear all clipboard history",
description: "Clear all clipboard history", "icon": "delete_sweep",
icon: "delete_sweep", "onActivate": function () {
onActivate: function() {
CliphistService.wipeAll() CliphistService.wipeAll()
launcher.close() launcher.close()
} }
} }]
]
} }
// Get search results // Get search results
@ -64,10 +61,10 @@ QtObject {
// Special command: clear // Special command: clear
if (query === "clear") { if (query === "clear") {
return [{ return [{
name: "Clear Clipboard History", "name": "Clear Clipboard History",
description: "Remove all items from clipboard history", "description": "Remove all items from clipboard history",
icon: "delete_sweep", "icon": "delete_sweep",
onActivate: function() { "onActivate": function () {
CliphistService.wipeAll() CliphistService.wipeAll()
launcher.close() launcher.close()
} }
@ -110,11 +107,10 @@ QtObject {
// Show empty state if no results // Show empty state if no results
if (results.length === 0) { if (results.length === 0) {
results.push({ results.push({
name: searchTerm ? "No matching clipboard items" : "Clipboard is empty", "name": searchTerm ? "No matching clipboard items" : "Clipboard is empty",
description: searchTerm ? `No items containing "${query}"` : "Copy something to see it here", "description": searchTerm ? `No items containing "${query}"` : "Copy something to see it here",
icon: "content_paste_off", "icon": "content_paste_off",
onActivate: function() { "onActivate": function () {// Do nothing
// Do nothing
} }
}) })
} }
@ -127,9 +123,9 @@ QtObject {
const meta = parseImageMeta(item.preview) const meta = parseImageMeta(item.preview)
return { return {
name: meta ? `Image ${meta.w}×${meta.h}` : "Image", "name": meta ? `Image ${meta.w}×${meta.h}` : "Image",
description: meta ? `${meta.fmt} ${meta.size}` : item.mime || "Image data", "description": meta ? `${meta.fmt} ${meta.size}` : item.mime || "Image data",
icon: "image" "icon": "image"
} }
} }
@ -158,9 +154,9 @@ QtObject {
} }
return { return {
name: title, "name": title,
description: description, "description": description,
icon: "description" "icon": "description"
} }
} }
@ -174,10 +170,10 @@ QtObject {
} }
return { return {
size: match[1], "size": match[1],
fmt: (match[2] || "").toUpperCase(), "fmt": (match[2] || "").toUpperCase(),
w: Number(match[3]), "w": Number(match[3]),
h: Number(match[4]) "h": Number(match[4])
} }
} }
} }