From 43319ede03336f60026625d3cc93ee6812a4ca98 Mon Sep 17 00:00:00 2001 From: zhu yaliang Date: Fri, 19 Apr 2024 10:43:39 +0800 Subject: [PATCH] At the end of drag and drop, grab and release seat Fix https://github.com/mate-desktop/engrampa/issues/515 --- src/fr-window.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/fr-window.c b/src/fr-window.c index 20ca551c..f0fbc78c 100644 --- a/src/fr-window.c +++ b/src/fr-window.c @@ -4160,6 +4160,25 @@ file_list_drag_begin (GtkWidget *widget, return TRUE; } +static void +grab_widget (GtkWidget *widget) +{ + + GdkWindow *window; + GdkDisplay *display; + GdkSeat *seat; + + g_return_if_fail (widget != NULL); + window = gtk_widget_get_window (widget); + display = gdk_window_get_display (window); + + seat = gdk_display_get_default_seat (display); + gdk_seat_grab (seat, window, + GDK_SEAT_CAPABILITY_ALL, TRUE, + NULL, NULL, NULL, NULL); + gdk_seat_ungrab (seat); +} + static void file_list_drag_end (GtkWidget *widget, GdkDragContext *context, @@ -4168,6 +4187,33 @@ file_list_drag_end (GtkWidget *widget, FrWindow *window = data; debug (DEBUG_INFO, "::DragEnd -->\n"); + GtkWidget *xgrab_shell; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + xgrab_shell = NULL; + while (parent) + { + gboolean viewable = TRUE; + GtkWidget *tmp = parent; + while (tmp) + { + if (!gtk_widget_get_mapped (tmp)) + { + viewable = FALSE; + break; + } + tmp = gtk_widget_get_parent (tmp); + } + + if (viewable) + xgrab_shell = parent; + parent = gtk_widget_get_parent (parent); + } + if (xgrab_shell) + { + grab_widget (widget); + } gdk_property_delete (gdk_drag_context_get_source_window (context), XDS_ATOM);