move copyTitleToClipboard logic into Surface

This commit is contained in:
Priyanshu
2026-02-13 21:30:13 +05:30
parent de49b7f27b
commit d2841220a8
2 changed files with 12 additions and 9 deletions

View File

@@ -1901,15 +1901,7 @@ const Action = struct {
pub fn copyTitleToClipboard(target: apprt.Target) bool {
return switch (target) {
.app => false,
.surface => |v| surface: {
const title = v.rt_surface.surface.getEffectiveTitle() orelse break :surface false;
if (title.len == 0) break :surface false;
v.rt_surface.surface.setClipboard(.standard, &.{.{
.mime = "text/plain",
.data = title,
}}, false);
break :surface true;
},
.surface => |v| v.rt_surface.gobj().copyTitleToClipboard(),
};
}

View File

@@ -1989,6 +1989,17 @@ pub const Surface = extern struct {
return priv.title_override orelse priv.title;
}
/// Copies the effective title to the clipboard.
pub fn copyTitleToClipboard(self: *Self) bool {
const title = self.getEffectiveTitle() orelse return false;
if (title.len == 0) return false;
self.setClipboard(.standard, &.{.{
.mime = "text/plain",
.data = title,
}}, false);
return true;
}
/// Set the title for this surface, copies the value. This should always
/// be the title as set by the terminal program, not any manually set
/// title. For manually set titles see `setTitleOverride`.