diff --git a/CLAUDE.md b/CLAUDE.md
index bacd590..c02e05f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -92,6 +92,7 @@ Never modify: `PROMPT.md` (the user's brief), the user's other projects under `~
| `TUNAL_SETTINGS=<0-5> cargo run -p tunal --
--screenshot --size 1000x700` (`XDG_CONFIG_HOME=`) | settings dialog page over a folder | S013 |
| `TUNAL_DRAG=x1,y1,x2,y2[,hold] TUNAL_REDUCED_MOTION=1 cargo run -p tunal -- --screenshot --size 1200x760` (`XDG_CONFIG_HOME=`) | drags between window points and drops (drop menu) or holds (glow + drag image) before the frame | S014 |
| `Xvfb :97 &` then `env -u WAYLAND_DISPLAY DISPLAY=:97 target/debug/tunal &` and `DISPLAY=:97 target/debug/examples/xdnd_probe x1 y1 x2 y2` (or `in x y `) | X11 native DnD: fake XTEST drag out of the window onto a probe target, or a probe source dropping into the app; Xvfb only | S031 |
+| same, with `SLINT_BACKEND=winit-software` (so `DISPLAY=:97 import -window root ` captures it), then `DISPLAY=:97 target/debug/examples/xdnd_probe click x y [count] [gap_ms] [hover_ms]` | real clicks (XTEST) on a window point after resting `hover_ms` there, e.g. the split toggle with a tooltip showing; Xvfb only | split/tooltip fix |
| `TUNAL_APPEARANCE=1 XDG_CONFIG_HOME= cargo run -p tunal -- --screenshot --size 1000x760` | folder appearance dialog for `` (theme icons looked up at once); `cargo run -p tunal-dirmeta --example roundtrip -- ` sets `Icon` in `/.directory` and prints the old values | S015 |
| `TUNAL_PLAY= XDG_CONFIG_HOME= cargo run -p tunal -- --screenshot [--dark] --size 1200x760` | player bar open on that file, a third in (tags, cover, waveform read at once; no audio output) | S023 |
| `TUNAL_TAGS=editor\|lookup\|mapping\|apply:: TUNAL_TAGS_SYNC=1 TUNAL_MUSICBRAINZ= XDG_CONFIG_HOME= cargo run -p tunal -- --screenshot --size 1000x760` | tag editor / lookup / mapping over a folder; `apply` also writes the tags (scratch copies only); mock = a local server for both services | S021 |
diff --git a/crates/tunal/examples/xdnd_probe.rs b/crates/tunal/examples/xdnd_probe.rs
index 67f615f..c20ca10 100644
--- a/crates/tunal/examples/xdnd_probe.rs
+++ b/crates/tunal/examples/xdnd_probe.rs
@@ -5,6 +5,10 @@
//!
//! `xdnd_probe in x y uri`: the other way round, a source dropping `uri` (as
//! `text/uri-list`) on the window at (x, y); prints the target's status and finish.
+//!
+//! `xdnd_probe click x y [count] [gap_ms] [hover_ms]`: moves the pointer to (x, y), rests
+//! there `hover_ms` (default 0), then clicks `count` times (default 1) `gap_ms` apart
+//! (default 400), printing the seconds since the epoch of each click.
use std::time::{Duration, Instant};
@@ -29,6 +33,9 @@ fn main() {
if std::env::args().nth(1).as_deref() == Some("in") {
return drag_in();
}
+ if std::env::args().nth(1).as_deref() == Some("click") {
+ return click();
+ }
let n: Vec = std::env::args()
.skip(1)
.filter_map(|a| a.parse().ok())
@@ -139,6 +146,50 @@ fn main() {
}
}
+fn click() {
+ let n: Vec = std::env::args()
+ .skip(2)
+ .filter_map(|a| a.parse().ok())
+ .collect();
+ let (x, y, count, gap, hover) = match n[..] {
+ [x, y] => (x, y, 1, 400, 0),
+ [x, y, c] => (x, y, c, 400, 0),
+ [x, y, c, g] => (x, y, c, g, 0),
+ [x, y, c, g, h] => (x, y, c, g, h),
+ _ => {
+ eprintln!("usage: xdnd_probe click x y [count] [gap_ms] [hover_ms]");
+ return;
+ }
+ };
+ let (c, screen) = x11rb::connect(None).unwrap();
+ let root = c.setup().roots[screen].root;
+ // Arrive from a few pixels away, as a hand would: the window sees a move onto (x, y).
+ for dx in [4, 0] {
+ c.xtest_fake_input(6, 0, CURRENT_TIME, root, x as i16 - dx, y as i16, 0)
+ .unwrap();
+ c.flush().unwrap();
+ std::thread::sleep(Duration::from_millis(20));
+ }
+ std::thread::sleep(Duration::from_millis(hover.max(30)));
+ for i in 0..count {
+ if i > 0 {
+ std::thread::sleep(Duration::from_millis(gap));
+ }
+ c.xtest_fake_input(4, 1, CURRENT_TIME, root, 0, 0, 0)
+ .unwrap();
+ c.get_input_focus().unwrap().reply().unwrap();
+ std::thread::sleep(Duration::from_millis(40));
+ c.xtest_fake_input(5, 1, CURRENT_TIME, root, 0, 0, 0)
+ .unwrap();
+ // A round trip: the server has taken the release before the next press (or exit).
+ c.get_input_focus().unwrap().reply().unwrap();
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap_or_default();
+ println!("probe: click {} at {:.3}", i + 1, now.as_secs_f64());
+ }
+}
+
fn d_copy(c: &impl Connection) -> u32 {
atom(c, "XdndActionCopy")
}
diff --git a/crates/tunal/src/shell/mod.rs b/crates/tunal/src/shell/mod.rs
index 5d4ac2b..98a6a26 100644
--- a/crates/tunal/src/shell/mod.rs
+++ b/crates/tunal/src/shell/mod.rs
@@ -376,6 +376,8 @@ impl Shell {
}
}
+ /// Splits the current tab (the new pane opens at the active pane's folder) or closes the
+ /// pane that isn't active. The kept pane keeps its view: only the other row changes.
fn toggle_split(&self) {
let (split, dir) = {
let tabs = self.tabs.borrow();
@@ -383,11 +385,18 @@ impl Shell {
(tab.panes.len() > 1, tab.panes[tab.active].dir())
};
if split {
- let mut tabs = self.tabs.borrow_mut();
- let tab = &mut tabs[self.current.get()];
- let keep = tab.panes.remove(tab.active);
- tab.panes = vec![keep];
- tab.active = 0;
+ let other = {
+ let mut tabs = self.tabs.borrow_mut();
+ let tab = &mut tabs[self.current.get()];
+ let keep = tab.panes.remove(tab.active);
+ let other = 1 - tab.active;
+ tab.panes = vec![keep];
+ tab.active = 0;
+ other
+ };
+ if other < self.pane_rows.row_count() {
+ self.pane_rows.remove(other);
+ }
} else {
let pane = self.new_pane(dir.unwrap_or_else(|| Uri::from_path(&places::home())));
let mut tabs = self.tabs.borrow_mut();
@@ -435,7 +444,9 @@ impl Shell {
}
}
- /// Shows the current tab: its panes, then everything that follows the active pane.
+ /// Shows the current tab: its panes, then everything that follows the active pane. Rows
+ /// are updated, added or removed one by one: the pane views already there stay, so
+ /// switching tabs or the split doesn't build every view again.
fn show_current(&self) {
let rows: Vec = {
let tabs = self.tabs.borrow();
@@ -445,12 +456,16 @@ impl Shell {
.map(|p| p.data())
.collect()
};
- if rows.len() == self.pane_rows.row_count() {
- for (i, row) in rows.into_iter().enumerate() {
+ let count = rows.len();
+ for (i, row) in rows.into_iter().enumerate() {
+ if i < self.pane_rows.row_count() {
self.pane_rows.set_row_data(i, row);
+ } else {
+ self.pane_rows.push(row);
}
- } else {
- self.pane_rows.set_vec(rows);
+ }
+ while self.pane_rows.row_count() > count {
+ self.pane_rows.remove(self.pane_rows.row_count() - 1);
}
self.show_chrome();
self.focus_active();
diff --git a/crates/tunal/ui/app.slint b/crates/tunal/ui/app.slint
index 9070b7e..10cecc6 100644
--- a/crates/tunal/ui/app.slint
+++ b/crates/tunal/ui/app.slint
@@ -17,6 +17,7 @@ import { Sidebar, SidebarSection, PlaceItem } from "shell/sidebar.slint";
import { StatusBar } from "shell/status-bar.slint";
import { PlayerBar, PlayerData } from "shell/player-bar.slint";
import { ToastStack, ToastData, ToastProgress } from "components/toast.slint";
+import { TooltipLayer } from "components/tooltip.slint";
import { DialogAction } from "components/dialog.slint";
import { ConflictDialog, ConflictInfo } from "dialogs/conflict.slint";
import { ConfirmDialog } from "dialogs/confirm.slint";
@@ -975,4 +976,8 @@ export component MainWindow inherits Window {
root.toast-removed(i);
}
}
+ TooltipLayer {
+ width: 100%;
+ height: 100%;
+ }
}
diff --git a/crates/tunal/ui/components/icon-button.slint b/crates/tunal/ui/components/icon-button.slint
index 48ed7ca..819191f 100644
--- a/crates/tunal/ui/components/icon-button.slint
+++ b/crates/tunal/ui/components/icon-button.slint
@@ -13,6 +13,9 @@ export component IconButton inherits StateLayer {
// A tonal circle at rest (toolbar buttons) instead of a bare glyph.
in property tonal;
in-out property checked;
+ // The owner keeps `checked` (bound to its own state): a click only reports, so the
+ // binding is never broken by the button flipping it.
+ in property bound;
in property size: 40px;
in property icon-size: 24px;
@@ -35,7 +38,7 @@ export component IconButton inherits StateLayer {
}
activated => {
- if root.toggle {
+ if root.toggle && !root.bound {
root.checked = !root.checked;
}
}
diff --git a/crates/tunal/ui/components/state-layer.slint b/crates/tunal/ui/components/state-layer.slint
index 4b92b1c..32bbbc8 100644
--- a/crates/tunal/ui/components/state-layer.slint
+++ b/crates/tunal/ui/components/state-layer.slint
@@ -1,6 +1,6 @@
import { Theme } from "../theme.slint";
import { Motion, MotionClock } from "../motion.slint";
-import { Tooltip } from "tooltip.slint";
+import { Tips } from "tooltip.slint";
// A state shown regardless of the pointer and focus, for gallery screenshots.
export enum ForceState { none, hover, pressed, focused }
@@ -121,12 +121,12 @@ export component StateLayer inherits Rectangle {
changed has-hover => {
if !self.has-hover {
root.tip-due = false;
- tip.close();
+ root.hide-tip();
}
}
changed pressed => {
if self.pressed {
- tip.close();
+ root.hide-tip();
}
}
}
@@ -183,23 +183,26 @@ export component StateLayer inherits Rectangle {
}
// Runs only while hovered and the tooltip is not yet shown: nothing ticks when idle.
+ // The tooltip itself is the window's `TooltipLayer`.
property tip-due;
+ property tip-owner: -1;
+ function hide-tip() {
+ if Tips.owner == root.tip-owner {
+ Tips.shown = false;
+ }
+ }
Timer {
interval: Motion.tooltip-delay;
running: root.tooltip != "" && touch.has-hover && !touch.pressed && !root.tip-due;
triggered => {
root.tip-due = true;
- tip.show();
- }
- }
-
- tip := PopupWindow {
- close-policy: no-auto-close;
- x: (root.width - self.width) / 2;
- y: root.height + Theme.space-1;
-
- Tooltip {
- text: root.tooltip;
+ Tips.owner += 1;
+ root.tip-owner = Tips.owner;
+ Tips.text = root.tooltip;
+ Tips.x = root.absolute-position.x + root.width / 2;
+ Tips.bottom = root.absolute-position.y + root.height;
+ Tips.top = root.absolute-position.y;
+ Tips.shown = true;
}
}
}
diff --git a/crates/tunal/ui/components/tooltip.slint b/crates/tunal/ui/components/tooltip.slint
index 9144298..a178913 100644
--- a/crates/tunal/ui/components/tooltip.slint
+++ b/crates/tunal/ui/components/tooltip.slint
@@ -33,3 +33,32 @@ export component Tooltip inherits Rectangle {
}
}
}
+
+// The one tooltip of a window, drawn by its `TooltipLayer`. A control's StateLayer fills it
+// in when its hover delay runs out and empties it again when the pointer leaves or presses.
+// (Each control used to open a PopupWindow of its own: while one showed, Slint dropped every
+// click outside it, so the second click on a button often did nothing.)
+export global Tips {
+ in-out property text;
+ // Window coordinates of the control's centre, its bottom and its top.
+ in-out property x;
+ in-out property bottom;
+ in-out property top;
+ in-out property shown;
+ // Bumped by each control that shows the tooltip: only the latest one hides it.
+ in-out property owner;
+}
+
+// Draws `Tips` above everything else in the window: place it last (`width: 100%;
+// height: 100%;`). It has no touch area, so the pointer goes through it.
+export component TooltipLayer inherits Rectangle {
+ if Tips.shown: tip := Tooltip {
+ text: Tips.text;
+ width: self.preferred-width;
+ x: clamp(Tips.x - self.width / 2, Theme.window-margin, max(Theme.window-margin, root.width - self.width - Theme.window-margin));
+ // Below the control, or above it when there is no room below.
+ y: Tips.bottom + Theme.space-1 + self.height + Theme.window-margin <= root.height
+ ? Tips.bottom + Theme.space-1
+ : Tips.top - Theme.space-1 - self.height;
+ }
+}
diff --git a/crates/tunal/ui/gallery.slint b/crates/tunal/ui/gallery.slint
index d89d8f2..c8e7e73 100644
--- a/crates/tunal/ui/gallery.slint
+++ b/crates/tunal/ui/gallery.slint
@@ -2,7 +2,7 @@ import { Theme } from "theme.slint";
import { Icon, Icons } from "components/icon.slint";
import { Shape, ShapeKind, FileShapes } from "components/shape.slint";
import { ForceState } from "components/state-layer.slint";
-import { Tooltip } from "components/tooltip.slint";
+import { Tooltip, TooltipLayer } from "components/tooltip.slint";
import { Button, ButtonKind } from "components/button.slint";
import { IconButton } from "components/icon-button.slint";
import { Chip, ChipKind } from "components/chip.slint";
@@ -486,4 +486,8 @@ export component Gallery inherits Window {
}
}
+ TooltipLayer {
+ width: 100%;
+ height: 100%;
+ }
}
diff --git a/crates/tunal/ui/shell/toolbar.slint b/crates/tunal/ui/shell/toolbar.slint
index c08d7ca..adc11ba 100644
--- a/crates/tunal/ui/shell/toolbar.slint
+++ b/crates/tunal/ui/shell/toolbar.slint
@@ -63,6 +63,7 @@ export component Toolbar inherits Rectangle {
IconButton {
icon: Icons.side-navigation;
toggle: true;
+ bound: true;
checked: root.sidebar;
tooltip: "Sidebar (F9)";
clicked => {
@@ -148,14 +149,10 @@ export component Toolbar inherits Rectangle {
if !root.compact: VerticalLayout {
alignment: center;
IconButton {
- // `checked` is flipped by the click: follow `previews` again after it.
- property state: root.previews;
icon: Icons.image;
toggle: true;
- checked: self.state;
- changed state => {
- self.checked = self.state;
- }
+ bound: true;
+ checked: root.previews;
tooltip: "Previews";
clicked => {
root.previews-toggled();
@@ -180,6 +177,7 @@ export component Toolbar inherits Rectangle {
IconButton {
icon: Icons.vertical-split;
toggle: true;
+ bound: true;
checked: root.split;
tooltip: "Split view (F3)";
clicked => {