widget/qt/nsScreenQt.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/qt/nsScreenQt.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include <QColor>
     1.9 +#include <QRect>
    1.10 +#include <QGuiApplication>
    1.11 +#include <QTransform>
    1.12 +#include <QScreen>
    1.13 +
    1.14 +#include "nsScreenQt.h"
    1.15 +#include "nsXULAppAPI.h"
    1.16 +
    1.17 +nsScreenQt::nsScreenQt(int aScreen)
    1.18 +    : mScreen(aScreen)
    1.19 +{
    1.20 +    // nothing else to do. I guess we could cache a bunch of information
    1.21 +    // here, but we want to ask the device at runtime in case anything
    1.22 +    // has changed.
    1.23 +}
    1.24 +
    1.25 +nsScreenQt::~nsScreenQt()
    1.26 +{
    1.27 +}
    1.28 +
    1.29 +NS_IMETHODIMP
    1.30 +nsScreenQt::GetRect(int32_t *outLeft,int32_t *outTop,
    1.31 +                    int32_t *outWidth,int32_t *outHeight)
    1.32 +{
    1.33 +    QRect r = QGuiApplication::screens()[mScreen]->geometry();
    1.34 +
    1.35 +    *outTop = r.x();
    1.36 +    *outLeft = r.y();
    1.37 +    *outWidth = r.width();
    1.38 +    *outHeight = r.height();
    1.39 +
    1.40 +    return NS_OK;
    1.41 +}
    1.42 +
    1.43 +NS_IMETHODIMP
    1.44 +nsScreenQt::GetAvailRect(int32_t *outLeft,int32_t *outTop,
    1.45 +                         int32_t *outWidth,int32_t *outHeight)
    1.46 +{
    1.47 +    QRect r = QGuiApplication::screens()[mScreen]->geometry();
    1.48 +
    1.49 +    *outTop = r.x();
    1.50 +    *outLeft = r.y();
    1.51 +    *outWidth = r.width();
    1.52 +    *outHeight = r.height();
    1.53 +
    1.54 +    return NS_OK;
    1.55 +}
    1.56 +
    1.57 +NS_IMETHODIMP
    1.58 +nsScreenQt::GetPixelDepth(int32_t *aPixelDepth)
    1.59 +{
    1.60 +    // #############
    1.61 +    *aPixelDepth = QGuiApplication::primaryScreen()->depth();
    1.62 +    return NS_OK;
    1.63 +}
    1.64 +
    1.65 +NS_IMETHODIMP
    1.66 +nsScreenQt::GetColorDepth(int32_t *aColorDepth)
    1.67 +{
    1.68 +    // ###############
    1.69 +    return GetPixelDepth(aColorDepth);
    1.70 +}

mercurial