mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
gtk: send copy_to_clipboard toast from Surface
Move the toast we send when copying to the clipboard to the Surface implementation. Previously, we only called this from the gtk accelerator callback which we only call when the *last set* keybind is activated. We also only send a toast if we have copied to the standard clipboard, as opposed to the selection clipboard. By default, we have copy-to-clipboard true for linux, which sets the selection keyboard on any select. This becomes *very* noisy.
This commit is contained in:
@ -1080,6 +1080,13 @@ pub fn setClipboardString(
|
|||||||
if (!confirm) {
|
if (!confirm) {
|
||||||
const clipboard = getClipboard(@ptrCast(self.gl_area), clipboard_type);
|
const clipboard = getClipboard(@ptrCast(self.gl_area), clipboard_type);
|
||||||
c.gdk_clipboard_set_text(clipboard, val.ptr);
|
c.gdk_clipboard_set_text(clipboard, val.ptr);
|
||||||
|
// We only toast if we are copying to the standard clipboard.
|
||||||
|
if (clipboard_type == .standard and
|
||||||
|
self.app.config.@"adw-toast".@"clipboard-copy")
|
||||||
|
{
|
||||||
|
if (self.container.window()) |window|
|
||||||
|
window.sendToast("Copied to clipboard");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ pub fn onConfigReloaded(self: *Window) void {
|
|||||||
self.sendToast("Reloaded the configuration");
|
self.sendToast("Reloaded the configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sendToast(self: *Window, title: [:0]const u8) void {
|
pub fn sendToast(self: *Window, title: [:0]const u8) void {
|
||||||
if (comptime !adwaita.versionAtLeast(0, 0, 0)) return;
|
if (comptime !adwaita.versionAtLeast(0, 0, 0)) return;
|
||||||
const toast_overlay = self.toast_overlay orelse return;
|
const toast_overlay = self.toast_overlay orelse return;
|
||||||
const toast = c.adw_toast_new(title);
|
const toast = c.adw_toast_new(title);
|
||||||
@ -895,10 +895,6 @@ fn gtkActionCopy(
|
|||||||
log.warn("error performing binding action error={}", .{err});
|
log.warn("error performing binding action error={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (self.app.config.@"adw-toast".@"clipboard-copy") {
|
|
||||||
self.sendToast("Copied to clipboard");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gtkActionPaste(
|
fn gtkActionPaste(
|
||||||
|
Reference in New Issue
Block a user