diff options
author | Po Lu <luangruo@yahoo.com> | 2022-03-17 08:54:30 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-03-17 08:55:16 +0800 |
commit | c223e2aefcabc7ad29c4be186fc07825bbcce196 (patch) | |
tree | edfea0ef55b7fda8be85b411a41643c1c5591fe6 | |
parent | f7e0e5b7aeb928353065a3667c5231c4e4559d28 (diff) | |
download | emacs-c223e2aefcabc7ad29c4be186fc07825bbcce196.tar.gz |
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.
-rw-r--r-- | src/xterm.c | 45 |
1 files changed, 33 insertions, 12 deletions
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. */ |