moving nsIScreen and implementations to widget. (files copied on cvs server already). bug 322942 r=vlad sr=roc

This commit is contained in:
pavlov%pavlov.net 2006-01-11 21:56:25 +00:00
parent c9cadb3ef2
commit 6b3baceeca
32 changed files with 40 additions and 1552 deletions

View File

@ -50,8 +50,6 @@ XPIDLSRCS = \
nsIFontEnumerator.idl \
nsIFontList.idl \
nsIScriptableRegion.idl \
nsIScreen.idl \
nsIScreenManager.idl \
nsIPrintOptions.idl \
nsIPrintSettings.idl \
nsIPrintSettingsService.idl \

View File

@ -1,55 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corp.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
[scriptable, uuid(f728830e-1dd1-11b2-9598-fb9f414f2465)]
interface nsIScreen : nsISupports
{
void GetRect ( out long left, out long top, out long width, out long height );
void GetAvailRect ( out long left, out long top, out long width, out long height );
readonly attribute long pixelDepth;
readonly attribute long colorDepth;
};
%{ C++
%}

View File

@ -1,66 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corp.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIScreen.idl"
[scriptable, uuid(662e7b78-1dd2-11b2-a3d3-fc1e5f5fb9d4)]
interface nsIScreenManager : nsISupports
{
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
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;
};
%{ C++
%}

View File

