diff --git a/CHANGES.txt b/CHANGES.txt index 386385231..91e1292df 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,8 @@ Changes in FLTK 1.5.0 Released: xxx yy 2026 Bug Fixes and other Improvements + - Member function int Fl::get_mouse(int&, int&) has now a return value providing the + number of the mouse-containing screen (previously, return type was void). Platform Specific Fixes and Build Procedure Improvements diff --git a/FL/core/events.H b/FL/core/events.H index 01c0fd7ed..e5a2e69d5 100644 --- a/FL/core/events.H +++ b/FL/core/events.H @@ -145,14 +145,17 @@ FL_EXPORT inline int event_dy() { return e_dy; } // /** - Return where the mouse is on the screen by doing a round-trip query to - the server. You should use Fl::event_x_root() and + Return the number of the mouse-containing screen and computes the mouse screen coordinates. + This requires a round-trip query to the server. You should use Fl::event_x_root() and Fl::event_y_root() if possible, but this is necessary if you are not sure if a mouse event has been processed recently (such as to position your first window). If the display is not open, this will open it. + \param X,Y assigned with the mouse screen coordinates upon return + \return number of the mouse-containing screen + \since 1.5 added a function return value */ -FL_EXPORT extern void get_mouse(int &,int &); +FL_EXPORT extern int get_mouse(int &X,int &Y); // // Mouse Click Functions diff --git a/src/Fl.cxx b/src/Fl.cxx index 399d8249b..22196316c 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -2310,8 +2310,8 @@ int Fl::get_key(int k) { return screen_driver()->get_key(k); } -void Fl::get_mouse(int &x, int &y) { - Fl::screen_driver()->get_mouse(x, y); +int Fl::get_mouse(int &x, int &y) { + return Fl::screen_driver()->get_mouse(x, y); } const char * fl_filename_name(const char *name) { diff --git a/src/Fl_Window_hotspot.cxx b/src/Fl_Window_hotspot.cxx index 66e463c85..529a1ee1d 100644 --- a/src/Fl_Window_hotspot.cxx +++ b/src/Fl_Window_hotspot.cxx @@ -22,9 +22,9 @@ void Fl_Window::hotspot(int X, int Y, int offscreen) { int mx,my; // Update the screen position based on the mouse position. - Fl::get_mouse(mx,my); + int ms = Fl::get_mouse(mx,my); // put the window on the mouse-containing screen - this->screen_num(Fl::screen_num(mx, my)); + this->screen_num(ms); X = mx-X; Y = my-Y; // If offscreen is 0 (the default), make sure that the window