[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 2 07:54:58 UTC 2019
vcl/unx/gtk3/gtk3gtkinst.cxx | 53 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
New commits:
commit f420aa3e027e04e49b7031ebf0613debcaab2ea0
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed May 1 17:06:37 2019 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu May 2 09:54:03 2019 +0200
GtkTreeView drag and drop highlight doesn't look right
Under gtk 3.24.8 dragging into the TreeView is not highlighting the entire
rreeView widget, just the rectangle which has no entries in it. This looks ok
when its empty, but not when it has some entries in it, and when the list is
full, there is then no border highlight.
So as a workaround highlight the parent container on drag start, and undo it on
drag end, and trigger removal of the treeview's highlight effort.
Change-Id: I37be1e53a9ad3c6b810b579f6e5699c45b7b8e2b
Reviewed-on: https://gerrit.libreoffice.org/71624
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index e72d659536bd..38369c6b1b46 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1314,6 +1314,7 @@ protected:
private:
bool m_bTakeOwnership;
bool m_bFrozen;
+ bool m_bDraggedOver;
sal_uInt16 m_nLastMouseButton;
gulong m_nFocusInSignalId;
gulong m_nMnemonicActivateSignalId;
@@ -1465,9 +1466,18 @@ private:
return true;
}
+ virtual void drag_started()
+ {
+ }
+
static gboolean signalDragMotion(GtkWidget *pWidget, GdkDragContext *context, gint x, gint y, guint time, gpointer widget)
{
GtkInstanceWidget* pThis = static_cast<GtkInstanceWidget*>(widget);
+ if (!pThis->m_bDraggedOver)
+ {
+ pThis->m_bDraggedOver = true;
+ pThis->drag_started();
+ }
return pThis->m_xDropTarget->signalDragMotion(pWidget, context, x, y, time);
}
@@ -1483,10 +1493,19 @@ private:
pThis->m_xDropTarget->signalDragDropReceived(pWidget, context, x, y, data, ttype, time);
}
+ virtual void drag_ended()
+ {
+ }
+
static void signalDragLeave(GtkWidget *pWidget, GdkDragContext *context, guint time, gpointer widget)
{
GtkInstanceWidget* pThis = static_cast<GtkInstanceWidget*>(widget);
pThis->m_xDropTarget->signalDragLeave(pWidget, context, time);
+ if (pThis->m_bDraggedOver)
+ {
+ pThis->m_bDraggedOver = false;
+ pThis->drag_ended();
+ }
}
public:
@@ -1495,6 +1514,7 @@ public:
, m_pBuilder(pBuilder)
, m_bTakeOwnership(bTakeOwnership)
, m_bFrozen(false)
+ , m_bDraggedOver(false)
, m_nLastMouseButton(0)
, m_nFocusInSignalId(0)
, m_nMnemonicActivateSignalId(0)
@@ -5902,6 +5922,7 @@ private:
std::vector<int> m_aSavedSortColumns;
std::vector<int> m_aViewColToModelCol;
std::vector<int> m_aModelColToViewCol;
+ bool m_bWorkAroundBadDragRegion;
gint m_nTextCol;
gint m_nImageCol;
gint m_nExpanderImageCol;
@@ -6216,6 +6237,7 @@ public:
: GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership)
, m_pTreeView(pTreeView)
, m_pTreeStore(GTK_TREE_STORE(gtk_tree_view_get_model(m_pTreeView)))
+ , m_bWorkAroundBadDragRegion(false)
, m_nTextCol(-1)
, m_nImageCol(-1)
, m_nExpanderImageCol(-1)
@@ -7380,6 +7402,9 @@ public:
// unhighlight current highlighted row
gtk_tree_view_set_drag_dest_row(m_pTreeView, nullptr, pos);
+ if (m_bWorkAroundBadDragRegion)
+ gtk_drag_unhighlight(GTK_WIDGET(m_pTreeView));
+
GtkTreePath *path = nullptr;
GtkTreeViewDropPosition gtkpos = GTK_TREE_VIEW_DROP_BEFORE;
bool ret = gtk_tree_view_get_dest_row_at_pos(m_pTreeView, rPos.X(), rPos.Y(),
@@ -7460,6 +7485,34 @@ public:
return g_DragSource;
}
+ // Under gtk 3.24.8 dragging into the TreeView is not highlighting
+ // entire TreeView widget, just the rectangle which has no entries
+ // in it, so as a workaround highlight the parent container
+ // on drag start, and undo it on drag end, and trigger removal
+ // of the treeview's highlight effort
+ virtual void drag_started() override
+ {
+ GtkWidget* pWidget = GTK_WIDGET(m_pTreeView);
+ GtkWidget* pParent = gtk_widget_get_parent(pWidget);
+ if (GTK_IS_SCROLLED_WINDOW(pParent))
+ {
+ gtk_drag_unhighlight(pWidget);
+ gtk_drag_highlight(pParent);
+ m_bWorkAroundBadDragRegion = true;
+ }
+ }
+
+ virtual void drag_ended() override
+ {
+ if (m_bWorkAroundBadDragRegion)
+ {
+ GtkWidget* pWidget = GTK_WIDGET(m_pTreeView);
+ GtkWidget* pParent = gtk_widget_get_parent(pWidget);
+ gtk_drag_unhighlight(pParent);
+ m_bWorkAroundBadDragRegion = false;
+ }
+ }
+
virtual ~GtkInstanceTreeView() override
{
g_signal_handler_disconnect(m_pTreeView, m_nDragEndSignalId);
More information about the Libreoffice-commits
mailing list