@ -90,10 +90,6 @@
{ 0x199c7040, 0xcab0, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_SCREENMANAGER_CID \
{ 0xc401eb80, 0xf9ea, 0x11d3, \
{ 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } }
#define NS_PRINTSETTINGSSERVICE_CID \
{ 0x841387c8, 0x72e6, 0x484b, \
{ 0x92, 0x96, 0xbf, 0x6e, 0xea, 0x80, 0xd5, 0x8a } }

View File

@ -101,8 +101,6 @@ CPPSRCS = \
nsImageGTK.cpp \
nsGCCache.cpp \
nsRenderingContextGTK.cpp \
nsScreenGtk.cpp \
nsScreenManagerGtk.cpp \
nsPrintOptionsGTK.cpp \
nsFontMetricsUtils.cpp \
$(NULL)

View File

@ -50,7 +50,6 @@
#include "nsDeviceContextSpecG.h"
// aka nsDeviceContextSpecFactoryGTK.h
#include "nsDeviceContextSpecFactoryG.h"
#include "nsScreenManagerGtk.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextGTK.h"
#include "nsImageGTK.h"
@ -85,7 +84,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGtk)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsGTK, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
@ -291,11 +289,6 @@ static const nsModuleComponentInfo components[] =
// "@mozilla.org/gfx/fontlist;1"
NS_FONTLIST_CONTRACTID,
nsFontListConstructor },
{ "Gtk Screen Manager",
NS_SCREENMANAGER_CID,
// "@mozilla.org/gfx/screenmanager/gtk;1",
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerGtkConstructor },
{ "Gtk Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/gtk;1",

View File

@ -1,190 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher A. Aillon <caillon@redhat.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenGtk.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/Xatom.h>
nsScreenGtk :: nsScreenGtk ( )
: mScreenNum(0),
mRect(0, 0, 0, 0),
mAvailRect(0, 0, 0, 0)
{
}
nsScreenGtk :: ~nsScreenGtk()
{
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenGtk, nsIScreen)
NS_IMETHODIMP
nsScreenGtk :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = mRect.x;
*outTop = mRect.y;
*outWidth = mRect.width;
*outHeight = mRect.height;
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenGtk :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = mAvailRect.x;
*outTop = mAvailRect.y;
*outWidth = mAvailRect.width;
*outHeight = mAvailRect.height;
return NS_OK;
} // GetAvailRect
NS_IMETHODIMP
nsScreenGtk :: GetPixelDepth(PRInt32 *aPixelDepth)
{
GdkVisual * rgb_visual = gdk_rgb_get_visual();
*aPixelDepth = rgb_visual->depth;
return NS_OK;
} // GetPixelDepth
NS_IMETHODIMP
nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth ( aColorDepth );
} // GetColorDepth
void
nsScreenGtk :: Init ()
{
mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
// We need to account for the taskbar, etc in the available rect.
// See http://freedesktop.org/Standards/wm-spec/index.html#id2767771
// XXX It doesn't change that often, but we should probably
// listen for changes to _NET_WORKAREA.
// XXX do we care about _NET_WM_STRUT_PARTIAL? That will
// add much more complexity to the code here (our screen
// could have a non-rectangular shape), but should
// lead to greater accuracy.
#if GTK_CHECK_VERSION(2,2,0)
GdkWindow *root_window = gdk_get_default_root_window();
#else
GdkWindow *root_window = GDK_ROOT_PARENT();
#endif // GTK_CHECK_VERSION(2,2,0)
long *workareas;
GdkAtom type_returned;
int format_returned;
int length_returned;
#if GTK_CHECK_VERSION(2,0,0)
GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
#else
GdkAtom cardinal_atom = (GdkAtom) XA_CARDINAL;
#endif
gdk_error_trap_push();
// gdk_property_get uses (length + 3) / 4, hence G_MAXLONG - 3 here.
if (!gdk_property_get(root_window,
gdk_atom_intern ("_NET_WORKAREA", FALSE),
cardinal_atom,
0, G_MAXLONG - 3, FALSE,
&type_returned,
&format_returned,
&length_returned,
(guchar **) &workareas)) {
// This window manager doesn't support the freedesktop standard.
// Nothing we can do about it, so assume full screen size.
return;
}
// Flush the X queue to catch errors now.
gdk_flush();
if (!gdk_error_trap_pop() &&
type_returned == cardinal_atom &&
length_returned && (length_returned % 4) == 0 &&
format_returned == 32) {
int num_items = length_returned / sizeof(long);
for (int i = 0; i < num_items; i += 4) {
nsRect workarea(workareas[i], workareas[i + 1],
workareas[i + 2], workareas[i + 3]);
if (!mRect.Contains(workarea)) {
NS_WARNING("Invalid bounds");
continue;
}
mAvailRect.IntersectRect(mAvailRect, workarea);
}
}
g_free (workareas);
}
#ifdef MOZ_ENABLE_XINERAMA
void
nsScreenGtk :: Init (XineramaScreenInfo *aScreenInfo)
{
nsRect xineRect(aScreenInfo->x_org, aScreenInfo->y_org,
aScreenInfo->width, aScreenInfo->height);
mScreenNum = aScreenInfo->screen_number;
mAvailRect = mRect = xineRect;
}
#endif // MOZ_ENABLE_XINERAMA

View File

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenGtk_h___
#define nsScreenGtk_h___
#include "nsIScreen.h"
#include "nsRect.h"
#ifdef MOZ_ENABLE_XINERAMA
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
#endif // MOZ_ENABLE_XINERAMA
//------------------------------------------------------------------------
class nsScreenGtk : public nsIScreen
{
public:
nsScreenGtk();
~nsScreenGtk();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
void Init();
#ifdef MOZ_ENABLE_XINERAMA
void Init(XineramaScreenInfo *aScreenInfo);
#endif
private:
PRUint32 mScreenNum;
nsRect mRect; // in pixels, not twips
nsRect mAvailRect; // in pixels, not twips
};
#endif // nsScreenGtk_h___

View File

