summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-04-28 13:50:07 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-04-28 15:40:01 +0200
commitb68d0688feb7b01eca91b33566887200de7fc89a (patch)
treebeea61f9177f2b07208a39d16887123a5b99372a
parent33e1b8dda549630a6b782fa465b21f0c4f269280 (diff)
Add resize event support to QWindow.
(cherry picked from commit 12b4e7e5a2b18cdd23f540821e1f2785f62b0b9a)
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp7
-rw-r--r--examples/opengl/hellowindow/hellowindow.h1
-rw-r--r--src/gui/kernel/kernel.pri1
-rw-r--r--src/gui/kernel/qguiapplication_qpa.cpp29
-rw-r--r--src/gui/kernel/qwindow_qpa.cpp46
-rw-r--r--src/gui/kernel/qwindow_qpa_p.h92
6 files changed, 137 insertions, 39 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index 6de48e8c95..b0576c1255 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -34,6 +34,13 @@ void HelloWindow::mousePressEvent(QMouseEvent *)
updateColor();
}
+void HelloWindow::resizeEvent(QResizeEvent *)
+{
+ glContext()->makeCurrent();
+
+ glViewport(0, 0, geometry().width(), geometry().height());
+}
+
void HelloWindow::updateColor()
{
float colors[][4] =
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
index b0adecbb10..f0b8ee8b45 100644
--- a/examples/opengl/hellowindow/hellowindow.h
+++ b/examples/opengl/hellowindow/hellowindow.h
@@ -13,6 +13,7 @@ public:
protected:
void mousePressEvent(QMouseEvent *);
+ void resizeEvent(QResizeEvent *);
private slots:
void render();
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index d7a4f42acf..c77d62ad6d 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -230,6 +230,7 @@ qpa {
kernel/qwindowformat_qpa.h \
kernel/qguiapplication_qpa.h \
kernel/qguiapplication_qpa_p.h \
+ kernel/qwindow_qpa_p.h \
kernel/qwindow_qpa.h
SOURCES += \
diff --git a/src/gui/kernel/qguiapplication_qpa.cpp b/src/gui/kernel/qguiapplication_qpa.cpp
index 4c4f4278b9..3a09c686c0 100644
--- a/src/gui/kernel/qguiapplication_qpa.cpp
+++ b/src/gui/kernel/qguiapplication_qpa.cpp
@@ -61,6 +61,7 @@
#include <QWindowSystemInterface>
#include "private/qwindowsysteminterface_qpa_p.h"
+#include "private/qwindow_qpa_p.h"
#ifndef QT_NO_CLIPBOARD
#include <QtGui/QClipboard>
@@ -658,8 +659,32 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr
{
if (e->tlw.isNull())
return;
- QWidget *tlw = e->tlw.data() ? e->tlw.data()->widget() : 0;
- if (!tlw || !tlw->isWindow())
+
+ QWindow *window = e->tlw.data();
+ QWidget *tlw = window ? window->widget() : 0;
+ if (!tlw) {
+ if (window) {
+ QRect newRect = e->newGeometry;
+ QRect cr = window->geometry();
+
+ bool isResize = cr.size() != newRect.size();
+ bool isMove = cr.topLeft() != newRect.topLeft();
+ window->d_func()->geometry = newRect;
+ if (isResize) {
+ QResizeEvent e(newRect.size(), cr.size());
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+
+ if (isMove) {
+ //### frame geometry
+ QMoveEvent e(newRect.topLeft(), cr.topLeft());
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+ }
+ return;
+ }
+
+ if (!tlw->isWindow())
return; //geo of native child widgets is controlled by lighthouse
//so we already have sent the events; besides this new rect
//is not mapped to parent
diff --git a/src/gui/kernel/qwindow_qpa.cpp b/src/gui/kernel/qwindow_qpa.cpp
index 469afaa3d2..0e24752711 100644
--- a/src/gui/kernel/qwindow_qpa.cpp
+++ b/src/gui/kernel/qwindow_qpa.cpp
@@ -46,44 +46,13 @@
#include "qplatformglcontext_qpa.h"
#include "qwindowcontext_qpa.h"
+#include "qwindow_qpa_p.h"
#include "qapplication_p.h"
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
-class QWindowPrivate : public QObjectPrivate
-{
-public:
- QWindowPrivate()
- : QObjectPrivate()
- , windowFlags(Qt::Window)
- , surfaceType(QWindow::RasterSurface)
- , platformWindow(0)
- , visible(false)
- , glContext(0)
- , widget(0)
- {
- isWindow = true;
- }
-
- ~QWindowPrivate()
- {
-
- }
-
- Qt::WindowFlags windowFlags;
- QWindow::SurfaceType surfaceType;
- QWindow *parentWindow;
- QPlatformWindow *platformWindow;
- bool visible;
- QWindowFormat requestedFormat;
- QString windowTitle;
- QRect geometry;
- QWindowContext *glContext;
- QWidget *widget;
-};
-
QWindow::QWindow(QWindow *parent)
: QObject(*new QWindowPrivate())
{
@@ -397,7 +366,6 @@ bool QWindow::close()
void QWindow::resizeEvent(QResizeEvent *)
{
- qDebug() << "unimplemented:" << __FILE__ << __LINE__;
}
void QWindow::showEvent(QShowEvent *)
@@ -414,19 +382,23 @@ bool QWindow::event(QEvent *event)
{
switch (event->type()) {
case QEvent::MouseMove:
- mouseMoveEvent((QMouseEvent*)event);
+ mouseMoveEvent(static_cast<QMouseEvent*>(event));
break;
case QEvent::MouseButtonPress:
- mousePressEvent((QMouseEvent*)event);
+ mousePressEvent(static_cast<QMouseEvent*>(event));
break;
case QEvent::MouseButtonRelease:
- mouseReleaseEvent((QMouseEvent*)event);
+ mouseReleaseEvent(static_cast<QMouseEvent*>(event));
break;
case QEvent::MouseButtonDblClick:
- mouseDoubleClickEvent((QMouseEvent*)event);
+ mouseDoubleClickEvent(static_cast<QMouseEvent*>(event));
+ break;
+
+ case QEvent::Resize:
+ resizeEvent(static_cast<QResizeEvent*>(event));
break;
default:
diff --git a/src/gui/kernel/qwindow_qpa_p.h b/src/gui/kernel/qwindow_qpa_p.h
new file mode 100644
index 0000000000..5a1b8cdcdd
--- /dev/null
+++ b/src/gui/kernel/qwindow_qpa_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOW_QPA_P_H
+#define QWINDOW_QPA_P_H
+
+#include <QtGui/qwindow_qpa.h>
+
+#include <QtCore/private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindowPrivate : public QObjectPrivate
+{
+public:
+ QWindowPrivate()
+ : QObjectPrivate()
+ , windowFlags(Qt::Window)
+ , surfaceType(QWindow::RasterSurface)
+ , platformWindow(0)
+ , visible(false)
+ , glContext(0)
+ , widget(0)
+ {
+ isWindow = true;
+ }
+
+ ~QWindowPrivate()
+ {
+
+ }
+
+ Qt::WindowFlags windowFlags;
+ QWindow::SurfaceType surfaceType;
+ QWindow *parentWindow;
+ QPlatformWindow *platformWindow;
+ bool visible;
+ QWindowFormat requestedFormat;
+ QString windowTitle;
+ QRect geometry;
+ QWindowContext *glContext;
+ QWidget *widget;
+};
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOW_QPA_P_H