diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-25 09:07:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-25 15:03:33 +0100 |
commit | 64ad7b44e3b36f538a23a851b0e9df7ee0df52b7 (patch) | |
tree | 003feb7b59b938b5ad7a5b9c9b648a594df4ff93 | |
parent | fe5366d9d2d57ee3648589db86d2c17f43febb6b (diff) |
cancelling drag from drag-begin doesn't work, call it async
Change-Id: I9323e8ab4d3df9f2ded0c7bfb21582faa3b5e1a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89412
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 9d958393a5f1..155472a91532 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1819,6 +1819,7 @@ protected: DECL_LINK(async_signal_focus_in, void*, void); DECL_LINK(async_signal_focus_out, void*, void); + DECL_LINK(async_drag_cancel, void*, void); void launch_signal_focus_in() { @@ -1871,6 +1872,15 @@ protected: return false; } + void launch_drag_cancel(GdkDragContext* context) + { + // post our drag cancel to happen at the next available event cycle + if (m_pDragCancelEvent) + return; + g_object_ref(context); + m_pDragCancelEvent = Application::PostUserEvent(LINK(this, GtkInstanceWidget, async_drag_cancel), context); + } + void signal_focus_out() { m_aFocusOutHdl.Call(*this); @@ -1958,6 +1968,7 @@ private: int m_nPressStartY; ImplSVEvent* m_pFocusInEvent; ImplSVEvent* m_pFocusOutEvent; + ImplSVEvent* m_pDragCancelEvent; GtkCssProvider* m_pBgCssProvider; GdkDragAction m_eDragAction; gulong m_nFocusInSignalId; @@ -2238,7 +2249,7 @@ private: { if (do_signal_drag_begin()) { - gtk_drag_cancel(context); + launch_drag_cancel(context); return; } if (!m_xDragSource) @@ -2318,6 +2329,7 @@ public: , m_nPressStartY(-1) , m_pFocusInEvent(nullptr) , m_pFocusOutEvent(nullptr) + , m_pDragCancelEvent(nullptr) , m_pBgCssProvider(nullptr) , m_eDragAction(GdkDragAction(0)) , m_nFocusInSignalId(0) @@ -2895,6 +2907,8 @@ public: Application::RemoveUserEvent(m_pFocusInEvent); if (m_pFocusOutEvent) Application::RemoveUserEvent(m_pFocusOutEvent); + if (m_pDragCancelEvent) + Application::RemoveUserEvent(m_pDragCancelEvent); if (m_nDragMotionSignalId) g_signal_handler_disconnect(m_pWidget, m_nDragMotionSignalId); if (m_nDragDropSignalId) @@ -3012,6 +3026,14 @@ IMPL_LINK_NOARG(GtkInstanceWidget, async_signal_focus_out, void*, void) signal_focus_out(); } +IMPL_LINK(GtkInstanceWidget, async_drag_cancel, void*, arg, void) +{ + m_pDragCancelEvent = nullptr; + GdkDragContext* context = static_cast<GdkDragContext*>(arg); + gtk_drag_cancel(context); + g_object_unref(context); +} + namespace { OString MapToGtkAccelerator(const OUString &rStr) |