Skip to content

Commit

Permalink
Make Fl_Screen_Driver::get_mouse(int&, int&) return the number of the…
Browse files Browse the repository at this point in the history
… mouse-containing screen.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12264 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Jun 17, 2017
1 parent ea56e74 commit 2cda5a4
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 44 deletions.
10 changes: 4 additions & 6 deletions FL/Fl_Screen_Driver.H
Expand Up @@ -76,16 +76,14 @@ public:
virtual int w() = 0;
virtual int h() = 0;
virtual int screen_count();
virtual void screen_xywh(int &X, int &Y, int &W, int &H);
virtual void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
virtual void screen_xywh(int &X, int &Y, int &W, int &H, int n) = 0;
virtual void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
virtual int screen_num(int x, int y);
virtual int screen_num(int x, int y, int w, int h);
virtual void screen_dpi(float &h, float &v, int n=0) = 0;
virtual void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
virtual void screen_work_area(int &X, int &Y, int &W, int &H, int n) = 0;
virtual void screen_work_area(int &X, int &Y, int &W, int &H);
// --- audible output
virtual void beep(int type) = 0;
// --- global events
Expand Down Expand Up @@ -151,7 +149,7 @@ public:
// the default implementation may be enough
virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
// implement to support Fl::get_mouse()
virtual void get_mouse(int &x, int &y) {}
virtual int get_mouse(int &x, int &y) {return 0;}
// optional methods to enable/disable input methods for complex scripts
virtual void enable_im() {}
virtual void disable_im() {}
Expand Down
18 changes: 1 addition & 17 deletions src/Fl_Screen_Driver.cxx
Expand Up @@ -54,28 +54,12 @@ int Fl_Screen_Driver::visual(int) {
}


void Fl_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H)
{
int x, y;
get_mouse(x, y);
screen_xywh(X, Y, W, H, x, y);
}


void Fl_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my)
{
screen_xywh(X, Y, W, H, screen_num(mx, my));
}


void Fl_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H)
{
int x, y;
get_mouse(x, y);
screen_work_area(X, Y, W, H, x, y);
}