@ -1,237 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerGtk.h"
#include "nsScreenGtk.h"
#include "nsIComponentManager.h"
#include "nsRect.h"
#include "nsAutoPtr.h"
#include <gdk/gdkx.h>
#ifdef MOZ_ENABLE_XINERAMA
// this header rocks!
extern "C"
{
#include <X11/extensions/Xinerama.h>
}
#endif /* MOZ_ENABLE_XINERAMA */
nsScreenManagerGtk :: nsScreenManagerGtk ( )
{
// 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.
mNumScreens = 0;
}
nsScreenManagerGtk :: ~nsScreenManagerGtk()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenManagerGtk, nsIScreenManager)
// this function will make sure that everything has been initialized.
nsresult
nsScreenManagerGtk :: EnsureInit(void)
{
if (!mCachedScreenArray) {
mCachedScreenArray = do_CreateInstance("@mozilla.org/supports-array;1");
if (!mCachedScreenArray) {
return NS_ERROR_OUT_OF_MEMORY;
}
#ifdef MOZ_ENABLE_XINERAMA
// get the number of screens via xinerama
XineramaScreenInfo *screenInfo;
if (XineramaIsActive(GDK_DISPLAY())) {
screenInfo = XineramaQueryScreens(GDK_DISPLAY(), &mNumScreens);
}
else {
screenInfo = NULL;
mNumScreens = 1;
}
#else
mNumScreens = 1;
#endif
// there will be < 2 screens if we are either not building with
// xinerama support or xinerama isn't running on the current
// display.
if (mNumScreens < 2) {
mNumScreens = 1;
nsRefPtr<nsScreenGtk> screen = new nsScreenGtk();
if (!screen)
return NS_ERROR_OUT_OF_MEMORY;
screen->Init();
nsISupports *supportsScreen = screen;
mCachedScreenArray->AppendElement(supportsScreen);
}
// If Xinerama is enabled and there's more than one screen, fill
// in the info for all of the screens. If that's not the case
// then nsScreenGTK() defaults to the screen width + height
#ifdef MOZ_ENABLE_XINERAMA
else {
#ifdef DEBUG
printf("Xinerama superpowers activated for %d screens!\n", mNumScreens);
#endif
int i;
for (i=0; i < mNumScreens; i++) {
nsRefPtr<nsScreenGtk> screen = new nsScreenGtk();
if (!screen) {
return NS_ERROR_OUT_OF_MEMORY;
}
// initialize this screen object
screen->Init(&screenInfo[i]);
nsISupports *screenSupports = screen;
mCachedScreenArray->AppendElement(screenSupports);
}
}
#endif /* MOZ_ENABLE_XINERAMA */
}
return NS_OK;;
}
//
// ScreenForRect
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
NS_IMETHODIMP
nsScreenManagerGtk :: ScreenForRect ( PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight,
nsIScreen **aOutScreen )
{
nsresult rv;
rv = EnsureInit();
if (NS_FAILED(rv)) {
NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from ScreenForRect\n");
return rv;
}
// which screen ( index from zero ) should we return?
PRUint32 which = 0;
// Optimize for the common case. If the number of screens is only
// one then this will fall through with which == 0 and will get the
// primary screen.
if (mNumScreens > 1) {
// walk the list of screens and find the one that has the most
// surface area.
PRUint32 count;
mCachedScreenArray->Count(&count);
PRUint32 i;
PRUint32 area = 0;
nsRect windowRect(aX, aY, aWidth, aHeight);
for (i=0; i < count; i++) {
PRInt32 x, y, width, height;
x = y = width = height = 0;
nsCOMPtr<nsIScreen> screen;
mCachedScreenArray->GetElementAt(i, getter_AddRefs(screen));
screen->GetRect(&x, &y, &width, &height);
// calculate the surface area
nsRect screenRect(x, y, width, height);
screenRect.IntersectRect(screenRect, windowRect);
PRUint32 tempArea = screenRect.width * screenRect.height;
if (tempArea >= area) {
which = i;
area = tempArea;
}
}
}
nsCOMPtr<nsIScreen> outScreen;
mCachedScreenArray->GetElementAt(which, getter_AddRefs(outScreen));
*aOutScreen = outScreen.get();
NS_IF_ADDREF(*aOutScreen);
return NS_OK;
} // ScreenForRect
//
// GetPrimaryScreen
//
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
//
NS_IMETHODIMP
nsScreenManagerGtk :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
{
nsresult rv;
rv = EnsureInit();
if (NS_FAILED(rv)) {
NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from GetPrimaryScreen\n");
return rv;
}
nsCOMPtr <nsIScreen> screen;
mCachedScreenArray->GetElementAt(0, getter_AddRefs(screen));
*aPrimaryScreen = screen.get();
NS_IF_ADDREF(*aPrimaryScreen);
return NS_OK;
} // GetPrimaryScreen
//
// GetNumberOfScreens
//
// Returns how many physical screens are available.
//
NS_IMETHODIMP
nsScreenManagerGtk :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
nsresult rv;
rv = EnsureInit();
if (NS_FAILED(rv)) {
NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from GetNumberOfScreens\n");
return rv;
}
*aNumberOfScreens = mNumScreens;
return NS_OK;
} // GetNumberOfScreens

View File

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerGtk_h___
#define nsScreenManagerGtk_h___
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
//------------------------------------------------------------------------
class nsScreenManagerGtk : public nsIScreenManager
{
public:
nsScreenManagerGtk ( );
virtual ~nsScreenManagerGtk();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsresult EnsureInit(void);
// cache the primary screen object to avoid memory allocation every
// time
nsCOMPtr<nsISupportsArray> mCachedScreenArray;
// how many screens do we have?
int mNumScreens;
};
#endif // nsScreenManagerGtk_h___

View File

@ -82,8 +82,6 @@ CPPSRCS = \
nsUnicodeFontMappingMac.cpp \
nsUnicodeMappingUtil.cpp \
nsUnicodeRenderingToolkit.cpp \
nsScreenMac.cpp \
nsScreenManagerMac.cpp \
nsPrintOptionsX.cpp \
nsPrintSettingsX.cpp \
nsPrintSessionX.cpp \

View File

@ -52,7 +52,6 @@
#include "nsPrintOptionsX.h"
#include "nsPrintSessionX.h"
#include "nsDeviceContextSpecFactoryM.h"
#include "nsScreenManagerMac.h"
#include "nsBlender.h"
#include "nsCOMPtr.h"
#include "nsUnicodeMappingUtil.h"
@ -77,7 +76,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
#ifdef MOZ_WIDGET_COCOA
NS_GENERIC_FACTORY_CONSTRUCTOR(nsQDFlushManager)
@ -154,10 +152,6 @@ static const nsModuleComponentInfo components[] =
NS_FONTLIST_CID,
"@mozilla.org/gfx/fontlist;1",
nsFontListConstructor },
{ "nsScreenManager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerMacConstructor },
{ "windows image frame",
GFX_IMAGEFRAME_CID,
"@mozilla.org/gfx/image/frame;2",

View File

@ -1,109 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenMac.h"
#include <MacWindows.h>
nsScreenMac :: nsScreenMac ( GDHandle inScreen )
: mScreen(inScreen)
{
NS_ASSERTION ( inScreen, "Passing null device to nsScreenMac" );
// 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.
}
nsScreenMac :: ~nsScreenMac()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenMac, nsIScreen)
NS_IMETHODIMP
nsScreenMac :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = (**mScreen).gdRect.left;
*outTop = (**mScreen).gdRect.top;
*outWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left;
*outHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top;
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenMac :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
Rect adjustedRect;
::GetAvailableWindowPositioningBounds ( mScreen, &adjustedRect );
*outLeft = adjustedRect.left;
*outTop = adjustedRect.top;
*outWidth = adjustedRect.right - adjustedRect.left;
*outHeight = adjustedRect.bottom - adjustedRect.top;
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenMac :: GetPixelDepth(PRInt32 *aPixelDepth)
{
*aPixelDepth = (**(**mScreen).gdPMap).pixelSize;
return NS_OK;
} // GetPixelDepth
NS_IMETHODIMP
nsScreenMac :: GetColorDepth(PRInt32 *aColorDepth)
{
*aColorDepth = (**(**mScreen).gdPMap).pixelSize;
return NS_OK;
} // GetColorDepth

View File

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenMac_h___
#define nsScreenMac_h___
#include "nsIScreen.h"
#include <Quickdraw.h>
//------------------------------------------------------------------------
class nsScreenMac : public nsIScreen
{
public:
nsScreenMac ( GDHandle inScreen );
~nsScreenMac();
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()); }
GDHandle mScreen; // the device that represents this screen
};
#endif // nsScreenMac_h___

