From 3d2531c12c54f9ab923603655016077450c23ab2 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 4 Apr 2022 11:37:12 +0000 Subject: [PATCH] Fix generation of extra DND events while dragging on Haiku * src/haiku_support.cc (be_drag_message): Set new DND flag. (be_drag_and_drop_in_progress): New function. * src/haiku_support.h: Update prototypes. * src/haikuterm.c (haiku_read_socket): Don't store DND motion events if DND is in progress. --- src/haiku_support.cc | 19 +++++++++++++++++-- src/haiku_support.h | 3 +++ src/haikuterm.c | 14 +++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 64556ba51b6..40112e2b717 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -122,6 +122,7 @@ static int current_window_id; static void *grab_view = NULL; static BLocker grab_view_locker; +static bool drag_and_drop_in_progress; /* This could be a private API, but it's used by (at least) the Qt port, so it's probably here to stay. */ @@ -4111,6 +4112,8 @@ be_drag_message (void *view, void *message, bool allow_same_view, resume_thread (infos[1].object); unblock_input_function (); + drag_and_drop_in_progress = true; + while (true) { block_input_function (); @@ -4128,12 +4131,24 @@ be_drag_message (void *view, void *message, bool allow_same_view, process_pending_signals_function (); if (should_quit_function ()) - return true; + { + drag_and_drop_in_progress = false; + return true; + } if (infos[1].events & B_EVENT_INVALID) - return false; + { + drag_and_drop_in_progress = false; + return false; + } infos[0].events = B_EVENT_READ; infos[1].events = B_EVENT_INVALID; } } + +bool +be_drag_and_drop_in_progress (void) +{ + return drag_and_drop_in_progress; +} diff --git a/src/haiku_support.h b/src/haiku_support.h index ac3029fbf3f..d0a78c693b9 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -951,6 +951,9 @@ extern "C" void (*process_pending_signals_function) (void), bool (*should_quit_function) (void)); + extern bool + be_drag_and_drop_in_progress (void); + #ifdef __cplusplus extern void * find_appropriate_view_for_draw (void *vw); diff --git a/src/haikuterm.c b/src/haikuterm.c index 91e985e196a..e2d6a9a4670 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -3145,12 +3145,16 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) another program is dragging stuff over us. */ do_help = -1; - inev.kind = DRAG_N_DROP_EVENT; - inev.arg = Qlambda; - XSETINT (inev.x, b->x); - XSETINT (inev.y, b->y); - XSETFRAME (inev.frame_or_window, f); + if (!be_drag_and_drop_in_progress ()) + { + inev.kind = DRAG_N_DROP_EVENT; + inev.arg = Qlambda; + + XSETINT (inev.x, b->x); + XSETINT (inev.y, b->y); + XSETFRAME (inev.frame_or_window, f); + } break; } } -- 2.39.5