2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsScreenCocoa.h"
|
2008-02-20 15:47:05 -08:00
|
|
|
#include "nsObjCExceptions.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCocoaUtils.h"
|
|
|
|
|
|
|
|
nsScreenCocoa::nsScreenCocoa (NSScreen *screen)
|
|
|
|
{
|
2008-02-20 15:47:05 -08:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
|
|
|
mScreen = [screen retain];
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsScreenCocoa::~nsScreenCocoa ()
|
|
|
|
{
|
2008-02-20 15:47:05 -08:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
|
|
|
[mScreen release];
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenCocoa::GetRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight)
|
|
|
|
{
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect r = nsCocoaUtils::CocoaRectToGeckoRect([mScreen frame]);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-20 15:47:05 -08:00
|
|
|
*outX = r.x;
|
|
|
|
*outY = r.y;
|
|
|
|
*outWidth = r.width;
|
|
|
|
*outHeight = r.height;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-20 15:47:05 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenCocoa::GetAvailRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight)
|
|
|
|
{
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect r = nsCocoaUtils::CocoaRectToGeckoRect([mScreen visibleFrame]);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-20 15:47:05 -08:00
|
|
|
*outX = r.x;
|
|
|
|
*outY = r.y;
|
|
|
|
*outWidth = r.width;
|
|
|
|
*outHeight = r.height;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-20 15:47:05 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenCocoa::GetPixelDepth(PRInt32 *aPixelDepth)
|
|
|
|
{
|
2008-02-20 15:47:05 -08:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-20 15:47:05 -08:00
|
|
|
NSWindowDepth depth = [mScreen depth];
|
|
|
|
int bpp = NSBitsPerPixelFromDepth(depth);
|
|
|
|
|
|
|
|
*aPixelDepth = bpp;
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenCocoa::GetColorDepth(PRInt32 *aColorDepth)
|
|
|
|
{
|
2008-02-20 15:47:05 -08:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
|
|
|
|
NSWindowDepth depth = [mScreen depth];
|
|
|
|
int bpp = NSBitsPerPixelFromDepth (depth);
|
|
|
|
|
|
|
|
*aColorDepth = bpp;
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-20 15:47:05 -08:00
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|