View File

@ -1,184 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerMac.h"
#include "nsScreenMac.h"
#include "nsCOMPtr.h"
class ScreenListItem
{
public:
ScreenListItem ( GDHandle inGD, nsIScreen* inScreen )
: mGD(inGD), mScreen(inScreen) { } ;
GDHandle mGD;
nsCOMPtr<nsIScreen> mScreen;
};
nsScreenManagerMac :: nsScreenManagerMac ( )
{
// 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.
}
nsScreenManagerMac :: ~nsScreenManagerMac()
{
// walk our list of cached screens and delete them.
for ( int i = 0; i < mScreenList.Count(); ++i ) {
ScreenListItem* item = NS_REINTERPRET_CAST(ScreenListItem*, mScreenList[i]);
delete item;
}
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenManagerMac, nsIScreenManager)
//
// CreateNewScreenObject
//
// Utility routine. Creates a new screen object from the given device handle
//
nsIScreen*
nsScreenManagerMac :: CreateNewScreenObject ( GDHandle inDevice )
{
nsIScreen* retScreen = nsnull;
// look through our screen list, hoping to find it. If it's not there,
// add it and return the new one.
for ( int i = 0; i < mScreenList.Count(); ++i ) {
ScreenListItem* curr = NS_REINTERPRET_CAST(ScreenListItem*, mScreenList[i]);
if ( inDevice == curr->mGD ) {
NS_IF_ADDREF(retScreen = curr->mScreen.get());
return retScreen;
}
} // for each screen.
// didn't find it in the list, so add it and return that item.
retScreen = new nsScreenMac ( inDevice );
ScreenListItem* listItem = new ScreenListItem ( inDevice, retScreen );
mScreenList.AppendElement ( listItem );
NS_IF_ADDREF(retScreen);
return retScreen;
}
//
// ScreenForRect
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
NS_IMETHODIMP
nsScreenManagerMac :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inWidth, PRInt32 inHeight,
nsIScreen **outScreen )
{
if ( !(inWidth || inHeight) ) {
NS_WARNING ( "trying to find screen for sizeless window, using primary monitor" );
*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
return NS_OK;
} // ScreenForRect
//
// GetPrimaryScreen
//
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
//
NS_IMETHODIMP
nsScreenManagerMac :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
{
*aPrimaryScreen = CreateNewScreenObject ( ::GetMainDevice() ); // addrefs
return NS_OK;
} // 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

View File

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerMac_h___
#define nsScreenManagerMac_h___
#include "nsIScreenManager.h"
#include <Quickdraw.h>
#include "nsVoidArray.h"
class nsIScreen;
//------------------------------------------------------------------------
class nsScreenManagerMac : public nsIScreenManager
{
public:
nsScreenManagerMac ( );
virtual ~nsScreenManagerMac();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsIScreen* CreateNewScreenObject ( GDHandle inDevice ) ;
nsAutoVoidArray mScreenList;
};
#endif // nsScreenManagerMac_h___

View File

@ -44,8 +44,6 @@
#include "nsUnitConversion.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIScreen.h"
#include "nsIScreenManager.h"
#include <math.h>
#include "prprf.h"

View File

@ -81,8 +81,6 @@ CPPSRCS = \
nsThebesBlender.cpp \
nsThebesGfxFactory.cpp \
nsThebesRenderingContext.cpp \
nsThebesScreen.cpp \
nsThebesScreenManager.cpp \
nsThebesFontMetrics.cpp \
nsThebesFontEnumerator.cpp \
$(NULL)

View File

@ -48,8 +48,6 @@
#include "nsThebesRenderingContext.h"
#include "nsThebesImage.h"
#include "nsThebesRegion.h"
#include "nsThebesScreen.h"
#include "nsThebesScreenManager.h"
#include "nsThebesBlender.h"
#include "nsThebesFontMetrics.h"
#include "nsThebesFontEnumerator.h"
@ -61,7 +59,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesDeviceContext)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRenderingContext)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesImage)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesScreenManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
static NS_IMETHODIMP nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
@ -127,10 +124,6 @@ static const nsModuleComponentInfo components[] =
NS_REGION_CID,
"@mozilla.org/gfx/region/nsThebes;1",
nsThebesRegionConstructor },
{ "Thebes Screen Manager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsThebesScreenManagerConstructor },
{ "Scriptable Region",
NS_SCRIPTABLE_REGION_CID,
"@mozilla.org/gfx/region;1",

View File

@ -1,182 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsThebesScreen.h"
#ifdef MOZ_ENABLE_GTK2
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/Xatom.h>
#elif defined (XP_WIN)
#include "gfxWindowsSurface.h"
#endif
NS_IMPL_ISUPPORTS1(nsThebesScreen, nsIScreen)
nsThebesScreen::nsThebesScreen()
:
mScreenNum(0), mRect(0, 0, 0, 0), mAvailRect(0, 0, 0, 0)
{
NS_INIT_ISUPPORTS();
}
nsThebesScreen::~nsThebesScreen()
{
}
NS_IMETHODIMP
nsThebesScreen::GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = mRect.x;
*outTop = mRect.y;
*outWidth = mRect.width;
*outHeight = mRect.height;
return NS_OK;
}
NS_IMETHODIMP
nsThebesScreen::GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = mAvailRect.x;
*outTop = mAvailRect.y;
*outWidth = mAvailRect.width;
*outHeight = mAvailRect.height;
return NS_OK;
}
NS_IMETHODIMP
nsThebesScreen::GetPixelDepth(PRInt32 *aPixelDepth)
{
#ifdef XP_WIN
HDC hDCScreen = GetDC(nsnull);
*aPixelDepth = GetDeviceCaps(hDCScreen, BITSPIXEL);
ReleaseDC(nsnull, hDCScreen);
#else
*aPixelDepth = 24;
#endif
return NS_OK;
}
NS_IMETHODIMP
nsThebesScreen::GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth(aColorDepth);
}
void
nsThebesScreen::Init ()
{
#ifdef MOZ_ENABLE_GTK2
mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
// We need to account for the taskbar, etc in the available rect.
// See http://freedesktop.org/Standards/wm-spec/index.html#id2767771
// XXX It doesn't change that often, but we should probably
// listen for changes to _NET_WORKAREA.
// XXX do we care about _NET_WM_STRUT_PARTIAL? That will
// add much more complexity to the code here (our screen
// could have a non-rectangular shape), but should
// lead to greater accuracy.
#if GTK_CHECK_VERSION(2,2,0)
GdkWindow *root_window = gdk_get_default_root_window();
#else
GdkWindow *root_window = GDK_ROOT_PARENT();
#endif // GTK_CHECK_VERSION(2,2,0)
long *workareas;
GdkAtom type_returned;
int format_returned;
int length_returned;
#if GTK_CHECK_VERSION(2,0,0)
GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
#else
GdkAtom cardinal_atom = (GdkAtom) XA_CARDINAL;
#endif
gdk_error_trap_push();
if (!gdk_property_get(root_window,
gdk_atom_intern ("_NET_WORKAREA", FALSE),
cardinal_atom,
0, G_MAXLONG, FALSE,
&type_returned,
&format_returned,
&length_returned,
(guchar **) &workareas)) {
// This window manager doesn't support the freedesktop standard.
// Nothing we can do about it, so assume full screen size.
return;
}
// Flush the X queue to catch errors now.
gdk_flush();
if (!gdk_error_trap_pop() &&
type_returned == cardinal_atom &&
length_returned && (length_returned % 4) == 0 &&
format_returned == 32) {
int num_items = length_returned / sizeof(long);
for (int i = 0; i < num_items; i += 4) {
nsRect workarea(workareas[i], workareas[i + 1],
workareas[i + 2], workareas[i + 3]);
if (!mRect.Contains(workarea)) {
NS_WARNING("Invalid bounds");
continue;
}
mAvailRect.IntersectRect(mAvailRect, workarea);
}
}
#elif defined(XP_WIN)
// XXX writeme
mAvailRect = mRect = nsRect(0, 0, 1600, 1200);
#else
#error Write me!
#endif
}

