Browse Source

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...



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8981 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/49/head
Ian MacArthur 14 years ago
parent
commit
ce3185a94f
  1. 29
      src/screen_xywh.cxx

29
src/screen_xywh.cxx

@ -59,6 +59,8 @@ static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) { @@ -59,6 +59,8 @@ static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) {
// (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)) {
@ -76,7 +78,6 @@ static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) { @@ -76,7 +78,6 @@ static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) {
}
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 @@ static void screen_init() { @@ -86,21 +87,17 @@ static void screen_init() {
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;
}
}
}

Loading…
Cancel
Save