diff --git a/gfx/src/windows/nsScreenManagerWin.cpp b/gfx/src/windows/nsScreenManagerWin.cpp index 155596a71e6d..e023b74bc94b 100644 --- a/gfx/src/windows/nsScreenManagerWin.cpp +++ b/gfx/src/windows/nsScreenManagerWin.cpp @@ -107,7 +107,7 @@ NS_IMPL_ISUPPORTS(nsScreenManagerWin, NS_GET_IID(nsIScreenManager)) // screen. This should change when a multi-monitor impl is done. // nsIScreen* -nsScreenManagerWin :: CreateNewScreenObject ( HDC inContext, void* inScreen ) +nsScreenManagerWin :: CreateNewScreenObject ( void* inScreen ) { nsIScreen* retScreen = nsnull; @@ -121,7 +121,7 @@ nsScreenManagerWin :: CreateNewScreenObject ( HDC inContext, void* inScreen ) } } // for each screen. - retScreen = new nsScreenWin(inContext, inScreen); + retScreen = new nsScreenWin(inScreen); ScreenListItem* listItem = new ScreenListItem ( (HMONITOR)inScreen, retScreen ); mScreenList.AppendElement ( listItem ); @@ -144,7 +144,7 @@ nsScreenManagerWin :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inW { if ( !(inWidth || inHeight) ) { NS_WARNING ( "trying to find screen for sizeless window, using primary monitor" ); - *outScreen = CreateNewScreenObject ( ::GetDC(nsnull), nsnull ); // addrefs + *outScreen = CreateNewScreenObject ( nsnull ); // addrefs return NS_OK; } @@ -161,7 +161,7 @@ nsScreenManagerWin :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inW } #endif - *outScreen = CreateNewScreenObject ( ::GetDC(nsnull), genScreen ); // addrefs + *outScreen = CreateNewScreenObject ( genScreen ); // addrefs return NS_OK; @@ -177,7 +177,7 @@ nsScreenManagerWin :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inW NS_IMETHODIMP nsScreenManagerWin :: GetPrimaryScreen(nsIScreen** aPrimaryScreen) { - *aPrimaryScreen = CreateNewScreenObject ( ::GetDC(nsnull), nsnull ); // addrefs + *aPrimaryScreen = CreateNewScreenObject ( nsnull ); // addrefs return NS_OK; } // GetPrimaryScreen diff --git a/gfx/src/windows/nsScreenManagerWin.h b/gfx/src/windows/nsScreenManagerWin.h index 4c37e9036068..132bce2c3de9 100644 --- a/gfx/src/windows/nsScreenManagerWin.h +++ b/gfx/src/windows/nsScreenManagerWin.h @@ -45,7 +45,7 @@ public: private: - nsIScreen* CreateNewScreenObject ( HDC inContext, void* inScreen ) ; + nsIScreen* CreateNewScreenObject ( void* inScreen ) ; PRBool mHasMultiMonitorAPIs; PRUint32 mNumberOfScreens; diff --git a/gfx/src/windows/nsScreenWin.cpp b/gfx/src/windows/nsScreenWin.cpp index 251122f8619e..2a9e41756e6d 100644 --- a/gfx/src/windows/nsScreenWin.cpp +++ b/gfx/src/windows/nsScreenWin.cpp @@ -45,15 +45,19 @@ typedef BOOL (WINAPI *GetMonitorInfoProc)(HMONITOR inMon, LPMONITORINFO ioInfo); #endif -nsScreenWin :: nsScreenWin ( HDC inContext, void* inScreen ) - : mContext(inContext), mScreen(inScreen), mHasMultiMonitorAPIs(PR_FALSE), +nsScreenWin :: nsScreenWin ( void* inScreen ) + : mScreen(inScreen), mHasMultiMonitorAPIs(PR_FALSE), mGetMonitorInfoProc(nsnull) { NS_INIT_REFCNT(); - NS_ASSERTION ( inContext, "Passing null device to nsScreenWin" ); - NS_ASSERTION ( ::GetDeviceCaps(inContext, TECHNOLOGY) == DT_RASDISPLAY, "Not a display screen"); - +#ifdef DEBUG + HDC hDCScreen = ::GetDC(nsnull); + NS_ASSERTION(hDCScreen,"GetDC Failure"); + NS_ASSERTION ( ::GetDeviceCaps(hDCScreen, TECHNOLOGY) == DT_RASDISPLAY, "Not a display screen"); + ::ReleaseDC(nsnull,hDCScreen); +#endif + #if _MSC_VER >= 1200 // figure out if we can call the multiple monitor APIs that are only // available on Win98/2000. @@ -101,11 +105,15 @@ nsScreenWin :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRI } #endif if (!success) { - *outTop = *outLeft = 0; - *outWidth = ::GetDeviceCaps(mContext, HORZRES); - *outHeight = ::GetDeviceCaps(mContext, VERTRES); + HDC hDCScreen = ::GetDC(nsnull); + NS_ASSERTION(hDCScreen,"GetDC Failure"); + + *outTop = *outLeft = 0; + *outWidth = ::GetDeviceCaps(hDCScreen, HORZRES); + *outHeight = ::GetDeviceCaps(hDCScreen, VERTRES); + + ::ReleaseDC(nsnull, hDCScreen); } - return NS_OK; } // GetRect @@ -148,7 +156,12 @@ NS_IMETHODIMP nsScreenWin :: GetPixelDepth(PRInt32 *aPixelDepth) { //XXX not sure how to get this info for multiple monitors, this might be ok... - *aPixelDepth = ::GetDeviceCaps(mContext, BITSPIXEL); + HDC hDCScreen = ::GetDC(nsnull); + NS_ASSERTION(hDCScreen,"GetDC Failure"); + + *aPixelDepth = ::GetDeviceCaps(hDCScreen, BITSPIXEL); + + ::ReleaseDC(nsnull, hDCScreen); return NS_OK; } // GetPixelDepth diff --git a/gfx/src/windows/nsScreenWin.h b/gfx/src/windows/nsScreenWin.h index 2f81ff119c1d..f56e1a2030c9 100644 --- a/gfx/src/windows/nsScreenWin.h +++ b/gfx/src/windows/nsScreenWin.h @@ -31,24 +31,19 @@ class nsScreenWin : public nsIScreen { public: - nsScreenWin ( HDC inContext, void* inScreen ); + nsScreenWin ( void* inScreen ); ~nsScreenWin(); NS_DECL_ISUPPORTS NS_DECL_NSISCREEN private: - - // are we the primary screen? Needed so we can sub out the menubar if - // asked. - //PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); } // function pointers for multi-monitor API system calls that we use. Not // valid unless |mHasMultiMonitorAPIs| is true PRBool mHasMultiMonitorAPIs; FARPROC mGetMonitorInfoProc ; - HDC mContext; // the dc that represents this screen void* mScreen; // a |HMONITOR|, can't use this type in header file though. };