View File

@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSTHEBESSCREEN__H__
#define NSTHEBESSCREEN__H__
#include "nsIScreen.h"
#include "nsRect.h"
class nsThebesScreen : public nsIScreen
{
public:
nsThebesScreen();
virtual ~nsThebesScreen();
void Init();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
private:
PRUint32 mScreenNum;
nsRect mRect; // in pixels, not twips
nsRect mAvailRect; // in pixels, not twips
};
#endif /* NSTHEBESSCREEN__H__ */

View File

@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsThebesScreenManager.h"
#include "nsThebesScreen.h"
NS_IMPL_ISUPPORTS1(nsThebesScreenManager, nsIScreenManager)
nsThebesScreenManager::nsThebesScreenManager()
{
NS_INIT_ISUPPORTS();
}
nsThebesScreenManager::~nsThebesScreenManager()
{
}
nsIScreen*
nsThebesScreenManager::CreateNewScreenObject()
{
nsIScreen* retval = nsnull;
if (!mCachedMainScreen) {
nsThebesScreen *ncs = new nsThebesScreen();
ncs->Init();
mCachedMainScreen = ncs;
}
NS_IF_ADDREF(retval = mCachedMainScreen.get());
return retval;
}
NS_IMETHODIMP
nsThebesScreenManager::ScreenForRect(PRInt32 inLeft, PRInt32 inTop,
PRInt32 inWidth, PRInt32 inHeight,
nsIScreen **outScreen)
{
GetPrimaryScreen(outScreen);
return NS_OK;
}
NS_IMETHODIMP
nsThebesScreenManager::GetPrimaryScreen(nsIScreen **aPrimaryScreen)
{
*aPrimaryScreen = CreateNewScreenObject();
return NS_OK;
}
NS_IMETHODIMP
nsThebesScreenManager::GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
*aNumberOfScreens = 1;
return NS_OK;
}

