зеркало из https://github.com/mozilla/gecko-dev.git
screen manager and screen impls, first cut assuming only one monitor. make the dev context use them. r=pavlov.
This commit is contained in:
Родитель
85c4513169
Коммит
165909c877
|
@ -22,14 +22,14 @@
|
|||
|
||||
#include "nsScreenGtk.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
|
||||
nsScreenGtk :: nsScreenGtk ( )
|
||||
// : mScreen(inScreen)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
//NS_ASSERTION ( inScreen, "Passing null device to nsScreenGtk" );
|
||||
|
||||
// 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
|
||||
// has changed.
|
||||
|
@ -49,7 +49,7 @@ NS_IMPL_ISUPPORTS(nsScreenGtk, NS_GET_IID(nsIScreen))
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetWidth(PRInt32 *aWidth)
|
||||
{
|
||||
//*aWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left;
|
||||
*aWidth = gdk_screen_width();
|
||||
return NS_OK;
|
||||
|
||||
} // GetWidth
|
||||
|
@ -58,7 +58,7 @@ nsScreenGtk :: GetWidth(PRInt32 *aWidth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetHeight(PRInt32 *aHeight)
|
||||
{
|
||||
//*aHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top;
|
||||
*aHeight = gdk_screen_height();
|
||||
return NS_OK;
|
||||
|
||||
} // GetHeight
|
||||
|
@ -67,7 +67,9 @@ nsScreenGtk :: GetHeight(PRInt32 *aHeight)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
//*aPixelDepth = (**(**mScreen).gdPMap).pixelSize;
|
||||
GdkVisual * rgb_visual = gdk_rgb_get_visual();
|
||||
*aPixelDepth = rgb_visual->depth;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
@ -76,8 +78,7 @@ nsScreenGtk :: GetPixelDepth(PRInt32 *aPixelDepth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
//*aColorDepth = (**(**mScreen).gdPMap).pixelSize;
|
||||
return NS_OK;
|
||||
return GetPixelDepth ( aColorDepth );
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
@ -85,8 +86,7 @@ nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailWidth(PRInt32 *aAvailWidth)
|
||||
{
|
||||
GetWidth(aAvailWidth);
|
||||
return NS_OK;
|
||||
return GetWidth(aAvailWidth);
|
||||
|
||||
} // GetAvailWidth
|
||||
|
||||
|
@ -94,11 +94,7 @@ nsScreenGtk :: GetAvailWidth(PRInt32 *aAvailWidth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailHeight(PRInt32 *aAvailHeight)
|
||||
{
|
||||
//Rect adjustedRect;
|
||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
||||
//*aAvailHeight = adjustedRect.bottom - adjustedRect.top;
|
||||
|
||||
return NS_OK;
|
||||
return GetHeight(aAvailHeight);
|
||||
|
||||
} // GetAvailHeight
|
||||
|
||||
|
@ -106,7 +102,7 @@ nsScreenGtk :: GetAvailHeight(PRInt32 *aAvailHeight)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailLeft(PRInt32 *aAvailLeft)
|
||||
{
|
||||
//*aAvailLeft = (**mScreen).gdRect.left;
|
||||
*aAvailLeft = 0;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailLeft
|
||||
|
@ -115,10 +111,7 @@ nsScreenGtk :: GetAvailLeft(PRInt32 *aAvailLeft)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailTop(PRInt32 *aAvailTop)
|
||||
{
|
||||
//Rect adjustedRect;
|
||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
||||
//*aAvailTop = adjustedRect.top;
|
||||
|
||||
*aAvailTop = 0;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailTop
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
class nsScreenGtk : public nsIScreen
|
||||
{
|
||||
public:
|
||||
//nsScreenGtk ( GDHandle inScreen );
|
||||
nsScreenGtk ( );
|
||||
virtual ~nsScreenGtk();
|
||||
|
||||
|
@ -39,11 +38,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
// are we the primary screen? Needed so we can sub out the menubar if
|
||||
// asked.
|
||||
//PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); }
|
||||
|
||||
// GDHandle mScreen; // the device that represents this screen
|
||||
};
|
||||
|
||||
#endif // nsScreenGtk_h___
|
||||
|
|
|
@ -67,39 +67,10 @@ nsScreenManagerGtk :: CreateNewScreenObject ( )
|
|||
// The coordinates are in pixels (not twips) and in screen coordinates.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerGtk :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight,
|
||||
nsIScreen **outScreen )
|
||||
nsScreenManagerGtk :: 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
|
||||
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
|
||||
|
||||
*outScreen = CreateNewScreenObject ( deviceWindowIsOn ); // addrefs
|
||||
#endif
|
||||
GetPrimaryScreen ( outScreen );
|
||||
return NS_OK;
|
||||
|
||||
} // ScreenForRect
|
||||
|
@ -114,7 +85,7 @@ nsScreenManagerGtk :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inW
|
|||
NS_IMETHODIMP
|
||||
nsScreenManagerGtk :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
|
||||
{
|
||||
// *aPrimaryScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
|
||||
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
|
||||
return NS_OK;
|
||||
|
||||
} // GetPrimaryScreen
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
|
||||
#include "nsScreenGtk.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
|
||||
nsScreenGtk :: nsScreenGtk ( )
|
||||
// : mScreen(inScreen)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
//NS_ASSERTION ( inScreen, "Passing null device to nsScreenGtk" );
|
||||
|
||||
// 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
|
||||
// has changed.
|
||||
|
@ -49,7 +49,7 @@ NS_IMPL_ISUPPORTS(nsScreenGtk, NS_GET_IID(nsIScreen))
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetWidth(PRInt32 *aWidth)
|
||||
{
|
||||
//*aWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left;
|
||||
*aWidth = gdk_screen_width();
|
||||
return NS_OK;
|
||||
|
||||
} // GetWidth
|
||||
|
@ -58,7 +58,7 @@ nsScreenGtk :: GetWidth(PRInt32 *aWidth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetHeight(PRInt32 *aHeight)
|
||||
{
|
||||
//*aHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top;
|
||||
*aHeight = gdk_screen_height();
|
||||
return NS_OK;
|
||||
|
||||
} // GetHeight
|
||||
|
@ -67,7 +67,9 @@ nsScreenGtk :: GetHeight(PRInt32 *aHeight)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
//*aPixelDepth = (**(**mScreen).gdPMap).pixelSize;
|
||||
GdkVisual * rgb_visual = gdk_rgb_get_visual();
|
||||
*aPixelDepth = rgb_visual->depth;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
@ -76,8 +78,7 @@ nsScreenGtk :: GetPixelDepth(PRInt32 *aPixelDepth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
//*aColorDepth = (**(**mScreen).gdPMap).pixelSize;
|
||||
return NS_OK;
|
||||
return GetPixelDepth ( aColorDepth );
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
@ -85,8 +86,7 @@ nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailWidth(PRInt32 *aAvailWidth)
|
||||
{
|
||||
GetWidth(aAvailWidth);
|
||||
return NS_OK;
|
||||
return GetWidth(aAvailWidth);
|
||||
|
||||
} // GetAvailWidth
|
||||
|
||||
|
@ -94,11 +94,7 @@ nsScreenGtk :: GetAvailWidth(PRInt32 *aAvailWidth)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailHeight(PRInt32 *aAvailHeight)
|
||||
{
|
||||
//Rect adjustedRect;
|
||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
||||
//*aAvailHeight = adjustedRect.bottom - adjustedRect.top;
|
||||
|
||||
return NS_OK;
|
||||
return GetHeight(aAvailHeight);
|
||||
|
||||
} // GetAvailHeight
|
||||
|
||||
|
@ -106,7 +102,7 @@ nsScreenGtk :: GetAvailHeight(PRInt32 *aAvailHeight)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailLeft(PRInt32 *aAvailLeft)
|
||||
{
|
||||
//*aAvailLeft = (**mScreen).gdRect.left;
|
||||
*aAvailLeft = 0;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailLeft
|
||||
|
@ -115,10 +111,7 @@ nsScreenGtk :: GetAvailLeft(PRInt32 *aAvailLeft)
|
|||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailTop(PRInt32 *aAvailTop)
|
||||
{
|
||||
//Rect adjustedRect;
|
||||
//SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
|
||||
//*aAvailTop = adjustedRect.top;
|
||||
|
||||
*aAvailTop = 0;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailTop
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
class nsScreenGtk : public nsIScreen
|
||||
{
|
||||
public:
|
||||
//nsScreenGtk ( GDHandle inScreen );
|
||||
nsScreenGtk ( );
|
||||
virtual ~nsScreenGtk();
|
||||
|
||||
|
@ -39,11 +38,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
// are we the primary screen? Needed so we can sub out the menubar if
|
||||
// asked.
|
||||
//PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); }
|
||||
|
||||
// GDHandle mScreen; // the device that represents this screen
|
||||
};
|
||||
|
||||
#endif // nsScreenGtk_h___
|
||||
|
|
|
@ -67,39 +67,10 @@ nsScreenManagerGtk :: CreateNewScreenObject ( )
|
|||
// The coordinates are in pixels (not twips) and in screen coordinates.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerGtk :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight,
|
||||
nsIScreen **outScreen )
|
||||
nsScreenManagerGtk :: 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
|
||||
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
|
||||
|
||||
*outScreen = CreateNewScreenObject ( deviceWindowIsOn ); // addrefs
|
||||
#endif
|
||||
GetPrimaryScreen ( outScreen );
|
||||
return NS_OK;
|
||||
|
||||
} // ScreenForRect
|
||||
|
@ -114,7 +85,7 @@ nsScreenManagerGtk :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inW
|
|||
NS_IMETHODIMP
|
||||
nsScreenManagerGtk :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
|
||||
{
|
||||
// *aPrimaryScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
|
||||
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
|
||||
return NS_OK;
|
||||
|
||||
} // GetPrimaryScreen
|
||||
|
|
Загрузка…
Ссылка в новой задаче