From c66b7cf55b6913dcf33d49d4f6bf9db51ccf39a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 4 Oct 2011 13:11:30 +0200 Subject: Added Orientation API to QScreen and QWindow. QScreen now has a primary and current orientation, and a QWindow can set its orientation as well. The current screen orientation is just a hint to the application. Change-Id: I4635982cfac2d16634d4edd5c6ab78e9d0ac55a4 Reviewed-on: http://codereview.qt-project.org/5988 Reviewed-by: Paul Olav Tvete Sanity-Review: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/corelib/global/qnamespace.h | 8 ++ src/corelib/global/qnamespace.qdoc | 13 +++ src/gui/kernel/qevent.cpp | 61 ++----------- src/gui/kernel/qevent.h | 16 +--- src/gui/kernel/qevent_p.h | 6 +- src/gui/kernel/qguiapplication.cpp | 20 +++-- src/gui/kernel/qguiapplication_p.h | 2 +- src/gui/kernel/qplatformscreen_qpa.cpp | 33 +++++++ src/gui/kernel/qplatformscreen_qpa.h | 3 + src/gui/kernel/qplatformwindow_qpa.cpp | 14 +++ src/gui/kernel/qplatformwindow_qpa.h | 2 + src/gui/kernel/qscreen.cpp | 118 ++++++++++++++++++++++++++ src/gui/kernel/qscreen.h | 15 ++++ src/gui/kernel/qwindow.cpp | 35 ++++++++ src/gui/kernel/qwindow.h | 5 ++ src/gui/kernel/qwindow_p.h | 2 + src/gui/kernel/qwindowsysteminterface_qpa.cpp | 18 ++-- src/gui/kernel/qwindowsysteminterface_qpa.h | 7 +- src/gui/kernel/qwindowsysteminterface_qpa_p.h | 22 ++--- 19 files changed, 300 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 807bed8a61..4c1cff8eee 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -283,6 +283,14 @@ public: Q_DECLARE_FLAGS(WindowStates, WindowState) + enum ScreenOrientation { + UnknownOrientation, + LandscapeOrientation, + PortraitOrientation, + InvertedLandscapeOrientation, + InvertedPortraitOrientation + }; + enum WidgetAttribute { WA_Disabled = 0, WA_UnderMouse = 1, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 08df79af28..5df88898cf 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1825,6 +1825,19 @@ */ +/*! + \enum Qt::ScreenOrientation + + This enum type specifies the various orientations a screen might have. + + \value UnknownOrientation The orientation is unknown or the platform doesn't support orientations. + \value LandscapeOrientation Landscape orientation, display width is greater than display height. + \value PortraitOrientation Portrait orientation, display height is greater than display width, + rotated 90 degree clockwise relative to landscape. + \value InvertedLandscapeOrientation Inverted landscape orientation, rotated 180 degrees relative to landscape. + \value InvertedPortraitOrientation Inverted portrait orientation, rotated 180 degrees relative to portrait. +*/ + /*! \enum Qt::ContextMenuPolicy diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index bbca4efd0c..7acb5f7ce5 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4327,59 +4327,16 @@ const QScrollEventPrivate *QScrollEvent::d_func() const return reinterpret_cast(d); } -/*! - \enum QScreenOrientationChangeEvent::Orientation - - This enum describes the orientations that a device can have. - - \value Portrait The device is in a position where its top edge is pointing up. - - \value Landscape The device is rotated clockwise 90 degrees, so that its left edge is pointing up. - - \value PortraitInverted The device is rotated 180 degrees, so that its bottom edge is pointing up. - - \value LandscapeInverted The device is counterclockwise 90 degrees, so that its right edge is pointing up. - - \sa QScreenOrientationChangeEvent::orientation() - \sa QScreenOrientationChangeEvent::orientationInDegrees() -*/ - -/*! - Creates a new QScreenOrientationChangeEvent - \a screenOrientationInDegrees is the new screen orientation, expressed in degrees. - The orientation must be expressed in steps of 90 degrees. -*/ -QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(qint32 screenOrientationInDegrees) - : QEvent(QEvent::OrientationChange) -{ - d = reinterpret_cast(new QScreenOrientationChangeEventPrivate()); - d_func()->orientationInDegrees = screenOrientationInDegrees; - - qint32 orientationIndex = (qAbs(screenOrientationInDegrees) % 360) / 90; - // flip around the negative coords to correct order. - if (screenOrientationInDegrees < 0) { - if (orientationIndex == 1) - orientationIndex = 3; - else if (orientationIndex == 3) - orientationIndex = 1; - } - - orientationIndex = qPow(2, orientationIndex); - d_func()->orientation = (QScreenOrientationChangeEvent::Orientation)(orientationIndex); - d_func()->isValid = (screenOrientationInDegrees % 90 == 0); -} - /*! Creates a new QScreenOrientationChangeEvent \a orientation is the new orientation of the screen. */ -QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreenOrientationChangeEvent::Orientation screenOrientation) +QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation) : QEvent(QEvent::OrientationChange) { d = reinterpret_cast(new QScreenOrientationChangeEventPrivate()); + d_func()->screen = screen; d_func()->orientation = screenOrientation; - d_func()->orientationInDegrees = 90 * ((uint)screenOrientation); - d_func()->isValid = true; } /*! @@ -4391,21 +4348,19 @@ QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent() } /*! - Returns the orientation of the screen. + Returns the screen whose orientation changed. */ -QScreenOrientationChangeEvent::Orientation QScreenOrientationChangeEvent::orientation() const +QScreen *QScreenOrientationChangeEvent::screen() const { - return d_func()->orientation; + return d_func()->screen; } /*! - Returns the screen orientation in degrees. - The orientation is expressed in steps of 90 degrees and depends on the previous value of the orientation. - This is intended to allow for smooth animations from one orientation to the other. + Returns the orientation of the screen. */ -qint32 QScreenOrientationChangeEvent::orientationInDegrees() const +Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const { - return d_func()->orientationInDegrees; + return d_func()->orientation; } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 7e9ca97051..eea9b2bdf1 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -69,6 +69,7 @@ class QAction; #ifndef QT_NO_GESTURES class QGesture; #endif +class QScreen; class Q_GUI_EXPORT QInputEvent : public QEvent { @@ -840,24 +841,15 @@ class QScreenOrientationChangeEventPrivate; class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent { public: - enum Orientation { - Portrait = 1, - Landscape = 2, - PortraitInverted = 4, - LandscapeInverted = 8 - }; - QScreenOrientationChangeEvent(qint32 screenOrientationInDegrees); - QScreenOrientationChangeEvent(Orientation screenOrientation); + QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation); ~QScreenOrientationChangeEvent(); - bool isValid() const; - qint32 orientationInDegrees() const; - Orientation orientation() const; + QScreen *screen() const; + Qt::ScreenOrientation orientation() const; private: QScreenOrientationChangeEventPrivate *d_func(); const QScreenOrientationChangeEventPrivate *d_func() const; - }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 59eb270230..f304f44846 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -159,9 +159,9 @@ public: inline QScreenOrientationChangeEventPrivate() { } - QScreenOrientationChangeEvent::Orientation orientation; - qint32 orientationInDegrees; - bool isValid; + + QScreen *screen; + Qt::ScreenOrientation orientation; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 29b961a170..723f69199f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -533,9 +533,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv QGuiApplicationPrivate::processCloseEvent( static_cast(e)); break; - case QWindowSystemInterfacePrivate::ScreenCountChange: - QGuiApplicationPrivate::reportScreenCount( - static_cast(e)); + case QWindowSystemInterfacePrivate::ScreenOrientation: + QGuiApplicationPrivate::reportScreenOrientationChange( + static_cast(e)); break; case QWindowSystemInterfacePrivate::ScreenGeometry: QGuiApplicationPrivate::reportGeometryChange( @@ -919,16 +919,20 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To } } -void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *) +void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) return; - //QGuiApplication::desktop()->d_func()->updateScreenList(); - // signal anything listening for creation or deletion of screens - //QDesktopWidget *desktop = QGuiApplication::desktop(); - //emit desktop->screenCountChanged(e->count); + if (!e->screen) + return; + + QScreen *s = e->screen.data(); + emit s->currentOrientationChanged(s->currentOrientation()); + + QScreenOrientationChangeEvent event(s, s->currentOrientation()); + QCoreApplication::sendEvent(QCoreApplication::instance(), &event); } void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index ccaf1292ae..20489afe10 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -114,7 +114,7 @@ public: static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e); - static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e); + static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e); static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e); diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp index 86dc0bd588..3fdb809137 100644 --- a/src/gui/kernel/qplatformscreen_qpa.cpp +++ b/src/gui/kernel/qplatformscreen_qpa.cpp @@ -164,6 +164,39 @@ QDpi QPlatformScreen::logicalDpi() const 25.4 * s.height() / ps.height()); } +/*! + Reimplement this function in subclass to return the primary orientation + of the screen, i.e. the orientation the display controller or equivalent + expects. + + The default implementation returns Qt::PortraitOrientation if the + geometry's height is greater or Qt::LandscapeOrientation if the geometry's + width is greater. +*/ +Qt::ScreenOrientation QPlatformScreen::primaryOrientation() const +{ + return geometry().height() > geometry().width() ? Qt::PortraitOrientation : + Qt::LandscapeOrientation; +} + +/*! + Reimplement this function in subclass to return the current orientation + of the screen, for example based on accelerometer data to determine + the physical screen orientation. + + The current orientation is only a hint to the application saying + what the preferred application orientation should be, the application + is free to limit itself to a certain set of supported orientations. + + The default implementation returns the same as primaryOrientation(). + + \sa primaryOrientation() +*/ +Qt::ScreenOrientation QPlatformScreen::currentOrientation() const +{ + return primaryOrientation(); +} + QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window) { return window->screen()->handle(); diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h index 6917d5eca5..64115a6cd5 100644 --- a/src/gui/kernel/qplatformscreen_qpa.h +++ b/src/gui/kernel/qplatformscreen_qpa.h @@ -99,6 +99,9 @@ public: virtual QSizeF physicalSize() const; virtual QDpi logicalDpi() const; + virtual Qt::ScreenOrientation currentOrientation() const; + virtual Qt::ScreenOrientation primaryOrientation() const; + virtual QWindow *topLevelAt(const QPoint &point) const; virtual QList virtualSiblings() const; diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp index f736f1d923..b29112abef 100644 --- a/src/gui/kernel/qplatformwindow_qpa.cpp +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -231,6 +231,20 @@ void QPlatformWindow::requestActivateWindow() QWindowSystemInterface::handleWindowActivated(window()); } +/*! + Set the orientation of the platform window's contents. + + This is a hint to the window manager in case it needs to display + additional content like popups, dialogs, status bars, or similar + in relation to the window. + + \sa QWindow::setOrientation() +*/ +void QPlatformWindow::setOrientation(Qt::ScreenOrientation orientation) +{ + Q_UNUSED(orientation); +} + bool QPlatformWindow::setKeyboardGrabEnabled(bool grab) { Q_UNUSED(grab); diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h index ffc3b75c1b..c6b5bb80ea 100644 --- a/src/gui/kernel/qplatformwindow_qpa.h +++ b/src/gui/kernel/qplatformwindow_qpa.h @@ -95,6 +95,8 @@ public: virtual void setOpacity(qreal level); virtual void requestActivateWindow(); + virtual void setOrientation(Qt::ScreenOrientation orientation); + virtual bool setKeyboardGrabEnabled(bool grab); virtual bool setMouseGrabEnabled(bool grab); diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index c2049af1e5..1f0d2f9fe6 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -278,4 +278,122 @@ QRect QScreen::availableVirtualGeometry() const return result; } +/*! + Gets the primary screen orientation. + + The primary screen orientation is the orientation that corresponds + to an un-rotated screen buffer. When the current orientation is equal + to the primary orientation no rotation needs to be done by the + application. +*/ +Qt::ScreenOrientation QScreen::primaryOrientation() const +{ + Q_D(const QScreen); + return d->platformScreen->primaryOrientation(); +} + +/*! + Gets the current orientation of the screen. + + The current orientation is a hint to the application saying + what the preferred application orientation should be, based on the + current orientation of the physical display and / or other factors. + + \sa primaryOrientation() + \sa currentOrientationChanged() +*/ +Qt::ScreenOrientation QScreen::currentOrientation() const +{ + Q_D(const QScreen); + return d->platformScreen->currentOrientation(); +} + +/*! + Convenience function to compute the angle of rotation to get from + rotation \a a to rotation \a b. + + The result will be 0, 90, 180, or 270. +*/ +int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) +{ + if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b) + return 0; + + int delta = int(b) - int(a); + + if (delta < 0) + delta = delta + 4; + + int angles[] = { 0, 90, 180, 270 }; + return angles[delta]; +} + +/*! + Convenience function to compute a transform that maps from the coordinate system + defined by orientation \a a into the coordinate system defined by orientation + \a b and target dimensions \a target. + + Example, \a a is Qt::Landscape, \a b is Qt::Portrait, and \a target is QRect(0, 0, w, h) + the resulting transform will be such that the point QPoint(0, 0) is mapped to QPoint(0, w), + and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w) + is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h). +*/ +QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) +{ + if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b) + return QTransform(); + + int angle = angleBetween(a, b); + + QTransform result; + switch (angle) { + case 90: + result.translate(target.width(), 0); + break; + case 180: + result.translate(target.width(), target.height()); + break; + case 270: + result.translate(0, target.height()); + break; + default: + Q_ASSERT(false); + } + result.rotate(angle); + + return result; +} + +/*! + Maps the rect between two screen orientations. + + This will flip the x and y dimensions of the rectangle if orientation \a is + Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation \b is + Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa. +*/ +QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) +{ + if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b) + return rect; + + if ((a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation) + != (b == Qt::PortraitOrientation || b == Qt::InvertedPortraitOrientation)) + { + return QRect(rect.y(), rect.x(), rect.height(), rect.width()); + } + + return rect; +} + +/*! + \fn QScreen::currentOrientationChanged() + + This signal is emitted when the current orientation of the screen + changes. The current orientation is a hint to the application saying + what the preferred application orientation should be, based on the + current orientation of the physical display and / or other factors. + + \sa currentOrientation() +*/ + QT_END_NAMESPACE diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 72681eb6da..2d075cfc5e 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -48,6 +48,10 @@ #include #include +#include + +#include + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -93,10 +97,21 @@ public: QSize availableVirtualSize() const; QRect availableVirtualGeometry() const; + Qt::ScreenOrientation primaryOrientation() const; + Qt::ScreenOrientation currentOrientation() const; + + static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b); + static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target); + static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect); + +Q_SIGNALS: + void currentOrientationChanged(Qt::ScreenOrientation orientation); + private: QScreen(QPlatformScreen *screen); Q_DISABLE_COPY(QScreen) + friend class QGuiApplicationPrivate; friend class QPlatformScreen; }; diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b1c26a39f1..04098b44c8 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -349,6 +349,41 @@ bool QWindow::isActive() const } } +/*! + Returns the window's currently set orientation. + + The default value is Qt::UnknownOrientation. + + \sa setOrientation(), QScreen::currentOrientation() +*/ +Qt::ScreenOrientation QWindow::orientation() const +{ + Q_D(const QWindow); + return d->orientation; +} + +/*! + Set the orientation of the window's contents. + + This is a hint to the window manager in case it needs to display + additional content like popups, dialogs, status bars, or similar + in relation to the window. + + The recommended orientation is QScreen::currentOrientation() but + an application doesn't have to support all possible orientations, + and thus can opt to ignore the current screen orientation. + + \sa QScreen::currentOrientation() +*/ +void QWindow::setOrientation(Qt::ScreenOrientation orientation) +{ + Q_D(QWindow); + d->orientation = orientation; + if (d->platformWindow) { + d->platformWindow->setOrientation(orientation); + } +} + Qt::WindowState QWindow::windowState() const { Q_D(const QWindow); diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 499582e348..20cc823f2e 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -47,6 +47,8 @@ #include #include +#include + #include #include #include @@ -126,6 +128,9 @@ public: bool isActive() const; + Qt::ScreenOrientation orientation() const; + void setOrientation(Qt::ScreenOrientation orientation); + Qt::WindowState windowState() const; void setWindowState(Qt::WindowState state); diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 1ef8f59d33..ee91b61cf1 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -76,6 +76,7 @@ public: , windowState(Qt::WindowNoState) , resizeEventPending(true) , positionPolicy(WindowFrameExclusive) + , orientation(Qt::UnknownOrientation) , maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX) , modality(Qt::NonModal) , transientParent(0) @@ -110,6 +111,7 @@ public: Qt::WindowState windowState; bool resizeEventPending; PositionPolicy positionPolicy; + Qt::ScreenOrientation orientation; QSize minimumSize; QSize maximumSize; diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 1745c1bafa..41a21c67a9 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -249,24 +249,24 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEv QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } -void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex) +void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen) { - QWindowSystemInterfacePrivate::ScreenGeometryEvent *e = - new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screenIndex); + QWindowSystemInterfacePrivate::ScreenOrientationEvent *e = + new QWindowSystemInterfacePrivate::ScreenOrientationEvent(screen); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } -void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex) +void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen) { - QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e = - new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screenIndex); + QWindowSystemInterfacePrivate::ScreenGeometryEvent *e = + new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screen); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } -void QWindowSystemInterface::handleScreenCountChange(int count) +void QWindowSystemInterface::handleScreenAvailableGeometryChange(QScreen *screen) { - QWindowSystemInterfacePrivate::ScreenCountEvent *e = - new QWindowSystemInterfacePrivate::ScreenCountEvent(count); + QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e = + new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screen); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 0581899500..7102a0fe04 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -112,9 +113,9 @@ public: static Qt::DropAction handleDrop(QWindow *w, QMimeData *dropData, const QPoint &p); // Changes to the screen - static void handleScreenGeometryChange(int screenIndex); - static void handleScreenAvailableGeometryChange(int screenIndex); - static void handleScreenCountChange(int count); + static void handleScreenOrientationChange(QScreen *screen); + static void handleScreenGeometryChange(QScreen *screen); + static void handleScreenAvailableGeometryChange(QScreen *screen); // For event dispatcher implementations static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 121c997e8a..44746500aa 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -60,9 +60,9 @@ public: Wheel, Key, Touch, + ScreenOrientation, ScreenGeometry, ScreenAvailableGeometry, - ScreenCountChange, Map, Unmap, Expose @@ -194,25 +194,25 @@ public: }; - class ScreenCountEvent : public WindowSystemEvent { + class ScreenOrientationEvent : public WindowSystemEvent { public: - ScreenCountEvent (int count) - : WindowSystemEvent(ScreenCountChange) , count(count) { } - int count; + ScreenOrientationEvent(QScreen *s) + : WindowSystemEvent(ScreenOrientation), screen(s) { } + QWeakPointer screen; }; class ScreenGeometryEvent : public WindowSystemEvent { public: - ScreenGeometryEvent(int index) - : WindowSystemEvent(ScreenGeometry), index(index) { } - int index; + ScreenGeometryEvent(QScreen *s) + : WindowSystemEvent(ScreenGeometry), screen(s) { } + QWeakPointer screen; }; class ScreenAvailableGeometryEvent : public WindowSystemEvent { public: - ScreenAvailableGeometryEvent(int index) - : WindowSystemEvent(ScreenAvailableGeometry), index(index) { } - int index; + ScreenAvailableGeometryEvent(QScreen *s) + : WindowSystemEvent(ScreenAvailableGeometry), screen(s) { } + QWeakPointer screen; }; class MapEvent : public WindowSystemEvent { -- cgit v1.2.3