Add int return type to Fl::get_mouse(int&, int&) providing the number of mouse-containing screen.
Some checks failed
Build and Test / build-linux (push) Has been cancelled
Build and Test / build-wayland (push) Has been cancelled
Build and Test / build-macos (push) Has been cancelled
Build and Test / build-windows (push) Has been cancelled

This commit is contained in:
ManoloFLTK
2026-03-13 15:53:52 +01:00
parent a342d9f3d5
commit b4f73314a7
4 changed files with 12 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -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