From e17aeaff6fede3ef943cba1b848b36b3e3a5cf41 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Sat, 18 Mar 2000 00:56:34 +0000 Subject: [PATCH] adding numberOfScreens to interface. minor cleanup. --- gfx/idl/nsIScreenManager.idl | 5 ++++- gfx/src/gtk/nsScreenManagerGtk.cpp | 16 +++++++++++++++- gfx/src/mac/nsScreenManagerMac.cpp | 26 +++++++++++++++++++++++--- gfx/src/mac/nsScreenManagerMac.h | 2 +- gfx/src/windows/nsScreenManagerWin.cpp | 16 +++++++++++++++- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/gfx/idl/nsIScreenManager.idl b/gfx/idl/nsIScreenManager.idl index 90805b7d2532..a8bf14fdeb4f 100644 --- a/gfx/idl/nsIScreenManager.idl +++ b/gfx/idl/nsIScreenManager.idl @@ -32,12 +32,15 @@ interface nsIScreenManager : nsISupports // // The coordinates are in pixels (not twips) and in screen coordinates. // - nsIScreen screenForRect ( in long top, in long left, in long width, in long height ) ; + nsIScreen screenForRect ( in long left, in long top, in long width, in long height ) ; // The screen with the menubar/taskbar. This shouldn't be needed very // often. readonly attribute nsIScreen primaryScreen; + // Holds the number of screens that are available + readonly attribute unsigned long numberOfScreens; + }; diff --git a/gfx/src/gtk/nsScreenManagerGtk.cpp b/gfx/src/gtk/nsScreenManagerGtk.cpp index 6117a5b0f5f4..b9d9f69b2d39 100644 --- a/gfx/src/gtk/nsScreenManagerGtk.cpp +++ b/gfx/src/gtk/nsScreenManagerGtk.cpp @@ -67,7 +67,7 @@ nsScreenManagerGtk :: CreateNewScreenObject ( ) // The coordinates are in pixels (not twips) and in screen coordinates. // NS_IMETHODIMP -nsScreenManagerGtk :: ScreenForRect ( PRInt32 /*inTop*/, PRInt32 /*inLeft*/, PRInt32 /*inWidth*/, +nsScreenManagerGtk :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRInt32 /*inWidth*/, PRInt32 /*inHeight*/, nsIScreen **outScreen ) { GetPrimaryScreen ( outScreen ); @@ -90,3 +90,17 @@ nsScreenManagerGtk :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen) } // GetPrimaryScreen + +// +// GetNumberOfScreens +// +// Returns how many physical screens are available. +// +NS_IMETHODIMP +nsScreenManagerGtk :: GetNumberOfScreens(PRUint32 *aNumberOfScreens) +{ + *aNumberOfScreens = 1; + return NS_OK; + +} // GetNumberOfScreens + diff --git a/gfx/src/mac/nsScreenManagerMac.cpp b/gfx/src/mac/nsScreenManagerMac.cpp index c7b474ae498f..c636a8d799ce 100644 --- a/gfx/src/mac/nsScreenManagerMac.cpp +++ b/gfx/src/mac/nsScreenManagerMac.cpp @@ -67,11 +67,11 @@ nsScreenManagerMac :: CreateNewScreenObject ( GDHandle inDevice ) // The coordinates are in pixels (not twips) and in screen coordinates. // NS_IMETHODIMP -nsScreenManagerMac :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight, +nsScreenManagerMac :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inWidth, PRInt32 inHeight, nsIScreen **outScreen ) { - if ( !(inTop || inLeft || inWidth || inHeight) ) { - NS_WARNING ( "trying to find screen for sizeless window" ); + if ( !(inWidth || inHeight) ) { + NS_WARNING ( "trying to find screen for sizeless window, using primary monitor" ); *outScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs return NS_OK; } @@ -117,3 +117,23 @@ nsScreenManagerMac :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen) } // GetPrimaryScreen + +// +// GetNumberOfScreens +// +// Returns how many physical screens are available. +// +NS_IMETHODIMP +nsScreenManagerMac :: GetNumberOfScreens(PRUint32 *aNumberOfScreens) +{ + *aNumberOfScreens = 0; + GDHandle currDevice = ::GetDeviceList(); + while ( currDevice ) { + if ( ::TestDeviceAttribute(currDevice, screenDevice) && ::TestDeviceAttribute(currDevice, screenActive) ) + ++(*aNumberOfScreens); + currDevice = ::GetNextDevice(currDevice); + } + return NS_OK; + +} // GetNumberOfScreens + diff --git a/gfx/src/mac/nsScreenManagerMac.h b/gfx/src/mac/nsScreenManagerMac.h index 497db48911f3..212a071867ae 100644 --- a/gfx/src/mac/nsScreenManagerMac.h +++ b/gfx/src/mac/nsScreenManagerMac.h @@ -34,7 +34,7 @@ class nsScreenManagerMac : public nsIScreenManager { public: nsScreenManagerMac ( ); - ~nsScreenManagerMac(); + virtual ~nsScreenManagerMac(); NS_DECL_ISUPPORTS NS_DECL_NSISCREENMANAGER diff --git a/gfx/src/windows/nsScreenManagerWin.cpp b/gfx/src/windows/nsScreenManagerWin.cpp index 03a457263ed5..b67dd65118a8 100644 --- a/gfx/src/windows/nsScreenManagerWin.cpp +++ b/gfx/src/windows/nsScreenManagerWin.cpp @@ -67,7 +67,7 @@ nsScreenManagerWin :: CreateNewScreenObject ( HDC inScreen ) // The coordinates are in pixels (not twips) and in screen coordinates. // NS_IMETHODIMP -nsScreenManagerWin :: ScreenForRect ( PRInt32 inTop, PRInt32 inLeft, PRInt32 inWidth, PRInt32 inHeight, +nsScreenManagerWin :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inWidth, PRInt32 inHeight, nsIScreen **outScreen ) { if ( !(inWidth || inHeight) ) { @@ -108,3 +108,17 @@ nsScreenManagerWin :: GetPrimaryScreen(nsIScreen** aPrimaryScreen) } // GetPrimaryScreen + +// +// GetNumberOfScreens +// +// Returns how many physical screens are available. +// +NS_IMETHODIMP +nsScreenManagerWin :: GetNumberOfScreens(PRUint32 *aNumberOfScreens) +{ + *aNumberOfScreens = 1; + return NS_OK; + +} // GetNumberOfScreens +