[gimp/gimp-2-8] Bug 744127 - Restore tab hover delay during drag-n-drops
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Bug 744127 - Restore tab hover delay during drag-n-drops
- Date: Thu, 19 Feb 2015 21:43:59 +0000 (UTC)
commit 74352ca2caba0c5c68ec8a143ad135508609b605
Author: Michael Natterer <mitch gimp org>
Date: Thu Feb 19 21:18:21 2015 +0100
Bug 744127 - Restore tab hover delay during drag-n-drops
Fix the return values of drag_motion() and drag_drop() callbacks.
Commit 7b85cf4de8938bfe833de223026bd6e99d585bac started mixing up
the two unrelated concepts
- the widgets has handled the event
- a drop here would do something / did something successfully
into one boolean value being both the function's return value and
a success indicator for the DND operation.
Untangle the concepts again by returning FALSE when
gimp_paned_box_will_handle_drag() returns TRUE (indicating that the
docking DND mechanism will kick in), and always returning TRUE
otherwise; and by using the state "drop was / would be successful"
only for calling gdk_drag_status() and gtk_drag_finish().
This way we make sure that:
- drag_leave() is called reliably again (because we return TRUE if no
other widget will handle the event)
- drag data is freed reliably again (because we always call
gtk_drag_finish())
(cherry picked from commit 29456b96f95955d109f5a59e15ceff32945dc48d)
app/widgets/gimpdockable.c | 51 ++++++++++++++-------------
app/widgets/gimpdockbook.c | 81 +++++++++++++++++++++----------------------
app/widgets/gimppanedbox.c | 33 +++++++++---------
app/widgets/gimptoolbox.c | 67 ++++++++++++++++++------------------
4 files changed, 115 insertions(+), 117 deletions(-)
---
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index 47afdb4..a4493fa 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -349,18 +349,25 @@ gimp_dockable_drag_motion (GtkWidget *widget,
gint y,
guint time)
{
- GimpDockable *dockable = GIMP_DOCKABLE (widget);
- gboolean other_will_handle = FALSE;
+ GimpDockable *dockable = GIMP_DOCKABLE (widget);
+
+ if (gimp_paned_box_will_handle_drag (dockable->p->drag_handler,
+ widget,
+ context,
+ x, y,
+ time))
+ {
+ gdk_drag_status (context, 0, time);
+ gimp_highlight_widget (widget, FALSE);
+
+ return FALSE;
+ }
- other_will_handle = gimp_paned_box_will_handle_drag (dockable->p->drag_handler,
- widget,
- context,
- x, y,
- time);
+ gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ gimp_highlight_widget (widget, TRUE);
- gdk_drag_status (context, other_will_handle ? 0 : GDK_ACTION_MOVE, time);
- gimp_highlight_widget (widget, ! other_will_handle);
- return other_will_handle ? FALSE : TRUE;
+ /* Return TRUE so drag_leave() is called */
+ return TRUE;
}
static gboolean
@@ -371,7 +378,7 @@ gimp_dockable_drag_drop (GtkWidget *widget,
guint time)
{
GimpDockable *dockable = GIMP_DOCKABLE (widget);
- gboolean handled = FALSE;
+ gboolean dropped;
if (gimp_paned_box_will_handle_drag (dockable->p->drag_handler,
widget,
@@ -379,21 +386,15 @@ gimp_dockable_drag_drop (GtkWidget *widget,
x, y,
time))
{
- /* Make event fall through to the drag handler */
- handled = FALSE;
- }
- else
- {
- handled =
- gimp_dockbook_drop_dockable (GIMP_DOCKABLE (widget)->p->dockbook,
- gtk_drag_get_source_widget (context));
+ return FALSE;
}
- /* We must call gtk_drag_finish() ourselves */
- if (handled)
- gtk_drag_finish (context, TRUE, TRUE, time);
+ dropped = gimp_dockbook_drop_dockable (GIMP_DOCKABLE (widget)->p->dockbook,
+ gtk_drag_get_source_widget (context));
- return handled;
+ gtk_drag_finish (context, dropped, TRUE, time);
+
+ return TRUE;
}
static void
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index bd27fcc..5e2a429 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -386,18 +386,25 @@ gimp_dockbook_drag_motion (GtkWidget *widget,
gint y,
guint time)
{
- GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
- gboolean other_will_handle = FALSE;
-
- other_will_handle = gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
- widget,
- context,
- x, y,
- time);
-
- gdk_drag_status (context, other_will_handle ? 0 : GDK_ACTION_MOVE, time);
- gimp_highlight_widget (widget, ! other_will_handle);
- return other_will_handle ? FALSE : TRUE;
+ GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
+
+ if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
+ widget,
+ context,
+ x, y,
+ time))
+ {
+ gdk_drag_status (context, 0, time);
+ gimp_highlight_widget (widget, FALSE);
+
+ return FALSE;
+ }
+
+ gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ gimp_highlight_widget (widget, TRUE);
+
+ /* Return TRUE so drag_leave() is called */
+ return TRUE;
}
static gboolean
@@ -408,7 +415,7 @@ gimp_dockbook_drag_drop (GtkWidget *widget,
guint time)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
- gboolean handled = FALSE;
+ gboolean dropped;
if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
widget,
@@ -416,21 +423,15 @@ gimp_dockbook_drag_drop (GtkWidget *widget,
x, y,
time))
{
- /* Make event fall through to the drag handler */
- handled = FALSE;
- }
- else
- {
- handled =
- gimp_dockbook_drop_dockable (dockbook,
- gtk_drag_get_source_widget (context));
+ return FALSE;
}
- /* We must call gtk_drag_finish() ourselves */
- if (handled)
- gtk_drag_finish (context, TRUE, TRUE, time);
+ dropped = gimp_dockbook_drop_dockable (dockbook,
+ gtk_drag_get_source_widget (context));
- return handled;
+ gtk_drag_finish (context, dropped, TRUE, time);
+
+ return TRUE;
}
static gboolean
@@ -1447,17 +1448,18 @@ gimp_dockbook_tab_drag_motion (GtkWidget *widget,
GimpDockbook *dockbook = gimp_dockable_get_dockbook (dockable);
GtkTargetList *target_list;
GdkAtom target_atom;
- gboolean handle = FALSE;
+ gboolean handle;
- /* If the handler will handle the drag, return FALSE */
if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
widget,
context,
x, y,
time))
{
- handle = FALSE;
- goto finish;
+ gdk_drag_status (context, 0, time);
+ gimp_highlight_widget (widget, FALSE);
+
+ return FALSE;
}
if (! dockbook->p->tab_hover_timeout ||
@@ -1479,10 +1481,11 @@ gimp_dockbook_tab_drag_motion (GtkWidget *widget,
handle = gtk_target_list_find (target_list, target_atom, NULL);
- finish:
gdk_drag_status (context, handle ? GDK_ACTION_MOVE : 0, time);
gimp_highlight_widget (widget, handle);
- return handle;
+
+ /* Return TRUE so drag_leave() is called */
+ return TRUE;
}
static gboolean
@@ -1494,21 +1497,19 @@ gimp_dockbook_tab_drag_drop (GtkWidget *widget,
{
GimpDockable *dest_dockable;
GtkWidget *source;
- gboolean handle = FALSE;
+ gboolean dropped = FALSE;
dest_dockable = g_object_get_data (G_OBJECT (widget), "gimp-dockable");
source = gtk_drag_get_source_widget (context);
- /* If the handler will handle the drag, return FALSE */
if (gimp_paned_box_will_handle_drag (gimp_dockable_get_drag_handler (dest_dockable),
widget,
context,
x, y,
time))
{
- handle = FALSE;
- goto finish;
+ return FALSE;
}
if (dest_dockable && source)
@@ -1535,7 +1536,7 @@ gimp_dockbook_tab_drag_drop (GtkWidget *widget,
g_object_unref (src_dockable);
- handle = TRUE;
+ dropped = TRUE;
}
else if (src_dockable != dest_dockable)
{
@@ -1547,16 +1548,14 @@ gimp_dockbook_tab_drag_drop (GtkWidget *widget,
dockbook_signals[DOCKABLE_REORDERED], 0,
src_dockable);
- handle = TRUE;
+ dropped = TRUE;
}
}
}
- finish:
- if (handle)
- gtk_drag_finish (context, TRUE, TRUE, time);
+ gtk_drag_finish (context, dropped, TRUE, time);
- return handle;
+ return TRUE;
}
static GtkWidget *
diff --git a/app/widgets/gimppanedbox.c b/app/widgets/gimppanedbox.c
index a00a735..1400293 100644
--- a/app/widgets/gimppanedbox.c
+++ b/app/widgets/gimppanedbox.c
@@ -353,9 +353,10 @@ gimp_paned_box_drag_motion (GtkWidget *widget,
x, y,
time))
{
- /* A parent widget will handle the event, just go to the end */
- handle = FALSE;
- goto finish;
+ gdk_drag_status (context, 0, time);
+ gimp_highlight_widget (widget, FALSE);
+
+ return FALSE;
}
gtk_widget_get_allocation (widget, &allocation);
@@ -433,10 +434,11 @@ gimp_paned_box_drag_motion (GtkWidget *widget,
/* Save the insert index for drag-drop */
paned_box->p->insert_index = insert_index;
- finish:
gdk_drag_status (context, handle ? GDK_ACTION_MOVE : 0, time);
gimp_highlight_widget (widget, handle);
- return handle;
+
+ /* Return TRUE so drag_leave() is called */
+ return TRUE;
}
static gboolean
@@ -446,8 +448,8 @@ gimp_paned_box_drag_drop (GtkWidget *widget,
gint y,
guint time)
{
- gboolean found = FALSE;
GimpPanedBox *paned_box = GIMP_PANED_BOX (widget);
+ gboolean dropped;
if (gimp_paned_box_will_handle_drag (paned_box->p->drag_handler,
widget,
@@ -455,25 +457,22 @@ gimp_paned_box_drag_drop (GtkWidget *widget,
x, y,
time))
{
- /* A parent widget will handle the event, just go to the end */
- found = FALSE;
- goto finish;
+ return FALSE;
}
-
+
if (paned_box->p->dropped_cb)
{
GtkWidget *source = gtk_drag_get_source_widget (context);
if (source)
- found = paned_box->p->dropped_cb (source,
- paned_box->p->insert_index,
- paned_box->p->dropped_cb_data);
+ dropped = paned_box->p->dropped_cb (source,
+ paned_box->p->insert_index,
+ paned_box->p->dropped_cb_data);
}
- finish:
- if (found)
- gtk_drag_finish (context, TRUE, TRUE, time);
- return found;
+ gtk_drag_finish (context, dropped, TRUE, time);
+
+ return TRUE;
}
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index b3dee39..0c422a9 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -475,22 +475,27 @@ gimp_toolbox_drag_motion (GtkWidget *widget,
guint time,
GimpToolbox *toolbox)
{
- gboolean other_will_handle = FALSE;
- gboolean we_will_handle = FALSE;
- gboolean handled = FALSE;
-
- other_will_handle = gimp_paned_box_will_handle_drag (toolbox->p->drag_handler,
- widget,
- context,
- x, y,
- time);
- we_will_handle = (gtk_drag_dest_find_target (widget, context, NULL) !=
- GDK_NONE);
-
- handled = ! other_will_handle && we_will_handle;
- gdk_drag_status (context, handled ? GDK_ACTION_MOVE : 0, time);
- gimp_highlight_widget (widget, handled);
- return handled;
+ gboolean handle;
+
+ if (gimp_paned_box_will_handle_drag (toolbox->p->drag_handler,
+ widget,
+ context,
+ x, y,
+ time))
+ {
+ gdk_drag_status (context, 0, time);
+ gimp_highlight_widget (widget, FALSE);
+
+ return FALSE;
+ }
+
+ handle = (gtk_drag_dest_find_target (widget, context, NULL) != GDK_NONE);
+
+ gdk_drag_status (context, handle ? GDK_ACTION_MOVE : 0, time);
+ gimp_highlight_widget (widget, handle);
+
+ /* Return TRUE so drag_leave() is called */
+ return TRUE;
}
static gboolean
@@ -501,7 +506,8 @@ gimp_toolbox_drag_drop (GtkWidget *widget,
guint time,
GimpToolbox *toolbox)
{
- gboolean handled = FALSE;
+ GdkAtom target;
+ gboolean dropped = FALSE;
if (gimp_paned_box_will_handle_drag (toolbox->p->drag_handler,
widget,
@@ -509,28 +515,21 @@ gimp_toolbox_drag_drop (GtkWidget *widget,
x, y,
time))
{
- /* Make event fall through to the drag handler */
- handled = FALSE;
+ return FALSE;
}
- else
- {
- GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);
- if (target != GDK_NONE)
- {
- /* The URI handlers etc will handle this */
- gtk_drag_get_data (widget, context, target, time);
- handled = TRUE;
- }
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+
+ if (target != GDK_NONE)
+ {
+ /* The URI handlers etc will handle this */
+ gtk_drag_get_data (widget, context, target, time);
+ dropped = TRUE;
}
- if (handled)
- gtk_drag_finish (context,
- TRUE /*success*/,
- (context->action == GDK_ACTION_MOVE) /*del*/,
- time);
+ gtk_drag_finish (context, dropped, (context->action == GDK_ACTION_MOVE), time);
- return handled;
+ return TRUE;
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]