0

I have a gtkmm application which shares a clipboard from a VNC client (gtk-vnc) to/from the host. For reference, here is the relevant code:

signal_vnc_server_cut_text().connect([this](const Glib::ustring &text) {
    auto clipboard = Gtk::Clipboard::get();
    m_clipboard_text = text;
    /* Works correctly on Windows and Linux */
    clipboard->set_text(text);
    clipboard->store();
});
Gtk::Clipboard::get()->signal_owner_change().connect([this](GdkEventOwnerChange *) {
    auto clipboard = Gtk::Clipboard::get();
    auto text = clipboard->wait_for_text();
    /* text is correct on Linux, but see below for Windows */
    std::cout << "Clipboard got: " << text << std::endl;
    if (!text.empty() && text != m_clipboard_text)
        client_cut_text(text);
});

The current code works as expected on a Linux host (can copy and paste both directions). However, on Windows, any time I attempt to copy from the host, wait_for_text() returns whatever text was in the copy buffer when the app started. Copying from the client on Windows does get the correct text (which I can then paste on the host fine), but once I copy from the host again, the clipboard data is reset to whatever was there from the start.

Am I missing something, or is this a Gtk bug?

4

1 回答 1

0

我做了一些挖掘,这似乎是一个 GTK 错误,特别与此错误修复相关: https ://bugzilla.gnome.org/show_bug.cgi?id=781814

使用模拟此补丁之前的行为的自定义版本恢复更改或替换 wait_for_text 可解决剪贴板异常问题。

于 2017-10-26T22:59:25.130 回答