Reduce usage of QDesktopWidget to resolve screen properties in QtWidgets

Removes the need to initialize QDesktopWidget, just to look up which
screen a widget would map to, the geometry of a screen, number of
screens, etc.

Change-Id: Ieb153b9ff6d3fba645fc528d6e430e8392f990bf
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-08-13 15:19:20 +02:00
parent 52ad5afe1c
commit 23697466ca
26 changed files with 178 additions and 68 deletions

View File

@ -41,6 +41,7 @@
#include "qapplication.h" #include "qapplication.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qdrawutil.h" #include "qdrawutil.h"
#include "qevent.h" #include "qevent.h"
#include "qimage.h" #include "qimage.h"
@ -1698,7 +1699,7 @@ void QColorDialogPrivate::initWidgets()
#else #else
// small displays (e.g. PDAs) cannot fit the full color dialog, // small displays (e.g. PDAs) cannot fit the full color dialog,
// so just use the color picker. // so just use the color picker.
smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350); smallDisplay = (QDesktopWidgetPrivate::width() < 480 || QDesktopWidgetPrivate::height() < 350);
const int lumSpace = topLay->spacing() / 2; const int lumSpace = topLay->spacing() / 2;
#endif #endif
@ -1744,7 +1745,7 @@ void QColorDialogPrivate::initWidgets()
} else { } else {
// better color picker size for small displays // better color picker size for small displays
#if defined(QT_SMALL_COLORDIALOG) #if defined(QT_SMALL_COLORDIALOG)
QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); QSize screenSize = QDesktopWidgetPrivate::availableGeometry(QCursor::pos()).size();
pWidth = pHeight = qMin(screenSize.width(), screenSize.height()); pWidth = pHeight = qMin(screenSize.width(), screenSize.height());
pHeight -= 20; pHeight -= 20;
if(screenSize.height() > screenSize.width()) if(screenSize.height() > screenSize.width())

View File

@ -50,6 +50,7 @@
#include "qevent.h" #include "qevent.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qapplication.h" #include "qapplication.h"
#include "qlayout.h" #include "qlayout.h"
#include "qsizegrip.h" #include "qsizegrip.h"
@ -811,13 +812,13 @@ void QDialog::adjustPosition(QWidget* w)
w = w->window(); w = w->window();
QRect desk; QRect desk;
if (w) { if (w) {
scrn = QApplication::desktop()->screenNumber(w); scrn = QDesktopWidgetPrivate::screenNumber(w);
} else if (QApplication::desktop()->isVirtualDesktop()) { } else if (QDesktopWidgetPrivate::isVirtualDesktop()) {
scrn = QApplication::desktop()->screenNumber(QCursor::pos()); scrn = QDesktopWidgetPrivate::screenNumber(QCursor::pos());
} else { } else {
scrn = QApplication::desktop()->screenNumber(this); scrn = QDesktopWidgetPrivate::screenNumber(this);
} }
desk = QApplication::desktop()->availableGeometry(scrn); desk = QDesktopWidgetPrivate::availableGeometry(scrn);
QWidgetList list = QApplication::topLevelWidgets(); QWidgetList list = QApplication::topLevelWidgets();
for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) { for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) {

View File

@ -60,6 +60,7 @@
#include <QtGui/qfont.h> #include <QtGui/qfont.h>
#include <QtGui/qfontmetrics.h> #include <QtGui/qfontmetrics.h>
#include <QtGui/qclipboard.h> #include <QtGui/qclipboard.h>
#include <private/qdesktopwidget_p.h>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
# include <QtCore/qt_windows.h> # include <QtCore/qt_windows.h>
@ -357,7 +358,7 @@ void QMessageBoxPrivate::updateSize()
if (!q->isVisible()) if (!q->isVisible())
return; return;
QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); QSize screenSize = QDesktopWidgetPrivate::availableGeometry(QCursor::pos()).size();
int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
// on small screens allows the messagebox be the same size as the screen // on small screens allows the messagebox be the same size as the screen
if (screenSize.width() <= 1024) if (screenSize.width() <= 1024)

View File

@ -46,6 +46,7 @@
#include "qboxlayout.h" #include "qboxlayout.h"
#include "qlayoutitem.h" #include "qlayoutitem.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qevent.h" #include "qevent.h"
#include "qframe.h" #include "qframe.h"
#include "qlabel.h" #include "qlabel.h"
@ -396,7 +397,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title,
/* /*
There is no widthForHeight() function, so we simulate it with a loop. There is no widthForHeight() function, so we simulate it with a loop.
*/ */
int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); int candidateSubTitleWidth = qMin(512, 2 * QDesktopWidgetPrivate::width() / 3);
int delta = candidateSubTitleWidth >> 1; int delta = candidateSubTitleWidth >> 1;
while (delta > 0) { while (delta > 0) {
if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta) if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta)

View File

