DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2640
Version: 1.3-current
FLTK 1.1.X has traditionally returned the screen size on X11, when using
the x,y,w,h methods (basically returning DisplayWidth/DisplayHeight). When
FLTK 1.1.8 arrived, STR 1482 was fixed, so that these methods instead
returned the work area. Unfortunately the documentation was not updated.
screen_xywh suffers from a similar problem. The documentation clearly says
that the screen coordinates should be returned; not the work area. On multi
monitor Apple systems, this is also the case. However, in most other cases,
the workarea is returned instead.
The attached patch fixes the documentation of the x,y,w,h methods, and
fixes screen_xywh to consistently return the screen coordinates on all
platforms. This preserves the behaviour of x,y,w,h since FLTK 1.1.8 and
allows apps to retrieve the work area, but also provides methods to
retrieve the full screen coordinates, following the present screen_xywh
documentation.
Link: http://www.fltk.org/str.php?L2640
Version: 1.3-current
Index: src/screen_xywh.cxx
===================================================================
--- src/screen_xywh.cxx (revision 8678)
+++ src/screen_xywh.cxx (arbetskopia)
@@ -31,8 +31,8 @@
#include <config.h>
-// Number of screens...
-static int num_screens = 0;
+// Number of screens returned by multi monitor aware API; -1 before init
+static int num_screens = -1;
#ifdef WIN32
# if !defined(HMONITOR_DECLARED) && (_WIN32_WINNT < 0x0500)
@@ -67,7 +67,7 @@
// GetMonitorInfo(mon, &mi);
// (but we use our self-aquired function pointer instead)
if (fl_gmi(mon, &mi)) {
- screens[num_screens] = mi.rcWork;
+ screens[num_screens] = mi.rcMonitor;
// find the pixel size
if (mi.cbSize == sizeof(mi)) {
@@ -85,6 +85,7 @@
}
static void screen_init() {
+ num_screens = 0;
// Since not all versions of Windows include multiple monitor support,
// we do a run-time check for the required functions...
HMODULE hMod = GetModuleHandle("USER32.DLL");
@@ -103,7 +104,6 @@
if (fl_gmi) {
// We have GetMonitorInfoA, enumerate all the screens...
- num_screens = 0;
// EnumDisplayMonitors(0,0,screen_cb,0);
// (but we use our self-aquired function pointer instead)
fl_edm(0, 0, screen_cb, 0);
@@ -115,6 +115,10 @@
// If we get here, assume we have 1 monitor...
num_screens = 1;
+ screens[0].top = 0;
+ screens[0].left = 0;
+ screens[0].right = GetSystemMetrics(SM_CXSCREEN);
+ screens[0].bottom = GetSystemMetrics(SM_CYSCREEN);
}
#elif defined(__APPLE__)
static XRectangle screens[16];
@@ -129,7 +133,7 @@
for( i = 0; i < count; i++) {
r = CGDisplayBounds(displays[i]);
screens[i].x = int(r.origin.x);
- screens[i].y = int(r.size.height - (r.origin.y + r.size.height));
+ screens[i].y = int(r.origin.y);
screens[i].width = int(r.size.width);
screens[i].height = int(r.size.height);
CGSize s = CGDisplayScreenSize(displays[i]);
@@ -182,9 +186,9 @@
Gets the number of available screens.
*/
int Fl::screen_count() {
- if (!num_screens) screen_init();
+ if (num_screens < 0) screen_init();
- return num_screens;
+ return num_screens ? num_screens : 1;
}
/**
@@ -194,10 +198,10 @@
\param[in] mx, my the absolute screen position
*/
void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
- if (!num_screens) screen_init();
+ if (num_screens < 0) screen_init();
#ifdef WIN32
- if (num_screens > 1) {
+ if (num_screens > 0) {
int i;
for (i = 0; i < num_screens; i ++) {
@@ -212,7 +216,7 @@
}
}
#elif defined(__APPLE__)
- if (num_screens > 1) {
+ if (num_screens > 0) {
int i;
for (i = 0; i < num_screens; i ++) {
@@ -229,7 +233,7 @@
}
}
#elif HAVE_XINERAMA
- if (num_screens > 1) {
+ if (num_screens > 0) {
int i;
for (i = 0; i < num_screens; i ++) {
@@ -263,10 +267,10 @@
\see void 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) {
- if (!num_screens) screen_init();
+ if (num_screens < 0) screen_init();
#ifdef WIN32
- if (num_screens > 1 && n >= 0 && n < num_screens) {
+ if (num_screens > 0 && n >= 0 && n < num_screens) {
X = screens[n].left;
Y = screens[n].top;
W = screens[n].right - screens[n].left;
@@ -274,7 +278,7 @@
return;
}
#elif defined(__APPLE__)
- if (num_screens > 1 && n >= 0 && n < num_screens) {
+ if (num_screens > 0 && n >= 0 && n < num_screens) {
X = screens[n].x;
Y = screens[n].y;
W = screens[n].width;
@@ -282,7 +286,7 @@
return;
}
#elif HAVE_XINERAMA
- if (num_screens > 1 && n >= 0 && n < num_screens) {
+ if (num_screens > 0 && n >= 0 && n < num_screens) {
X = screens[n].x_org;
Y = screens[n].y_org;
W = screens[n].width;
@@ -343,7 +347,7 @@
*/
void Fl::screen_dpi(float &h, float &v, int n)
{
- if (!num_screens) screen_init();
+ if (num_screens < 0) screen_init();
h = v = 0.0f;
#ifdef WIN32
Index: FL/Fl.H
===================================================================
--- FL/Fl.H (revision 8678)
+++ FL/Fl.H (arbetskopia)
@@ -766,13 +766,13 @@
fl global screen functions declared in <FL/Fl.H>
@{ */
// screen size:
- /** Returns the origin of the current screen, where 0 indicates the left
side of the screen. */
+ /** Returns the origin of the current screen work area, where 0 indicates
the left side of the screen. */
static int x(); // platform dependent
- /** Returns the origin of the current screen, where 0 indicates the top edge
of the screen. */
+ /** Returns the origin of the current screen work area, where 0 indicates
the top edge of the screen. */
static int y(); // platform dependent
- /** Returns the width of the screen in pixels. */
+ /** Returns the width of the screen work area in pixels. */
static int w(); // platform dependent
- /** Returns the height of the screen in pixels. */
+ /** Returns the height of the screen work area in pixels. */
static int h(); // platform dependent
// multi-head support:
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs