Skip to content

Commit

Permalink
At the end of drag and drop, grab and release seat
Browse files Browse the repository at this point in the history
Fix #515
  • Loading branch information
zhuyaliang committed Apr 19, 2024
1 parent 7890312 commit 43319ed
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/fr-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down

0 comments on commit 43319ed

Please sign in to comment.