diff options
Diffstat (limited to 'src/gui/gui.zig')
| -rw-r--r-- | src/gui/gui.zig | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig index f78678c0..863bb81e 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -446,7 +446,7 @@ const Gui = struct { font_name_len: u8 = 0, /// A replica client's: the session's font request it last followed /// (syncReplicaFont), as a hash of the request. - remote_font_request: ?u64 = null, + session_font_request: ?u64 = null, px: f32, tagline_px: f32, tagline_percent: u8, @@ -578,7 +578,7 @@ fn acknowledgeGuiFont(g: *const Gui, core: *pardes.Pardes) void { } /// A replica client's font is the window's raster state: it follows the -/// session's request by the face's name on this machine (fonts.remote), +/// session's request by the face's name on this machine (fonts.fromSession), /// never acknowledging it or otherwise changing the replicated core. fn syncReplicaFont(g: *Gui, core: *const pardes.Pardes, gpa: std.mem.Allocator) bool { const f = &core.settings.font; @@ -590,12 +590,12 @@ fn syncReplicaFont(g: *Gui, core: *const pardes.Pardes, gpa: std.mem.Allocator) hash.update(name); hash.update(std.mem.asBytes(&f.requested_size_hundredths)); const request = hash.final(); - if (g.remote_font_request == request) return false; - g.remote_font_request = request; + if (g.session_font_request == request) return false; + g.session_font_request = request; var arena: std.heap.ArenaAllocator = .init(gpa); defer arena.deinit(); - const face = fonts.remote(arena.allocator(), path, name) orelse { - log.warn("remote font is not installed here: {s}", .{name}); + const face = fonts.fromSession(arena.allocator(), path, name) orelse { + log.warn("the session's font is not installed here: {s}", .{name}); return false; }; const bytes = filesystem.readFile(gpa, face.path) catch return false; @@ -768,8 +768,8 @@ pub fn run(init: std.process.Init, opts: pardes.Options, headless: bool) !void { /// `pardes-gui --attach=<socket>:<session>` (and `<host>:<session>`, /// through ssh, main.zig): this window a replica client of a session -/// elsewhere, as the tty's `remote` is a terminal's (`remoteSession`). -pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, session: []const u8, far: bool) !void { +/// elsewhere, as the tty's `runClient` is a terminal's (`clientSession`). +pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8, session: []const u8, far: bool) !void { return runNative(init, opts, false, .{ .path = path, .session = session, .far = far }); } @@ -963,7 +963,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di // compositor moves it, as it does a title bar. if (!test_mode and !c.SDL_SetWindowHitTest(window, hitTest, &g)) log.warn("SDL_SetWindowHitTest: {s}", .{c.SDL_GetError()}); - if (dial) |to| return remoteSession(init, &g, opts_in, test_mode, to); + if (dial) |to| return clientSession(init, &g, opts_in, test_mode, to); try localSession(init, &g, opts_in, test_mode, headless); } @@ -1185,7 +1185,7 @@ fn localSession( } } -/// A window's link to a session elsewhere (`remoteSession`): what the +/// A window's link to a session elsewhere (`clientSession`): what the /// window's input made, fed to the replica once its own view is put back, /// and what the link's reader took off the stream. const Client = struct { @@ -1267,7 +1267,7 @@ const Client = struct { } /// Its own view drawn in the window, outside any step, as the tty's - /// client draws its terminal (tui.zig `Remote.draw`): what presenting + /// client draws its terminal (tui.zig `Client.draw`): what presenting /// writes in the core (a frame skipped, one owed) is put back. fn draw(cl: *Client, s: *Shell) void { const r = cl.link.r; @@ -1297,7 +1297,7 @@ fn clientReader(cl: *Client, fd: c_int, rest: *replica.Framer) void { } /// What the window does over its own view (`Replica.within`), its inputs -/// posted to the client (`Input.remote`): an SDL event dispatched, its size +/// posted to the client (`Input.client`): an SDL event dispatched, its size /// (the tagline's face too), the pointer under a frame that moved, the /// timedemo's and the test feed's steps. const OwnView = struct { @@ -1311,9 +1311,9 @@ const OwnView = struct { fn run(v: *OwnView, core: *pardes.Pardes) anyerror!void { if (v.sev) |sev| return dispatch(v.g, v.in, sev); const g = v.g; - if (syncReplicaFont(g, core, v.s.gpa)) v.s.remote.?.link.dirty = true; - if (scrollRows(g, v.in, v.s.gpa)) v.s.remote.?.link.dirty = true; - if (fitTaglineFont(g, core.settings.font.tagline_percent)) v.s.remote.?.link.dirty = true; + if (syncReplicaFont(g, core, v.s.gpa)) v.s.client.?.link.dirty = true; + if (scrollRows(g, v.in, v.s.gpa)) v.s.client.?.link.dirty = true; + if (fitTaglineFont(g, core.settings.font.tagline_percent)) v.s.client.?.link.dirty = true; const geom = windowCells(g); if (resizeOf(core.view(), geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) |ev| v.in.post(ev); if (v.pointer) refreshPresentedPointer(g, v.in); @@ -1328,9 +1328,9 @@ const OwnView = struct { /// is, a replica client of that session (docs/next-daemon.md, "Phase 6: GUI /// replica notes"). Its own core, loaded from the session's dump, applies /// its input at once (src/replica.zig) and draws its own view; the -/// session's units are the truth it rolls back to. The tty's `remote`, with +/// session's units are the truth it rolls back to. The tty's `runClient`, with /// a window for a terminal. -fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_mode: bool, to: Dial) !void { +fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_mode: bool, to: Dial) !void { const io = init.io; const gpa = init.gpa; const Said = struct { @@ -1389,7 +1389,7 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ .inotify_fd = -1, .watches = &watches, .test_mode = test_mode, - .remote = &client, + .client = &client, }; g.no_blink = test_mode; defer g.hit_core = null; @@ -1399,7 +1399,7 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ // session let it go to upgrade. The window stays as it is. while (true) { const core = r.core(); - g.remote_font_request = null; + g.session_font_request = null; shell.core = core; shell.gview = joined.view; shell.surface = null; @@ -1417,7 +1417,7 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ log.warn("{s}", .{link.notice()}); } const reader = try std.Thread.spawn(.{}, clientReader, .{ &client, joined.fd, &joined.rest }); - var in: Input = .{ .core = core, .shell = &shell, .remote = &client }; + var in: Input = .{ .core = core, .shell = &shell, .client = &client }; // What it is, then its size, are its view's first inputs. link.input(.{ .frontend = .{ .windowed = true, .native_images = true, .native_image_patches = true } }); var drew = false; @@ -1757,13 +1757,13 @@ const Input = struct { core: *pardes.Pardes, /// The shell whose window this is (views.zig: its view is `gview`). shell: ?*Shell = null, - /// A replica client's (`remote`): its inputs go to its link, never + /// A replica client's (`runClient`): its inputs go to its link, never /// straight to the core, which only reads here. - remote: ?*Client = null, + client: ?*Client = null, quit: bool = false, fn post(in: *Input, ev: pardes.Event) void { - if (in.remote) |r| return r.post(ev); + if (in.client) |r| return r.post(ev); // The window's input is its own view's, a replica client's input // the session's last or not. if (in.shell) |s| if (s.core.live != s.gview) { @@ -1773,7 +1773,7 @@ const Input = struct { } fn close(in: *Input) void { - if (in.remote) |r| { + if (in.client) |r| { r.link.quit = true; in.quit = true; return; @@ -1810,7 +1810,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void { updateDisplayScale(g.window); // Underlines are drawn into the glyphs a logical pixel thick. resetGlyphAtlas(g); - if (in.remote) |r| { + if (in.client) |r| { r.link.dirty = true; } else in.core.needs_frame = true; }, @@ -1824,7 +1824,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void { c.SDL_EVENT_WINDOW_CLOSE_REQUESTED => in.close(), c.SDL_EVENT_WINDOW_FOCUS_GAINED => { in.post(.{ .focus = true }); - if (in.remote == null) upgrade.noticeNewer(in.core); + if (in.client == null) upgrade.noticeNewer(in.core); }, c.SDL_EVENT_WINDOW_FOCUS_LOST => in.post(.{ .focus = false }), c.SDL_EVENT_WINDOW_MOUSE_LEAVE => { @@ -2144,7 +2144,7 @@ fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void { in.post(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = mc.col, .row = mc.row, .tag_hit = mc.tag_hit, .body_hit = mc.body_hit, .ctrl = w.mods.ctrl, .shift = w.mods.shift, .alt = w.mods.alt } }); while (g.program_wheel <= -1) : (g.program_wheel += 1) in.post(.{ .mouse = .{ .button = .wheel_up, .kind = .press, .col = mc.col, .row = mc.row, .tag_hit = mc.tag_hit, .body_hit = mc.body_hit, .ctrl = w.mods.ctrl, .shift = w.mods.shift, .alt = w.mods.alt } }); - } else if (in.remote != null) { + } else if (in.client != null) { // A replica client's notch is whole rows at once, with no // glide; a touchpad's fraction is the window's picture // (scrollRows), its whole rows ordinary inputs. @@ -2204,7 +2204,7 @@ const WheelTurn = struct { x: f32 = 0, y: f32 = 0, integer_y: i32 = 0, precise: fn setFontPx(g: *Gui, in: *Input, want: f32) void { if (want == g.px) return; g.px = want; - if (in.remote) |r| { + if (in.client) |r| { refitFont(g, null); r.link.dirty = true; } else { @@ -2417,8 +2417,8 @@ const Shell = struct { gview: u8 = 0, /// Upgrade was asked from this pane, to be done between steps (`upgradeNow`). upgrade_asked: ?u8 = null, - /// This window a replica client of a session elsewhere (`remote`). - remote: ?*Client = null, + /// This window a replica client of a session elsewhere (`runClient`). + client: ?*Client = null, /// The session's replica clients (src/replica.zig), on sockets: views /// of their own with no window here. peers: replica.Peers = .{}, @@ -3179,7 +3179,7 @@ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) void { const s = shellOf(ctx); const core = s.core; // A replica client draws outside the pump, which marks it there. - if (s.remote != null) core.frames.mark_render = pardes.FrameStats.nowNs(); + if (s.client != null) core.frames.mark_render = pardes.FrameStats.nowNs(); const g = s.gui orelse return; frame_started_ns = monoNs(); const frame = surface; @@ -3731,7 +3731,7 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool { }); // A replica client's rows apply after its view is parked again: // its scroll has not moved yet. - if (in.remote == null and pane.scroll() == was) { + if (in.client == null and pane.scroll() == was) { resetScroll(g); return false; } @@ -3741,7 +3741,7 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool { // the last one, a fraction of a row off, and the next turn's frame // jumps from there (against the turn when it reverses). const moved = st.rows != 0 or st.lag != g.scroll_lag; - if (moved and in.remote == null) core.needs_frame = true; + if (moved and in.client == null) core.needs_frame = true; g.scroll_lag = st.lag; g.scroll_rect = r; const body_y = core.bodyTop(pane, r); @@ -7980,7 +7980,7 @@ test "trackpad rotation never types search keys into an insert-mode file or raw _ = try core.setTestFile("unchanged\n"); var client: Client = .{ .link = undefined, .io = std.testing.io, .gpa = gpa, .texts = .init(gpa) }; defer client.deinit(); - var in: Input = .{ .core = core, .remote = &client }; + var in: Input = .{ .core = core, .client = &client }; var g: Gui = undefined; g.trackpad = .{}; var ev: c.UITrackpadEvent = std.mem.zeroes(c.UITrackpadEvent); @@ -8049,7 +8049,7 @@ test "detached trackpad scrolling keeps fractions local and queues whole rows fo _ = try core.render(arena.allocator()); var client: Client = .{ .link = undefined, .io = std.testing.io, .gpa = gpa, .texts = .init(gpa) }; defer client.deinit(); - var in: Input = .{ .core = core, .remote = &client }; + var in: Input = .{ .core = core, .client = &client }; const id = core.view().active; const r = core.view().rects[id]; var g: Gui = undefined; |
