[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 6 09:34:16 UTC 2020
vcl/unx/gtk3/gtk3gtkinst.cxx | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
New commits:
commit 2194e2dd7e54ad6babec26cf05226b35d34cd309
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Nov 5 11:14:23 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Nov 6 10:33:40 2020 +0100
Resolves: tdf#137181 set the clipboard asynchronously
because apparently hitting the wayland compositor repeatedly with
clipboard changes without a chance of reply triggers a "Lost connection
to Wayland compositor" failure, so make it happen on the next
event loop and have only one event pending
Change-Id: I24d22e70f5f614fa0c9d3d1672e064d9c57be57e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105339
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 6f14c46d5e58..cede2908dbc4 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -693,12 +693,14 @@ class VclGtkClipboard :
GdkAtom m_nSelection;
osl::Mutex m_aMutex;
gulong m_nOwnerChangedSignalId;
+ ImplSVEvent* m_pSetClipboardEvent;
Reference<css::datatransfer::XTransferable> m_aContents;
Reference<css::datatransfer::clipboard::XClipboardOwner> m_aOwner;
std::vector< Reference<css::datatransfer::clipboard::XClipboardListener> > m_aListeners;
std::vector<GtkTargetEntry> m_aGtkTargets;
VclToGtkHelper m_aConversionHelper;
+ DECL_LINK(AsyncSetGtkClipboard, void*, void);
public:
explicit VclGtkClipboard(GdkAtom nSelection);
@@ -879,6 +881,11 @@ void VclGtkClipboard::OwnerPossiblyChanged(GtkClipboard* clipboard)
void VclGtkClipboard::ClipboardClear()
{
+ if (m_pSetClipboardEvent)
+ {
+ Application::RemoveUserEvent(m_pSetClipboardEvent);
+ m_pSetClipboardEvent = nullptr;
+ }
for (auto &a : m_aGtkTargets)
g_free(a.target);
m_aGtkTargets.clear();
@@ -965,6 +972,7 @@ VclGtkClipboard::VclGtkClipboard(GdkAtom nSelection)
datatransfer::clipboard::XFlushableClipboard, XServiceInfo>
(m_aMutex)
, m_nSelection(nSelection)
+ , m_pSetClipboardEvent(nullptr)
{
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
m_nOwnerChangedSignalId = g_signal_connect(clipboard, "owner-change",
@@ -991,6 +999,7 @@ VclGtkClipboard::~VclGtkClipboard()
gtk_clipboard_clear(clipboard);
ClipboardClear();
}
+ assert(!m_pSetClipboardEvent);
assert(m_aGtkTargets.empty());
}
@@ -1033,6 +1042,13 @@ std::vector<GtkTargetEntry> VclToGtkHelper::FormatsToGtk(const css::uno::Sequenc
return aGtkTargets;
}
+IMPL_LINK_NOARG(VclGtkClipboard, AsyncSetGtkClipboard, void*, void)
+{
+ osl::ClearableMutexGuard aGuard( m_aMutex );
+ m_pSetClipboardEvent = nullptr;
+ SetGtkClipboard();
+}
+
void VclGtkClipboard::SetGtkClipboard()
{
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
@@ -1081,7 +1097,8 @@ void VclGtkClipboard::setContents(
m_aGtkTargets = aGtkTargets;
- SetGtkClipboard();
+ if (!m_pSetClipboardEvent)
+ m_pSetClipboardEvent = Application::PostUserEvent(LINK(this, VclGtkClipboard, AsyncSetGtkClipboard));
}
}
More information about the Libreoffice-commits
mailing list