widget/qt/nsScreenQt.cpp

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include <QColor>
michael@0 6 #include <QRect>
michael@0 7 #include <QGuiApplication>
michael@0 8 #include <QTransform>
michael@0 9 #include <QScreen>
michael@0 10
michael@0 11 #include "nsScreenQt.h"
michael@0 12 #include "nsXULAppAPI.h"
michael@0 13
michael@0 14 nsScreenQt::nsScreenQt(int aScreen)
michael@0 15 : mScreen(aScreen)
michael@0 16 {
michael@0 17 // nothing else to do. I guess we could cache a bunch of information
michael@0 18 // here, but we want to ask the device at runtime in case anything
michael@0 19 // has changed.
michael@0 20 }
michael@0 21
michael@0 22 nsScreenQt::~nsScreenQt()
michael@0 23 {
michael@0 24 }
michael@0 25
michael@0 26 NS_IMETHODIMP
michael@0 27 nsScreenQt::GetRect(int32_t *outLeft,int32_t *outTop,
michael@0 28 int32_t *outWidth,int32_t *outHeight)
michael@0 29 {
michael@0 30 QRect r = QGuiApplication::screens()[mScreen]->geometry();
michael@0 31
michael@0 32 *outTop = r.x();
michael@0 33 *outLeft = r.y();
michael@0 34 *outWidth = r.width();
michael@0 35 *outHeight = r.height();
michael@0 36
michael@0 37 return NS_OK;
michael@0 38 }
michael@0 39
michael@0 40 NS_IMETHODIMP
michael@0 41 nsScreenQt::GetAvailRect(int32_t *outLeft,int32_t *outTop,
michael@0 42 int32_t *outWidth,int32_t *outHeight)
michael@0 43 {
michael@0 44 QRect r = QGuiApplication::screens()[mScreen]->geometry();
michael@0 45
michael@0 46 *outTop = r.x();
michael@0 47 *outLeft = r.y();
michael@0 48 *outWidth = r.width();
michael@0 49 *outHeight = r.height();
michael@0 50
michael@0 51 return NS_OK;
michael@0 52 }
michael@0 53
michael@0 54 NS_IMETHODIMP
michael@0 55 nsScreenQt::GetPixelDepth(int32_t *aPixelDepth)
michael@0 56 {
michael@0 57 // #############
michael@0 58 *aPixelDepth = QGuiApplication::primaryScreen()->depth();
michael@0 59 return NS_OK;
michael@0 60 }
michael@0 61
michael@0 62 NS_IMETHODIMP
michael@0 63 nsScreenQt::GetColorDepth(int32_t *aColorDepth)
michael@0 64 {
michael@0 65 // ###############
michael@0 66 return GetPixelDepth(aColorDepth);
michael@0 67 }

mercurial