Skip to content

Error reading clipboard under wayland #1609

@SamiSieranoja

Description

@SamiSieranoja

Trying the Wayland on Ubuntu 22.04, with GTK 4.12.5 (motivated by [1]). Again, not sure if the bug is in my code or rubu-gnome, but I'm getting an error when trying to read clipboard data from any external program (if clipboard updated from same program, it works).

[1] https://gitlab.gnome.org/GNOME/gtk/-/issues/6493

https://github.com/SamiSieranoja/vimamsa/blob/41a5b24bdd2528eb73dbabfcaf65cb6f9d09f24f/lib/vimamsa/buffer_changetext.rb#L78

    clipboard = vma.gui.window.display.clipboard
    pp clipboard
    clipboard.read_text_async do |_clipboard, result|
      begin
        text = clipboard.read_text_finish(result)
      rescue Gio::IOError::NotSupported
        debug Gio::IOError::NotSupported
      else
        paste_finish(text, at, register)
      end
    end

Getting the following error:

#<GdkWaylandClipboard:0x00007f86d35e6f58 ptr=0x000055b586c25ae0>
GLib-CRITICAL **: g_unix_open_pipe: assertion '(flags & (FD_CLOEXEC)) == flags' failed
	from /home/sjs/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/gobject-introspection-4.2.1/lib/gobject-introspection/loader.rb:713:in `invoke'
	from /home/sjs/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/gobject-introspection-4.2.1/lib/gobject-introspection/loader.rb:581:in `read_text_async'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/buffer_changetext.rb:104:in `paste_start'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/buffer_changetext.rb:156:in `paste'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/key_bindings_vimlike.rb:126:in `block in <top (required)>'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/actions.rb:58:in `call'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/actions.rb:33:in `call_action'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/key_binding_tree.rb:627:in `exec_action'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/key_binding_tree.rb:580:in `block in handle_key_bindigs_action'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/key_binding_tree.rb:579:in `times'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/key_binding_tree.rb:579:in `handle_key_bindigs_action'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/key_binding_tree.rb:444:in `match_key_conf'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/gui_sourceview.rb:405:in `handle_key_event'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/gui.rb:519:in `block in reset_controllers'
	from /home/sjs/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/gobject-introspection-4.2.1/lib/gobject-introspection/loader.rb:713:in `invoke'
	from /home/sjs/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/gobject-introspection-4.2.1/lib/gobject-introspection/loader.rb:713:in `invoke'
	from /home/sjs/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/gobject-introspection-4.2.1/lib/gobject-introspection/loader.rb:581:in `run'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/gui.rb:733:in `init_window'
	from /home/sjs/Drive/code/vimamsa/git/lib/vimamsa/gui.rb:210:in `run'
	from exe/vimamsa:39:in `<main>'

Otherwise clipboard is working ok under Wayland and as a workaround I used the following hack:

    Thread.new {
      text = `xclip -selection c -o`
      paste_finish(text, at, register)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions