Move default implementation of update requests to QPlatformWindow
Change-Id: I4cbb8d2023068288e298ab21f5cd8bc258825c77 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
2d1ac61d95
commit
4d15f393a7
@ -1754,8 +1754,11 @@ int QGuiApplication::exec()
|
|||||||
*/
|
*/
|
||||||
bool QGuiApplication::notify(QObject *object, QEvent *event)
|
bool QGuiApplication::notify(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
if (object->isWindowType())
|
if (object->isWindowType()) {
|
||||||
QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event);
|
if (QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event))
|
||||||
|
return true; // Platform plugin ate the event
|
||||||
|
}
|
||||||
|
|
||||||
return QCoreApplication::notify(object, event);
|
return QCoreApplication::notify(object, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1777,18 +1780,18 @@ bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEvent
|
|||||||
return QCoreApplication::compressEvent(event, receiver, postedEvents);
|
return QCoreApplication::compressEvent(event, receiver, postedEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event)
|
bool QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event)
|
||||||
{
|
{
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return false;
|
||||||
QPlatformWindow *platformWindow = window->handle();
|
QPlatformWindow *platformWindow = window->handle();
|
||||||
if (!platformWindow)
|
if (!platformWindow)
|
||||||
return;
|
return false;
|
||||||
// spontaneous events come from the platform integration already, we don't need to send the events back
|
// spontaneous events come from the platform integration already, we don't need to send the events back
|
||||||
if (event->spontaneous())
|
if (event->spontaneous())
|
||||||
return;
|
return false;
|
||||||
// let the platform window do any handling it needs to as well
|
// let the platform window do any handling it needs to as well
|
||||||
platformWindow->windowEvent(event);
|
return platformWindow->windowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
|
bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
|
||||||
|
@ -173,7 +173,7 @@ public:
|
|||||||
|
|
||||||
static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
|
static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
|
||||||
|
|
||||||
static void sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
|
static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
|
||||||
|
|
||||||
static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
|
static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
|
||||||
{
|
{
|
||||||
|
@ -461,14 +461,26 @@ bool QPlatformWindow::setWindowModified(bool modified)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Reimplement this method to be able to do any platform specific event
|
Reimplement this method to be able to do any platform specific event
|
||||||
handling. All events for window() are passed to this function before being
|
handling. All non-synthetic events for window() are passed to this
|
||||||
sent to QWindow::event().
|
function before being sent to QWindow::event().
|
||||||
|
|
||||||
The default implementation is empty and does nothing with \a event.
|
Return true if the event should not be passed on to the QWindow.
|
||||||
|
|
||||||
|
Subclasses should always call the base class implementation.
|
||||||
*/
|
*/
|
||||||
void QPlatformWindow::windowEvent(QEvent *event)
|
bool QPlatformWindow::windowEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_D(QPlatformWindow);
|
||||||
|
|
||||||
|
if (event->type() == QEvent::Timer) {
|
||||||
|
if (static_cast<QTimerEvent *>(event)->timerId() == d->updateTimer.timerId()) {
|
||||||
|
d->updateTimer.stop();
|
||||||
|
deliverUpdateRequest();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -734,18 +746,16 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
|
|||||||
*/
|
*/
|
||||||
void QPlatformWindow::requestUpdate()
|
void QPlatformWindow::requestUpdate()
|
||||||
{
|
{
|
||||||
static int timeout = -1;
|
Q_D(QPlatformWindow);
|
||||||
if (timeout == -1) {
|
|
||||||
bool ok = false;
|
|
||||||
timeout = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME", &ok);
|
|
||||||
if (!ok)
|
|
||||||
timeout = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWindow *w = window();
|
static int updateInterval = []() {
|
||||||
QWindowPrivate *wp = qt_window_private(w);
|
bool ok = false;
|
||||||
Q_ASSERT(wp->updateTimer == 0);
|
int customUpdateInterval = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME", &ok);
|
||||||
wp->updateTimer = w->startTimer(timeout, Qt::PreciseTimer);
|
return ok ? customUpdateInterval : 5;
|
||||||
|
}();
|
||||||
|
|
||||||
|
Q_ASSERT(!d->updateTimer.isActive());
|
||||||
|
d->updateTimer.start(updateInterval, Qt::PreciseTimer, window());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
virtual bool setWindowModified(bool modified);
|
virtual bool setWindowModified(bool modified);
|
||||||
|
|
||||||
virtual void windowEvent(QEvent *event);
|
virtual bool windowEvent(QEvent *event);
|
||||||
|
|
||||||
virtual bool startSystemResize(const QPoint &pos, Qt::Corner corner);
|
virtual bool startSystemResize(const QPoint &pos, Qt::Corner corner);
|
||||||
virtual bool startSystemMove(const QPoint &pos);
|
virtual bool startSystemMove(const QPoint &pos);
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <QtGui/private/qtguiglobal_p.h>
|
#include <QtGui/private/qtguiglobal_p.h>
|
||||||
|
#include <QtCore/qbasictimer.h>
|
||||||
#include <QtCore/qrect.h>
|
#include <QtCore/qrect.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -60,6 +61,7 @@ class QPlatformWindowPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QRect rect;
|
QRect rect;
|
||||||
|
QBasicTimer updateTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -2328,19 +2328,6 @@ bool QWindow::event(QEvent *ev)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case QEvent::Timer: {
|
|
||||||
Q_D(QWindow);
|
|
||||||
if (static_cast<QTimerEvent *>(ev)->timerId() == d->updateTimer) {
|
|
||||||
killTimer(d->updateTimer);
|
|
||||||
d->updateTimer = 0;
|
|
||||||
if (d->platformWindow)
|
|
||||||
d->platformWindow->deliverUpdateRequest();
|
|
||||||
} else {
|
|
||||||
QObject::event(ev);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case QEvent::PlatformSurface: {
|
case QEvent::PlatformSurface: {
|
||||||
if ((static_cast<QPlatformSurfaceEvent *>(ev))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
|
if ((static_cast<QPlatformSurfaceEvent *>(ev))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
|
@ -97,7 +97,6 @@ public:
|
|||||||
, modality(Qt::NonModal)
|
, modality(Qt::NonModal)
|
||||||
, blockedByModalWindow(false)
|
, blockedByModalWindow(false)
|
||||||
, updateRequestPending(false)
|
, updateRequestPending(false)
|
||||||
, updateTimer(0)
|
|
||||||
, transientParent(0)
|
, transientParent(0)
|
||||||
, topLevelScreen(0)
|
, topLevelScreen(0)
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
@ -192,7 +191,6 @@ public:
|
|||||||
bool blockedByModalWindow;
|
bool blockedByModalWindow;
|
||||||
|
|
||||||
bool updateRequestPending;
|
bool updateRequestPending;
|
||||||
int updateTimer;
|
|
||||||
|
|
||||||
QPointer<QWindow> transientParent;
|
QPointer<QWindow> transientParent;
|
||||||
QPointer<QScreen> topLevelScreen;
|
QPointer<QScreen> topLevelScreen;
|
||||||
|
@ -2048,7 +2048,7 @@ void QWindowsWindow::setExStyle(unsigned s) const
|
|||||||
SetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE, s);
|
SetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowsWindow::windowEvent(QEvent *event)
|
bool QWindowsWindow::windowEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::WindowBlocked: // Blocked by another modal window.
|
case QEvent::WindowBlocked: // Blocked by another modal window.
|
||||||
@ -2064,6 +2064,8 @@ void QWindowsWindow::windowEvent(QEvent *event)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return QPlatformWindow::windowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowsWindow::propagateSizeHints()
|
void QWindowsWindow::propagateSizeHints()
|
||||||
|
@ -252,7 +252,7 @@ public:
|
|||||||
void raise() override { raise_sys(); }
|
void raise() override { raise_sys(); }
|
||||||
void lower() override { lower_sys(); }
|
void lower() override { lower_sys(); }
|
||||||
|
|
||||||
void windowEvent(QEvent *event) override;
|
bool windowEvent(QEvent *event) override;
|
||||||
|
|
||||||
void propagateSizeHints() override;
|
void propagateSizeHints() override;
|
||||||
static bool handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp);
|
static bool handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp);
|
||||||
|
@ -2587,7 +2587,7 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QXcbWindow::windowEvent(QEvent *event)
|
bool QXcbWindow::windowEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::FocusIn:
|
case QEvent::FocusIn:
|
||||||
@ -2613,7 +2613,7 @@ void QXcbWindow::windowEvent(QEvent *event)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QPlatformWindow::windowEvent(event);
|
return QPlatformWindow::windowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner)
|
bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner)
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
|
|
||||||
QSurfaceFormat format() const override;
|
QSurfaceFormat format() const override;
|
||||||
|
|
||||||
void windowEvent(QEvent *event) override;
|
bool windowEvent(QEvent *event) override;
|
||||||
|
|
||||||
bool startSystemResize(const QPoint &pos, Qt::Corner corner) override;
|
bool startSystemResize(const QPoint &pos, Qt::Corner corner) override;
|
||||||
bool startSystemMove(const QPoint &pos) override;
|
bool startSystemMove(const QPoint &pos) override;
|
||||||
|
@ -2952,8 +2952,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||||||
d->checkReceiverThread(receiver);
|
d->checkReceiverThread(receiver);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (receiver->isWindowType())
|
if (receiver->isWindowType()) {
|
||||||
QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(receiver), e);
|
if (QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(receiver), e))
|
||||||
|
return true; // Platform plugin ate the event
|
||||||
|
}
|
||||||
|
|
||||||
if(e->spontaneous()) {
|
if(e->spontaneous()) {
|
||||||
// Capture the current mouse and keyboard states. Doing so here is
|
// Capture the current mouse and keyboard states. Doing so here is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user