summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-11-05 11:14:23 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-11-06 10:33:40 +0100
commit2194e2dd7e54ad6babec26cf05226b35d34cd309 (patch)
tree08a33cd85a6968c2e2da233e7237a3a0f4a05b00 /vcl
parent4a22047371503602339d8aee690da0ab536ec7fe (diff)
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@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx19
1 files changed, 18 insertions, 1 deletions
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));
}
}