зеркало из https://github.com/mozilla/pjs.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:
Родитель
e11251afc0
Коммит
c4b93c0b32
|
@ -50,9 +50,9 @@ NS_IMPL_ISUPPORTS(nsScreenManagerWin, NS_GET_IID(nsIScreenManager))
|
||||||
// Utility routine. Creates a new screen object from the given device handle
|
// Utility routine. Creates a new screen object from the given device handle
|
||||||
//
|
//
|
||||||
nsIScreen*
|
nsIScreen*
|
||||||
nsScreenManagerWin :: CreateNewScreenObject ( )
|
nsScreenManagerWin :: CreateNewScreenObject ( HDC inScreen )
|
||||||
{
|
{
|
||||||
nsIScreen* retval = new nsScreenWin ( );
|
nsIScreen* retval = new nsScreenWin ( inScreen );
|
||||||
NS_IF_ADDREF(retval);
|
NS_IF_ADDREF(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -70,33 +70,22 @@ NS_IMETHODIMP
|
||||||
nsScreenManagerWin :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight,
|
nsScreenManagerWin :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight,
|
||||||
nsIScreen **outScreen )
|
nsIScreen **outScreen )
|
||||||
{
|
{
|
||||||
#if 0
|
if ( !(inWidth || inHeight) ) {
|
||||||
if ( !(inTop || inLeft || inWidth || inHeight) ) {
|
NS_WARNING ( "trying to find screen for sizeless window, using primary monitor" );
|
||||||
NS_WARNING ( "trying to find screen for sizeless window" );
|
*outScreen = CreateNewScreenObject ( ::GetDC(nsnull) ); // addrefs
|
||||||
*outScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect globalWindowBounds = { inTop, inLeft, inTop + inHeight, inLeft + inWidth };
|
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 );
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
*outScreen = CreateNewScreenObject ( deviceWindowIsOn ); // addrefs
|
*outScreen = CreateNewScreenObject ( deviceWindowIsOn ); // addrefs
|
||||||
#endif
|
#endif
|
||||||
|
@ -114,7 +103,7 @@ nsScreenManagerWin :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inW
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenManagerWin :: GetPrimaryScreen(nsIScreen** aPrimaryScreen)
|
nsScreenManagerWin :: GetPrimaryScreen(nsIScreen** aPrimaryScreen)
|
||||||
{
|
{
|
||||||
// *aPrimaryScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
|
*aPrimaryScreen = CreateNewScreenObject ( ::GetDC(nsnull) ); // addrefs
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetPrimaryScreen
|
} // GetPrimaryScreen
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define nsScreenManagerWin_h___
|
#define nsScreenManagerWin_h___
|
||||||
|
|
||||||
#include "nsIScreenManager.h"
|
#include "nsIScreenManager.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
class nsIScreen;
|
class nsIScreen;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
nsIScreen* CreateNewScreenObject ( ) ;
|
nsIScreen* CreateNewScreenObject ( HDC inScreen ) ;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,13 @@
|
||||||
#include "nsScreenWin.h"
|
#include "nsScreenWin.h"
|
||||||
|
|
||||||
|
|
||||||
nsScreenWin :: nsScreenWin ( )
|
nsScreenWin :: nsScreenWin ( HDC inScreen )
|
||||||
// : mScreen(inScreen)
|
: mScreen(inScreen)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
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
|
// 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
|
// 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
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetWidth(PRInt32 *aWidth)
|
nsScreenWin :: GetWidth(PRInt32 *aWidth)
|
||||||
{
|
{
|
||||||
//*aWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left;
|
*aWidth = ::GetDeviceCaps(mScreen, HORZRES);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetWidth
|
} // GetWidth
|
||||||
|
@ -58,7 +59,7 @@ nsScreenWin :: GetWidth(PRInt32 *aWidth)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetHeight(PRInt32 *aHeight)
|
nsScreenWin :: GetHeight(PRInt32 *aHeight)
|
||||||
{
|
{
|
||||||
//*aHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top;
|
*aHeight = ::GetDeviceCaps(mScreen, VERTRES);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetHeight
|
} // GetHeight
|
||||||
|
@ -67,7 +68,7 @@ nsScreenWin :: GetHeight(PRInt32 *aHeight)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetPixelDepth(PRInt32 *aPixelDepth)
|
nsScreenWin :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||||
{
|
{
|
||||||
//*aPixelDepth = (**(**mScreen).gdPMap).pixelSize;
|
*aPixelDepth = ::GetDeviceCaps(mScreen, BITSPIXEL);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetPixelDepth
|
} // GetPixelDepth
|
||||||
|
@ -76,8 +77,7 @@ nsScreenWin :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetColorDepth(PRInt32 *aColorDepth)
|
nsScreenWin :: GetColorDepth(PRInt32 *aColorDepth)
|
||||||
{
|
{
|
||||||
//*aColorDepth = (**(**mScreen).gdPMap).pixelSize;
|
return GetPixelDepth(aColorDepth);
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
} // GetColorDepth
|
} // GetColorDepth
|
||||||
|
|
||||||
|
@ -85,7 +85,10 @@ nsScreenWin :: GetColorDepth(PRInt32 *aColorDepth)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetAvailWidth(PRInt32 *aAvailWidth)
|
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;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetAvailWidth
|
} // GetAvailWidth
|
||||||
|
@ -94,10 +97,9 @@ nsScreenWin :: GetAvailWidth(PRInt32 *aAvailWidth)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetAvailHeight(PRInt32 *aAvailHeight)
|
nsScreenWin :: GetAvailHeight(PRInt32 *aAvailHeight)
|
||||||
{
|
{
|
||||||
//Rect adjustedRect;
|
RECT workArea;
|
||||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||||
//*aAvailHeight = adjustedRect.bottom - adjustedRect.top;
|
*aAvailHeight = workArea.bottom - workArea.top;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetAvailHeight
|
} // GetAvailHeight
|
||||||
|
@ -106,7 +108,9 @@ nsScreenWin :: GetAvailHeight(PRInt32 *aAvailHeight)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetAvailLeft(PRInt32 *aAvailLeft)
|
nsScreenWin :: GetAvailLeft(PRInt32 *aAvailLeft)
|
||||||
{
|
{
|
||||||
//*aAvailLeft = (**mScreen).gdRect.left;
|
RECT workArea;
|
||||||
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||||
|
*aAvailLeft = workArea.left;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetAvailLeft
|
} // GetAvailLeft
|
||||||
|
@ -115,9 +119,9 @@ nsScreenWin :: GetAvailLeft(PRInt32 *aAvailLeft)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScreenWin :: GetAvailTop(PRInt32 *aAvailTop)
|
nsScreenWin :: GetAvailTop(PRInt32 *aAvailTop)
|
||||||
{
|
{
|
||||||
//Rect adjustedRect;
|
RECT workArea;
|
||||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||||
//*aAvailTop = adjustedRect.top;
|
*aAvailTop = workArea.top;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#ifndef nsScreenWin_h___
|
#ifndef nsScreenWin_h___
|
||||||
#define nsScreenWin_h___
|
#define nsScreenWin_h___
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
#include "nsIScreen.h"
|
#include "nsIScreen.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
@ -30,8 +31,7 @@
|
||||||
class nsScreenWin : public nsIScreen
|
class nsScreenWin : public nsIScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//nsScreenWin ( GDHandle inScreen );
|
nsScreenWin ( HDC inScreen );
|
||||||
nsScreenWin ( );
|
|
||||||
~nsScreenWin();
|
~nsScreenWin();
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
@ -43,7 +43,7 @@ private:
|
||||||
// asked.
|
// asked.
|
||||||
//PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); }
|
//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___
|
#endif // nsScreenWin_h___
|
||||||
|
|
Загрузка…
Ссылка в новой задаче