STR #2860: Mods for full screen support.
Applied the fltk-1.3.x-screen_num.patch git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9982 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
bedb7fd6f0
commit
5d4fed1ef9
2
FL/Fl.H
2
FL/Fl.H
@ -826,6 +826,8 @@ public:
|
||||
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
|
||||
static void screen_xywh(int &X, int &Y, int &W, int &H, int n);
|
||||
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
|
||||
static int screen_num(int x, int y);
|
||||
static int screen_num(int x, int y, int w, int h);
|
||||
static void screen_dpi(float &h, float &v, int n=0);
|
||||
static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
|
||||
static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
|
||||
|
@ -215,21 +215,6 @@ int Fl::screen_count() {
|
||||
return num_screens ? num_screens : 1;
|
||||
}
|
||||
|
||||
static int find_screen_with_point(int mx, int my) {
|
||||
int screen = 0;
|
||||
if (num_screens < 0) screen_init();
|
||||
|
||||
for (int i = 0; i < num_screens; i ++) {
|
||||
int sx, sy, sw, sh;
|
||||
Fl::screen_xywh(sx, sy, sw, sh, i);
|
||||
if ((mx >= sx) && (mx < (sx+sw)) && (my >= sy) && (my < (sy+sh))) {
|
||||
screen = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the bounding box of a screen
|
||||
that contains the specified screen position \p mx, \p my
|
||||
@ -237,7 +222,7 @@ static int find_screen_with_point(int mx, int my) {
|
||||
\param[in] mx, my the absolute screen position
|
||||
*/
|
||||
void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
|
||||
screen_xywh(X, Y, W, H, find_screen_with_point(mx, my));
|
||||
screen_xywh(X, Y, W, H, screen_num(mx, my));
|
||||
}
|
||||
|
||||
|
||||
@ -248,7 +233,7 @@ void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
|
||||
\param[in] mx, my the absolute screen position
|
||||
*/
|
||||
void Fl::screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my) {
|
||||
screen_work_area(X, Y, W, H, find_screen_with_point(mx, my));
|
||||
screen_work_area(X, Y, W, H, screen_num(mx, my));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,6 +306,39 @@ void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int n) {
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the screen bounding rect for the screen
|
||||
which intersects the most with the rectangle
|
||||
defined by \p mx, \p my, \p mw, \p mh.
|
||||
\param[out] X,Y,W,H the corresponding screen bounding box
|
||||
\param[in] mx, my, mw, mh the rectangle to search for intersection with
|
||||
\see void screen_xywh(int &X, int &Y, int &W, int &H, int n)
|
||||
*/
|
||||
void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh) {
|
||||
screen_xywh(X, Y, W, H, screen_num(mx, my, mw, mh));
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the screen number of a screen
|
||||
that contains the specified screen position \p x, \p y
|
||||
\param[in] x, y the absolute screen position
|
||||
*/
|
||||
int Fl::screen_num(int x, int y) {
|
||||
int screen = 0;
|
||||
if (num_screens < 0) screen_init();
|
||||
|
||||
for (int i = 0; i < num_screens; i ++) {
|
||||
int sx, sy, sw, sh;
|
||||
Fl::screen_xywh(sx, sy, sw, sh, i);
|
||||
if ((x >= sx) && (x < (sx+sw)) && (y >= sy) && (y < (sy+sh))) {
|
||||
screen = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
// Return the number of pixels common to the two rectangular areas
|
||||
static inline float fl_intersection(int x1, int y1, int w1, int h1,
|
||||
int x2, int y2, int w2, int h2) {
|
||||
if(x1+w1 < x2 || x2+w2 < x1 || y1+h1 < y2 || y2+h2 < y1)
|
||||
@ -333,30 +351,26 @@ static inline float fl_intersection(int x1, int y1, int w1, int h1,
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the screen bounding rect for the screen
|
||||
Gets the screen number for the screen
|
||||
which intersects the most with the rectangle
|
||||
defined by \p mx, \p my, \p mw, \p mh.
|
||||
\param[out] X,Y,W,H the corresponding screen bounding box
|
||||
\param[in] mx, my, mw, mh the rectangle to search for intersection with
|
||||
\see void screen_xywh(int &X, int &Y, int &W, int &H, int n)
|
||||
defined by \p x, \p y, \p w, \p h.
|
||||
\param[in] x, y, w, h the rectangle to search for intersection with
|
||||
*/
|
||||
void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh) {
|
||||
int Fl::screen_num(int x, int y, int w, int h) {
|
||||
int best_screen = 0;
|
||||
float best_intersection = 0.;
|
||||
for(int i = 0; i < Fl::screen_count(); i++) {
|
||||
for (int i = 0; i < Fl::screen_count(); i++) {
|
||||
int sx, sy, sw, sh;
|
||||
Fl::screen_xywh(sx, sy, sw, sh, i);
|
||||
float sintersection = fl_intersection(mx, my, mw, mh, sx, sy, sw, sh);
|
||||
if(sintersection > best_intersection) {
|
||||
float sintersection = fl_intersection(x, y, w, h, sx, sy, sw, sh);
|
||||
if (sintersection > best_intersection) {
|
||||
best_screen = i;
|
||||
best_intersection = sintersection;
|
||||
}
|
||||
}
|
||||
screen_xywh(X, Y, W, H, best_screen);
|
||||
return best_screen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Gets the screen resolution in dots-per-inch for the given screen.
|
||||
\param[out] h, v horizontal and vertical resolution
|
||||
|
Loading…
x
Reference in New Issue
Block a user