mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 08:35:26 +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
110 lines
2.6 KiB
C++
110 lines
2.6 KiB
C++
/* 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 "qdesktopwidget.h"
|
|
#include "qapplication.h"
|
|
|
|
#include "nsScreenManagerQt.h"
|
|
#include "nsScreenQt.h"
|
|
|
|
nsScreenManagerQt::nsScreenManagerQt()
|
|
{
|
|
desktop = 0;
|
|
screens = 0;
|
|
}
|
|
|
|
nsScreenManagerQt::~nsScreenManagerQt()
|
|
{
|
|
delete [] screens;
|
|
}
|
|
|
|
// addref, release, QI
|
|
NS_IMPL_ISUPPORTS1(nsScreenManagerQt, nsIScreenManager)
|
|
|
|
void nsScreenManagerQt::init()
|
|
{
|
|
if (desktop)
|
|
return;
|
|
|
|
desktop = QApplication::desktop();
|
|
nScreens = desktop->numScreens();
|
|
screens = new nsCOMPtr<nsIScreen>[nScreens];
|
|
|
|
for (int i = 0; i < nScreens; ++i)
|
|
screens[i] = new nsScreenQt(i);
|
|
}
|
|
|
|
//
|
|
// 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
|
|
nsScreenManagerQt::ScreenForRect(int32_t inLeft, int32_t inTop,
|
|
int32_t inWidth, int32_t inHeight,
|
|
nsIScreen **outScreen)
|
|
{
|
|
if (!desktop)
|
|
init();
|
|
|
|
QRect r(inLeft, inTop, inWidth, inHeight);
|
|
int best = 0;
|
|
int area = 0;
|
|
for (int i = 0; i < nScreens; ++i) {
|
|
const QRect& rect = desktop->screenGeometry(i);
|
|
QRect intersection = r▭
|
|
int a = intersection.width()*intersection.height();
|
|
if (a > area) {
|
|
best = i;
|
|
area = a;
|
|
}
|
|
}
|
|
|
|
NS_IF_ADDREF(*outScreen = screens[best]);
|
|
return NS_OK;
|
|
}
|
|
|
|
//
|
|
// GetPrimaryScreen
|
|
//
|
|
// The screen with the menubar/taskbar. This shouldn't be needed very
|
|
// often.
|
|
//
|
|
NS_IMETHODIMP
|
|
nsScreenManagerQt::GetPrimaryScreen(nsIScreen **aPrimaryScreen)
|
|
{
|
|
if (!desktop)
|
|
init();
|
|
|
|
NS_IF_ADDREF(*aPrimaryScreen = screens[0]);
|
|
return NS_OK;
|
|
}
|
|
|
|
//
|
|
// GetNumberOfScreens
|
|
//
|
|
// Returns how many physical screens are available.
|
|
//
|
|
NS_IMETHODIMP
|
|
nsScreenManagerQt::GetNumberOfScreens(uint32_t *aNumberOfScreens)
|
|
{
|
|
if (!desktop)
|
|
init();
|
|
|
|
*aNumberOfScreens = desktop->numScreens();
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScreenManagerQt :: 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
|
|
QRect rect = static_cast<QWidget*>(aWidget)->geometry();
|
|
return ScreenForRect(rect.x(), rect.y(), rect.width(), rect.height(), outScreen);
|
|
}
|