@ -284,6 +284,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
#include <QtCore/qscopedvaluerollback.h> #include <QtCore/qscopedvaluerollback.h>
#include <QtWidgets/qapplication.h> #include <QtWidgets/qapplication.h>
#include <QtWidgets/qdesktopwidget.h> #include <QtWidgets/qdesktopwidget.h>
#include <private/qdesktopwidget_p.h>
#include <QtGui/qevent.h> #include <QtGui/qevent.h>
#include <QtWidgets/qlayout.h> #include <QtWidgets/qlayout.h>
#include <QtGui/qtransform.h> #include <QtGui/qtransform.h>
@ -1248,7 +1249,7 @@ QSize QGraphicsView::sizeHint() const
if (d->scene) { if (d->scene) {
QSizeF baseSize = d->matrix.mapRect(sceneRect()).size(); QSizeF baseSize = d->matrix.mapRect(sceneRect()).size();
baseSize += QSizeF(d->frameWidth * 2, d->frameWidth * 2); baseSize += QSizeF(d->frameWidth * 2, d->frameWidth * 2);
return baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4).toSize(); return baseSize.boundedTo((3 * QDesktopWidgetPrivate::size()) / 4).toSize();
} }
return QAbstractScrollArea::sizeHint(); return QAbstractScrollArea::sizeHint();
} }

View File

