summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2021-11-05 12:46:21 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2021-11-05 12:46:21 +0100
commit0ad192a27b85974376bf5251287cf9905dfbfc85 (patch)
tree6c8a7ffca8e2028459fc6edb0c6c4854c69c20c8 /src
parent995a48dd003b51291bb1f2c5513c529a1ad8dfed (diff)
Make "FLTK_CONSOLIDATE_MOTION" user-definable (issue #76)
This undocumented macro is used on X11 and macOS platforms to consolidate mouse move events, i.e. to collect some events and send them later as one event. The old macro name CONSOLIDATE_MOTION has been renamed to FLTK_CONSOLIDATE_MOTION since it is now a "global" symbol. Users can define FLTK_CONSOLIDATE_MOTION in their build system, e.g. on the compiler commandline, as 0 or 1 to disable or enable this feature, respectively. In FLTK 1.3 the default was 0 (OFF) on macOS and 1 (ON) on X11. In FLTK 1.4 the default is always 0 (OFF).
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm8
-rw-r--r--src/Fl_x.cxx13
2 files changed, 13 insertions, 8 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 2b9861027..63c6c8e93 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -14,8 +14,10 @@
// https://www.fltk.org/bugs.php
//
+#ifndef FLTK_CONSOLIDATE_MOTION
+#define FLTK_CONSOLIDATE_MOTION 0
+#endif
-#define CONSOLIDATE_MOTION 0
extern "C" {
#include <pthread.h>
}
@@ -107,7 +109,7 @@ static NSMutableArray *dropped_files_list = nil; // list of files dropped at app
typedef void (*open_cb_f_type)(const char *);
static Fl_Window *starting_moved_window = NULL; // the moved window which brings its subwins with it
-#if CONSOLIDATE_MOTION
+#if FLTK_CONSOLIDATE_MOTION
static Fl_Window* send_motion;
extern Fl_Window* fl_xmousewin;
#endif
@@ -760,7 +762,7 @@ static int do_queued_events( double time = 0.0 )
}
fl_lock_function();
-#if CONSOLIDATE_MOTION
+#if FLTK_CONSOLIDATE_MOTION
if (send_motion && send_motion == fl_xmousewin) {
send_motion = 0;
Fl::handle(FL_MOVE, fl_xmousewin);
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 6bce6293c..dc64ce291 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -16,7 +16,10 @@
#if !defined(FL_DOXYGEN)
-# define CONSOLIDATE_MOTION 1
+# ifndef FLTK_CONSOLIDATE_MOTION
+# define FLTK_CONSOLIDATE_MOTION 0
+# endif
+
/**** Define this if your keyboard lacks a backspace key... ****/
/* #define BACKSPACE_HACK 1 */
@@ -199,7 +202,7 @@ void Fl_X11_System_Driver::remove_fd(int n) {
extern int fl_send_system_handlers(void *e);
-#if CONSOLIDATE_MOTION
+#if FLTK_CONSOLIDATE_MOTION
static Fl_Window* send_motion;
extern Fl_Window* fl_xmousewin;
#endif
@@ -215,7 +218,7 @@ static void do_queued_events() {
}
// we send FL_LEAVE only if the mouse did not enter some other window:
if (!in_a_window) Fl::handle(FL_LEAVE, 0);
-#if CONSOLIDATE_MOTION
+#if FLTK_CONSOLIDATE_MOTION
else if (send_motion && send_motion == fl_xmousewin) {
send_motion = 0;
Fl::handle(FL_MOVE, fl_xmousewin);
@@ -1209,7 +1212,7 @@ static int px, py;
static ulong ptime;
static void set_event_xy(Fl_Window *win) {
-# if CONSOLIDATE_MOTION
+# if FLTK_CONSOLIDATE_MOTION
send_motion = 0;
# endif
float s = 1;
@@ -2135,7 +2138,7 @@ int fl_handle(const XEvent& thisevent)
case MotionNotify:
set_event_xy(window);
-# if CONSOLIDATE_MOTION
+# if FLTK_CONSOLIDATE_MOTION
send_motion = fl_xmousewin = window;
in_a_window = true;
return 0;