summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev/gui/gui.zig12
-rw-r--r--test/daemon.py118
2 files changed, 94 insertions, 36 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index 2756f69b..2e5dc5c2 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -1530,6 +1530,9 @@ const StdinFeed = struct {
// window pixels, built as SDL would and run through dispatch,
// so a driver exercises the real pointer path (pixel to cell,
// tag and body hits). SGR mouse carries only cells.
+ // mouse;pointer;<SDL button, 0 for none>;<x>;<y>: a motion as
+ // `motion` builds it, pushed onto SDL's queue as a mouse's
+ // comes, for the window's wait to take with the rest.
// finger;<kind>;<id>;<x>;<y>;<pressure>
// close: the window's close button
// One the read cut short, or what may yet begin one, waits for
@@ -1558,7 +1561,7 @@ const StdinFeed = struct {
// counts them: shift 4, meta (alt) 8, ctrl 16.
const held = std.fmt.parseInt(u8, parts.next() orelse "0", 10) catch 0;
var sev = std.mem.zeroes(c.SDL_Event);
- const k = std.meta.stringToEnum(enum { wheel, focus, motion, down, up }, kind) orelse .up;
+ const k = std.meta.stringToEnum(enum { wheel, focus, motion, pointer, down, up }, kind) orelse .up;
switch (k) {
.wheel => {
// ESC]777;mouse;wheel;<y, SDL's sign: up positive>;<x>;<y>BEL:
@@ -1572,7 +1575,7 @@ const StdinFeed = struct {
},
// ESC]777;mouse;focus;<1 gained, 0 lost>;0;0BEL
.focus => sev.type = if (button != 0) c.SDL_EVENT_WINDOW_FOCUS_GAINED else c.SDL_EVENT_WINDOW_FOCUS_LOST,
- .motion => {
+ .motion, .pointer => {
sev.type = c.SDL_EVENT_MOUSE_MOTION;
sev.motion.x = x;
sev.motion.y = y;
@@ -1586,6 +1589,11 @@ const StdinFeed = struct {
sev.button.y = y;
},
}
+ if (k == .pointer) {
+ sev.motion.windowID = c.SDL_GetWindowID(gp.window);
+ _ = c.SDL_PushEvent(&sev);
+ continue;
+ }
const before = c.SDL_GetModState();
var mods: c.SDL_Keymod = 0;
if (held & 4 != 0) mods |= c.SDL_KMOD_LSHIFT;
diff --git a/test/daemon.py b/test/daemon.py
index a94fbbbf..9c846369 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -2153,15 +2153,22 @@ def window_clients(binary, gui_binary):
def client_motion(binary, gui_binary):
- """A run of pointer motions over a client window is one move to its last
- position, as the session's own window takes it (gui.zig waitInput): not
- an input each, which the session steps one by one and sends every other
- client as a unit each, every one of them replayed and drawn again (the
- user's "resizing feels very slow with several clients", 2026-11-24: a
- 1000 Hz mouse is a thousand inputs a second). 300 motions written at
- once to a window client's test feed: the inputs it sent the session
- (its PARDES_REPLICA_STATS) are a pass's each, a few, not 300; a terminal
- client watching takes as few units."""
+ """A run of pointer motions is one move to its last position (gui.zig
+ Input.moved), over a client window and over the session's own window
+ with a client attached: not an input each, which the session steps one
+ by one and sends every client as a unit each, every one of them
+ replayed and drawn again (the user's "resizing feels very slow with
+ several clients", 2026-11-24: a 1000 Hz mouse is a thousand inputs a
+ second). 300 motions written at once, 30 bytes each: the window takes
+ them a read of its test feed (1024 bytes) a pass, so at most ten
+ passes, each one input; with the five a client makes anyway (what it
+ is, its size, its focus, two keys) at most 15, asserted at most 20.
+ Three roads: the feed's own dispatch (`motion`) and SDL's queue
+ (`pointer`: the same motion pushed as a mouse's comes) over a window
+ client of a terminal's session, the inputs it sent the session (its
+ PARDES_REPLICA_STATS); and SDL's queue over a window's session with a
+ terminal client watching, a drag, the frames the window drew (its
+ status: on main each motion was its own wait, `split`, a frame each)."""
scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
scratch.mkdir(parents=True, exist_ok=True)
root = Path(tempfile.mkdtemp(prefix='cm-', dir=os.environ.get('TMPDIR') or scratch))
@@ -2172,8 +2179,7 @@ def client_motion(binary, gui_binary):
(root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n')
notes = root / 'notes.txt'
notes.write_text(''.join(f'line {i} of the notes\n' for i in range(300)))
- started, terms = [], []
- w = None
+ started, terms, windows = [], [], []
try:
sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
@@ -2188,38 +2194,82 @@ def client_motion(binary, gui_binary):
t = tt.spawn([binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(root / 't.stats')))
started.append(t.pid)
wait_for('the terminal client\'s first frame', lambda: b'line 3 of the notes' in tt.text(), timeout=30)
- stats = root / 'w.stats'
- w = Window(root, 'w', [gui_binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(stats)))
- started.append(w.pid)
- w.keys(b'jj')
- wait_for('the window\'s keys in the session', lambda: b'line' in nine.read(f'/pane/{pane}/body'), timeout=30)
- time.sleep(2)
motions = 300
- w.p.stdin.write(b''.join(f'\x1b]777;mouse;motion;0;{200 + 3 * i};{300 + i % 40}\x07'.encode() for i in range(motions)))
- w.p.stdin.flush()
- time.sleep(3)
- assert w.close() == 0, w.said()[-800:]
- said = checks(stats)[-1].split()
- sent = int(said[said.index('inputs') + 1])
- tt_units = None
+
+ def burst(win, kind, button=0):
+ win.p.stdin.write(b''.join(f'\x1b]777;mouse;{kind};{button};{200 + 3 * i};{300 + i % 40}\x07'.encode() for i in range(motions)))
+ win.p.stdin.flush()
+
+ def said(path, word):
+ line = checks(path)[-1].split()
+ return int(line[line.index(word) + 1])
+
+ sent = {}
+ for kind in ('motion', 'pointer'):
+ stats = root / f'w-{kind}.stats'
+ w = Window(root, f'w-{kind}', [gui_binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(stats)))
+ windows.append(w)
+ started.append(w.pid)
+ w.keys(b'jj')
+ wait_for('the window\'s keys in the session', lambda: b'line' in nine.read(f'/pane/{pane}/body'), timeout=30)
+ time.sleep(2)
+ burst(w, kind)
+ time.sleep(3)
+ assert w.close() == 0, w.said()[-800:]
+ sent[kind] = said(stats, 'inputs')
t.send_signal(signal.SIGHUP)
t.wait(timeout=10)
- tl = checks(root / 't.stats')
- if tl:
- words = tl[-1].split()
- tt_units = int(words[words.index('units') + 1])
- print(f'daemon: {motions} motions over a client window: it sent the session {sent} inputs; '
- f'the terminal client took {tt_units} units')
- assert sent <= 40, (f'{motions} pointer motions over a client window were {sent} inputs to its session, '
- 'each a unit for every client: not coalesced as the session\'s own window does')
+ tt_units = said(root / 't.stats', 'units') if checks(root / 't.stats') else None
+ print(f'daemon: {motions} motions over a client window: it sent the session {sent["motion"]} inputs by the feed, '
+ f'{sent["pointer"]} by SDL\'s queue; the terminal client took {tt_units} units')
+ for kind, n in sent.items():
+ assert n <= 20, (f'{motions} pointer motions ({kind}) over a client window were {n} inputs to its session, '
+ 'each a unit for every client: not one a pass')
exit_session(nine, pane)
sess.wait(timeout=60)
nine.socket.close()
+ # The session's own window, a terminal client watching: SDL's queue.
+ win = Window(root, 'win', [gui_binary, '--9p=win', str(notes)], dict(env, PARDES_DAEMON='on'))
+ windows.append(win)
+ started.append(win.pid)
+ wait_for('the window session\'s 9P socket', (root / 'pardes-9p-win.sock').exists, timeout=30)
+ wait_for('the replica socket', sock.exists)
+ nine = Client(root / 'pardes-9p-win.sock')
+ pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
+ tb = Term(24, 80)
+ terms.append(tb)
+ b = tb.spawn([binary, f'--attach={sock}:win'], dict(env, PARDES_REPLICA_STATS=str(root / 'b.stats')))
+ started.append(b.pid)
+ wait_for('the terminal client\'s first frame', lambda: b'line 3 of the notes' in tb.text(), timeout=30)
+ time.sleep(2)
+
+ def frames():
+ return int((root / 'win' / 'status').read_text().split()[1])
+
+ # A drag selecting: each motion moves what the window shows.
+ win.mouse('down', 1, 200, 300)
+ time.sleep(1)
+ before = frames()
+ burst(win, 'pointer', 1)
+ time.sleep(3)
+ drawn = frames() - before
+ win.mouse('up', 1, 1097, 339)
+ time.sleep(1)
+ b.send_signal(signal.SIGHUP)
+ b.wait(timeout=10)
+ print(f'daemon: {motions} motions of a drag over the session\'s own window, a terminal client watching: '
+ f'the window drew {drawn} frames; the client {said(root / "b.stats", "draws")} in all')
+ assert drawn <= 20, (f'{motions} pointer motions over the session\'s window were {drawn} frames of it with a client '
+ 'attached: each motion its own wait (split), a step and a unit each, not one a pass')
+ exit_session(nine, pane)
+ assert win.close() == 0, win.said()[-800:]
+ nine.socket.close()
finally:
for tm in terms:
tm.close()
- if w and w.p.poll() is None:
- w.p.kill()
+ for w in windows:
+ if w.p.poll() is None:
+ w.p.kill()
for pid in started + processes(root):
try:
os.kill(pid, signal.SIGKILL)