@ -72,6 +72,11 @@ int QDesktopScreenWidget::screenNumber() const
} }
const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const
{
return QDesktopWidgetPrivate::screenGeometry(widget);
}
const QRect QDesktopWidgetPrivate::screenGeometry(const QWidget *widget)
{ {
if (Q_UNLIKELY(!widget)) { if (Q_UNLIKELY(!widget)) {
qWarning("QDesktopWidget::screenGeometry(): Attempt " qWarning("QDesktopWidget::screenGeometry(): Attempt "
@ -85,6 +90,11 @@ const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const
} }
const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const
{
return QDesktopWidgetPrivate::availableGeometry(widget);
}
const QRect QDesktopWidgetPrivate::availableGeometry(const QWidget *widget)
{ {
if (Q_UNLIKELY(!widget)) { if (Q_UNLIKELY(!widget)) {
qWarning("QDesktopWidget::availableGeometry(): Attempt " qWarning("QDesktopWidget::availableGeometry(): Attempt "
@ -194,16 +204,51 @@ QDesktopWidget::~QDesktopWidget()
} }
bool QDesktopWidget::isVirtualDesktop() const bool QDesktopWidget::isVirtualDesktop() const
{
return QDesktopWidgetPrivate::isVirtualDesktop();
}
bool QDesktopWidgetPrivate::isVirtualDesktop()
{ {
return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1; return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
} }
QRect QDesktopWidgetPrivate::geometry()
{
return QGuiApplication::primaryScreen()->virtualGeometry();
}
QSize QDesktopWidgetPrivate::size()
{
return geometry().size();
}
int QDesktopWidgetPrivate::width()
{
return geometry().width();
}
int QDesktopWidgetPrivate::height()
{
return geometry().height();
}
int QDesktopWidget::primaryScreen() const int QDesktopWidget::primaryScreen() const
{
return QDesktopWidgetPrivate::primaryScreen();
}
int QDesktopWidgetPrivate::primaryScreen()
{ {
return 0; return 0;
} }
int QDesktopWidget::numScreens() const int QDesktopWidget::numScreens() const
{
return QDesktopWidgetPrivate::numScreens();
}
int QDesktopWidgetPrivate::numScreens()
{ {
return qMax(QGuiApplication::screens().size(), 1); return qMax(QGuiApplication::screens().size(), 1);
} }
@ -217,6 +262,11 @@ QWidget *QDesktopWidget::screen(int screen)
} }
const QRect QDesktopWidget::availableGeometry(int screenNo) const const QRect QDesktopWidget::availableGeometry(int screenNo) const
{
return QDesktopWidgetPrivate::availableGeometry(screenNo);
}
const QRect QDesktopWidgetPrivate::availableGeometry(int screenNo)
{ {
QList<QScreen *> screens = QGuiApplication::screens(); QList<QScreen *> screens = QGuiApplication::screens();
if (screenNo == -1) if (screenNo == -1)
@ -228,6 +278,11 @@ const QRect QDesktopWidget::availableGeometry(int screenNo) const
} }
const QRect QDesktopWidget::screenGeometry(int screenNo) const const QRect QDesktopWidget::screenGeometry(int screenNo) const
{
return QDesktopWidgetPrivate::screenGeometry(screenNo);
}
const QRect QDesktopWidgetPrivate::screenGeometry(int screenNo)
{ {
QList<QScreen *> screens = QGuiApplication::screens(); QList<QScreen *> screens = QGuiApplication::screens();
if (screenNo == -1) if (screenNo == -1)
@ -239,6 +294,11 @@ const QRect QDesktopWidget::screenGeometry(int screenNo) const
} }
int QDesktopWidget::screenNumber(const QWidget *w) const int QDesktopWidget::screenNumber(const QWidget *w) const
{
return QDesktopWidgetPrivate::screenNumber(w);
}
int QDesktopWidgetPrivate::screenNumber(const QWidget *w)
{ {
if (!w) if (!w)
return primaryScreen(); return primaryScreen();
@ -286,6 +346,11 @@ int QDesktopWidget::screenNumber(const QWidget *w) const
} }
int QDesktopWidget::screenNumber(const QPoint &p) const int QDesktopWidget::screenNumber(const QPoint &p) const
{
return QDesktopWidgetPrivate::screenNumber(p);
}
int QDesktopWidgetPrivate::screenNumber(const QPoint &p)
{ {
const QList<QScreen *> screens = QGuiApplication::screens(); const QList<QScreen *> screens = QGuiApplication::screens();
if (!screens.isEmpty()) { if (!screens.isEmpty()) {

View File

@ -87,6 +87,29 @@ public:
void _q_availableGeometryChanged(); void _q_availableGeometryChanged();
QDesktopScreenWidget *widgetForScreen(QScreen *qScreen) const; QDesktopScreenWidget *widgetForScreen(QScreen *qScreen) const;
static bool isVirtualDesktop();
static QRect geometry();
static QSize size();
static int width();
static int height();
static int numScreens();
static int primaryScreen();
static int screenNumber(const QWidget *widget = nullptr);
static int screenNumber(const QPoint &);
static const QRect screenGeometry(int screen = -1);
static const QRect screenGeometry(const QWidget *widget);
static const QRect screenGeometry(const QPoint &point)
{ return screenGeometry(screenNumber(point)); }
static const QRect availableGeometry(int screen = -1);
static const QRect availableGeometry(const QWidget *widget);
static const QRect availableGeometry(const QPoint &point)
{ return availableGeometry(screenNumber(point)); }
QList<QDesktopScreenWidget *> screens; QList<QDesktopScreenWidget *> screens;
}; };

View File

@ -42,6 +42,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#include <private/qdesktopwidget_p.h>
#include <qevent.h> #include <qevent.h>
#include <qpointer.h> #include <qpointer.h>
#include <qstyle.h> #include <qstyle.h>
@ -362,10 +363,10 @@ bool QTipLabel::eventFilter(QObject *o, QEvent *e)
int QTipLabel::getTipScreen(const QPoint &pos, QWidget *w) int QTipLabel::getTipScreen(const QPoint &pos, QWidget *w)
{ {
if (QApplication::desktop()->isVirtualDesktop()) if (QDesktopWidgetPrivate::isVirtualDesktop())
return QApplication::desktop()->screenNumber(pos); return QDesktopWidgetPrivate::screenNumber(pos);
else else
return QApplication::desktop()->screenNumber(w); return QDesktopWidgetPrivate::screenNumber(w);
} }
void QTipLabel::placeTip(const QPoint &pos, QWidget *w) void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
@ -395,11 +396,11 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
extern bool qt_mac_app_fullscreen; //qapplication_mac.mm extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
QRect screen; QRect screen;
if(qt_mac_app_fullscreen) if(qt_mac_app_fullscreen)
screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w)); screen = QDesktopWidgetPrivate::screenGeometry(getTipScreen(pos, w));
else else
screen = QApplication::desktop()->availableGeometry(getTipScreen(pos, w)); screen = QDesktopWidgetPrivate::availableGeometry(getTipScreen(pos, w));
#else #else
QRect screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w)); QRect screen = QDesktopWidgetPrivate::screenGeometry(getTipScreen(pos, w));
#endif #endif
QPoint p = pos; QPoint p = pos;

View File

@ -42,6 +42,7 @@
#include "qapplication.h" #include "qapplication.h"
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qevent.h" #include "qevent.h"
#include "qpixmap.h" #include "qpixmap.h"
#include "qscreen.h" #include "qscreen.h"
@ -209,7 +210,7 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor
} }
else else
{ {
int sw = QApplication::desktop()->width() / 3; int sw = QDesktopWidgetPrivate::width() / 3;
if (sw < 200) if (sw < 200)
sw = 200; sw = 200;
else if (sw > 300) else if (sw > 300)
@ -582,14 +583,14 @@ void QWhatsThisPrivate::say(QWidget * widget, const QString &text, int x, int y)
// okay, now to find a suitable location // okay, now to find a suitable location
int scr = (widget ? int scr = (widget ?
QApplication::desktop()->screenNumber(widget) : QDesktopWidgetPrivate::screenNumber(widget) :
#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && !defined(QT_NO_CURSOR) #if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && !defined(QT_NO_CURSOR)
QCursor::x11Screen() QCursor::x11Screen()
#else #else
QApplication::desktop()->screenNumber(QPoint(x,y)) QDesktopWidgetPrivate::screenNumber(QPoint(x,y))
#endif #endif
); );
QRect screen = QApplication::desktop()->screenGeometry(scr); QRect screen = QDesktopWidgetPrivate::screenGeometry(scr);
int w = whatsThat->width(); int w = whatsThat->width();
int h = whatsThat->height(); int h = whatsThat->height();

View File

@ -1454,7 +1454,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
topData()->initialScreenIndex = -1; topData()->initialScreenIndex = -1;
if (screenNumber < 0) { if (screenNumber < 0) {
screenNumber = q->windowType() != Qt::Desktop screenNumber = q->windowType() != Qt::Desktop
? QApplication::desktop()->screenNumber(q) : 0; ? QDesktopWidgetPrivate::screenNumber(q) : 0;
} }
win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR)); win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR));
} }
@ -7162,7 +7162,7 @@ void QWidgetPrivate::fixPosIncludesFrame()
if (q->testAttribute(Qt::WA_DontShowOnScreen)) { if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
te->posIncludesFrame = 0; te->posIncludesFrame = 0;
} else { } else {
if (q->windowHandle()) { if (q->windowHandle() && q->windowHandle()->handle()) {
updateFrameStrut(); updateFrameStrut();
if (!q->data->fstrut_dirty) { if (!q->data->fstrut_dirty) {
data.crect.translate(te->frameStrut.x(), te->frameStrut.y()); data.crect.translate(te->frameStrut.x(), te->frameStrut.y());
@ -7358,7 +7358,7 @@ QByteArray QWidget::saveGeometry() const
// - Qt 4.8.6 - today, 5.4 - today: Version 2.0, save screen width in addition to check for high DPI scaling. // - Qt 4.8.6 - today, 5.4 - today: Version 2.0, save screen width in addition to check for high DPI scaling.
quint16 majorVersion = 2; quint16 majorVersion = 2;
quint16 minorVersion = 0; quint16 minorVersion = 0;
const int screenNumber = QApplication::desktop()->screenNumber(this); const int screenNumber = QDesktopWidgetPrivate::screenNumber(this);
stream << magicNumber stream << magicNumber
<< majorVersion << majorVersion
<< minorVersion << minorVersion
@ -7372,7 +7372,7 @@ QByteArray QWidget::saveGeometry() const
<< qint32(screenNumber) << qint32(screenNumber)
<< quint8(windowState() & Qt::WindowMaximized) << quint8(windowState() & Qt::WindowMaximized)
<< quint8(windowState() & Qt::WindowFullScreen) << quint8(windowState() & Qt::WindowFullScreen)
<< qint32(QApplication::desktop()->screenGeometry(screenNumber).width()); // 1.1 onwards << qint32(QDesktopWidgetPrivate::screenGeometry(screenNumber).width()); // 1.1 onwards
return array; return array;
} }
@ -7438,10 +7438,9 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
if (majorVersion > 1) if (majorVersion > 1)
stream >> restoredScreenWidth; stream >> restoredScreenWidth;
const QDesktopWidget * const desktop = QApplication::desktop(); if (restoredScreenNumber >= QDesktopWidgetPrivate::numScreens())
if (restoredScreenNumber >= desktop->numScreens()) restoredScreenNumber = QDesktopWidgetPrivate::primaryScreen();
restoredScreenNumber = desktop->primaryScreen(); const qreal screenWidthF = qreal(QDesktopWidgetPrivate::screenGeometry(restoredScreenNumber).width());
const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width());
// Sanity check bailing out when large variations of screen sizes occur due to // Sanity check bailing out when large variations of screen sizes occur due to
// high DPI scaling or different levels of DPI awareness. // high DPI scaling or different levels of DPI awareness.
if (restoredScreenWidth) { if (restoredScreenWidth) {
@ -7468,7 +7467,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
.expandedTo(d_func()->adjustedSize())); .expandedTo(d_func()->adjustedSize()));
} }
const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); const QRect availableGeometry = QDesktopWidgetPrivate::availableGeometry(restoredScreenNumber);
// Modify the restored geometry if we are about to restore to coordinates // Modify the restored geometry if we are about to restore to coordinates
// that would make the window "lost". This happens if: // that would make the window "lost". This happens if:
@ -7509,7 +7508,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
// Setting a geometry on an already maximized window causes this to be // Setting a geometry on an already maximized window causes this to be
// restored into a broken, half-maximized state, non-resizable state (QTBUG-4397). // restored into a broken, half-maximized state, non-resizable state (QTBUG-4397).
// Move the window in normal state if needed. // Move the window in normal state if needed.
if (restoredScreenNumber != desktop->screenNumber(this)) { if (restoredScreenNumber != QDesktopWidgetPrivate::screenNumber(this)) {
setWindowState(Qt::WindowNoState); setWindowState(Qt::WindowNoState);
setGeometry(restoredNormalGeometry); setGeometry(restoredNormalGeometry);
} }
@ -8573,9 +8572,9 @@ QSize QWidgetPrivate::adjustedSize() const
if (exp & Qt::Vertical) if (exp & Qt::Vertical)
s.setHeight(qMax(s.height(), 100)); s.setHeight(qMax(s.height(), 100));
#if 0 // Used to be included in Qt4 for Q_WS_X11 #if 0 // Used to be included in Qt4 for Q_WS_X11
QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen()); QRect screen = QDesktopWidgetPrivate::screenGeometry(q->x11Info().screen());
#else // all others #else // all others
QRect screen = QApplication::desktop()->screenGeometry(q->pos()); QRect screen = QDesktopWidgetPrivate::screenGeometry(q->pos());
#endif #endif
s.setWidth(qMin(s.width(), screen.width()*2/3)); s.setWidth(qMin(s.width(), screen.width()*2/3));
s.setHeight(qMin(s.height(), screen.height()*2/3)); s.setHeight(qMin(s.height(), screen.height()*2/3));
@ -10719,7 +10718,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
f |= Qt::Window; f |= Qt::Window;
if (targetScreen == -1) { if (targetScreen == -1) {
if (parent) if (parent)
targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); targetScreen = QDesktopWidgetPrivate::screenNumber(q->parentWidget()->window());
} }
} }