void Fl_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my)
{
screen_work_area(X, Y, W, H, screen_num(mx, my));
Expand Down Expand Up @@ -103,7 +87,7 @@ int Fl_Screen_Driver::screen_num(int x, int y)

for (int i = 0; i < num_screens; i ++) {
int sx, sy, sw, sh;
Fl::screen_xywh(sx, sy, sw, sh, i);
screen_xywh(sx, sy, sw, sh, i);
if ((x >= sx) && (x < (sx+sw)) && (y >= sy) && (y < (sy+sh))) {
screen = i;
break;
Expand Down
3 changes: 2 additions & 1 deletion src/Fl_cocoa.mm
Expand Up @@ -1896,12 +1896,13 @@ static void get_window_frame_sizes(int &bx, int &by, int &bt) {
/*
* get the current mouse pointer world coordinates
*/
void Fl_Cocoa_Screen_Driver::get_mouse(int &x, int &y)
int Fl_Cocoa_Screen_Driver::get_mouse(int &x, int &y)
{
open_display();
NSPoint pt = [NSEvent mouseLocation];
x = int(pt.x);
y = int(main_screen_height - pt.y);
return screen_num(x, y);
}


Expand Down
3 changes: 2 additions & 1 deletion src/Fl_win32.cxx
Expand Up @@ -583,11 +583,12 @@ void Fl_WinAPI_Screen_Driver::disable_im() {

////////////////////////////////////////////////////////////////

void Fl_WinAPI_Screen_Driver::get_mouse(int &x, int &y) {
int Fl_WinAPI_Screen_Driver::get_mouse(int &x, int &y) {
POINT p;
GetCursorPos(&p);
x = p.x;
y = p.y;
return screen_num(x, y);
}

////////////////////////////////////////////////////////////////
Expand Down
6 changes: 4 additions & 2 deletions src/Fl_x.cxx
Expand Up @@ -733,10 +733,12 @@ int Fl_X11_Screen_Driver::get_mouse_unscaled(int &mx, int &my) {
}


void Fl_X11_Screen_Driver::get_mouse(int &xx, int &yy) {
float s = scale(get_mouse_unscaled(xx, yy));
int Fl_X11_Screen_Driver::get_mouse(int &xx, int &yy) {
int snum = get_mouse_unscaled(xx, yy);
float s = scale(snum);
xx = xx/s;
yy = yy/s;
return snum;
}

////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
Expand Up @@ -90,7 +90,7 @@ public:
virtual int compose(int &del);
virtual uchar *read_image(uchar *p, int x, int y, int w, int h, int alpha);
virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
virtual void get_mouse(int &x, int &y);
virtual int get_mouse(int &x, int &y);
virtual void enable_im();
virtual void disable_im();
virtual void open_display_platform();
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
Expand Up @@ -74,7 +74,7 @@ public:
virtual int dnd(int unused);
virtual int compose(int &del);
virtual Fl_RGB_Image *read_win_rectangle(uchar *p, int X, int Y, int w, int h, int alpha);
virtual void get_mouse(int &x, int &y);
virtual int get_mouse(int &x, int &y);
virtual void enable_im();
virtual void disable_im();
virtual void open_display_platform();
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/X11/Fl_X11_Screen_Driver.H
Expand Up @@ -57,7 +57,6 @@ public:
virtual float desktop_scale_factor();
int screen_num_unscaled(int x, int y);
int screen_num_unscaled(int x, int y, int w, int h);
virtual void screen_xywh(int &X, int &Y, int &W, int &H);
#endif

static int ewmh_supported();
Expand Down Expand Up @@ -96,7 +95,7 @@ public:
virtual void compose_reset();
virtual int text_display_can_leak();
virtual Fl_RGB_Image *read_win_rectangle(uchar *p, int X, int Y, int w, int h, int alpha);
virtual void get_mouse(int &x, int &y);
virtual int get_mouse(int &x, int &y);
virtual void enable_im();
virtual void disable_im();
virtual void open_display_platform();
Expand Down
11 changes: 0 additions & 11 deletions src/drivers/X11/Fl_X11_Screen_Driver.cxx
Expand Up @@ -1215,17 +1215,6 @@ int Fl_X11_Screen_Driver::screen_num_unscaled(int x, int y, int w, int h)
#endif

#if USE_XFT
void Fl_X11_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H)
{
int xx, yy;
int ns = get_mouse_unscaled(xx,yy);
float s = screens[ns].scale;
X = screens[ns].x_org / s;
Y = screens[ns].y_org / s;
W = screens[ns].width / s;
H = screens[ns].height / s;
}


#if HAVE_DLSYM && HAVE_DLFCN_H

Expand Down
8 changes: 6 additions & 2 deletions src/screen_xywh.cxx
Expand Up @@ -171,7 +171,9 @@ void Fl::screen_dpi(float &h, float &v, int n)
*/
void Fl::screen_xywh(int &X, int &Y, int &W, int &H)
{
Fl::screen_driver()->screen_xywh(X, Y, W, H);
int mx, my;
int nscreen = Fl::screen_driver()->get_mouse(mx, my);
Fl::screen_driver()->screen_xywh(X, Y, W, H, nscreen);
}


Expand All @@ -182,7 +184,9 @@ void Fl::screen_xywh(int &X, int &Y, int &W, int &H)
*/
void Fl::screen_work_area(int &X, int &Y, int &W, int &H)
{
Fl::screen_driver()->screen_xywh(X, Y, W, H);
int mx, my;
int nscreen = Fl::screen_driver()->get_mouse(mx, my);
Fl::screen_driver()->screen_work_area(X, Y, W, H, nscreen);
}


Expand Down

0 comments on commit 2cda5a4

Please sign in to comment.