From: Po Lu Date: Thu, 17 Mar 2022 00:54:30 +0000 (+0800) Subject: Improve GTK support for X11 drag-n-drop X-Git-Tag: emacs-29.0.90~1931^2~1088 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c223e2aefcabc7ad29c4be186fc07825bbcce196;p=emacs.git Improve GTK support for X11 drag-n-drop * src/xterm.c (x_dnd_begin_drag_and_drop): Run nested GTK event loop instead, so GTK gets the correct events. --- diff --git a/src/xterm.c b/src/xterm.c index 46a22d8dc1b..59c3cefd598 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -702,6 +702,19 @@ static Lisp_Object xg_default_icon_file; static char emacs_class[] = EMACS_CLASS; #endif +#ifdef USE_GTK +static int current_count; +static int current_finish; +static struct input_event *current_hold_quit; +#endif + +enum +{ + X_EVENT_NORMAL, + X_EVENT_GOTO_OUT, + X_EVENT_DROP +}; + enum xembed_info { XEMBED_MAPPED = 1 << 0 @@ -1072,9 +1085,11 @@ Lisp_Object x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, bool return_frame_p) { +#ifndef USE_GTK XEvent next_event; - struct input_event hold_quit; int finish; +#endif + struct input_event hold_quit; char *atom_name; Lisp_Object action, ltimestamp; @@ -1104,15 +1119,25 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, if (return_frame_p) x_dnd_return_frame = 1; + current_count = 0; + while (x_dnd_in_progress) { +#ifdef USE_GTK hold_quit.kind = NO_EVENT; + current_finish = X_EVENT_NORMAL; + current_hold_quit = &hold_quit; +#endif block_input (); +#ifndef USE_GTK XNextEvent (FRAME_X_DISPLAY (f), &next_event); handle_one_xevent (FRAME_DISPLAY_INFO (f), &next_event, &finish, &hold_quit); +#else + gtk_main_iteration (); +#endif unblock_input (); if (hold_quit.kind != NO_EVENT) @@ -1130,10 +1155,17 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, } FRAME_DISPLAY_INFO (f)->grabbed = 0; +#ifdef USE_GTK + current_hold_quit = NULL; +#endif quit (); } } +#ifdef USE_GTK + current_hold_quit = NULL; +#endif + if (x_dnd_return_frame == 3) { x_dnd_return_frame_object->mouse_moved = true; @@ -10125,13 +10157,6 @@ static struct x_display_info *XTread_socket_fake_io_error; static struct x_display_info *next_noop_dpyinfo; -enum -{ - X_EVENT_NORMAL, - X_EVENT_GOTO_OUT, - X_EVENT_DROP -}; - /* Filter events for the current X input method. DPYINFO is the display this event is for. EVENT is the X event to filter. @@ -10207,10 +10232,6 @@ x_filter_event (struct x_display_info *dpyinfo, XEvent *event) #endif #ifdef USE_GTK -static int current_count; -static int current_finish; -static struct input_event *current_hold_quit; - /* This is the filter function invoked by the GTK event loop. It is invoked before the XEvent is translated to a GdkEvent, so we have a chance to act on the event before GTK. */