View File

@ -160,6 +160,7 @@
#include "QtWidgets/qapplication.h" #include "QtWidgets/qapplication.h"
#include "QtGui/qevent.h" #include "QtGui/qevent.h"
#include "QtWidgets/qdesktopwidget.h" #include "QtWidgets/qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "QtWidgets/qlineedit.h" #include "QtWidgets/qlineedit.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -922,7 +923,7 @@ void QCompleterPrivate::_q_autoResizePopup()
void QCompleterPrivate::showPopup(const QRect& rect) void QCompleterPrivate::showPopup(const QRect& rect)
{ {
const QRect screen = QApplication::desktop()->availableGeometry(widget); const QRect screen = QDesktopWidgetPrivate::availableGeometry(widget);
Qt::LayoutDirection dir = widget->layoutDirection(); Qt::LayoutDirection dir = widget->layoutDirection();
QPoint pos; QPoint pos;
int rh, w; int rh, w;

View File

@ -59,6 +59,7 @@
#include "qgridlayout.h" #include "qgridlayout.h"
#include "qapplication.h" #include "qapplication.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qbitmap.h" #include "qbitmap.h"
#include <private/qhighdpiscaling_p.h> #include <private/qhighdpiscaling_p.h>
@ -535,7 +536,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
// smart size for the message label // smart size for the message label
int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3; int limit = QDesktopWidgetPrivate::availableGeometry(msgLabel).size().width() / 3;
if (msgLabel->sizeHint().width() > limit) { if (msgLabel->sizeHint().width() > limit) {
msgLabel->setWordWrap(true); msgLabel->setWordWrap(true);
if (msgLabel->sizeHint().width() > limit) { if (msgLabel->sizeHint().width() > limit) {
@ -602,7 +603,7 @@ void QBalloonTip::resizeEvent(QResizeEvent *ev)
void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow) void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow)
{ {
this->showArrow = showArrow; this->showArrow = showArrow;
QRect scr = QApplication::desktop()->screenGeometry(pos); QRect scr = QDesktopWidgetPrivate::screenGeometry(pos);
QSize sh = sizeHint(); QSize sh = sizeHint();
const int border = 1; const int border = 1;
const int ah = 18, ao = 18, aw = 18, rc = 7; const int ah = 18, ao = 18, aw = 18, rc = 7;

View File

@ -45,6 +45,7 @@
#include <qlineedit.h> #include <qlineedit.h>
#include <qapplication.h> #include <qapplication.h>
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#include <private/qdesktopwidget_p.h>
#include <qlistview.h> #include <qlistview.h>
#if QT_CONFIG(tableview) #if QT_CONFIG(tableview)
#include <qtableview.h> #include <qtableview.h>
@ -262,8 +263,8 @@ QRect QComboBoxPrivate::popupGeometry(int screen) const
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
return useFullScreenForPopupMenu ? return useFullScreenForPopupMenu ?
QApplication::desktop()->screenGeometry(screen) : QDesktopWidgetPrivate::screenGeometry(screen) :
QApplication::desktop()->availableGeometry(screen); QDesktopWidgetPrivate::availableGeometry(screen);
} }
bool QComboBoxPrivate::updateHoverControl(const QPoint &pos) bool QComboBoxPrivate::updateHoverControl(const QPoint &pos)
@ -2607,7 +2608,7 @@ void QComboBox::showPopup()
QComboBoxPrivateContainer* container = d->viewContainer(); QComboBoxPrivateContainer* container = d->viewContainer();
QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt, QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxListBoxPopup, this)); QStyle::SC_ComboBoxListBoxPopup, this));
QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this)); QRect screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(this));
QPoint below = mapToGlobal(listRect.bottomLeft()); QPoint below = mapToGlobal(listRect.bottomLeft());
int belowHeight = screen.bottom() - below.y(); int belowHeight = screen.bottom() - below.y();

