diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-08-05 18:05:18 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-08-07 17:27:45 +0800 |
| commit | 374215148a08f75f84adf730187986735b18c45b (patch) | |
| tree | 3d8a0184e7e07235301a67d255f866d891556593 | |
| parent | 336432ad45c8ca02acfb3e731561c385dd2cba74 (diff) | |
perf(launcher:selection): if check instead of function clamp
| -rw-r--r-- | launcher/Launcher.qml | 23 | ||||
| -rw-r--r-- | launcher/components/SelectionState.qml | 9 |
2 files changed, 8 insertions, 24 deletions
diff --git a/launcher/Launcher.qml b/launcher/Launcher.qml index 9b49699..7577139 100644 --- a/launcher/Launcher.qml +++ b/launcher/Launcher.qml @@ -358,15 +358,6 @@ ILauncher { let set = 0; - // normalize to keep selectedPriority within bounds - function clampPriority() { - const max = Math.max(0, SelectionState.priorities.length - 1); - if (SelectionState.selectedPriority < 0) - SelectionState.selectedPriority = max; - else if (SelectionState.selectedPriority > max) - SelectionState.selectedPriority = 0; - } - switch (direction) { case 1: if (item.prev()) @@ -388,21 +379,15 @@ ILauncher { switch (set) { case 1: - SelectionState.selectedPriority++; - clampPriority(); + if (SelectionState.selectedPriority < SelectionState.priorities.length - 1) + SelectionState.selectedPriority++; break; case -1: - SelectionState.selectedPriority--; - clampPriority(); + if (SelectionState.selectedPriority > 0) + SelectionState.selectedPriority--; break; } - // try focus handoff to the new item if it exposes focus/select API - const newItem = SelectionState?.priorities[SelectionState.selectedPriority] || null; - if (newItem && newItem.focus) - newItem.focus(); - - // sync selection rectangle after priority change selectionSync.running = true; } diff --git a/launcher/components/SelectionState.qml b/launcher/components/SelectionState.qml index d945d70..2e53155 100644 --- a/launcher/components/SelectionState.qml +++ b/launcher/components/SelectionState.qml @@ -12,13 +12,12 @@ Singleton { // order them based on widgets(which came from order from config) onPrioritiesChanged: { - // priorities = priorities.filter(item => item.priority === true); // bind loop - // dunno y ts works w/o triggering a binding loop but okay.. - for (let i = 0; i < priorities.length; i++) - if (priorities[i].priority !== true) + for (let i = priorities.length - 1; i >= 0; i--) + if (!priorities[i] || priorities[i].priority !== true) priorities.splice(i, 1); - priorities.sort((a, b) => widgets.indexOf(a) - widgets.indexOf(b)); + priorities.sort((a, b) => (widgets.indexOf(a) - widgets.indexOf(b)) || 0); + priorities.forEach((item, index) => {}); } |
