summaryrefslogtreecommitdiff
path: root/src/file_watch.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_watch.zig')
-rw-r--r--src/file_watch.zig31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/file_watch.zig b/src/file_watch.zig
index 89d0fdaf..b8f9df39 100644
--- a/src/file_watch.zig
+++ b/src/file_watch.zig
@@ -78,7 +78,7 @@ pub const shader_slot = theme_slot + 1;
pub const Table = [shader_slot + pardes.config.Runtime.Post.max]?Watch;
/// Whether this OS has a watcher at all. Off it every entry point below
-/// returns the inert answer: `watchPath` installs nothing, so `watches` stays
+/// returns the inert answer: `watchPane` installs nothing, so `watches` stays
/// empty and `reloadPane` returns false for every slot. The core then keeps its
/// own record of what was asked and simply never gets a `file_changed`, which
/// is what a host with no watcher has always done here.
@@ -224,7 +224,7 @@ pub fn drain(fd: c_int) bool {
///
/// The handle is an inotify wd on linux and an open directory descriptor on
/// macos, and BOTH have to answer "the same directory twice is the same
-/// handle": `watchPath`'s sharing loop compares handles to decide when the last
+/// handle": `watchPane`'s sharing loop compares handles to decide when the last
/// user of a mark is gone, and `Watch` keeps no path to compare instead.
/// inotify does that deduplication itself. On macos it is done here, by device
/// and inode, because each EVFILT_VNODE filter needs a descriptor of its own.
@@ -375,7 +375,11 @@ fn unmark(fd: c_int, old: Watch, drop_dir: bool) void {
}
}
-fn watchPath(
+/// Mark or unmark the pathname in `slot`: a pane's id, `theme_slot` or a
+/// shader's. Panes in the same directory share an inotify descriptor, so
+/// removing one pane drops the kernel mark only after its last user
+/// disappears.
+pub fn watchPane(
fd: c_int,
watches: *Table,
slot: usize,
@@ -415,26 +419,11 @@ fn watchPath(
}
}
-/// Mark or unmark one pane pathname. Panes in the same directory share an
-/// inotify descriptor, so removing one pane drops the kernel mark only after
-/// its last user disappears.
-pub fn watchPane(
- fd: c_int,
- watches: *Table,
- id: u8,
- path: ?[]const u8,
- serial: u32,
- generation: Generation,
-) void {
- std.debug.assert(id < pardes.MAX_PANES);
- watchPath(fd, watches, id, path, serial, generation);
-}
-
/// Mark the post chain files' directories, one slot each, dropping the
/// marks of files no longer in it.
pub fn watchShaders(fd: c_int, watches: *Table, paths: []const []const u8) void {
for (0..pardes.config.Runtime.Post.max) |i|
- watchPath(fd, watches, shader_slot + i, if (i < paths.len) paths[i] else null, 0, .{ .text = 0 });
+ watchPane(fd, watches, shader_slot + i, if (i < paths.len) paths[i] else null, 0, .{ .text = 0 });
}
/// Reconcile one marked pane. A true result requests an immediate second pass:
@@ -594,7 +583,7 @@ pub fn applyThemeEffect(
on: bool,
animate: bool,
) bool {
- watchPath(fd, watches, theme_slot, null, 0, .{ .text = 0 });
+ watchPane(fd, watches, theme_slot, null, 0, .{ .text = 0 });
if (!on) return false;
const request = colors.themeFileRequest(core, generation) orelse return false;
// What fails here is the ThemeFile write's failure too, which waits on
@@ -611,7 +600,7 @@ pub fn applyThemeEffect(
return false;
}
const hash = std.hash.Wyhash.hash(0, bytes);
- watchPath(fd, watches, theme_slot, request.path, generation, .{ .text = hash });
+ watchPane(fd, watches, theme_slot, request.path, generation, .{ .text = hash });
if (watches[theme_slot] == null) return false;
return reloadTheme(core, gpa, watches, false);
}