summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-08-14 16:15:32 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-08-14 16:15:32 +0800
commite20c465cd276c2c80c253f1b4c201c8e56f1e980 (patch)
treec30b3f36fc2049012cd2ae4de80d4945be800311
parent8b45c0c2506e54fccbdb83b423be627a7a43f56e (diff)
perf: delayed heavy processing
seems stupid but it actually allows the UI thread to get priority and render first, giving a more smooth expereince
-rw-r--r--launcher/Launcher.qml14
-rw-r--r--services/Clip.qml19
2 files changed, 28 insertions, 5 deletions
diff --git a/launcher/Launcher.qml b/launcher/Launcher.qml
index 8ac9032..44da816 100644
--- a/launcher/Launcher.qml
+++ b/launcher/Launcher.qml
@@ -109,15 +109,19 @@ ILauncher {
spacing: 0
TextInput {
id: textInput
+ property bool pendingUpdate: false
+
Layout.fillHeight: true
Layout.fillWidth: true
Layout.maximumWidth: implicitWidth
+
color: Colors.foreground1
selectionColor: Colors.background3
+
text: launcher.state?.input || ""
clip: true
focus: true
- renderType: Text.CurveRendering
+
antialiasing: true
smooth: true
font {
@@ -174,7 +178,13 @@ ILauncher {
}
onTextChanged: {
if (launcher.state.input !== textInput.text)
- launcher.state.input = textInput.text; // TODO: find ways to optimize this, like how i was using an alias
+ pendingUpdate = true;
+ Qt.callLater(() => {
+ if (pendingUpdate) {
+ pendingUpdate = false;
+ launcher.state.input = textInput.text; // TODO: find ways to optimize this, like how i was using an alias
+ }
+ });
}
onCursorPositionChanged: {
launcher.state.cursorPosition = textInput.cursorPosition;
diff --git a/services/Clip.qml b/services/Clip.qml
index 1bf78d0..b83c6d8 100644
--- a/services/Clip.qml
+++ b/services/Clip.qml
@@ -87,8 +87,15 @@ Searchable {
running: true
command: ["cliphist", "-preview-width", 9 ** 9, "-max-items", 9 ** 9, "list"]
stdout: StdioCollector {
+ property bool pending: false
onStreamFinished: () => {
- _clipHist = this.text.split(/\r?\n/);
+ pending = true;
+ Qt.callLater(() => {
+ if (pending) {
+ pending = false;
+ _clipHist = this.text.split(/\r?\n/);
+ }
+ });
}
}
}
@@ -98,8 +105,15 @@ Searchable {
running: true
command: ["sh", Quickshell.shellDir + "/utils/cliphist-img.sh"]
stdout: StdioCollector {
+ property bool pending: false
onStreamFinished: () => {
- _clipImg = this.text.split(/\r?\n/);
+ pending = true;
+ Qt.callLater(() => {
+ if (pending) {
+ pending = false;
+ _clipImg = this.text.split(/\r?\n/);
+ }
+ });
}
}
}
@@ -122,7 +136,6 @@ Searchable {
stdout: SplitParser {
onRead: line => {
- console.log('h');
_update();
}
}