View File

@ -42,6 +42,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <qdatetimeedit.h> #include <qdatetimeedit.h>
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#include <private/qdesktopwidget_p.h>
#include <qdebug.h> #include <qdebug.h>
#include <qevent.h> #include <qevent.h>
#include <qlineedit.h> #include <qlineedit.h>
@ -2516,7 +2517,7 @@ void QDateTimeEditPrivate::positionCalendarPopup()
pos = q->mapToGlobal(pos); pos = q->mapToGlobal(pos);
pos2 = q->mapToGlobal(pos2); pos2 = q->mapToGlobal(pos2);
QSize size = monthCalendar->sizeHint(); QSize size = monthCalendar->sizeHint();
QRect screen = QApplication::desktop()->availableGeometry(pos); QRect screen = QDesktopWidgetPrivate::availableGeometry(pos);
//handle popup falling "off screen" //handle popup falling "off screen"
if (q->layoutDirection() == Qt::RightToLeft) { if (q->layoutDirection() == Qt::RightToLeft) {
pos.setX(pos.x()-size.width()); pos.setX(pos.x()-size.width());

View File

@ -45,6 +45,7 @@
#endif #endif
#include "QtWidgets/qstyle.h" #include "QtWidgets/qstyle.h"
#include "QtWidgets/qdesktopwidget.h" #include "QtWidgets/qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "QtWidgets/qapplication.h" #include "QtWidgets/qapplication.h"
#include "QtCore/qvariant.h" #include "QtCore/qvariant.h"
#include "qdockarealayout_p.h" #include "qdockarealayout_p.h"
@ -3043,11 +3044,10 @@ QSize QDockAreaLayout::minimumSize() const
QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget) QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
{ {
QRect desktop; QRect desktop;
QDesktopWidget *desktopW = QApplication::desktop(); if (QDesktopWidgetPrivate::isVirtualDesktop())
if (desktopW->isVirtualDesktop()) desktop = QDesktopWidgetPrivate::screenGeometry(rect.topLeft());
desktop = desktopW->screenGeometry(rect.topLeft());
else else
desktop = desktopW->screenGeometry(widget); desktop = QDesktopWidgetPrivate::screenGeometry(widget);
if (desktop.isValid()) { if (desktop.isValid()) {
rect.setWidth(qMin(rect.width(), desktop.width())); rect.setWidth(qMin(rect.width(), desktop.width()));

View File

@ -51,6 +51,8 @@
#include "qelapsedtimer.h" #include "qelapsedtimer.h"
#include "qdebug.h" #include "qdebug.h"
#include <private/qdesktopwidget_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
/* /*
@ -98,7 +100,7 @@ static QAlphaWidget* q_blend = 0;
Constructs a QAlphaWidget. Constructs a QAlphaWidget.
*/ */
QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f) QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f)
: QWidget(QApplication::desktop()->screen(QApplication::desktop()->screenNumber(w)), f) : QWidget(QApplication::desktop()->screen(QDesktopWidgetPrivate::screenNumber(w)), f)
{ {
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
setEnabled(false); setEnabled(false);

View File

@ -47,6 +47,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <private/qcombobox_p.h> #include <private/qcombobox_p.h>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <private/qdesktopwidget_p.h>
#include <qdebug.h> #include <qdebug.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -540,7 +541,7 @@ bool QFontComboBox::event(QEvent *e)
QListView *lview = qobject_cast<QListView*>(view()); QListView *lview = qobject_cast<QListView*>(view());
if (lview) { if (lview) {
lview->window()->setFixedWidth(qMin(width() * 5 / 3, lview->window()->setFixedWidth(qMin(width() * 5 / 3,
QApplication::desktop()->availableGeometry(lview).width())); QDesktopWidgetPrivate::availableGeometry(lview).width()));
} }
} }
return QComboBox::event(e); return QComboBox::event(e);

View File

@ -168,6 +168,7 @@
#include <QFontMetrics> #include <QFontMetrics>
#include <QStyleOption> #include <QStyleOption>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <private/qdesktopwidget_p.h>
#include <QDebug> #include <QDebug>
#include <qmath.h> #include <qmath.h>
#include <private/qlayoutengine_p.h> #include <private/qlayoutengine_p.h>
@ -1746,7 +1747,7 @@ QSize QMdiArea::sizeHint() const
} }
const int scaleFactor = 3 * (nestedCount + 1); const int scaleFactor = 3 * (nestedCount + 1);
QSize desktopSize = QApplication::desktop()->size(); QSize desktopSize = QDesktopWidgetPrivate::size();
QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor); QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor);
for (QMdiSubWindow *child : d_func()->childWindows) { for (QMdiSubWindow *child : d_func()->childWindows) {
if (!sanityCheck(child, "QMdiArea::sizeHint")) if (!sanityCheck(child, "QMdiArea::sizeHint"))

View File

@ -75,6 +75,7 @@
#include <private/qaction_p.h> #include <private/qaction_p.h>
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme.h>
#include <private/qdesktopwidget_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -100,7 +101,7 @@ class QTornOffMenu : public QMenu
Q_Q(QTornOffMenu); Q_Q(QTornOffMenu);
QSize size = menuSize; QSize size = menuSize;
const QPoint p = (!initialized) ? causedMenu->pos() : q->pos(); const QPoint p = (!initialized) ? causedMenu->pos() : q->pos();
QRect screen = popupGeometry(QApplication::desktop()->screenNumber(p)); QRect screen = popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);
const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, q); const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, q);
if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) { if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) {
@ -267,9 +268,9 @@ QRect QMenuPrivate::popupGeometry(const QWidget *widget) const
{ {
if (QGuiApplicationPrivate::platformTheme() && if (QGuiApplicationPrivate::platformTheme() &&
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) { QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
return QApplication::desktop()->screenGeometry(widget); return QDesktopWidgetPrivate::screenGeometry(widget);
} else { } else {
return QApplication::desktop()->availableGeometry(widget); return QDesktopWidgetPrivate::availableGeometry(widget);
} }
} }
@ -278,9 +279,9 @@ QRect QMenuPrivate::popupGeometry(int screen) const
{ {
if (QGuiApplicationPrivate::platformTheme() && if (QGuiApplicationPrivate::platformTheme() &&
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) { QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
return QApplication::desktop()->screenGeometry(screen); return QDesktopWidgetPrivate::screenGeometry(screen);
} else { } else {
return QApplication::desktop()->availableGeometry(screen); return QDesktopWidgetPrivate::availableGeometry(screen);
} }
} }
@ -2332,7 +2333,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
screen = d->popupGeometry(this); screen = d->popupGeometry(this);
else else
#endif #endif
screen = d->popupGeometry(QApplication::desktop()->screenNumber(p)); screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
d->updateActionRects(screen); d->updateActionRects(screen);
QPoint pos; QPoint pos;
@ -3601,7 +3602,7 @@ void QMenu::internalDelayedPopup()
screen = d->popupGeometry(this); screen = d->popupGeometry(this);
else else
#endif #endif
screen = d->popupGeometry(QApplication::desktop()->screenNumber(pos())); screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(pos()));
int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
const QRect actionRect(d->actionRect(d->currentAction)); const QRect actionRect(d->actionRect(d->currentAction));

