Author: ianmacarthur
Date: 2011-08-18 09:23:07 -0700 (Thu, 18 Aug 2011)
New Revision: 8981
Log:
Initial fixes for window position at or beyond (0,0) under win32.
This is not the whole story, but is better.
We were messing up the initialisation of num_screens on Win32 in that
it was being set to a non-zero value by a call to
GetSystemMetrics(SM_CMONITORS) but was then subsequently incremented
even higher by each iteration call to the screen_cb(...) function,
so what we were storing for the screen rectangles was a bit messed up.
Under fltk-1.1, the code used to explicitly reset num_screens to zero
before starting to iterate the screen_cb(...) function, so that worked OK.
I have sort-of restored that behaviour, and removed the (now redundant)
call to GetSystemMetrics(SM_CMONITORS) since we *always* enumerate the
monitors now to get the per-screen DPI values out.
I've also put in a commented out stub where we could store the per-screen
work-area, which it seems we do also need now, though I have not yet
contrived to actually implement that.
Volunteers welcomed...
Modified:
branches/branch-1.3/src/screen_xywh.cxx
Modified: branches/branch-1.3/src/screen_xywh.cxx
===================================================================
--- branches/branch-1.3/src/screen_xywh.cxx 2011-08-18 13:43:39 UTC (rev
8980)
+++ branches/branch-1.3/src/screen_xywh.cxx 2011-08-18 16:23:07 UTC (rev
8981)
@@ -35,7 +35,7 @@
// functions from the USER32.DLL . If these functions are not available, we
// will gracefully fall back to single monitor support.
//
-// If we were to insist on the existence of "EnumDisplayMonitors" and
+// If we were to insist on the existence of "EnumDisplayMonitors" and
// "GetMonitorInfoA", it would be impossible to use FLTK on Windows 2000
// before SP2 or earlier.
@@ -59,7 +59,9 @@
// (but we use our self-aquired function pointer instead)
if (fl_gmi(mon, &mi)) {
screens[num_screens] = mi.rcMonitor;
-
+// If we also want to record the work area, we would also store mi.rcWork at
this point
+// work_area[num_screens] = mi.rcWork;
+
// find the pixel size
if (mi.cbSize == sizeof(mi)) {
HDC screen = CreateDC(mi.szDevice, NULL, NULL, NULL);
@@ -69,14 +71,13 @@
}
ReleaseDC(0L, screen);
}
-
+
num_screens ++;
}
return TRUE;
}
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");
@@ -86,21 +87,17 @@
fl_edm_func fl_edm = (fl_edm_func)GetProcAddress(hMod,
"EnumDisplayMonitors");
if (fl_edm) {
- // We do have EnumDisplayMonitors, so lets find out how many monitors...
- num_screens = GetSystemMetrics(SM_CMONITORS);
-
-// if (num_screens > 1) {
- // If there is more than 1 monitor, enumerate them...
- fl_gmi = (fl_gmi_func)GetProcAddress(hMod, "GetMonitorInfoA");
-
- if (fl_gmi) {
- // We have GetMonitorInfoA, enumerate all the screens...
-// EnumDisplayMonitors(0,0,screen_cb,0);
-// (but we use our self-aquired function pointer instead)
- fl_edm(0, 0, screen_cb, 0);
- return;
- }
-// }
+ // we have EnumDisplayMonitors - do we also have GetMonitorInfoA ?
+ fl_gmi = (fl_gmi_func)GetProcAddress(hMod, "GetMonitorInfoA");
+ if (fl_gmi) {
+ // We have GetMonitorInfoA, enumerate all the screens...
+// EnumDisplayMonitors(0,0,screen_cb,0);
+// (but we use our self-aquired function pointer instead)
+// NOTE: num_screens is incremented in screen_cb so we must first reset
it here...
+ num_screens = 0;
+ fl_edm(0, 0, screen_cb, 0);
+ return;
+ }
}
}
@@ -172,7 +169,7 @@
int mm = DisplayWidthMM(fl_display, fl_screen);
dpi[0] = mm ? Fl::w()*25.4f/mm : 0.0f;
mm = DisplayHeightMM(fl_display, fl_screen);
- dpi[1] = mm ? Fl::h()*25.4f/mm : dpi[0];
+ dpi[1] = mm ? Fl::h()*25.4f/mm : dpi[0];
}
#endif // WIN32
@@ -187,7 +184,7 @@
}
/**
- Gets the bounding box of a screen
+ Gets the bounding box of a screen
that contains the specified screen position \p mx, \p my
\param[out] X,Y,W,H the corresponding screen bounding box
\param[in] mx, my the absolute screen position
@@ -211,10 +208,10 @@
}
/**
- Gets the screen bounding rect for the given screen.
+ Gets the screen bounding rect for the given screen.
\param[out] X,Y,W,H the corresponding screen bounding box
\param[in] n the screen number (0 to Fl::screen_count() - 1)
- \see void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)
+ \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 < 0) screen_init();
@@ -300,20 +297,20 @@
}
screen_xywh(X, Y, W, H, best_screen);
}
-
+
/**
- Gets the screen resolution in dots-per-inch for the given screen.
+ Gets the screen resolution in dots-per-inch for the given screen.
\param[out] h, v horizontal and vertical resolution
\param[in] n the screen number (0 to Fl::screen_count() - 1)
- \see void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)
+ \see void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)
*/
void Fl::screen_dpi(float &h, float &v, int n)
{
if (num_screens < 0) screen_init();
h = v = 0.0f;
-
+
#ifdef WIN32
if (n >= 0 && n < num_screens) {
h = float(dpi[n][0]);
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit