[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 24 07:44:33 UTC 2021
vcl/inc/unx/gtk/gtkinst.hxx | 6 +++++-
vcl/unx/gtk3/gtkinst.cxx | 25 +++++++++++++++++++++----
2 files changed, 26 insertions(+), 5 deletions(-)
New commits:
commit a02b9277a354922d4dc887d72349af9e4573c025
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun May 23 19:59:00 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 24 09:43:50 2021 +0200
gtk4: make basic text pasting work again
Change-Id: I23b029f7accb7ee65f1dfdf1eaa2643faafff14a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116023
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 922475a7526f..7058c383c8a3 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -71,10 +71,14 @@ private:
class GtkTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
{
-#if !GTK_CHECK_VERSION(4, 0, 0)
protected:
+#if !GTK_CHECK_VERSION(4, 0, 0)
std::map<OUString, GdkAtom> m_aMimeTypeToAtom;
+#endif
+#if GTK_CHECK_VERSION(4, 0, 0)
+ std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector(const char * const *targets, gint n_targets);
+#else
std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector(GdkAtom *targets, gint n_targets);
#endif
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index a5e97e95856d..5d991ccf840b 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -550,8 +550,11 @@ namespace
};
}
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavorsAsVector(const char * const *targets, gint n_targets)
+#else
std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavorsAsVector(GdkAtom *targets, gint n_targets)
+#endif
{
std::vector<css::datatransfer::DataFlavor> aVector;
@@ -559,14 +562,20 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo
for (gint i = 0; i < n_targets; ++i)
{
+#if GTK_CHECK_VERSION(4, 0, 0)
+ const gchar* pName = targets[i];
+#else
gchar* pName = gdk_atom_name(targets[i]);
+#endif
const char* pFinalName = pName;
css::datatransfer::DataFlavor aFlavor;
// omit text/plain;charset=unicode since it is not well defined
if (rtl_str_compare(pName, "text/plain;charset=unicode") == 0)
{
+#if !GTK_CHECK_VERSION(4, 0, 0)
g_free(pName);
+#endif
continue;
}
@@ -584,7 +593,9 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo
// them out for now before they confuse this code's clients:
if (rtl_str_indexOfChar(pFinalName, '/') == -1)
{
+#if !GTK_CHECK_VERSION(4, 0, 0)
g_free(pName);
+#endif
continue;
}
@@ -610,7 +621,9 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo
}
}
aVector.push_back(aFlavor);
+#if !GTK_CHECK_VERSION(4, 0, 0)
g_free(pName);
+#endif
}
//If we have text, but no UTF-16 format which is basically the only
@@ -626,7 +639,6 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo
return aVector;
}
-#endif
css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL GtkTransferable::getTransferDataFlavors()
{
@@ -741,9 +753,14 @@ public:
{
std::vector<css::datatransfer::DataFlavor> aVector;
-#if !GTK_CHECK_VERSION(4, 0, 0)
GdkClipboard* clipboard = clipboard_get(m_eSelection);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ GdkContentFormats* pFormats = gdk_clipboard_get_formats(clipboard);
+ gsize n_targets;
+ const char * const *targets = gdk_content_formats_get_mime_types(pFormats, &n_targets);
+ aVector = GtkTransferable::getTransferDataFlavorsAsVector(targets, n_targets);
+#else
GdkAtom *targets;
gint n_targets;
if (gtk_clipboard_wait_for_targets(clipboard, &targets, &n_targets))
@@ -1095,9 +1112,9 @@ void VclGtkClipboard::flushClipboard()
VclGtkClipboard::~VclGtkClipboard()
{
-#if !GTK_CHECK_VERSION(4, 0, 0)
GdkClipboard* clipboard = clipboard_get(m_eSelection);
g_signal_handler_disconnect(clipboard, m_nOwnerChangedSignalId);
+#if !GTK_CHECK_VERSION(4, 0, 0)
if (!m_aGtkTargets.empty())
{
gtk_clipboard_clear(clipboard);
More information about the Libreoffice-commits
mailing list