mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
e368dc9c85
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
117 lines
3.1 KiB
Plaintext
117 lines
3.1 KiB
Plaintext
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsScreenManagerCocoa.h"
|
|
#include "nsObjCExceptions.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsCocoaUtils.h"
|
|
|
|
NS_IMPL_ISUPPORTS1(nsScreenManagerCocoa, nsIScreenManager)
|
|
|
|
nsScreenManagerCocoa::nsScreenManagerCocoa()
|
|
{
|
|
}
|
|
|
|
nsScreenManagerCocoa::~nsScreenManagerCocoa()
|
|
{
|
|
}
|
|
|
|
nsScreenCocoa*
|
|
nsScreenManagerCocoa::ScreenForCocoaScreen(NSScreen *screen)
|
|
{
|
|
for (uint32_t i = 0; i < mScreenList.Length(); ++i) {
|
|
nsScreenCocoa* sc = mScreenList[i];
|
|
if (sc->CocoaScreen() == screen) {
|
|
// doesn't addref
|
|
return sc;
|
|
}
|
|
}
|
|
|
|
// didn't find it; create and insert
|
|
nsRefPtr<nsScreenCocoa> sc = new nsScreenCocoa(screen);
|
|
mScreenList.AppendElement(sc);
|
|
return sc.get();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScreenManagerCocoa::ScreenForRect (int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight,
|
|
nsIScreen **outScreen)
|
|
{
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator];
|
|
NSRect inRect = nsCocoaUtils::GeckoRectToCocoaRect(nsIntRect(aX, aY, aWidth, aHeight));
|
|
NSScreen *screenWindowIsOn = [NSScreen mainScreen];
|
|
float greatestArea = 0;
|
|
|
|
while (NSScreen *screen = [screenEnum nextObject]) {
|
|
NSDictionary *desc = [screen deviceDescription];
|
|
if ([desc objectForKey:NSDeviceIsScreen] == nil)
|
|
continue;
|
|
|
|
NSRect r = NSIntersectionRect([screen frame], inRect);
|
|
float area = r.size.width * r.size.height;
|
|
if (area > greatestArea) {
|
|
greatestArea = area;
|
|
screenWindowIsOn = screen;
|
|
}
|
|
}
|
|
|
|
*outScreen = ScreenForCocoaScreen(screenWindowIsOn);
|
|
NS_ADDREF(*outScreen);
|
|
return NS_OK;
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScreenManagerCocoa::GetPrimaryScreen (nsIScreen **outScreen)
|
|
{
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
// 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_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScreenManagerCocoa::GetNumberOfScreens (uint32_t *aNumberOfScreens)
|
|
{
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
NSArray *ss = [NSScreen screens];
|
|
|
|
*aNumberOfScreens = [ss count];
|
|
|
|
return NS_OK;
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScreenManagerCocoa::ScreenForNativeWidget (void *nativeWidget, nsIScreen **outScreen)
|
|
{
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
NSWindow *window = static_cast<NSWindow*>(nativeWidget);
|
|
if (window) {
|
|
nsIScreen *screen = ScreenForCocoaScreen([window screen]);
|
|
*outScreen = screen;
|
|
NS_ADDREF(*outScreen);
|
|
return NS_OK;
|
|
}
|
|
|
|
*outScreen = nullptr;
|
|
return NS_OK;
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
|
}
|