View File

@ -60,6 +60,7 @@
#include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme.h>
#include "private/qguiapplication_p.h" #include "private/qguiapplication_p.h"
#include "qpa/qplatformintegration.h" #include "qpa/qplatformintegration.h"
#include <private/qdesktopwidget_p.h>
#ifndef QT_NO_MENUBAR #ifndef QT_NO_MENUBAR
@ -322,7 +323,7 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
QSize popup_size = activeMenu->sizeHint(); QSize popup_size = activeMenu->sizeHint();
//we put the popup menu on the screen containing the bottom-center of the action rect //we put the popup menu on the screen containing the bottom-center of the action rect
QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0)); QRect screenRect = QDesktopWidgetPrivate::screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));
pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height()); const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height());
@ -1566,7 +1567,7 @@ QSize QMenuBar::minimumSizeHint() const
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
if(as_gui_menubar) { if(as_gui_menubar) {
int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width(); int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width();
d->calcActionRects(w - (2 * fw), 0); d->calcActionRects(w - (2 * fw), 0);
for (int i = 0; ret.isNull() && i < d->actions.count(); ++i) for (int i = 0; ret.isNull() && i < d->actions.count(); ++i)
ret = d->actionRects.at(i).size(); ret = d->actionRects.at(i).size();
@ -1618,7 +1619,7 @@ QSize QMenuBar::sizeHint() const
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
if(as_gui_menubar) { if(as_gui_menubar) {
const int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width(); const int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width();
d->calcActionRects(w - (2 * fw), 0); d->calcActionRects(w - (2 * fw), 0);
for (int i = 0; i < d->actionRects.count(); ++i) { for (int i = 0; i < d->actionRects.count(); ++i) {
const QRect &actionRect = d->actionRects.at(i); const QRect &actionRect = d->actionRects.at(i);

View File

@ -40,6 +40,7 @@
#include "qapplication.h" #include "qapplication.h"
#include "qbitmap.h" #include "qbitmap.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#if QT_CONFIG(dialog) #if QT_CONFIG(dialog)
#include <private/qdialog_p.h> #include <private/qdialog_p.h>
#endif #endif
@ -607,7 +608,7 @@ QPoint QPushButtonPrivate::adjustedMenuPosition()
QPoint globalPos = q->mapToGlobal(rect.topLeft()); QPoint globalPos = q->mapToGlobal(rect.topLeft());
int x = globalPos.x(); int x = globalPos.x();
int y = globalPos.y(); int y = globalPos.y();
const QRect availableGeometry = QApplication::desktop()->availableGeometry(q); const QRect availableGeometry = QDesktopWidgetPrivate::availableGeometry(q);
if (horizontal) { if (horizontal) {
if (globalPos.y() + rect.height() + menuSize.height() <= availableGeometry.bottom()) { if (globalPos.y() + rect.height() + menuSize.height() <= availableGeometry.bottom()) {
y += rect.height(); y += rect.height();

View File

@ -57,6 +57,7 @@
#endif #endif
#include <private/qwidget_p.h> #include <private/qwidget_p.h>
#include <private/qdesktopwidget_p.h>
#include <QtWidgets/qabstractscrollarea.h> #include <QtWidgets/qabstractscrollarea.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -314,7 +315,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
bool hasVerticalSizeConstraint = true; bool hasVerticalSizeConstraint = true;
bool hasHorizontalSizeConstraint = true; bool hasHorizontalSizeConstraint = true;
if (tlw->isWindow()) if (tlw->isWindow())
availableGeometry = QApplication::desktop()->availableGeometry(tlw); availableGeometry = QDesktopWidgetPrivate::availableGeometry(tlw);
else { else {
const QWidget *tlwParent = tlw->parentWidget(); const QWidget *tlwParent = tlw->parentWidget();
// Check if tlw is inside QAbstractScrollArea/QScrollArea. // Check if tlw is inside QAbstractScrollArea/QScrollArea.

View File

@ -41,6 +41,7 @@
#include "qapplication.h" #include "qapplication.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qpainter.h" #include "qpainter.h"
#include "qpixmap.h" #include "qpixmap.h"
#include "qtextdocument.h" #include "qtextdocument.h"
@ -282,7 +283,7 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap)
QRect r(QPoint(), d->pixmap.size() / d->pixmap.devicePixelRatio()); QRect r(QPoint(), d->pixmap.size() / d->pixmap.devicePixelRatio());
resize(r.size()); resize(r.size());
move(QApplication::desktop()->screenGeometry().center() - r.center()); move(QDesktopWidgetPrivate::screenGeometry().center() - r.center());
if (isVisible()) if (isVisible())
repaint(); repaint();
} }

View File

@ -44,6 +44,7 @@
#include "qapplication.h" #include "qapplication.h"
#include "qbitmap.h" #include "qbitmap.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qevent.h" #include "qevent.h"
#include "qlayout.h" #include "qlayout.h"
#include "qstackedwidget.h" #include "qstackedwidget.h"
@ -829,7 +830,7 @@ QSize QTabWidget::sizeHint() const
if(usesScrollButtons()) if(usesScrollButtons())
t = t.boundedTo(QSize(200,200)); t = t.boundedTo(QSize(200,200));
else else
t = t.boundedTo(QApplication::desktop()->size()); t = t.boundedTo(QDesktopWidgetPrivate::size());
QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t); QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
@ -897,7 +898,7 @@ int QTabWidget::heightForWidth(int width) const
if(usesScrollButtons()) if(usesScrollButtons())
t = t.boundedTo(QSize(200,200)); t = t.boundedTo(QSize(200,200));
else else
t = t.boundedTo(QApplication::desktop()->size()); t = t.boundedTo(QDesktopWidgetPrivate::size());
const bool tabIsHorizontal = (d->pos == North || d->pos == South); const bool tabIsHorizontal = (d->pos == North || d->pos == South);
const int contentsWidth = width - padding.width(); const int contentsWidth = width - padding.width();

View File

@ -41,6 +41,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#include <private/qdesktopwidget_p.h>
#include <qdrawutil.h> #include <qdrawutil.h>
#include <qevent.h> #include <qevent.h>
#include <qicon.h> #include <qicon.h>
@ -745,7 +746,7 @@ void QToolButtonPrivate::popupTimerDone()
#endif #endif
QPoint p; QPoint p;
const QRect rect = q->rect(); // Find screen via point in case of QGraphicsProxyWidget. const QRect rect = q->rect(); // Find screen via point in case of QGraphicsProxyWidget.
QRect screen = QApplication::desktop()->availableGeometry(q->mapToGlobal(rect.center())); QRect screen = QDesktopWidgetPrivate::availableGeometry(q->mapToGlobal(rect.center()));
QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint(); QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
if (horizontal) { if (horizontal) {
if (q->isRightToLeft()) { if (q->isRightToLeft()) {

View File

@ -43,6 +43,7 @@
#include "qframe.h" #include "qframe.h"
#include "qapplication.h" #include "qapplication.h"
#include "qdesktopwidget.h" #include "qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
#include "qcursor.h" #include "qcursor.h"
#include "qsizegrip.h" #include "qsizegrip.h"
#include "qevent.h" #include "qevent.h"
@ -258,7 +259,7 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)
// Workaround for window managers which refuse to move a tool window partially offscreen. // Workaround for window managers which refuse to move a tool window partially offscreen.
if (QGuiApplication::platformName() == QLatin1String("xcb")) { if (QGuiApplication::platformName() == QLatin1String("xcb")) {
const QRect desktop = QApplication::desktop()->availableGeometry(widget); const QRect desktop = QDesktopWidgetPrivate::availableGeometry(widget);
pp.rx() = qMax(pp.x(), desktop.left()); pp.rx() = qMax(pp.x(), desktop.left());
pp.ry() = qMax(pp.y(), desktop.top()); pp.ry() = qMax(pp.y(), desktop.top());
p.rx() = qMin(p.x(), desktop.right()); p.rx() = qMin(p.x(), desktop.right());
@ -379,7 +380,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
switch (e->key()) { switch (e->key()) {
case Qt::Key_Left: case Qt::Key_Left:
pos.rx() -= delta; pos.rx() -= delta;
if (pos.x() <= QApplication::desktop()->geometry().left()) { if (pos.x() <= QDesktopWidgetPrivate::geometry().left()) {
if (mode == TopLeft || mode == BottomLeft) { if (mode == TopLeft || mode == BottomLeft) {
moveOffset.rx() += delta; moveOffset.rx() += delta;
invertedMoveOffset.rx() += delta; invertedMoveOffset.rx() += delta;
@ -404,7 +405,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
break; break;
case Qt::Key_Right: case Qt::Key_Right:
pos.rx() += delta; pos.rx() += delta;
if (pos.x() >= QApplication::desktop()->geometry().right()) { if (pos.x() >= QDesktopWidgetPrivate::geometry().right()) {
if (mode == TopRight || mode == BottomRight) { if (mode == TopRight || mode == BottomRight) {
moveOffset.rx() += delta; moveOffset.rx() += delta;
invertedMoveOffset.rx() += delta; invertedMoveOffset.rx() += delta;
@ -429,7 +430,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
break; break;
case Qt::Key_Up: case Qt::Key_Up:
pos.ry() -= delta; pos.ry() -= delta;
if (pos.y() <= QApplication::desktop()->geometry().top()) { if (pos.y() <= QDesktopWidgetPrivate::geometry().top()) {
if (mode == TopLeft || mode == TopRight) { if (mode == TopLeft || mode == TopRight) {
moveOffset.ry() += delta; moveOffset.ry() += delta;
invertedMoveOffset.ry() += delta; invertedMoveOffset.ry() += delta;
@ -454,7 +455,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
break; break;
case Qt::Key_Down: case Qt::Key_Down:
pos.ry() += delta; pos.ry() += delta;
if (pos.y() >= QApplication::desktop()->geometry().bottom()) { if (pos.y() >= QDesktopWidgetPrivate::geometry().bottom()) {
if (mode == BottomLeft || mode == BottomRight) { if (mode == BottomLeft || mode == BottomRight) {
moveOffset.ry() += delta; moveOffset.ry() += delta;
invertedMoveOffset.ry() += delta; invertedMoveOffset.ry() += delta;