diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-07-14 17:44:12 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-07-14 18:02:17 +0200 |
| commit | 12592753166337548c9f80f7247803070433b2fd (patch) | |
| tree | 407c7eca83af69b25e5a7ddbf5f6ce9e5967d3d0 | |
| parent | f8d0b591ab388d5ed9fb2956989b4d8c51f41fed (diff) | |
Keep sending FL_DRAG until all mouse buttons are released
The old version would send FL_MOVE events after dragging with more
than one mouse buttons pressed, as soon as the first button was
released.
The new version sends FL_DRAG until the last mouse button is released
and then FL_MOVE, as usual.
This change affects dragging only if more than one mouse button is
pushed and held while dragging. The order of pushing and releasing
mouse buttons does not affect the behavior.
| -rw-r--r-- | src/Fl.cxx | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index f1ad4d75c..429c5c74a 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1359,7 +1359,7 @@ int Fl::handle_(int e, Fl_Window* window) ret = (wi && send_event(e, wi, window)); if (pbm != belowmouse()) { #ifdef DEBUG - printf("Fl::handle(e=%d, window=%p);\n", e, window); + printf("Fl::handle(e=%d, window=%p) -- Fl_Tooltip::enter(%p);\n", e, window, belowmouse()); #endif // DEBUG Fl_Tooltip::enter(belowmouse()); } @@ -1367,19 +1367,44 @@ int Fl::handle_(int e, Fl_Window* window) } case FL_RELEASE: { -// printf("FL_RELEASE: window=%p, pushed() = %p, grab() = %p, modal() = %p\n", -// window, pushed(), grab(), modal()); + + // Mouse drag release mode - Jul 14, 2023, Albrecht-S (WIP): + // 0 = old: *first* mouse button release ("up") turns drag mode off + // 1 = new: *last* mouse button release ("up") turns drag mode off + // The latter enables dragging with two or more pressed mouse buttons + // and to continue dragging (i.e. sending FL_DRAG) until the *last* + // mouse button is released. + // See fltk.general, thread started on Jul 12, 2023 + // "Is handling simultaneous Left-click and Right-click drags supported?" + + static const int drag_release = 1; // should be 1 => new behavior since Jul 2023 + + // Implementation notes: + // (1) Mode 1 (new): only if *all* mouse buttons have been released, the + // Fl::pushed_ widget is reset to 0 (NULL) so subsequent system "move" + // events are no longer sent as FL_DRAG events. + // (2) Mode 0 (old): Fl::pushed_ was reset on the *first* mouse button release. + // (3) The constant 'drag_release' should be removed once the new mode has been + // confirmed to work correctly and no side effects have been observed. + // Hint: remove condition "!drag_release || " twice (below). + + // printf("FL_RELEASE: window=%p, pushed() = %p, grab() = %p, modal() = %p, drag_release = %d, buttons = 0x%x\n", + // window, pushed(), grab(), modal(), drag_release, Fl::event_buttons()>>24); if (grab()) { wi = grab(); - pushed_ = 0; // must be zero before callback is done! + if (!drag_release || !Fl::event_buttons()) + pushed_ = 0; // must be zero before callback is done! } else if (pushed()) { wi = pushed(); - pushed_ = 0; // must be zero before callback is done! - } else if (modal() && wi != modal()) return 0; + if (!drag_release || !Fl::event_buttons()) + pushed_ = 0; // must be zero before callback is done! + } else if (modal() && wi != modal()) + return 0; int r = send_event(e, wi, window); fl_fix_focus(); - return r;} + return r; + } case FL_UNFOCUS: window = 0; |
