зеркало из https://github.com/mozilla/gecko-dev.git
Single-monitor impl of screen manager/object for win32 just to get something in place. DevContext
now uses it, but will also have to be tweaked when the multi-monitor impl is implemented. Just pushing code around for now, nothing major. r=danm.
This commit is contained in:
Родитель
165909c877
Коммит
90c4bd940e
|
@ -50,9 +50,9 @@ NS_IMPL_ISUPPORTS(nsScreenManagerWin, NS_GET_IID(nsIScreenManager))
|
|||
// Utility routine. Creates a new screen object from the given device handle
|
||||
//
|
||||
nsIScreen*
|
||||
nsScreenManagerWin :: CreateNewScreenObject ( )
|
||||
nsScreenManagerWin :: CreateNewScreenObject ( HDC inScreen )
|
||||
{
|
||||
nsIScreen* retval = new nsScreenWin ( );
|
||||
nsIScreen* retval = new nsScreenWin ( inScreen );
|
||||
NS_IF_ADDREF(retval);
|
||||
return retval;
|
||||
}
|
||||
|
@ -70,34 +70,23 @@ NS_IMETHODIMP
|
|||
nsScreenManagerWin :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight,
|
||||
nsIScreen **outScreen )
|
||||
{
|
||||
#if 0
|
||||
if ( !(inTop || inLeft || inWidth || inHeight) ) {
|
||||
NS_WARNING ( "trying to find screen for sizeless window" );
|
||||
*outScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
|
||||
if ( !(inWidth || inHeight) ) {
|
||||
NS_WARNING ( "trying to find screen for sizeless window, using primary monitor" );
|
||||
*outScreen = CreateNewScreenObject ( ::GetDC(nsnull) ); // addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Rect globalWindowBounds = { inTop, inLeft, inTop + inHeight, inLeft + inWidth };
|
||||
|
||||
GDHandle currDevice = ::GetDeviceList();
|
||||
GDHandle deviceWindowIsOn = ::GetMainDevice();
|
||||
PRInt32 greatestArea = 0;
|
||||
while ( currDevice ) {
|
||||
if ( ::TestDeviceAttribute(currDevice, screenDevice) && ::TestDeviceAttribute(currDevice, screenActive) ) {
|
||||
// calc the intersection.
|
||||
Rect intersection;
|
||||
Rect devRect = (**currDevice).gdRect;
|
||||
::SectRect ( &globalWindowBounds, &devRect, &intersection );
|
||||
PRInt32 intersectArea = (intersection.right - intersection.left) *
|
||||
(intersection.bottom - intersection.top);
|
||||
if ( intersectArea > greatestArea ) {
|
||||
greatestArea = intersectArea;
|
||||
deviceWindowIsOn = currDevice;
|
||||
}
|
||||
} // if device is a screen and visible
|
||||
currDevice = ::GetNextDevice(currDevice);
|
||||
} // foreach device in list
|
||||
RECT globalWindowBounds = { inLeft, inTop, inLeft + inWidth, inTop + inHeight };
|
||||
|
||||
// we want to use ::MonitorFromRect() but it doesn't exist under 95/NT. For now, just
|
||||
// always return the primary monitor.
|
||||
|
||||
*outScreen = CreateNewScreenObject ( ::GetDC(nsnull) ); // addrefs
|
||||
|
||||
#if 0
|
||||
HMONITOR screen = ::MonitorFromRect ( &globalWindowBounds, MONITOR_DEFAULTTOPRIMARY );
|
||||
|
||||
|
||||
*outScreen = CreateNewScreenObject ( deviceWindowIsOn ); // addrefs
|
||||
#endif
|
||||
return NS_OK;
|
||||
|
@ -112,9 +101,9 @@ nsScreenManagerWin :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inW
|
|||
// often.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerWin :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
|
||||
nsScreenManagerWin :: GetPrimaryScreen(nsIScreen** aPrimaryScreen)
|
||||
{
|
||||
// *aPrimaryScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
|
||||
*aPrimaryScreen = CreateNewScreenObject ( ::GetDC(nsnull) ); // addrefs
|
||||
return NS_OK;
|
||||
|
||||
} // GetPrimaryScreen
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define nsScreenManagerWin_h___
|
||||
|
||||
#include "nsIScreenManager.h"
|
||||
#include <windows.h>
|
||||
|
||||
class nsIScreen;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
nsIScreen* CreateNewScreenObject ( ) ;
|
||||
nsIScreen* CreateNewScreenObject ( HDC inScreen ) ;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
#include "nsScreenWin.h"
|
||||
|
||||
|
||||
nsScreenWin :: nsScreenWin ( )
|
||||
// : mScreen(inScreen)
|
||||
nsScreenWin :: nsScreenWin ( HDC inScreen )
|
||||
: mScreen(inScreen)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
//NS_ASSERTION ( inScreen, "Passing null device to nsScreenWin" );
|
||||
NS_ASSERTION ( inScreen, "Passing null device to nsScreenWin" );
|
||||
NS_ASSERTION ( ::GetDeviceCaps(inScreen, TECHNOLOGY) == DT_RASDISPLAY, "Not a display screen");
|
||||
|
||||
// nothing else to do. I guess we could cache a bunch of information
|
||||
// here, but we want to ask the device at runtime in case anything
|
||||
|
@ -49,7 +50,7 @@ NS_IMPL_ISUPPORTS(nsScreenWin, NS_GET_IID(nsIScreen))
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetWidth(PRInt32 *aWidth)
|
||||
{
|
||||
//*aWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left;
|
||||
*aWidth = ::GetDeviceCaps(mScreen, HORZRES);
|
||||
return NS_OK;
|
||||
|
||||
} // GetWidth
|
||||
|
@ -58,7 +59,7 @@ nsScreenWin :: GetWidth(PRInt32 *aWidth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetHeight(PRInt32 *aHeight)
|
||||
{
|
||||
//*aHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top;
|
||||
*aHeight = ::GetDeviceCaps(mScreen, VERTRES);
|
||||
return NS_OK;
|
||||
|
||||
} // GetHeight
|
||||
|
@ -67,7 +68,7 @@ nsScreenWin :: GetHeight(PRInt32 *aHeight)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
//*aPixelDepth = (**(**mScreen).gdPMap).pixelSize;
|
||||
*aPixelDepth = ::GetDeviceCaps(mScreen, BITSPIXEL);
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
@ -76,8 +77,7 @@ nsScreenWin :: GetPixelDepth(PRInt32 *aPixelDepth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
//*aColorDepth = (**(**mScreen).gdPMap).pixelSize;
|
||||
return NS_OK;
|
||||
return GetPixelDepth(aColorDepth);
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
@ -85,7 +85,10 @@ nsScreenWin :: GetColorDepth(PRInt32 *aColorDepth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetAvailWidth(PRInt32 *aAvailWidth)
|
||||
{
|
||||
GetWidth(aAvailWidth);
|
||||
// XXX Needs to be rewritten for a non-primary monitor?
|
||||
RECT workArea;
|
||||
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||
*aAvailWidth = workArea.right - workArea.left;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailWidth
|
||||
|
@ -94,10 +97,9 @@ nsScreenWin :: GetAvailWidth(PRInt32 *aAvailWidth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetAvailHeight(PRInt32 *aAvailHeight)
|
||||
{
|
||||
//Rect adjustedRect;
|
||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
||||
//*aAvailHeight = adjustedRect.bottom - adjustedRect.top;
|
||||
|
||||
RECT workArea;
|
||||
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||
*aAvailHeight = workArea.bottom - workArea.top;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailHeight
|
||||
|
@ -106,7 +108,9 @@ nsScreenWin :: GetAvailHeight(PRInt32 *aAvailHeight)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetAvailLeft(PRInt32 *aAvailLeft)
|
||||
{
|
||||
//*aAvailLeft = (**mScreen).gdRect.left;
|
||||
RECT workArea;
|
||||
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||
*aAvailLeft = workArea.left;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailLeft
|
||||
|
@ -115,9 +119,9 @@ nsScreenWin :: GetAvailLeft(PRInt32 *aAvailLeft)
|
|||
NS_IMETHODIMP
|
||||
nsScreenWin :: GetAvailTop(PRInt32 *aAvailTop)
|
||||
{
|
||||
//Rect adjustedRect;
|
||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
||||
//*aAvailTop = adjustedRect.top;
|
||||
RECT workArea;
|
||||
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||
*aAvailTop = workArea.top;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef nsScreenWin_h___
|
||||
#define nsScreenWin_h___
|
||||
|
||||
#include <windows.h>
|
||||
#include "nsIScreen.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -30,8 +31,7 @@
|
|||
class nsScreenWin : public nsIScreen
|
||||
{
|
||||
public:
|
||||
//nsScreenWin ( GDHandle inScreen );
|
||||
nsScreenWin ( );
|
||||
nsScreenWin ( HDC inScreen );
|
||||
~nsScreenWin();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -43,7 +43,7 @@ private:
|
|||
// asked.
|
||||
//PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); }
|
||||
|
||||
// GDHandle mScreen; // the device that represents this screen
|
||||
HDC mScreen; // the dc that represents this screen
|
||||
};
|
||||
|
||||
#endif // nsScreenWin_h___
|
||||
|
|
Загрузка…
Ссылка в новой задаче