Skip to content

Commit

Permalink
Fix clearing clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent bac4181 commit f8e2a7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/run/display/gtk.cr
Expand Up @@ -50,7 +50,7 @@ module Run

def clipboard(&block : ::Gtk::Clipboard -> _)
act do
clip = ::Gtk::Clipboard.get(Gdk::Atom.intern("CLIPBOARD", true))
clip = ::Gtk::Clipboard.get(Gdk::Atom.intern("CLIPBOARD", false))
block.call(clip)
end
end
Expand Down
8 changes: 7 additions & 1 deletion src/run/runner.cr
Expand Up @@ -211,7 +211,13 @@ module Run
case down
when "clipboard"
display.gtk.clipboard do |clip|
clip.set_text(value, -1)
if value.empty?
# clip.clear # Doesn't do anything
# clip.set_text("", 0) # Doesn't work outside of ahkx11 itself, even though https://stackoverflow.com/q/2418487 says so. Maybe a Crystal GIR bug?
clip.image = GdkPixbuf::Pixbuf.new # Ugly but works
else
clip.set_text(value, value.size)
end
clip.store
end
else
Expand Down

0 comments on commit f8e2a7a

Please sign in to comment.