Commit c5870e66 authored by Nikolay Nizov's avatar Nikolay Nizov

Add screen rotation support

Raster windows are rotated by painter's rotation transform in compositor,
Quick (OpenGL) windows by custom RenderStage.
On TouchPad, the plugin tries to synchonize moment of screen rotation
with webOS UI rotation effect by disabling swapping buffers until
it gets proper SDL active event.
parent 34f811b0
......@@ -11,6 +11,7 @@ SOURCES += $$PWD/qweboswindow.cpp \
$$PWD/qwebosopenglcompositorbackingstore.cpp \
$$PWD/qweboswindowframe.cpp \
$$PWD/qwebosclipboard.cpp \
$$PWD/qwebosquickrenderstage.cpp \
$$PWD/qwebosservices.cpp
HEADERS += $$PWD/qweboswindow_p.h \
......@@ -26,6 +27,7 @@ HEADERS += $$PWD/qweboswindow_p.h \
$$PWD/qwebosopenglcompositorbackingstore_p.h \
$$PWD/qweboswindowframe_p.h \
$$PWD/qwebosclipboard_p.h \
$$PWD/qwebosquickrenderstage_p.h \
$$PWD/qwebosservices_p.h
INCLUDEPATH += $$PWD
......@@ -74,12 +74,22 @@ bool QWebOSGLContext::makeCurrent(QPlatformSurface *)
void QWebOSGLContext::doneCurrent()
{
m_integration->resumeSDLEvents();
}
void QWebOSGLContext::swapBuffers(QPlatformSurface *)
{
SDL_GL_SwapBuffers();
m_integration->resumeSDLEvents();
static QWebOSScreen *wScreen = static_cast<QWebOSScreen*>(QGuiApplication::primaryScreen()->handle());
if (wScreen->swapAllowed())
SDL_GL_SwapBuffers();
else {
glFinish();
}
wScreen->rotateIfNeeded();
doneCurrent();
}
void (*QWebOSGLContext::getProcAddress(const char *procName)) ()
......
......@@ -46,6 +46,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOffscreenSurface>
#include <QtGui/QWindow>
#include <QQuickWindow>
#include <QtCore/QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatforminputcontextfactory_p.h>
......@@ -61,6 +62,8 @@
#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
#include "qwebosopenglcompositorbackingstore_p.h"
#include <QtQuick/private/qsgrenderloop_p.h>
#include <SDL.h>
#include <PDL.h>
......@@ -102,27 +105,63 @@ void QWebOSIntegration::initialize()
if (!qEnvironmentVariableIsEmpty("QT_QPA_WEBOS_SCREEN_TIMEOUT_ENABLED"))
PDL_ScreenTimeoutEnable(PDL_TRUE);
addScreen(new QWebOSScreen(), true);
int sdlDelay = 100;
sdlDelay = qEnvironmentVariableIntValue("QT_QPA_WEBOS_EVENT_DELAY");
if (sdlDelay < 10)
sdlDelay = 10;
addScreen(new QWebOSScreen(this), true);
bool ok;
m_sdlDelay = qEnvironmentVariableIntValue("QT_QPA_WEBOS_EVENT_DELAY", &ok);
if (!ok)
m_sdlDelay = 100;
else
if (m_sdlDelay < 10)
m_sdlDelay = 10;
m_sdlDelayMinimized = qEnvironmentVariableIntValue("QT_QPA_WEBOS_EVENT_DELAY_MINIMIZED", &ok);
if (!ok)
m_sdlDelayMinimized = 1000;
else
if (m_sdlDelayMinimized < 10)
m_sdlDelayMinimized = 10;
m_sdlEventsPaused = false;
m_sdlEventsNeedUpdate = false;
m_sdlEventsTimer = new QTimer(this);
m_sdlEventsTimer->setInterval(sdlDelay);
m_sdlEventsTimer->setInterval(m_sdlDelay);
connect(m_sdlEventsTimer, &QTimer::timeout, this, &QWebOSIntegration::processSDLEvents);
connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QWebOSIntegration::onApplicationStateChanged);
m_sdlEventsTimer->start();
m_inputContext = new QWebOSInputContext(this);
m_screenEventThread = new QWebOSScreenEventThread(m_screenEventHandler, sdlDelay);
if (!qEnvironmentVariableIsEmpty("QT_IM_MODULE")) {
m_inputContext = QPlatformInputContextFactory::create();
} else {
m_inputContext = new QWebOSInputContext(this);
}
m_screenEventThread = new QWebOSScreenEventThread(m_screenEventHandler, m_sdlDelay, m_sdlDelayMinimized);
m_screenEventThread->start();
}
void QWebOSIntegration::onApplicationStateChanged(Qt::ApplicationState state)
{
m_sdlEventsTimer->setInterval((state == Qt::ApplicationInactive)? m_sdlDelayMinimized: m_sdlDelay);
requestUpdate();
}
void QWebOSIntegration::requestUpdate()
{
QWindowList wl = QGuiApplication::topLevelWindows();
foreach (QWindow *w, wl) {
QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(w);
if (quickWindow)
QSGRenderLoop::instance()->update(quickWindow);
else
w->requestUpdate();
}
}
void QWebOSIntegration::pauseSDLEvents()
{
m_sdlEventsPaused = true;
SDL_PumpEvents();
}
void QWebOSIntegration::resumeSDLEvents()
......@@ -131,7 +170,6 @@ void QWebOSIntegration::resumeSDLEvents()
if (m_sdlEventsNeedUpdate)
processSDLEvents();
m_sdlEventsNeedUpdate = false;
m_sdlEventsTimer->start();
}
void QWebOSIntegration::processSDLEvents()
......@@ -139,7 +177,7 @@ void QWebOSIntegration::processSDLEvents()
if (!m_sdlEventsPaused)
SDL_PumpEvents();
else
m_sdlEventsNeedUpdate = false;
m_sdlEventsNeedUpdate = true;
}
void QWebOSIntegration::destroy()
......
......@@ -105,9 +105,11 @@ public:
void pauseSDLEvents();
void resumeSDLEvents();
void requestUpdate();
private:
void processSDLEvents();
void onApplicationStateChanged(Qt::ApplicationState state);
QPlatformInputContext *m_inputContext;
QWebOSScreenEventHandler *m_screenEventHandler;
......@@ -119,6 +121,8 @@ private:
QTimer *m_sdlEventsTimer;
bool m_sdlEventsPaused;
bool m_sdlEventsNeedUpdate;
int m_sdlDelay;
int m_sdlDelayMinimized;
};
QT_END_NAMESPACE
......
......@@ -45,6 +45,9 @@
#include "qwebosopenglcompositor_p.h"
#include <QOpenGLPaintDevice>
#include <QtGui/QScreen>
#include <QGuiApplication>
QT_BEGIN_NAMESPACE
/*!
......@@ -148,8 +151,14 @@ void QOpenGLCompositor::renderAll(QOpenGLFramebufferObject *fbo)
for (int i = 0; i < m_windows.size(); ++i) {
QScreen *pS = QGuiApplication::primaryScreen();
QTransform orientationTransform = pS->transformBetween(pS->nativeOrientation(), pS->orientation(), pS->geometry()).inverted();
painter.setWorldTransform(orientationTransform);
m_windows.at(i)->drawFrame(painter);
painter.resetTransform();
painter.beginNativePainting();
m_blitter.bind();
......
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwebosquickrenderstage_p.h"
QT_BEGIN_NAMESPACE
bool QWebOSQuickRenderStage::render()
{
// based on https://github.com/qt/qtdeclarative/blob/5.9/src/quick/items/qquickwindow.cpp#L451
if ((!qp) || (!qweb)) return true;
QQuickWindow *q = qp->q_func();
if (!q) return true;
QWebOSScreen *screen = qweb->screen();
if (!screen) return true;
int fboId = 0;
const qreal devicePixelRatio = q->effectiveDevicePixelRatio();
QSize size = q->geometry().size();
int rotation = screen->angleBetween(screen->nativeOrientation(), screen->orientation());
QMatrix4x4 rotationMatrix;
rotationMatrix.setToIdentity();
rotationMatrix.rotate(rotation, 0, 0, 1);
if (qp->renderTargetId) {
QRect rect(QPoint(0, 0), qp->renderTargetSize);
fboId = qp->renderTargetId;
qp->renderer->setDeviceRect(rect);
qp->renderer->setViewportRect(rect);
if (QQuickRenderControl::renderWindowFor(q)) {
qp->renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
qp->renderer->setDevicePixelRatio(devicePixelRatio);
} else {
qp->renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()));
qp->renderer->setDevicePixelRatio(1);
}
}
else {
QRect rect = screen->geometry();
if ((rotation == 90) || (rotation == 270))
rect = rect.transposed();
qp->renderer->setDeviceRect(rect);
qp->renderer->setViewportRect(rect);
qp->renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
qp->renderer->setDevicePixelRatio(devicePixelRatio);
QMatrix4x4 target = qp->renderer->projectionMatrix();
target = rotationMatrix * target;
qp->renderer->setProjectionMatrix(target);
}
qp->context->renderNextFrame(qp->renderer, fboId);
return true;
}
bool QWebOSQuickRenderStage::swap()
{
return false;
}
QT_END_NAMESPACE
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWEBOSQUICKRENDERSTAGE_H
#define QWEBOSQUICKRENDERSTAGE_H
#include <private/qquickwindow_p.h>
#include <QtQuick/private/qsgrenderer_p.h>
#include <private/qquickrendercontrol_p.h>
#include "qweboswindow_p.h"
QT_BEGIN_NAMESPACE
class QWebOSQuickRenderStage: public QQuickCustomRenderStage
{
public:
QWebOSQuickRenderStage(QQuickWindowPrivate *win, QWebOSWindow *web): qp(win),qweb(web) {};
~QWebOSQuickRenderStage() {};
bool render();
bool swap();
private:
QQuickWindowPrivate *qp;
QWebOSWindow *qweb;
};
QT_END_NAMESPACE
#endif // QWEBOSQUICKRENDERSTAGE_H
......@@ -42,47 +42,152 @@
#include <qpa/qwindowsysteminterface.h>
#include "qwebosopenglcompositor_p.h"
#include <private/qmath_p.h>
#include "qwebosintegration_p.h"
#include "qwebosscreen_p.h"
#include "qweboswindow_p.h"
#include <QGuiApplication>
#include <QtSensors/QOrientationSensor>
#include <SDL.h>
QT_BEGIN_NAMESPACE
QWebOSScreen::QWebOSScreen()
: m_surface(NULL)
QWebOSScreen::QWebOSScreen(QWebOSIntegration *integration)
: m_rotateInProgress(false)
, m_surface(NULL)
, m_webosIntegration(integration)
, m_orientationSensor(new QOrientationSensor(this))
, m_screenOrientation(nativeOrientation())
, m_locked(false)
, m_lockOrientation(QOrientationReading::TopUp)
, m_needRotate(false)
, m_needRotateOrient(PDL_ORIENTATION_0)
, m_geometry(rawGeometry())
{
if (!qEnvironmentVariableIsEmpty("QT_QPA_WEBOS_AUTOROTATE")) {
connect(m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(orientationReadingChanged()));
QTimer::singleShot(0, this, SLOT(onStarted()));
}
else {
QRect r = rawGeometry();
static int rotation = qEnvironmentVariableIntValue("QT_QPA_WEBOS_ROTATION");
switch (rotation) {
case 0:
case 180:
case -180:
break;
case 90:
case -90: {
int h = r.height();
r.setHeight(r.width());
r.setWidth(h);
break;
}
default:
qWarning("Invalid rotation %d specified in QT_QPA_WEBOS_ROTATION", rotation);
break;
}
m_geometry = r;
}
}
QWebOSScreen::~QWebOSScreen()
{
PDL_UnregisterServiceCallback(QWebOSScreen::cb);
if (m_orientationSensor) {
m_orientationSensor->stop();
delete m_orientationSensor;
m_orientationSensor = NULL;
}
QOpenGLCompositor::destroy();
}
QRect QWebOSScreen::geometry() const
bool QWebOSScreen::swapAllowed() const
{
QRect r = rawGeometry();
// An attempt to synchronize webOS screen rotation graphical effect on TP
// with actual screen update by qt plugin
static QSize screenSize = rawGeometry().size();
static bool isTouchpad = (screenSize.width() > screenSize.height());
if (isTouchpad)
return ((!m_rotateInProgress) || (QGuiApplication::applicationState() == Qt::ApplicationInactive));
else
return true;
}
static int rotation = qEnvironmentVariableIntValue("QT_QPA_WEBOS_ROTATION");
switch (rotation) {
void QWebOSScreen::rotateIfNeeded()
{
if (m_needRotate)
PDL_SetOrientation(m_needRotateOrient);
m_needRotate = false;
}
void QWebOSScreen::startSensor()
{
if (!m_orientationSensor) return;
m_orientationSensor->start();
orientationReadingChanged();
}
void QWebOSScreen::stopSensor()
{
if (!m_orientationSensor) return;
m_orientationSensor->stop();
}
PDL_bool QWebOSScreen::cb(PDL_ServiceParameters *parms, void *user)
{
QWebOSScreen *s = static_cast<QWebOSScreen*>(user);
if (PDL_TRUE != PDL_ParamExists(parms, "rotationLock")) return PDL_TRUE;
int rotationLock = PDL_GetParamInt(parms, "rotationLock");
switch (rotationLock) {
case 0:
case 180:
case -180:
s->m_locked = false;
break;
case 90:
case -90: {
int h = r.height();
r.setHeight(r.width());
r.setWidth(h);
case 3:
s->m_lockOrientation = QOrientationReading::TopUp;
s->m_locked = true;
break;
}
default:
qWarning("Invalid rotation %d specified in QT_QPA_WEBOS_ROTATION", rotation);
case 4:
s->m_lockOrientation = QOrientationReading::TopDown;
s->m_locked = true;
break;
case 5:
s->m_lockOrientation = QOrientationReading::RightUp;
s->m_locked = true;
break;
case 6:
s->m_lockOrientation = QOrientationReading::LeftUp;
s->m_locked = true;
break;
}
return r;
if (s->m_locked) {
QTimer::singleShot(0, s, SLOT(stopSensor()));
s->updateOrientation(s->m_lockOrientation);
}
else {
QTimer::singleShot(0, s, SLOT(startSensor()));
}
return PDL_TRUE;
}
void QWebOSScreen::onStarted()
{
m_orientationSensor->start();
PDL_ServiceCallWithCallback("palm://com.palm.systemservice/getPreferences", "{\"subscribe\":true, \"keys\": [ \"rotationLock\" ]}", QWebOSScreen::cb, this, PDL_FALSE);
QGuiApplication::primaryScreen()->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation | Qt::InvertedLandscapeOrientation | Qt::InvertedPortraitOrientation);
}
QRect QWebOSScreen::geometry() const
{
return m_geometry;
}
QRect QWebOSScreen::rawGeometry() const
......@@ -171,12 +276,12 @@ qreal QWebOSScreen::pixelDensity() const
Qt::ScreenOrientation QWebOSScreen::nativeOrientation() const
{
return Qt::PrimaryOrientation;
return (rawGeometry().height() > rawGeometry().width())? Qt::PortraitOrientation: Qt::LandscapeOrientation;
}
Qt::ScreenOrientation QWebOSScreen::orientation() const
{
return Qt::PrimaryOrientation;
return m_screenOrientation;
}
qreal QWebOSScreen::refreshRate() const
......@@ -236,4 +341,54 @@ QPixmap QWebOSScreen::grabWindow(WId wid, int x, int y, int width, int height) c
return QPixmap();
}
void QWebOSScreen::orientationReadingChanged()
{
if (m_locked) return;
updateOrientation(m_orientationSensor->reading()->orientation());
}
void QWebOSScreen::updateOrientation(QOrientationReading::Orientation currentOrientation)
{
QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
switch (currentOrientation) {
case QOrientationReading::TopUp: /* 0° */
m_screenOrientation = nativeOrientation();
m_geometry = rawGeometry();
compositor->setRotation(0);
m_needRotateOrient = PDL_ORIENTATION_0;
break;
case QOrientationReading::LeftUp: /* 90° clockwise */
m_screenOrientation = nativeOrientation() == Qt::PortraitOrientation ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation;
m_geometry = rawGeometry().transposed();
compositor->setRotation(90);
m_needRotateOrient = PDL_ORIENTATION_90;
break;
case QOrientationReading::TopDown: /* 180° */
m_screenOrientation = nativeOrientation() == Qt::PortraitOrientation ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation;
m_geometry = rawGeometry();
compositor->setRotation(180);
m_needRotateOrient = PDL_ORIENTATION_180;
break;
case QOrientationReading::RightUp: /* 270° clockwise */
m_screenOrientation = nativeOrientation() == Qt::PortraitOrientation ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation;
m_geometry = rawGeometry().transposed();
compositor->setRotation(270);
m_needRotateOrient = PDL_ORIENTATION_270;
break;
default:
break;
}
if (m_screenOrientation == QPlatformScreen::screen()->orientation()) return;
QWindowSystemInterface::handleScreenOrientationChange(QPlatformScreen::screen(), m_screenOrientation);
m_rotateInProgress = true;
if (geometry() != screen()->geometry()) {
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), geometry());
resizeMaximizedWindows();
}
m_webosIntegration->requestUpdate();
m_needRotate = true;
}
QT_END_NAMESPACE
......@@ -53,18 +53,25 @@
#include "qwebosglobal_p.h"
#include <QtCore/QPointer>
#include <PDL.h>
#include <qpa/qplatformscreen.h>
#include <QtSensors/QOrientationReading>
QT_BEGIN_NAMESPACE
class QWebOSWindow;
class QOpenGLContext;
class QOrientationSensor;
class QWebOSIntegration;
class Q_WEBOS_EXPORT QWebOSScreen : public QPlatformScreen
class Q_WEBOS_EXPORT QWebOSScreen : public QObject, public QPlatformScreen
{
Q_OBJECT
public:
QWebOSScreen();
QWebOSScreen(QWebOSIntegration *integration);
~QWebOSScreen();
QRect geometry() const override;
......@@ -83,14 +90,34 @@ public:
QPixmap grabWindow(WId wid, int x, int y, int width, int height) const override;
void *primarySurface() const { return m_surface; }
bool m_rotateInProgress;
bool swapAllowed() const;
void rotateIfNeeded();
private:
void setPrimarySurface(void *surface);
void updateOrientation(QOrientationReading::Orientation currentOrientation);
QPointer<QWindow> m_pointerWindow;
void *m_surface;
friend class QWebOSWindow;
QWebOSIntegration *m_webosIntegration;
QOrientationSensor *m_orientationSensor;
Qt::ScreenOrientation m_screenOrientation;
bool m_locked;
QOrientationReading::Orientation m_lockOrientation;
bool m_needRotate;
PDL_Orientation m_needRotateOrient;
QRect m_geometry;
private Q_SLOTS:
void startSensor();
void stopSensor();
void orientationReadingChanged();
void onStarted();
static PDL_bool cb(PDL_ServiceParameters *parms, void *user);
};
QT_END_NAMESPACE
......
......@@ -229,6 +229,10 @@ void QWebOSScreenEventHandler::handleTouchEvent(SDL_Event event)
break;
}
QScreen *pS = QGuiApplication::primaryScreen();
QTransform lOrientationTransform = pS->transformBetween(pS->nativeOrientation(), pS->orientation(), pS->geometry());
pos = lOrientationTransform.map(pos);
// check if finger is valid
if (touchId < MaximumTouchPoints) {
......@@ -293,15 +297,21 @@ void QWebOSScreenEventHandler::handleTouchEvent(SDL_Event event)
void QWebOSScreenEventHandler::handleActiveEvent(SDL_Event event)
{
if (event.active.state == SDL_APPACTIVE) {
Qt::ApplicationState newState = (event.active.gain)? Qt::ApplicationActive : Qt::ApplicationInactive;
QWindowSystemInterface::handleApplicationStateChanged(newState);
if (event.active.state != SDL_APPACTIVE) return;
Qt::ApplicationState newState = (event.active.gain)? Qt::ApplicationActive : Qt::ApplicationInactive;
QWindowList wl = QGuiApplication::topLevelWindows();
foreach (QWindow *w, wl) {
w->requestUpdate();
}
if (newState == QGuiApplication::applicationState()) return;
static QWebOSScreen *wScreen = static_cast<QWebOSScreen*>(QGuiApplication::primaryScreen()->handle());
if (newState == Qt::ApplicationActive)
wScreen->m_rotateInProgress = false;
if ((newState == Qt::ApplicationInactive) && (wScreen->m_rotateInProgress)) {
wScreen->m_rotateInProgress = false;
m_webosIntegration->requestUpdate();
return;
}
QWindowSystemInterface::handleApplicationStateChanged(newState);
}
int QWebOSScreenEventHandler::handleSpecialKeys(SDLKey key, int def)
......
......@@ -54,10 +54,11 @@
#define qScreenEventThreadDebug QT_NO_QDEBUG_MACRO
#endif
QWebOSScreenEventThread::QWebOSScreenEventThread(QWebOSScreenEventHandler *screenEventHandler, int sdlDelay)
QWebOSScreenEventThread::QWebOSScreenEventThread(QWebOSScreenEventHandler *screenEventHandler, int sdlDelay, int sdlDelayMinimized)
: QThread(),
m_screenEventHandler(screenEventHandler),
m_sdlDelay(sdlDelay),
m_sdlDelayMinimized(sdlDelayMinimized),
m_quit(false)
{
screenEventHandler->setScreenEventThread(this);
......@@ -91,7 +92,7 @@ void QWebOSScreenEventThread::run()
// loop indefinitely
while (!m_quit) {
SDL_Delay(m_sdlDelay);
SDL_Delay((QGuiApplication::applicationState() == Qt::ApplicationInactive)? m_sdlDelayMinimized: m_sdlDelay);
while ( (!m_quit) && ((num = SDL_PeepEvents(sdl_events, 16, SDL_GETEVENT, SDL_ALLEVENTS)) > 0) ) {
for (int i = 0; i < num; i++) {
if (sdl_events[i].type ==