View File

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSTHEBESSCREENMANAGER__H__
#define NSTHEBESSCREENMANAGER__H__
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsCOMPtr.h"
class nsThebesScreenManager : public nsIScreenManager
{
public:
nsThebesScreenManager();
virtual ~nsThebesScreenManager();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsIScreen* CreateNewScreenObject();
nsCOMPtr<nsIScreen> mCachedMainScreen;
};
#endif /* NSTHEBESSCREENMANAGER__H__ */

View File

@ -98,6 +98,8 @@ XPIDLSRCS = \
nsIBidiKeyboard.idl \
nsIFullScreen.idl \
nsINativeScrollbar.idl \
nsIScreen.idl \
nsIScreenManager.idl \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))

View File

@ -177,3 +177,6 @@
#define NS_BIDIKEYBOARD_CID \
{ 0x2572e6b0, 0x7439, 0x11d4, { 0xb7, 0x7a, 0x0, 0x10, 0x4b, 0x41, 0x19, 0xf8 } }
#define NS_SCREENMANAGER_CID \
{ 0xc401eb80, 0xf9ea, 0x11d3, { 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } }

View File

@ -52,7 +52,6 @@
#include "nsBidiKeyboard.h"
// Drag & Drop, Clipboard
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
@ -60,7 +59,7 @@
#include "nsHTMLFormatConverter.h"
#include "nsDragService.h"
#include "nsNativeThemeWin.h"
#include "nsScreenManagerWin.h"
#include "nsIGenericFactory.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
@ -82,6 +81,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerWin)
static const nsModuleComponentInfo components[] =
{
{ "nsWindow",
@ -147,6 +148,10 @@ static const nsModuleComponentInfo components[] =
NS_HTMLFORMATCONVERTER_CID,
"@mozilla.org/widget/htmlformatconverter;1",
nsHTMLFormatConverterConstructor },
{ "nsScreenManagerWin",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerWinConstructor },
};

