mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
b=344323, allow nsCocoaWindow instances to be displayed on secondary monitors [correctly determine the screen for a given window under Cocoa], sr=stuart
This commit is contained in:
parent
1de6aee3bd
commit
80e42601ba
@ -693,40 +693,8 @@ nsThebesDeviceContext::ComputeFullAreaUsingScreen(nsRect* outRect)
|
|||||||
void
|
void
|
||||||
nsThebesDeviceContext::FindScreen(nsIScreen** outScreen)
|
nsThebesDeviceContext::FindScreen(nsIScreen** outScreen)
|
||||||
{
|
{
|
||||||
// now then, if we have more than one screen, we need to find which screen this
|
if (mWidget)
|
||||||
// window is on.
|
mScreenManager->ScreenForNativeWidget(mWidget, outScreen);
|
||||||
#ifdef XP_WIN
|
else
|
||||||
HWND window = NS_REINTERPRET_CAST(HWND, mWidget);
|
mScreenManager->GetPrimaryScreen(outScreen);
|
||||||
if (window) {
|
|
||||||
RECT globalPosition;
|
|
||||||
::GetWindowRect(window, &globalPosition);
|
|
||||||
if (mScreenManager) {
|
|
||||||
mScreenManager->ScreenForRect(globalPosition.left, globalPosition.top,
|
|
||||||
globalPosition.right - globalPosition.left,
|
|
||||||
globalPosition.bottom - globalPosition.top,
|
|
||||||
outScreen);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MOZ_ENABLE_GTK2
|
|
||||||
gint x, y, width, height, depth;
|
|
||||||
x = y = width = height = 0;
|
|
||||||
|
|
||||||
gdk_window_get_geometry(GDK_WINDOW(mWidget), &x, &y, &width, &height,
|
|
||||||
&depth);
|
|
||||||
gdk_window_get_origin(GDK_WINDOW(mWidget), &x, &y);
|
|
||||||
if (mScreenManager) {
|
|
||||||
mScreenManager->ScreenForRect(x, y, width, height, outScreen);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
|
||||||
// ???
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mScreenManager->GetPrimaryScreen(outScreen);
|
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,7 @@
|
|||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
#include "nsIScreen.idl"
|
#include "nsIScreen.idl"
|
||||||
|
|
||||||
|
[scriptable, uuid(e224bd44-252b-4b66-b869-99738250904a)]
|
||||||
[scriptable, uuid(662e7b78-1dd2-11b2-a3d3-fc1e5f5fb9d4)]
|
|
||||||
interface nsIScreenManager : nsISupports
|
interface nsIScreenManager : nsISupports
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -57,7 +56,11 @@ interface nsIScreenManager : nsISupports
|
|||||||
|
|
||||||
// Holds the number of screens that are available
|
// Holds the number of screens that are available
|
||||||
readonly attribute unsigned long numberOfScreens;
|
readonly attribute unsigned long numberOfScreens;
|
||||||
|
|
||||||
|
// Returns the nsIScreen instance for the given native widget pointer;
|
||||||
|
// the pointer is specific to the particular widget implementation,
|
||||||
|
// and is generally of the same type that NS_NATIVE_WIDGET is.
|
||||||
|
[noscript] nsIScreen screenForNativeWidget ( in voidPtr nativeWidget );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,8 +101,6 @@ MAC_LCPPSRCS = \
|
|||||||
nsMimeMapper.cpp \
|
nsMimeMapper.cpp \
|
||||||
nsStylClipboardUtils.cpp \
|
nsStylClipboardUtils.cpp \
|
||||||
nsToolkitBase.cpp \
|
nsToolkitBase.cpp \
|
||||||
nsScreenMac.cpp \
|
|
||||||
nsScreenManagerMac.cpp \
|
|
||||||
nsDeviceContextSpecFactoryM.cpp \
|
nsDeviceContextSpecFactoryM.cpp \
|
||||||
nsDeviceContextSpecX.cpp \
|
nsDeviceContextSpecX.cpp \
|
||||||
nsPrintOptionsX.cpp \
|
nsPrintOptionsX.cpp \
|
||||||
@ -139,6 +137,8 @@ CMMSRCS = \
|
|||||||
nsNativeScrollbar.mm \
|
nsNativeScrollbar.mm \
|
||||||
nsCursorManager.mm \
|
nsCursorManager.mm \
|
||||||
nsMacCursor.mm \
|
nsMacCursor.mm \
|
||||||
|
nsScreenCocoa.mm \
|
||||||
|
nsScreenManagerCocoa.mm \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
XPIDLSRCS += \
|
XPIDLSRCS += \
|
||||||
|
61
widget/src/cocoa/nsScreenCocoa.h
Normal file
61
widget/src/cocoa/nsScreenCocoa.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; 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 Corporation
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Vladimir Vukicevic <vladimir@pobox.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 ***** */
|
||||||
|
|
||||||
|
#ifndef NS_SCREEN_COCOA_H_
|
||||||
|
#define NS_SCREEN_COCOA_H_
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
#include "nsIScreen.h"
|
||||||
|
|
||||||
|
class nsScreenCocoa : public nsIScreen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsScreenCocoa (NSScreen *screen);
|
||||||
|
~nsScreenCocoa ();
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
NS_DECL_NSISCREEN
|
||||||
|
|
||||||
|
NSScreen *CocoaScreen() { return mScreen; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
NSScreen *mScreen;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
98
widget/src/cocoa/nsScreenCocoa.mm
Normal file
98
widget/src/cocoa/nsScreenCocoa.mm
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; 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 Corporation
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Vladimir Vukicevic <vladimir@pobox.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 "nsUnitConversion.h"
|
||||||
|
|
||||||
|
#include "nsScreenCocoa.h"
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(nsScreenCocoa, nsIScreen)
|
||||||
|
|
||||||
|
nsScreenCocoa::nsScreenCocoa (NSScreen *screen)
|
||||||
|
{
|
||||||
|
mScreen = [screen retain];
|
||||||
|
}
|
||||||
|
|
||||||
|
nsScreenCocoa::~nsScreenCocoa ()
|
||||||
|
{
|
||||||
|
[mScreen release];
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenCocoa::GetRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||||
|
{
|
||||||
|
NSRect r = [mScreen frame];
|
||||||
|
|
||||||
|
*outX = NSToIntFloor(r.origin.x);
|
||||||
|
*outY = NSToIntFloor(r.origin.y);
|
||||||
|
*outWidth = NSToIntFloor(r.size.width);
|
||||||
|
*outHeight = NSToIntFloor(r.size.height);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenCocoa::GetAvailRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||||
|
{
|
||||||
|
NSRect r = [mScreen visibleFrame];
|
||||||
|
|
||||||
|
*outX = NSToIntFloor(r.origin.x);
|
||||||
|
*outY = NSToIntFloor(r.origin.y);
|
||||||
|
*outWidth = NSToIntFloor(r.size.width);
|
||||||
|
*outHeight = NSToIntFloor(r.size.height);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenCocoa::GetPixelDepth(PRInt32 *aPixelDepth)
|
||||||
|
{
|
||||||
|
NSWindowDepth depth = [mScreen depth];
|
||||||
|
int bpp = NSBitsPerPixelFromDepth (depth);
|
||||||
|
|
||||||
|
*aPixelDepth = bpp;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenCocoa::GetColorDepth(PRInt32 *aColorDepth)
|
||||||
|
{
|
||||||
|
NSWindowDepth depth = [mScreen depth];
|
||||||
|
int bpp = NSBitsPerPixelFromDepth (depth);
|
||||||
|
|
||||||
|
*aColorDepth = bpp;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
66
widget/src/cocoa/nsScreenManagerCocoa.h
Normal file
66
widget/src/cocoa/nsScreenManagerCocoa.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; 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 Corporation
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Vladimir Vukicevic <vladimir@pobox.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 ***** */
|
||||||
|
|
||||||
|
#ifndef NS_SCREEN_MANAGER_COCOA_H_
|
||||||
|
#define NS_SCREEN_MANAGER_COCOA_H_
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
#include "nsCOMArray.h"
|
||||||
|
|
||||||
|
#include "nsIScreenManager.h"
|
||||||
|
|
||||||
|
#include "nsScreenCocoa.h"
|
||||||
|
|
||||||
|
class nsScreenManagerCocoa : public nsIScreenManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsScreenManagerCocoa ();
|
||||||
|
~nsScreenManagerCocoa ();
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
NS_DECL_NSISCREENMANAGER
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
nsScreenCocoa *ScreenForCocoaScreen (NSScreen *screen);
|
||||||
|
|
||||||
|
nsCOMArray<nsScreenCocoa> mScreenList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
132
widget/src/cocoa/nsScreenManagerCocoa.mm
Normal file
132
widget/src/cocoa/nsScreenManagerCocoa.mm
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; 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 Corporation
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Vladimir Vukicevic <vladimir@pobox.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 "nsCOMPtr.h"
|
||||||
|
|
||||||
|
#include "nsScreenManagerCocoa.h"
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(nsScreenManagerCocoa, nsIScreenManager)
|
||||||
|
|
||||||
|
nsScreenManagerCocoa::nsScreenManagerCocoa()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
nsScreenManagerCocoa::~nsScreenManagerCocoa()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
nsScreenCocoa*
|
||||||
|
nsScreenManagerCocoa::ScreenForCocoaScreen (NSScreen *screen)
|
||||||
|
{
|
||||||
|
for (PRInt32 i = 0; i < mScreenList.Count(); i++) {
|
||||||
|
nsScreenCocoa* sc = NS_STATIC_CAST(nsScreenCocoa*, mScreenList.ObjectAt(i));
|
||||||
|
|
||||||
|
if (sc->CocoaScreen() == screen) {
|
||||||
|
// doesn't addref
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// didn't find it; create and insert
|
||||||
|
nsCOMPtr<nsScreenCocoa> sc = new nsScreenCocoa(screen);
|
||||||
|
mScreenList.AppendObject(sc);
|
||||||
|
return sc.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerCocoa::ScreenForRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
|
||||||
|
nsIScreen **outScreen)
|
||||||
|
{
|
||||||
|
NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator];
|
||||||
|
NSRect inRect = { { aX, aY }, { aWidth, aHeight } };
|
||||||
|
|
||||||
|
while (NSScreen *screen = [screenEnum nextObject]) {
|
||||||
|
NSDictionary *desc = [screen deviceDescription];
|
||||||
|
if ([desc objectForKey:NSDeviceIsScreen] == nil)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (NSContainsRect ([screen frame], inRect)) {
|
||||||
|
nsScreenCocoa *sc = ScreenForCocoaScreen (screen);
|
||||||
|
*outScreen = sc;
|
||||||
|
NS_ADDREF(*outScreen);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*outScreen = nsnull;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerCocoa::GetPrimaryScreen (nsIScreen **outScreen)
|
||||||
|
{
|
||||||
|
// the mainScreen is the screen with the "key window" (focus, I assume?)
|
||||||
|
NSScreen *sc = [[NSScreen screens] objectAtIndex:0];
|
||||||
|
|
||||||
|
*outScreen = ScreenForCocoaScreen(sc);
|
||||||
|
NS_ADDREF(*outScreen);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerCocoa::GetNumberOfScreens (PRUint32 *aNumberOfScreens)
|
||||||
|
{
|
||||||
|
NSArray *ss = [NSScreen screens];
|
||||||
|
|
||||||
|
*aNumberOfScreens = [ss count];
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerCocoa::ScreenForNativeWidget (void *nativeWidget, nsIScreen **outScreen)
|
||||||
|
{
|
||||||
|
NSView *view = (NSView*) nativeWidget;
|
||||||
|
|
||||||
|
NSWindow *window = [view window];
|
||||||
|
if (window) {
|
||||||
|
nsIScreen *screen = ScreenForCocoaScreen([window screen]);
|
||||||
|
*outScreen = screen;
|
||||||
|
NS_ADDREF(*outScreen);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*outScreen = nsnull;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
@ -65,7 +65,7 @@
|
|||||||
#include "nsSound.h"
|
#include "nsSound.h"
|
||||||
|
|
||||||
#include "nsNativeScrollbar.h"
|
#include "nsNativeScrollbar.h"
|
||||||
#include "nsScreenManagerMac.h"
|
#include "nsScreenManagerCocoa.h"
|
||||||
#include "nsDeviceContextSpecX.h"
|
#include "nsDeviceContextSpecX.h"
|
||||||
#include "nsDeviceContextSpecFactoryM.h"
|
#include "nsDeviceContextSpecFactoryM.h"
|
||||||
#include "nsPrintOptionsX.h"
|
#include "nsPrintOptionsX.h"
|
||||||
@ -87,7 +87,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
|||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragHelperService)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragHelperService)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
|
||||||
@ -198,7 +198,7 @@ static const nsModuleComponentInfo gComponents[] =
|
|||||||
{ "nsScreenManager",
|
{ "nsScreenManager",
|
||||||
NS_SCREENMANAGER_CID,
|
NS_SCREENMANAGER_CID,
|
||||||
"@mozilla.org/gfx/screenmanager;1",
|
"@mozilla.org/gfx/screenmanager;1",
|
||||||
nsScreenManagerMacConstructor },
|
nsScreenManagerCocoaConstructor },
|
||||||
{ "nsDeviceContextSpec",
|
{ "nsDeviceContextSpec",
|
||||||
NS_DEVICE_CONTEXT_SPEC_CID,
|
NS_DEVICE_CONTEXT_SPEC_CID,
|
||||||
"@mozilla.org/gfx/devicecontextspec;1",
|
"@mozilla.org/gfx/devicecontextspec;1",
|
||||||
|
@ -235,3 +235,16 @@ nsScreenManagerGtk :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
|||||||
|
|
||||||
} // GetNumberOfScreens
|
} // GetNumberOfScreens
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerGtk :: ScreenForNativeWidget (void *aWidget, nsIScreen **outScreen)
|
||||||
|
{
|
||||||
|
// I don't know how to go from GtkWindow to nsIScreen, especially
|
||||||
|
// given xinerama and stuff, so let's just do this
|
||||||
|
gint x, y, width, height, depth;
|
||||||
|
x = y = width = height = 0;
|
||||||
|
|
||||||
|
gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height,
|
||||||
|
&depth);
|
||||||
|
gdk_window_get_origin(GDK_WINDOW(aWidget), &x, &y);
|
||||||
|
return ScreenForRect(x, y, width, height, outScreen);
|
||||||
|
}
|
||||||
|
@ -182,3 +182,8 @@ nsScreenManagerMac :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
|||||||
|
|
||||||
} // GetNumberOfScreens
|
} // GetNumberOfScreens
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerMac :: ScreenForNativeWidget(void *nativeWidget, nsIScreen **aScreen)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
@ -201,3 +201,11 @@ nsScreenManagerWin :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
} // GetNumberOfScreens
|
} // GetNumberOfScreens
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScreenManagerWin :: ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
|
||||||
|
{
|
||||||
|
HMONITOR mon = MonitorFromWindow ((HWND) aWidget, MONITOR_DEFAULTTOPRIMARY);
|
||||||
|
*outScreen = CreateNewScreenObject (mon);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user