Launcher: list recently opened apps first, latest first
- Apps opened recently now lead the launcher and the desktop, newest first, ahead of the defaults. - Remember up to 200 launches (was 8), so the recent order holds over time. - Apps not recently opened follow the defaults, then the rest A-Z. - Add a test for the launcher order and for recents moving apps in and out. - Update the Desk::shown and default-group comments to match. - Update the display interface with the touch seat events.
This commit is contained in:
1 parent
e30d9cc71f
commit
cb0ff0715e
3 files changed
+45
-13
No files matched your search
+32
-11
@@ -572,7 +572,7 @@ pub fn DesktopShell::set_output(self : DesktopShell, theme : @scene.ThemeTokens,
|
||||
self.panel_h = theme.panel_height
|
||||
}
|
||||
|
||||
///| Default launcher entries, in order: each group is matched against app ids (first hit wins).
|
||||
///| Apps listed ahead of the other never-opened ones, in order: each group is matched against app ids (first hit wins).
|
||||
let default_groups : Array[Array[String]] = [
|
||||
["foot", "konsole", "terminal", "kitty", "alacritty"],
|
||||
["dolphin", "nautilus", "thunar", "files"],
|
||||
@@ -581,8 +581,8 @@ let default_groups : Array[Array[String]] = [
|
||||
["systemsettings", "settings", "control"],
|
||||
]
|
||||
|
||||
///|
|
||||
let max_recents : Int = 8
|
||||
///| Launches remembered: enough that the launcher is in recently-opened order throughout.
|
||||
let max_recents : Int = 200
|
||||
|
||||
///|
|
||||
fn recents_path() -> String {
|
||||
@@ -604,9 +604,11 @@ fn load_recents() -> Array[String] {
|
||||
out
|
||||
}
|
||||
|
||||
///| Reorder the launcher: defaults first, then recents (newest first), then the rest A-Z.
|
||||
///| Reorder the launcher: opened apps first (latest first), then the defaults, then the rest A-Z.
|
||||
fn DesktopShell::order_apps(self : DesktopShell) -> Unit {
|
||||
let by_id : Map[String, @types.AppEntry] = {}
|
||||
// `apps` is in its last order: back to A-Z first. Strings compare shortest first; menus want A-Z.
|
||||
self.apps.sort_by((a, b) => a.name.to_lower().lexical_compare(b.name.to_lower()))
|
||||
for a in self.apps {
|
||||
by_id.set(a.id, a)
|
||||
}
|
||||
@@ -618,6 +620,12 @@ fn DesktopShell::order_apps(self : DesktopShell) -> Unit {
|
||||
out.push(a)
|
||||
}
|
||||
}
|
||||
for id in self.recents {
|
||||
match by_id.get(id) {
|
||||
Some(a) => take(a, out, seen)
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
for g in default_groups {
|
||||
let mut found = false
|
||||
for key in g {
|
||||
@@ -633,14 +641,8 @@ fn DesktopShell::order_apps(self : DesktopShell) -> Unit {
|
||||
}
|
||||
}
|
||||
}
|
||||
for id in self.recents {
|
||||
match by_id.get(id) {
|
||||
Some(a) => take(a, out, seen)
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
for a in self.apps {
|
||||
take(a, out, seen) // already A-Z from the scan
|
||||
take(a, out, seen)
|
||||
}
|
||||
self.apps.clear()
|
||||
for a in out {
|
||||
@@ -1250,3 +1252,22 @@ pub fn DesktopShell::render(
|
||||
}
|
||||
(bg, panel_ops)
|
||||
}
|
||||
|
||||
///|
|
||||
test "the launcher lists opened apps latest first, then defaults, then A-Z" {
|
||||
let s = DesktopShell::new(":0")
|
||||
s.apps.clear()
|
||||
s.recents.clear()
|
||||
for id in ["zed", "foot", "beta", "alpha", "mid"] {
|
||||
s.apps.push({ id, name: id, comment: "", category: "", glyph: "" })
|
||||
}
|
||||
s.order_apps()
|
||||
assert_eq(s.apps.map(a => a.id), ["foot", "alpha", "beta", "mid", "zed"])
|
||||
s.note_recent("zed")
|
||||
s.note_recent("mid")
|
||||
assert_eq(s.apps.map(a => a.id), ["mid", "zed", "foot", "alpha", "beta"])
|
||||
// An app that is no longer recent goes back to its A-Z place.
|
||||
s.recents.clear()
|
||||
s.note_recent("foot")
|
||||
assert_eq(s.apps.map(a => a.id), ["foot", "alpha", "beta", "mid", "zed"])
|
||||
}
|
||||
@@ -60,6 +60,17 @@ pub(all) enum SeatEvent {
|
||||
Key(KeyState)
|
||||
Modifiers(Modifiers)
|
||||
Scroll(ScrollDelta)
|
||||
TouchDown(TouchPoint)
|
||||
TouchMotion(TouchPoint)
|
||||
TouchUp(Int32)
|
||||
TouchCancel
|
||||
TouchPresent
|
||||
}
|
||||
|
||||
pub(all) struct TouchPoint {
|
||||
id : Int32
|
||||
x : Double
|
||||
y : Double
|
||||
}
|
||||
|
||||
// Type aliases
|
||||
|
||||
@@ -123,8 +123,8 @@ pub fn Desk::grid(self : Desk) -> (Int, Int) {
|
||||
(if cols < 1 { 1 } else { cols }, if rows < 1 { 1 } else { rows })
|
||||
}
|
||||
|
||||
///| The apps on the desktop: the first `count` of the catalog (its defaults and recent apps come
|
||||
/// first).
|
||||
///| The apps on the desktop: the first `count` of the catalog (its recently opened apps come
|
||||
/// first, then the defaults).
|
||||
pub fn Desk::shown(self : Desk, apps : Array[@types.AppEntry]) -> Array[@types.AppEntry] {
|
||||
let n = match self.count {
|
||||
"All" => apps.length()
|
||||
|
||||
Reference in new issue
Block a user