View File

@ -95,6 +95,8 @@ MAC_LCPPSRCS = \
nsStylClipboardUtils.cpp \
nsToolkitBase.cpp \
nsTSMStrategy.cpp \
nsScreenMac.cpp \
nsScreenManagerMac.cpp \
$(NULL)
@ -118,7 +120,7 @@ CMMSRCS = \
nsCursorManager.mm \
nsMacCursor.mm \
$(NULL)
XPIDLSRCS += \
nsIChangeManager.idl \
nsIMenuCommandDispatcher.idl \

View File

@ -166,10 +166,14 @@ static const nsModuleComponentInfo gComponents[] =
NS_NATIVESCROLLBAR_CID,
"@mozilla.org/widget/nativescrollbar;1",
nsNativeScrollbarConstructor },
{ "Native Theme Renderer",
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,
"@mozilla.org/chrome/chrome-native-theme;1",
nsNativeThemeMacConstructor }
nsNativeThemeMacConstructor },
{ "nsScreenManager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerMacConstructor }
};
NS_IMPL_NSGETMODULE(nsWidgetMacModule, gComponents)

View File

@ -51,6 +51,8 @@
#include "nsSound.h"
#include "nsBidiKeyboard.h"
#include "nsNativeKeyBindings.h"
#include "nsScreenManagerGtk.h"
#ifdef NATIVE_THEME_SUPPORT
#include "nsNativeThemeGTK.h"
#endif
@ -78,6 +80,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsClipboard, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGtk)
#ifdef NATIVE_THEME_SUPPORT
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
#endif
@ -211,6 +214,10 @@ static const nsModuleComponentInfo components[] =
NS_NATIVEKEYBINDINGSEDITOR_CID,
NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID,
nsNativeKeyBindingsTextAreaConstructor },
{ "Gtk Screen Manager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerGtkConstructor },
#ifdef NATIVE_THEME_SUPPORT
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,

View File

@ -109,6 +109,8 @@ CPPSRCS = nsAppShell.cpp \
nsStylClipboardUtils.cpp \
nsMacControl.cpp \
nsNativeScrollbar.cpp \
nsScreenMac.cpp \
nsScreenManagerMac.cpp \
$(GFX_LCPPSRCS) \
$(NULL)

View File

@ -64,6 +64,7 @@
#include "nsSound.h"
#include "nsBidiKeyboard.h"
#include "nsNativeThemeMac.h"
#include "nsScreenManagerMac.h"
#if USE_NATIVE_VERSION
@ -106,6 +107,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragHelperService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeScrollbar)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac)
static const nsModuleComponentInfo gComponents[] =
{
@ -199,10 +201,14 @@ static const nsModuleComponentInfo gComponents[] =
NS_BIDIKEYBOARD_CID,
"@mozilla.org/widget/bidikeyboard;1",
nsBidiKeyboardConstructor },
{ "Native Theme Renderer",
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,
"@mozilla.org/chrome/chrome-native-theme;1",
nsNativeThemeMacConstructor }
nsNativeThemeMacConstructor },
{ "nsScreenManager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerMacConstructor }
};
NS_IMPL_NSGETMODULE(nsWidgetMacModule, gComponents)

View File

@ -85,6 +85,8 @@ CPPSRCS = \
nsClipboard.cpp \
nsNativeThemeWin.cpp \
nsFilePicker.cpp \
nsScreenWin.cpp \
nsScreenManagerWin.cpp \
$(NULL)
ifneq ($(OS_ARCH), WINCE)