mirror of https://github.com/fltk/fltk
STR 2655: applied commited patch. Looks good to me.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8778 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
6fde8226fa
commit
4236124af2
|
@ -202,81 +202,21 @@ int Fl::screen_count() {
|
||||||
\param[in] mx, my the absolute screen position
|
\param[in] mx, my the absolute screen position
|
||||||
*/
|
*/
|
||||||
void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
|
void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
|
||||||
|
int screen = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (num_screens < 0) screen_init();
|
if (num_screens < 0) screen_init();
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
if (num_screens > 0) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i ++) {
|
for (i = 0; i < num_screens; i ++) {
|
||||||
if (mx >= screens[i].left && mx < screens[i].right &&
|
int sx, sy, sw, sh;
|
||||||
my >= screens[i].top && my < screens[i].bottom) {
|
Fl::screen_xywh(sx, sy, sw, sh, i);
|
||||||
X = screens[i].left;
|
if ((mx >= sx) && (mx < (sx+sw)) && (my >= sy) && (my < (sy+sh))) {
|
||||||
Y = screens[i].top;
|
screen = i;
|
||||||
W = screens[i].right - screens[i].left;
|
break;
|
||||||
H = screens[i].bottom - screens[i].top;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// if all else fails:
|
|
||||||
X = Fl::x();
|
|
||||||
Y = Fl::y();
|
|
||||||
W = Fl::w();
|
|
||||||
H = Fl::h();
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
if (num_screens > 0) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i ++) {
|
|
||||||
if (mx >= screens[i].x &&
|
|
||||||
mx < (screens[i].x + screens[i].width) &&
|
|
||||||
my >= screens[i].y &&
|
|
||||||
my < (screens[i].y + screens[i].height)) {
|
|
||||||
X = screens[i].x;
|
|
||||||
Y = screens[i].y;
|
|
||||||
W = screens[i].width;
|
|
||||||
H = screens[i].height;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if all else fails:
|
|
||||||
X = Fl::x();
|
|
||||||
Y = Fl::y();
|
|
||||||
W = Fl::w();
|
|
||||||
H = Fl::h();
|
|
||||||
#elif HAVE_XINERAMA
|
|
||||||
if (num_screens > 0 && screens) { // screens == NULL if !XineramaIsActive(fl_display)
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i ++) {
|
|
||||||
if (mx >= screens[i].x_org &&
|
|
||||||
mx < (screens[i].x_org + screens[i].width) &&
|
|
||||||
my >= screens[i].y_org &&
|
|
||||||
my < (screens[i].y_org + screens[i].height)) {
|
|
||||||
X = screens[i].x_org;
|
|
||||||
Y = screens[i].y_org;
|
|
||||||
W = screens[i].width;
|
|
||||||
H = screens[i].height;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if all else fails:
|
|
||||||
X = Fl::x();
|
|
||||||
Y = Fl::y();
|
|
||||||
W = Fl::w();
|
|
||||||
H = Fl::h();
|
|
||||||
#else
|
|
||||||
(void)mx;
|
|
||||||
(void)my;
|
|
||||||
X = 0;
|
|
||||||
Y = 0;
|
|
||||||
W = DisplayWidth(fl_display, fl_screen);
|
|
||||||
H = DisplayHeight(fl_display, fl_screen);
|
|
||||||
#endif // WIN32
|
|
||||||
|
|
||||||
|
screen_xywh(X, Y, W, H, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,47 +228,51 @@ void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
|
||||||
void Fl::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 n) {
|
||||||
if (num_screens < 0) screen_init();
|
if (num_screens < 0) screen_init();
|
||||||
|
|
||||||
|
if ((n < 0) || (n >= num_screens))
|
||||||
|
n = 0;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (num_screens > 0 && n >= 0 && n < num_screens) {
|
if (num_screens > 0) {
|
||||||
X = screens[n].left;
|
X = screens[n].left;
|
||||||
Y = screens[n].top;
|
Y = screens[n].top;
|
||||||
W = screens[n].right - screens[n].left;
|
W = screens[n].right - screens[n].left;
|
||||||
H = screens[n].bottom - screens[n].top;
|
H = screens[n].bottom - screens[n].top;
|
||||||
} else {
|
} else {
|
||||||
X = Fl::x();
|
/* Fallback if something is broken... */
|
||||||
Y = Fl::y();
|
X = 0;
|
||||||
W = Fl::w();
|
Y = 0;
|
||||||
H = Fl::h();
|
W = GetSystemMetrics(SM_CXSCREEN);
|
||||||
|
H = GetSystemMetrics(SM_CYSCREEN);
|
||||||
}
|
}
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
if (num_screens > 0 && n >= 0 && n < num_screens) {
|
if (num_screens > 0) {
|
||||||
X = screens[n].x;
|
X = screens[n].x;
|
||||||
Y = screens[n].y;
|
Y = screens[n].y;
|
||||||
W = screens[n].width;
|
W = screens[n].width;
|
||||||
H = screens[n].height;
|
H = screens[n].height;
|
||||||
} else {
|
} else {
|
||||||
X = Fl::x();
|
/* Fallback if something is broken... */
|
||||||
Y = Fl::y();
|
|
||||||
W = Fl::w();
|
|
||||||
H = Fl::h();
|
|
||||||
}
|
|
||||||
#elif HAVE_XINERAMA
|
|
||||||
if (num_screens > 0 && n >= 0 && n < num_screens && screens) {
|
|
||||||
X = screens[n].x_org;
|
|
||||||
Y = screens[n].y_org;
|
|
||||||
W = screens[n].width;
|
|
||||||
H = screens[n].height;
|
|
||||||
} else {
|
|
||||||
X = Fl::x();
|
X = Fl::x();
|
||||||
Y = Fl::y();
|
Y = Fl::y();
|
||||||
W = Fl::w();
|
W = Fl::w();
|
||||||
H = Fl::h();
|
H = Fl::h();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
#if HAVE_XINERAMA
|
||||||
|
if (num_screens > 0) {
|
||||||
|
X = screens[n].x_org;
|
||||||
|
Y = screens[n].y_org;
|
||||||
|
W = screens[n].width;
|
||||||
|
H = screens[n].height;
|
||||||
|
} else
|
||||||
|
#endif // HAVE_XINERAMA
|
||||||
|
{
|
||||||
|
/* Fallback if something is broken (or no Xinerama)... */
|
||||||
X = 0;
|
X = 0;
|
||||||
Y = 0;
|
Y = 0;
|
||||||
W = DisplayWidth(fl_display, fl_screen);
|
W = DisplayWidth(fl_display, fl_screen);
|
||||||
H = DisplayHeight(fl_display, fl_screen);
|
H = DisplayHeight(fl_display, fl_screen);
|
||||||
|
}
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue