summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-02-21 14:58:57 +0100
committerJoão Abecasis <joao.abecasis@nokia.com>2012-02-21 14:58:57 +0100
commit31a0358afb4fde998d1eeeaa80fc32e4420266c7 (patch)
tree938455353474196c1f49b0529b5b644e19c21f3e /src/gui/kernel
parent4c8a4058c359c8d163c643120426079fc80c8214 (diff)
parent69da8588d41bbf5ab785f5ad7c1fce76deefc7d0 (diff)
Merge remote-tracking branch 'gerrit/master' into containers
Conflicts: src/corelib/tools/qbytearray.h Change-Id: I03b1f3e05c9b7a45130887c522fcd9b7aa387129
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qclipboard_qpa.cpp1
-rw-r--r--src/gui/kernel/qdnd.cpp1
-rw-r--r--src/gui/kernel/qevent.cpp12
-rw-r--r--src/gui/kernel/qguiapplication.cpp116
-rw-r--r--src/gui/kernel/qguiapplication.h4
-rw-r--r--src/gui/kernel/qguiapplication_p.h17
-rw-r--r--src/gui/kernel/qinputmethod_p.h1
-rw-r--r--src/gui/kernel/qopenglcontext.cpp3
-rw-r--r--src/gui/kernel/qopenglcontext_p.h3
-rw-r--r--src/gui/kernel/qpalette.cpp62
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp7
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h5
-rw-r--r--src/gui/kernel/qplatformintegrationplugin_qpa.h2
-rw-r--r--src/gui/kernel/qplatformopenglcontext_qpa.h3
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformservices_qpa.cpp74
-rw-r--r--src/gui/kernel/qplatformservices_qpa.h65
-rw-r--r--src/gui/kernel/qplatformtheme_qpa.cpp36
-rw-r--r--src/gui/kernel/qplatformtheme_qpa.h19
-rw-r--r--src/gui/kernel/qplatformthemeplugin_qpa.h2
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp19
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h2
-rw-r--r--src/gui/kernel/qscreen.cpp48
-rw-r--r--src/gui/kernel/qscreen.h3
-rw-r--r--src/gui/kernel/qwindow.cpp94
-rw-r--r--src/gui/kernel/qwindow.h8
-rw-r--r--src/gui/kernel/qwindowdefs.h3
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp22
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h8
31 files changed, 574 insertions, 78 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 7b01ba14cd..9c5f3b10da 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -55,7 +55,8 @@ HEADERS += \
kernel/qtouchdevice.h \
kernel/qtouchdevice_p.h \
kernel/qplatformsharedgraphicscache_qpa.h \
- kernel/qplatformdialoghelper_qpa.h
+ kernel/qplatformdialoghelper_qpa.h \
+ kernel/qplatformservices_qpa.h
SOURCES += \
kernel/qclipboard_qpa.cpp \
@@ -97,7 +98,8 @@ SOURCES += \
kernel/qstylehints.cpp \
kernel/qtouchdevice.cpp \
kernel/qplatformsharedgraphicscache_qpa.cpp \
- kernel/qplatformdialoghelper_qpa.cpp
+ kernel/qplatformdialoghelper_qpa.cpp \
+ kernel/qplatformservices_qpa.cpp
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, egl) {
HEADERS += \
diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp
index ec940385b8..b33ccd42a2 100644
--- a/src/gui/kernel/qclipboard_qpa.cpp
+++ b/src/gui/kernel/qclipboard_qpa.cpp
@@ -46,6 +46,7 @@
#include "qmimedata.h"
#include "private/qguiapplication_p.h"
#include "qplatformclipboard_qpa.h"
+#include "qplatformintegration_qpa.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index b9f0fe4f5b..2fb250cf18 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -59,6 +59,7 @@
#include "qimagewriter.h"
#include "qdebug.h"
#include <ctype.h>
+#include <qplatformintegration_qpa.h>
#include <qplatformdrag_qpa.h>
#include <private/qguiapplication_p.h>
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 543f5453ff..c3a6be692b 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3305,15 +3305,21 @@ QWindowStateChangeEvent::~QWindowStateChangeEvent()
\section1 Event Handling
- All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd.
- Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and
- QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
+ All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd or
+ QEvent::TouchCancel. Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for
+ widgets and QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
filtered by an event filter, then no further touch events are sent until the next
QEvent::TouchBegin.
+ Some systems may send an event of type QEvent::TouchCancel. Upon receiving this event
+ applications are requested to ignore the entire active touch sequence. For example in a
+ composited system the compositor may decide to treat certain gestures as system-wide
+ gestures. Whenever such a decision is made (the gesture is recognized), the clients will be
+ notified with a QEvent::TouchCancel event so they can update their state accordingly.
+
The touchPoints() function returns a list of all touch points contained in the event.
Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class.
The Qt::TouchPointState enum describes the different states that a touch point may have.
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index b1cbb5fcae..7cb3d4b488 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -48,6 +48,8 @@
#include "qplatformfontdatabase_qpa.h"
#include "qplatformwindow_qpa.h"
#include "qplatformnativeinterface_qpa.h"
+#include "qplatformtheme_qpa.h"
+#include "qplatformintegration_qpa.h"
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/private/qcoreapplication_p.h>
@@ -126,6 +128,7 @@ QWindow *QGuiApplicationPrivate::focus_window = 0;
static QBasicMutex applicationFontMutex;
QFont *QGuiApplicationPrivate::app_font = 0;
+bool QGuiApplicationPrivate::obey_desktop_settings = true;
extern void qRegisterGuiVariant();
extern void qUnregisterGuiVariant();
@@ -184,7 +187,8 @@ QGuiApplication::~QGuiApplication()
QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
: QCoreApplicationPrivate(argc, argv, flags),
styleHints(0),
- inputMethod(0)
+ inputMethod(0),
+ lastTouchType(QEvent::TouchEnd)
{
self = this;
application_type = QCoreApplication::GuiClient;
@@ -502,6 +506,8 @@ void QGuiApplicationPrivate::init()
QWindowSystemInterface::sendWindowSystemEvents(QCoreApplicationPrivate::eventDispatcher, QEventLoop::AllEvents);
}
+extern void qt_cleanupFontDatabase();
+
QGuiApplicationPrivate::~QGuiApplicationPrivate()
{
is_app_closing = true;
@@ -526,6 +532,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
delete styleHints;
delete inputMethod;
+ qt_cleanupFontDatabase();
+
delete platform_integration;
platform_integration = 0;
}
@@ -655,6 +663,10 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
QGuiApplicationPrivate::reportLogicalDotsPerInchChange(
static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e));
break;
+ case QWindowSystemInterfacePrivate::ThemeChange:
+ QGuiApplicationPrivate::processThemeChanged(
+ static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e));
+ break;
case QWindowSystemInterfacePrivate::Map:
QGuiApplicationPrivate::processMapEvent(static_cast<QWindowSystemInterfacePrivate::MapEvent *>(e));
break;
@@ -882,6 +894,14 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa
}
}
+void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
+{
+ if (QWindow *window = tce->window.data()) {
+ QEvent e(QEvent::ThemeChange);
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+}
+
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
{
if (e->tlw.isNull())
@@ -946,8 +966,55 @@ Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey
void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
{
- QWindow *window = e->window.data();
QGuiApplicationPrivate *d = self;
+
+ if (e->touchType == QEvent::TouchCancel) {
+ // The touch sequence has been canceled (e.g. by the compositor).
+ // Send the TouchCancel to all windows with active touches and clean up.
+ QTouchEvent touchEvent(QEvent::TouchCancel, e->device, e->modifiers);
+ touchEvent.setTimestamp(e->timestamp);
+ QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it
+ = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd();
+ QSet<QWindow *> windowsNeedingCancel;
+ while (it != ite) {
+ QWindow *w = it->window.data();
+ if (w)
+ windowsNeedingCancel.insert(w);
+ ++it;
+ }
+ for (QSet<QWindow *>::const_iterator winIt = windowsNeedingCancel.constBegin(),
+ winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) {
+ touchEvent.setWindow(*winIt);
+ QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent);
+ }
+ if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) {
+ for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(),
+ synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) {
+ if (!synthIt->window)
+ continue;
+ QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(),
+ e->timestamp,
+ synthIt->pos,
+ synthIt->screenPos,
+ Qt::NoButton,
+ e->modifiers);
+ fake.synthetic = true;
+ processMouseEvent(&fake);
+ }
+ self->synthesizedMousePoints.clear();
+ }
+ self->activeTouchPoints.clear();
+ self->lastTouchType = e->touchType;
+ return;
+ }
+
+ // Prevent sending ill-formed event sequences: Cancel can only be followed by a Begin.
+ if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin)
+ return;
+
+ self->lastTouchType = e->touchType;
+
+ QWindow *window = e->window.data();
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents;
@@ -1097,6 +1164,8 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
// exclude touchpads as those generate their own mouse events
if (touchEvent.device()->type() != QTouchDevice::TouchPad) {
Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
+ if (b == Qt::NoButton)
+ self->synthesizedMousePoints.clear();
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints();
if (eventType == QEvent::TouchBegin)
@@ -1105,6 +1174,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
for (int i = 0; i < touchPoints.count(); ++i) {
const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i);
if (touchPoint.id() == m_fakeMouseSourcePointId) {
+ if (b != Qt::NoButton)
+ self->synthesizedMousePoints.insert(w, SynthesizedMouseData(
+ touchPoint.pos(), touchPoint.screenPos(), w));
QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp,
touchPoint.pos(),
touchPoint.screenPos(),
@@ -1313,6 +1385,9 @@ QClipboard * QGuiApplication::clipboard()
QPalette QGuiApplication::palette()
{
if (!QGuiApplicationPrivate::app_pal)
+ if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette())
+ QGuiApplicationPrivate::app_pal = new QPalette(*themePalette);
+ if (!QGuiApplicationPrivate::app_pal)
QGuiApplicationPrivate::app_pal = new QPalette(Qt::black);
return *QGuiApplicationPrivate::app_pal;
}
@@ -1407,6 +1482,17 @@ void QGuiApplicationPrivate::emitLastWindowClosed()
}
}
+bool QGuiApplicationPrivate::shouldQuit()
+{
+ /* if there is no visible top-level window left, we allow the quit */
+ QWindowList list = QGuiApplication::topLevelWindows();
+ for (int i = 0; i < list.size(); ++i) {
+ QWindow *w = list.at(i);
+ if (w->isVisible())
+ return false;
+ }
+ return true;
+}
/*!
\property QGuiApplication::layoutDirection
@@ -1562,6 +1648,32 @@ QStyleHints *QGuiApplication::styleHints() const
return d->styleHints;
}
+/*!
+ Sets whether Qt should use the system's standard colors, fonts, etc., to
+ \a on. By default, this is true.
+
+ This function must be called before creating the QGuiApplication object, like
+ this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 6
+
+ \sa desktopSettingsAware()
+*/
+void QGuiApplication::setDesktopSettingsAware(bool on)
+{
+ QGuiApplicationPrivate::obey_desktop_settings = on;
+}
+
+/*!
+ Returns true if Qt is set to use the system's standard colors, fonts, etc.;
+ otherwise returns false. The default is true.
+
+ \sa setDesktopSettingsAware()
+*/
+bool QGuiApplication::desktopSettingsAware()
+{
+ return QGuiApplicationPrivate::obey_desktop_settings;
+}
/*!
\since 5.0
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 75046d8767..c374a05986 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE
class QGuiApplicationPrivate;
class QPlatformNativeInterface;
+class QPlatformIntegration;
class QPalette;
class QScreen;
class QStyleHints;
@@ -121,6 +122,9 @@ public:
static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
QStyleHints *styleHints() const;
+ static void setDesktopSettingsAware(bool on);
+ static bool desktopSettingsAware();
+
QT_DEPRECATED QInputPanel *inputPanel() const;
QInputMethod *inputMethod() const;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index d9444ebe95..7e6e0aa8c7 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -51,14 +51,14 @@
#include <QWindowSystemInterface>
#include "private/qwindowsysteminterface_qpa_p.h"
-#include <QtGui/qplatformintegration_qpa.h>
-#include <QtGui/qplatformtheme_qpa.h>
#include "private/qshortcutmap_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+class QPlatformIntegration;
+class QPlatformTheme;
class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
{
@@ -74,6 +74,8 @@ public:
virtual void notifyLayoutDirectionChange();
virtual void notifyActiveWindowChange(QWindow *previous);
+ virtual bool shouldQuit();
+
static Qt::KeyboardModifiers modifier_buttons;
static Qt::MouseButtons mouse_buttons;
@@ -125,6 +127,7 @@ public:
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
+ static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);
@@ -181,6 +184,7 @@ public:
static QFont *app_font;
QStyleHints *styleHints;
+ static bool obey_desktop_settings;
QInputMethod *inputMethod;
static QList<QObject *> generic_plugin_list;
@@ -199,6 +203,15 @@ public:
QTouchEvent::TouchPoint touchPoint;
};
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue> activeTouchPoints;
+ QEvent::Type lastTouchType;
+ struct SynthesizedMouseData {
+ SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w)
+ : pos(p), screenPos(sp), window(w) { }
+ QPointF pos;
+ QPointF screenPos;
+ QWeakPointer<QWindow> window;
+ };
+ QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
private:
void init();
diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h
index 862764d1bc..8a17c85990 100644
--- a/src/gui/kernel/qinputmethod_p.h
+++ b/src/gui/kernel/qinputmethod_p.h
@@ -47,6 +47,7 @@
#include <QtCore/QWeakPointer>
#include <QTransform>
#include <qplatforminputcontext_qpa.h>
+#include <qplatformintegration_qpa.h>
#include <private/qguiapplication_p.h>
QT_BEGIN_HEADER
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 1b6d1d34c4..ba51653fcf 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qplatformopenglcontext_qpa.h"
+#include "qplatformintegration_qpa.h"
#include "qopenglcontext.h"
#include "qopenglcontext_p.h"
#include "qwindow.h"
@@ -289,7 +290,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
return false;
if (surface->surfaceType() != QSurface::OpenGLSurface) {
- qWarning() << "QOpenGLContext::makeBuffers() called with non-opengl surface";
+ qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface";
return false;
}
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 7b4e880ade..3e2c35f088 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -42,6 +42,8 @@
#ifndef QGUIGLCONTEXT_P_H
#define QGUIGLCONTEXT_P_H
+#ifndef QT_NO_OPENGL
+
#include "qopengl.h"
#include "qopenglcontext.h"
#include <private/qobject_p.h>
@@ -245,4 +247,5 @@ QT_END_NAMESPACE
QT_END_HEADER
+#endif // QT_NO_OPENGL
#endif // QGUIGLCONTEXT_P_H
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 627731ff20..d5b17fa665 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -41,6 +41,7 @@
#include "qpalette.h"
#include "qguiapplication.h"
+#include "qguiapplication_p.h"
#include "qdatastream.h"
#include "qvariant.h"
#include "qdebug.h"
@@ -64,6 +65,29 @@ static QColor qt_mix_colors(QColor a, QColor b)
(a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
}
+static void qt_palette_from_color(QPalette &pal, const QColor &button)
+{
+ int h, s, v;
+ button.getHsv(&h, &s, &v);
+ // inactive and active are the same..
+ const QBrush baseBrush = QBrush(v > 128 ? Qt::white : Qt::black);
+ const QBrush foregroundBrush = QBrush(v > 128 ? Qt::black : Qt::white);
+ const QBrush buttonBrush = QBrush(button);
+ const QBrush buttonBrushDark = QBrush(button.darker());
+ const QBrush buttonBrushDark150 = QBrush(button.darker(150));
+ const QBrush buttonBrushLight150 = QBrush(button.lighter(150));
+ const QBrush whiteBrush = QBrush(Qt::white);
+ pal.setColorGroup(QPalette::Active, foregroundBrush, buttonBrush, buttonBrushLight150,
+ buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
+ baseBrush, buttonBrush);
+ pal.setColorGroup(QPalette::Inactive, foregroundBrush, buttonBrush, buttonBrushLight150,
+ buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
+ baseBrush, buttonBrush);
+ pal.setColorGroup(QPalette::Disabled, buttonBrushDark, buttonBrush, buttonBrushLight150,
+ buttonBrushDark, buttonBrushDark150, buttonBrushDark,
+ whiteBrush, buttonBrush, buttonBrush);
+}
+
/*!
\fn const QColor &QPalette::color(ColorRole role) const
@@ -488,40 +512,20 @@ static QColor qt_mix_colors(QColor a, QColor b)
\sa QApplication::setPalette(), QApplication::palette()
*/
QPalette::QPalette()
- : d(QGuiApplication::palette().d),
- current_group(Active),
- resolve_mask(0)
-{
- d->ref.ref();
-}
-
-static void qt_palette_from_color(QPalette &pal, const QColor & button)
+ : d(0), current_group(Active), resolve_mask(0)
{
- QColor bg = button,
- btn = button,
- fg, base;
- int h, s, v;
- bg.getHsv(&h, &s, &v);
- if(v > 128) {
- fg = Qt::black;
- base = Qt::white;
+ // Initialize to application palette if present, else default to black.
+ // This makes it possible to instantiate QPalette outside QGuiApplication,
+ // for example in the platform plugins.
+ if (QGuiApplicationPrivate::app_pal) {
+ d = QGuiApplicationPrivate::app_pal->d;
+ d->ref.ref();
} else {
- fg = Qt::white;
- base = Qt::black;
+ init();
+ qt_palette_from_color(*this, Qt::black);
}
- //inactive and active are the same..
- pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
- QBrush(base), QBrush(bg));
- pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
- QBrush(base), QBrush(bg));
- pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()),
- QBrush(Qt::white), QBrush(bg), QBrush(bg));
}
-
/*!
Constructs a palette from the \a button color. The other colors are
automatically calculated, based on this color. \c Window will be
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index e867e4e588..7a3fe05f7a 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -107,6 +107,11 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
return 0;
}
+QPlatformServices *QPlatformIntegration::services() const
+{
+ return 0;
+}
+
/*!
\class QPlatformIntegration
\since 4.8
@@ -215,12 +220,14 @@ QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::Pix
return new QRasterPlatformPixmap(type);
}
+#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
Q_UNUSED(context);
qWarning("This plugin does not support createPlatformOpenGLContext!");
return 0;
}
+#endif
/*!
Factory function for QPlatformSharedGraphicsCache. This function will return 0 if the platform
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index efaf495b81..483964b8f3 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -66,6 +66,7 @@ class QPlatformAccessibility;
class QPlatformTheme;
class QPlatformDialogHelper;
class QPlatformSharedGraphicsCache;
+class QPlatformServices;
class Q_GUI_EXPORT QPlatformIntegration
{
@@ -86,7 +87,9 @@ public:
virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0;
+#ifndef QT_NO_OPENGL
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
+#endif
virtual QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const;
// Event dispatcher:
@@ -106,6 +109,8 @@ public:
// Access native handles. The window handle is already available from Wid;
virtual QPlatformNativeInterface *nativeInterface() const;
+ virtual QPlatformServices *services() const;
+
enum StyleHint {
CursorFlashTime,
KeyboardInputInterval,
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.h b/src/gui/kernel/qplatformintegrationplugin_qpa.h
index 84c2567bbd..d70569cbba 100644
--- a/src/gui/kernel/qplatformintegrationplugin_qpa.h
+++ b/src/gui/kernel/qplatformintegrationplugin_qpa.h
@@ -68,7 +68,7 @@ struct QPlatformIntegrationFactoryInterface : public QFactoryInterface
virtual QPlatformIntegration *create(const QString &key, const QStringList &paramList) = 0;
};
-#define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface"
+#define QPlatformIntegrationFactoryInterface_iid "org.qt-project.Qt.QPlatformIntegrationFactoryInterface"
Q_DECLARE_INTERFACE(QPlatformIntegrationFactoryInterface, QPlatformIntegrationFactoryInterface_iid)
diff --git a/src/gui/kernel/qplatformopenglcontext_qpa.h b/src/gui/kernel/qplatformopenglcontext_qpa.h
index 17d4e96f8e..af70368f5e 100644
--- a/src/gui/kernel/qplatformopenglcontext_qpa.h
+++ b/src/gui/kernel/qplatformopenglcontext_qpa.h
@@ -42,6 +42,8 @@
#ifndef QPLATFORMGLCONTEXT_H
#define QPLATFORMGLCONTEXT_H
+#ifndef QT_NO_OPENGL
+
#include <QtCore/qnamespace.h>
#include <QtGui/qsurfaceformat.h>
#include <QtGui/qwindow.h>
@@ -91,5 +93,6 @@ QT_END_NAMESPACE
QT_END_HEADER
+#endif // QT_NO_OPENGL
#endif // QPLATFORMGLCONTEXT_H
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
index b8f1430d1b..c832d853f4 100644
--- a/src/gui/kernel/qplatformscreen_qpa.cpp
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -93,7 +93,7 @@ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
QWindowList list = QGuiApplication::topLevelWindows();
for (int i = list.size()-1; i >= 0; --i) {
QWindow *w = list[i];
- if (w->visible() && w->geometry().contains(pos))
+ if (w->isVisible() && w->geometry().contains(pos))
return w;
}
diff --git a/src/gui/kernel/qplatformservices_qpa.cpp b/src/gui/kernel/qplatformservices_qpa.cpp
new file mode 100644
index 0000000000..7993a82f4e
--- /dev/null
+++ b/src/gui/kernel/qplatformservices_qpa.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformservices_qpa.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QString>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QPlatformServices
+ \since 5.0
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformServices provides the backend for desktop-related functionality.
+*/
+
+bool QPlatformServices::openUrl(const QUrl &url)
+{
+ qWarning("This plugin does not support QPlatformServices::openUrl() for '%s'.",
+ qPrintable(url.toString()));
+ return false;
+}
+
+bool QPlatformServices::openDocument(const QUrl &url)
+{
+ qWarning("This plugin does not support QPlatformServices::openDocument() for '%s'.",
+ qPrintable(url.toString()));
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformservices_qpa.h b/src/gui/kernel/qplatformservices_qpa.h
new file mode 100644
index 0000000000..aff2e5d6fe
--- /dev/null
+++ b/src/gui/kernel/qplatformservices_qpa.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMSERVICES_QPA_H
+#define QPLATFORMSERVICES_QPA_H
+
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QUrl;
+
+class Q_GUI_EXPORT QPlatformServices
+{
+public:
+ virtual ~QPlatformServices() { }
+
+ virtual bool openUrl(const QUrl &url);
+ virtual bool openDocument(const QUrl &url);
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QPLATFORMSERVICES_QPA_H
diff --git a/src/gui/kernel/qplatformtheme_qpa.cpp b/src/gui/kernel/qplatformtheme_qpa.cpp
index d2ff804ddf..aec465f0ff 100644
--- a/src/gui/kernel/qplatformtheme_qpa.cpp
+++ b/src/gui/kernel/qplatformtheme_qpa.cpp
@@ -42,6 +42,8 @@
#include "qplatformtheme_qpa.h"
#include <QtCore/QVariant>
+#include <QtCore/QStringList>
+#include <qpalette.h>
QT_BEGIN_NAMESPACE
@@ -68,6 +70,21 @@ QT_BEGIN_NAMESPACE
\value MaximumScrollBarDragDistance (int) Determines the value returned by
QStyle::pixelMetric(PM_MaximumDragDistance)
+ \value ToolButtonStyle (int) A value representing a Qt::ToolButtonStyle.
+
+ \value ToolBarIconSize Icon size for tool bars.
+
+ \value SystemIconThemeName (QString) Name of the icon theme.
+
+ \value SystemIconFallbackThemeName (QString) Name of the fallback icon theme.
+
+ \value IconThemeSearchPaths (QStringList) Search paths for icons.
+
+ \value ItemViewActivateItemOnSingleClick (bool) Activate items by single click.
+
+ \value StyleNames (QStringList) A list of preferred style names.
+
+
\sa themeHint(), QStyle::pixelMetric()
*/
@@ -95,9 +112,28 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ
return 0;
}
+const QPalette *QPlatformTheme::palette(Palette type) const
+{
+ Q_UNUSED(type)
+ return 0;
+}
+
QVariant QPlatformTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
+ case QPlatformTheme::ItemViewActivateItemOnSingleClick:
+ return QVariant(false);
+ case QPlatformTheme::ToolButtonStyle:
+ return QVariant(int(Qt::ToolButtonIconOnly));
+ case QPlatformTheme::ToolBarIconSize:
+ return QVariant(int(0));
+ case QPlatformTheme::SystemIconThemeName:
+ case QPlatformTheme::SystemIconFallbackThemeName:
+ return QVariant(QString());
+ case QPlatformTheme::IconThemeSearchPaths:
+ return QVariant(QStringList());
+ case QPlatformTheme::StyleNames:
+ return QVariant(QStringList());
case TextCursorWidth:
return QVariant(1);
case DropShadow:
diff --git a/src/gui/kernel/qplatformtheme_qpa.h b/src/gui/kernel/qplatformtheme_qpa.h
index 2b87e63287..036432054e 100644
--- a/src/gui/kernel/qplatformtheme_qpa.h
+++ b/src/gui/kernel/qplatformtheme_qpa.h
@@ -48,13 +48,13 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
class QMenu;
class QMenuBar;
class QPlatformMenu;
class QPlatformMenuBar;
class QPlatformDialogHelper;
class QVariant;
+class QPalette;
class Q_GUI_EXPORT QPlatformTheme
{
@@ -62,7 +62,14 @@ public:
enum ThemeHint {
TextCursorWidth,
DropShadow,
- MaximumScrollBarDragDistance
+ MaximumScrollBarDragDistance,
+ ToolButtonStyle,
+ ToolBarIconSize,
+ ItemViewActivateItemOnSingleClick,
+ SystemIconThemeName,
+ SystemIconFallbackThemeName,
+ IconThemeSearchPaths,
+ StyleNames
};
enum DialogType {
@@ -71,12 +78,20 @@ public:
FontDialog
};
+ enum Palette {
+ SystemPalette,
+ ToolTipPalette,
+ NPalettes
+ };
+
virtual QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const;
virtual QPlatformMenuBar *createPlatformMenuBar(QMenuBar *menuBar = 0) const;
virtual bool usePlatformNativeDialog(DialogType type) const;
virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
+ virtual const QPalette *palette(Palette type = SystemPalette) const;
+
virtual QVariant themeHint(ThemeHint hint) const;
};
diff --git a/src/gui/kernel/qplatformthemeplugin_qpa.h b/src/gui/kernel/qplatformthemeplugin_qpa.h
index fb4f9f9b7c..3ce7cc5b02 100644
--- a/src/gui/kernel/qplatformthemeplugin_qpa.h
+++ b/src/gui/kernel/qplatformthemeplugin_qpa.h
@@ -68,7 +68,7 @@ struct QPlatformThemeFactoryInterface : public QFactoryInterface
virtual QPlatformTheme *create(const QString &key, const QStringList &paramList) = 0;
};
-#define QPlatformThemeFactoryInterface_iid "com.nokia.Qt.QPlatformThemeFactoryInterface"
+#define QPlatformThemeFactoryInterface_iid "org.qt-project.Qt.QPlatformThemeFactoryInterface"
Q_DECLARE_INTERFACE(QPlatformThemeFactoryInterface, QPlatformThemeFactoryInterface_iid)
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index c52a1cf757..e12228d7bd 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -114,6 +114,10 @@ QSurfaceFormat QPlatformWindow::format() const
can happen programatically(from ie. user application) or by the window manager. This means that
there is no need to call this function specifically from the window manager callback, instead
call QWindowSystemInterface::handleGeometryChange(QWindow *w, const QRect &newRect);
+
+ The position(x, y) part of the rect might be inclusive or exclusive of the window frame
+ as returned by frameMargins(). You can detect this in the plugin by checking
+ qt_window_private(window())->positionPolicy.
*/
void QPlatformWindow::setGeometry(const QRect &rect)
{
@@ -142,6 +146,7 @@ QMargins QPlatformWindow::frameMargins() const
void QPlatformWindow::setVisible(bool visible)
{
Q_UNUSED(visible);
+ QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
}
/*!
Requests setting the window flags of this surface
@@ -152,6 +157,20 @@ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
return flags;
}
+
+
+/*!
+ Returns if this window is exposed in the windowing system.
+
+ An exposeEvent() is sent every time this value changes.
+ */
+
+bool QPlatformWindow::isExposed() const
+{
+ Q_D(const QPlatformWindow);
+ return d->window->visible();
+}
+
/*!
Requests setting the window state of this surface
to \a type. Returns the actual state set.
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
index 88bf633425..170f62162f 100644
--- a/src/gui/kernel/qplatformwindow_qpa.h
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -89,6 +89,8 @@ public:
virtual void raise();
virtual void lower();
+ virtual bool isExposed() const;
+
virtual void propagateSizeHints();
virtual void setOpacity(qreal level);
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 67eb991b19..da0716b7d5 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -41,6 +41,7 @@
#include "qscreen.h"
#include "qscreen_p.h"
+#include "qpixmap.h"
#include "qplatformscreen_qpa.h"
#include <QtCore/private/qobject_p.h>
@@ -542,4 +543,51 @@ void QScreenPrivate::updatePrimaryOrientation()
primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
}
+/*!
+ Creates and returns a pixmap constructed by grabbing the contents
+ of the given \a window restricted by QRect(\a x, \a y, \a width,
+ \a height).
+
+ The arguments (\a{x}, \a{y}) specify the offset in the window,
+ whereas (\a{width}, \a{height}) specify the area to be copied. If
+ \a width is negative, the function copies everything to the right
+ border of the window. If \a height is negative, the function
+ copies everything to the bottom of the window.
+
+ The window system identifier (\c WId) can be retrieved using the
+ QWidget::winId() function. The rationale for using a window
+ identifier and not a QWidget, is to enable grabbing of windows
+ that are not part of the application, window system frames, and so
+ on.
+
+ The grabWindow() function grabs pixels from the screen, not from
+ the window, i.e. if there is another window partially or entirely
+ over the one you grab, you get pixels from the overlying window,
+ too. The mouse cursor is generally not grabbed.
+
+ Note on X11 that if the given \a window doesn't have the same depth
+ as the root window, and another window partially or entirely
+ obscures the one you grab, you will \e not get pixels from the
+ overlying window. The contents of the obscured areas in the
+ pixmap will be undefined and uninitialized.
+
+ On Windows Vista and above grabbing a layered window, which is
+ created by setting the Qt::WA_TranslucentBackground attribute, will
+ not work. Instead grabbing the desktop widget should work.
+
+ \warning In general, grabbing an area outside the screen is not
+ safe. This depends on the underlying window system.
+ \since 5.0
+*/
+
+QPixmap QScreen::grabWindow(WId window, int x, int y, int w, int h) const
+{
+ const QPlatformScreen *platformScreen = handle();
+ if (!platformScreen) {
+ qWarning("%s invoked with handle==0", Q_FUNC_INFO);
+ return QPixmap();
+ }
+ return platformScreen->grabWindow(window, x, y, w, h);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index f73cd0836f..111e10d340 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -61,6 +61,7 @@ class QPlatformScreen;
class QScreenPrivate;
class QWindow;
class QRect;
+class QPixmap;
class Q_GUI_EXPORT QScreen : public QObject
{
@@ -124,6 +125,8 @@ public:
bool isPortrait(Qt::ScreenOrientation orientation);
bool isLandscape(Qt::ScreenOrientation orientation);
+ QPixmap grabWindow(WId window, int x, int y, int w, int h) const;
+
Q_SIGNALS:
void sizeChanged(const QSize &size);
void geometryChanged(const QRect &geometry);
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 4436884359..9c6b6c4bf7 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -42,6 +42,7 @@
#include "qwindow.h"
#include "qplatformwindow_qpa.h"
+#include "qplatformintegration_qpa.h"
#include "qsurfaceformat.h"
#ifndef QT_NO_OPENGL
#include "qplatformopenglcontext_qpa.h"
@@ -165,19 +166,14 @@ void QWindow::setVisible(bool visible)
return;
d->visible = visible;
emit visibleChanged(visible);
- if (QCoreApplication::instance() && !transientParent()) {
- QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
- if (visible) {
- applicationPrivate->ref();
- } else {
- applicationPrivate->deref();
- }
- }
if (!d->platformWindow)
create();
if (visible) {
+ // remove posted quit events when showing a new window
+ QCoreApplication::removePostedEvents(qApp, QEvent::Quit);
+
QShowEvent showEvent;
QGuiApplication::sendEvent(this, &showEvent);
}
@@ -190,8 +186,14 @@ void QWindow::setVisible(bool visible)
}
}
+
bool QWindow::visible() const
{
+ return isVisible();
+}
+
+bool QWindow::isVisible() const
+{
Q_D(const QWindow);
return d->visible;
@@ -219,7 +221,11 @@ WId QWindow::winId() const
Q_D(const QWindow);
if(!d->platformWindow)
const_cast<QWindow *>(this)->create();
- return d->platformWindow->winId();
+
+ WId id = d->platformWindow->winId();
+ // See the QPlatformWindow::winId() documentation
+ Q_ASSERT(id != WId(0));
+ return id;
}
QWindow *QWindow::parent() const
@@ -373,6 +379,25 @@ void QWindow::requestActivateWindow()
d->platformWindow->requestActivateWindow();
}
+
+/*!
+ Returns if this window is exposed in the windowing system.
+
+ When the window is not exposed, it is shown by the application
+ but it is still not showing in the windowing system, so the application
+ should minimize rendering and other graphical activities.
+
+ An exposeEvent() is sent every time this value changes.
+ */
+
+bool QWindow::isExposed() const
+{
+ Q_D(const QWindow);
+ if (d->platformWindow)
+ return d->platformWindow->isExposed();
+ return false;
+}
+
/*!
Returns true if the window should appear active from a style perspective.
@@ -511,15 +536,6 @@ void QWindow::setTransientParent(QWindow *parent)
QWindow *previousParent = d->transientParent;
d->transientParent = parent;
-
- if (QCoreApplication::instance() && d->visible) {
- QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
- if (parent && !previousParent) {
- applicationPrivate->deref();
- } else if (!parent && previousParent) {
- applicationPrivate->ref();
- }
- }
}
QWindow *QWindow::transientParent() const
@@ -731,6 +747,15 @@ void QWindow::setWindowIcon(const QImage &icon) const
void QWindow::destroy()
{
Q_D(QWindow);
+ QObjectList childrenWindows = children();
+ for (int i = 0; i < childrenWindows.size(); i++) {
+ QObject *object = childrenWindows.at(i);
+ if (object->isWindowType()) {
+ QWindow *w = static_cast<QWindow*>(object);
+ QGuiApplicationPrivate::window_list.removeAll(w);
+ w->destroy();
+ }
+ }
setVisible(false);
delete d->platformWindow;
d->platformWindow = 0;
@@ -881,22 +906,25 @@ bool QWindow::close()
if (QGuiApplicationPrivate::focus_window == this)
QGuiApplicationPrivate::focus_window = 0;
- QObjectList childrenWindows = children();
- for (int i = 0; i < childrenWindows.size(); i++) {
- QObject *object = childrenWindows.at(i);
- if (object->isWindowType()) {
- QWindow *w = static_cast<QWindow*>(object);
- QGuiApplicationPrivate::window_list.removeAll(w);
- w->destroy();
- }
- }
-
QGuiApplicationPrivate::window_list.removeAll(this);
destroy();
d->maybeQuitOnLastWindowClosed();
return true;
}
+
+
+/*!
+ The expose event is sent by the window system whenever the window's
+ exposure on screen changes.
+
+ If the window is moved off screen, is made totally obscured by another
+ window, iconified or similar, this function might be called and the
+ value of isExposed() might change to false. When this happens,
+ an application should stop its rendering as it is no longer visible
+ to the user.
+ */
+
void QWindow::exposeEvent(QExposeEvent *ev)
{
ev->ignore();
@@ -944,6 +972,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
touchEvent(static_cast<QTouchEvent *>(ev));
break;
@@ -979,7 +1008,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::Close: {
Q_D(QWindow);
- bool wasVisible = visible();
+ bool wasVisible = isVisible();
destroy();
if (wasVisible)
d->maybeQuitOnLastWindowClosed();
@@ -1113,13 +1142,16 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
bool lastWindowClosed = true;
for (int i = 0; i < list.size(); ++i) {
QWindow *w = list.at(i);
- if (!w->visible() || w->parent())
+ if (!w->isVisible())
continue;
lastWindowClosed = false;
break;
}
- if (lastWindowClosed)
+ if (lastWindowClosed) {
QGuiApplicationPrivate::emitLastWindowClosed();
+ QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
+ applicationPrivate->maybeQuit();
+ }
}
}
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 98b468b142..1461f12520 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -89,7 +89,7 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
public:
@@ -101,7 +101,9 @@ public:
void setSurfaceType(SurfaceType surfaceType);
SurfaceType surfaceType() const;
- bool visible() const;
+ QT_DEPRECATED bool visible() const;
+
+ bool isVisible() const;
void create();
@@ -150,6 +152,8 @@ public:
bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const;
+ bool isExposed() const;
+
QSize minimumSize() const;
QSize maximumSize() const;
QSize baseSize() const;
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
index 82cce0394b..c2d7a2fe2f 100644
--- a/src/gui/kernel/qwindowdefs.h
+++ b/src/gui/kernel/qwindowdefs.h
@@ -42,6 +42,7 @@
#ifndef QWINDOWDEFS_H
#define QWINDOWDEFS_H
+#include <QtCore/qglobal.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qnamespace.h>
@@ -99,7 +100,7 @@ QT_END_HEADER
-typedef unsigned long WId;
+typedef QT_PREPEND_NAMESPACE(quintptr) WId;
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
index ae94b75076..e6c4454104 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -296,6 +296,22 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTo
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
+void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device,
+ Qt::KeyboardModifiers mods)
+{
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleTouchCancelEvent(w, time, device, mods);
+}
+
+void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device,
+ Qt::KeyboardModifiers mods)
+{
+ QWindowSystemInterfacePrivate::TouchEvent *e =
+ new QWindowSystemInterfacePrivate::TouchEvent(w, timestamp, QEvent::TouchCancel, device,
+ QList<QTouchEvent::TouchPoint>(), mods);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation)
{
QWindowSystemInterfacePrivate::ScreenOrientationEvent *e =
@@ -324,6 +340,12 @@ void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *scree
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
+void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
+{
+ QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
void QWindowSystemInterface::handleMapEvent(QWindow *tlw)
{
QWindowSystemInterfacePrivate::MapEvent *e = new QWindowSystemInterfacePrivate::MapEvent(tlw);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
index b99363eda7..78152a1178 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.h
@@ -101,6 +101,8 @@ public:
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
static void handleTouchEvent(QWindow *w, ulong timestamp, QTouchDevice *device,
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
+ static void handleTouchCancelEvent(QWindow *w, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
+ static void handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
static void handleGeometryChange(QWindow *w, const QRect &newRect);
static void handleSynchronousGeometryChange(QWindow *w, const QRect &newRect);
@@ -128,6 +130,8 @@ public:
static void handleScreenAvailableGeometryChange(QScreen *screen, const QRect &newAvailableGeometry);
static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);
+ static void handleThemeChange(QWindow *tlw);
+
// For event dispatcher implementations
static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags);
static int windowSystemEventsQueued();
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
index 0bd9ba017a..661b39da88 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
@@ -64,6 +64,7 @@ public:
ScreenGeometry,
ScreenAvailableGeometry,
ScreenLogicalDotsPerInch,
+ ThemeChange,
Map,
Unmap,
Expose
@@ -230,6 +231,13 @@ public:
qreal dpiY;
};
+ class ThemeChangeEvent : public WindowSystemEvent {
+ public:
+ explicit ThemeChangeEvent(QWindow * w)
+ : WindowSystemEvent(ThemeChange), window(w) { }
+ QWeakPointer<QWindow> window;
+ };
+
class MapEvent : public WindowSystemEvent {
public:
MapEvent(QWindow *mapped)