summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/kernel.pri2
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp4
-rw-r--r--src/gui/kernel/qguiapplication_qpa.cpp12
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp5
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h3
-rw-r--r--src/gui/kernel/qwidget.cpp11
-rw-r--r--src/gui/kernel/qwidget.h1
-rw-r--r--src/gui/kernel/qwidget_p.h4
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp5
-rw-r--r--src/gui/kernel/qwidgetwindow_qpa.cpp59
-rw-r--r--src/gui/kernel/qwidgetwindow_qpa_p.h74
-rw-r--r--src/gui/kernel/qwindow_qpa.cpp12
-rw-r--r--src/gui/kernel/qwindow_qpa.h9
-rw-r--r--src/gui/kernel/qwindow_qpa_p.h2
-rw-r--r--src/gui/painting/qbackingstore.cpp4
-rw-r--r--src/gui/painting/qgraphicssystem_p.h2
-rw-r--r--src/gui/painting/qwindowsurface.cpp96
-rw-r--r--src/gui/painting/qwindowsurface_p.h25
-rw-r--r--src/opengl/qgraphicssystem_gl.cpp22
-rw-r--r--src/opengl/qgraphicssystem_gl_p.h2
-rw-r--r--src/opengl/qwindowsurface_gl.cpp70
-rw-r--r--src/opengl/qwindowsurface_gl_p.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp19
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.h4
26 files changed, 283 insertions, 181 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index c77d62ad6d..798d6aaf6f 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/qwidgetwindow_qpa_p.h \
kernel/qwindow_qpa_p.h \
kernel/qwindow_qpa.h
@@ -259,6 +260,7 @@ qpa {
kernel/qsessionmanager_qpa.cpp \
kernel/qwindowformat_qpa.cpp \
kernel/qguiapplication_qpa.cpp \
+ kernel/qwidgetwindow_qpa.cpp \
kernel/qwindow_qpa.cpp
contains(QT_CONFIG, glib) {
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
index 94b6cd5c41..a1c120183a 100644
--- a/src/gui/kernel/qapplication_qpa.cpp
+++ b/src/gui/kernel/qapplication_qpa.cpp
@@ -117,7 +117,7 @@ static bool qt_try_modal(QWidget *widget, QEvent::Type type)
-void QApplicationPrivate::enterModal_sys(QWidget *widget)
+void QApplicationPrivate::enterModal_sys(QWidget *)
{
#if 0
if (!qt_modal_stack)
@@ -127,7 +127,7 @@ void QApplicationPrivate::enterModal_sys(QWidget *widget)
#endif
}
-void QApplicationPrivate::leaveModal_sys(QWidget *widget )
+void QApplicationPrivate::leaveModal_sys(QWidget *)
{
#if 0
if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
diff --git a/src/gui/kernel/qguiapplication_qpa.cpp b/src/gui/kernel/qguiapplication_qpa.cpp
index e5fcf4445e..7a6c184fff 100644
--- a/src/gui/kernel/qguiapplication_qpa.cpp
+++ b/src/gui/kernel/qguiapplication_qpa.cpp
@@ -388,7 +388,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
QWindow *window = e->window.data();
- QWidget * tlw = window ? window->widget() : 0;
+ QWidget * tlw = 0;//window ? window->widget() : 0;
QPoint localPoint = e->localPos;
QPoint globalPoint = e->globalPos;
@@ -512,10 +512,12 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
implicit_mouse_grabber.clear();
}
+#if 0
if (mouseWidget != qt_last_mouse_receiver) {
// dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver);
qt_last_mouse_receiver = mouseWidget;
}
+#endif
// Remember, we might enter a modal event loop when sending the event,
// so think carefully before adding code below this point.
@@ -561,7 +563,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
if (!window)
return;
- QWidget *mouseWidget = window ? window->widget() : 0;
+ QWidget *mouseWidget = 0;//window ? window->widget() : 0;
// find the tlw if we didn't get it from the plugin
#if 0
@@ -605,7 +607,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
if (!window)
return;
- QObject *target = window->widget() ? static_cast<QObject *>(window->widget()) : static_cast<QObject *>(window);
+ QObject *target = window;//window->widget() ? static_cast<QObject *>(window->widget()) : static_cast<QObject *>(window);
#if 0
QWidget *focusW = 0;
@@ -643,7 +645,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
{
// QGuiApplicationPrivate::dispatchEnterLeave(e->enter.data(),0);
- qt_last_mouse_receiver = e->enter.data() ? e->enter.data()->widget() : 0;
+// qt_last_mouse_receiver = e->enter.data();
}
void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *)
@@ -672,7 +674,7 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr
if (!window)
return;
- QWidget *tlw = window->widget();
+ QWidget *tlw = 0;//window->widget();
QObject *target = tlw ? static_cast<QObject *>(tlw) : static_cast<QObject *>(window);
QRect newRect = e->newGeometry;
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
index 4fd6896a95..79059de4f7 100644
--- a/src/gui/kernel/qplatformscreen_qpa.cpp
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -95,6 +95,11 @@ QPlatformScreen * QPlatformScreen::platformScreenForWidget(const QWidget *widget
return integration->screens()[screenIndex];
}
+QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window)
+{
+ return QGuiApplicationPrivate::platformIntegration()->screens().at(0);
+}
+
/*!
\class QPlatformScreen
\since 4.8
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
index b3bb121331..cbaf5b9c47 100644
--- a/src/gui/kernel/qplatformscreen_qpa.h
+++ b/src/gui/kernel/qplatformscreen_qpa.h
@@ -77,6 +77,9 @@ public:
//jl: should this function be in QPlatformIntegration
//jl: maybe screenForWidget is a better name?
static QPlatformScreen *platformScreenForWidget(const QWidget *widget);
+
+ // temporary convenience
+ static QPlatformScreen *platformScreenForWindow(const QWindow *window);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index d107bf1df9..f6c95719c2 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -78,6 +78,7 @@
#endif
#if defined(Q_WS_QPA)
#include "qplatformwindow_qpa.h"
+#include "private/qwidgetwindow_qpa_p.h"
#endif
#include "qpainter.h"
#include "qtooltip.h"
@@ -358,9 +359,9 @@ QWidgetPrivate::~QWidgetPrivate()
class QDummyWindowSurface : public QWindowSurface
{
public:
- QDummyWindowSurface(QWidget *window) : QWindowSurface(window) {}
- QPaintDevice *paintDevice() { return window(); }
- void flush(QWidget *, const QRegion &, const QPoint &) {}
+ QDummyWindowSurface(QWindow *window) : QWindowSurface(window) {}
+ QPaintDevice *paintDevice() { return static_cast<QWidgetWindow *>(window())->widget(); }
+ void flush(QWindow *, const QRegion &, const QPoint &) {}
};
QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
@@ -370,12 +371,12 @@ QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
QWindowSurface *surface;
#ifndef QT_NO_PROPERTIES
if (q->property("_q_DummyWindowSurface").toBool()) {
- surface = new QDummyWindowSurface(q);
+ surface = new QDummyWindowSurface(q->windowHandle());
} else
#endif
{
if (QApplicationPrivate::graphicsSystem())
- surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
+ surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q->windowHandle());
else
surface = createDefaultWindowSurface_sys();
}
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 3ba0d3e2f0..03643646f8 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -761,6 +761,7 @@ private:
friend class QGraphicsProxyWidgetPrivate;
friend class QStyleSheetStyle;
friend struct QWidgetExceptionCleaner;
+ friend class QWidgetWindow;
#ifndef QT_NO_GESTURES
friend class QGestureManager;
friend class QWinNativePanGestureRecognizer;
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index e9e9ff8c72..7826cab795 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -103,7 +103,7 @@ class QWSManager;
class QCoreGraphicsPaintEnginePrivate;
#endif
#if defined(Q_WS_QPA)
-class QWindow;
+class QWidgetWindow;
#endif
class QPaintEngine;
class QPixmap;
@@ -233,7 +233,7 @@ struct QTLWExtra {
uint inExpose : 1; // Prevents drawing recursion
uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
#elif defined(Q_WS_QPA)
- QWindow *window;
+ QWidgetWindow *window;
quint32 screenIndex; // index in qplatformscreenlist
#endif
};
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
index 75c54a2c55..aef49dd212 100644
--- a/src/gui/kernel/qwidget_qpa.cpp
+++ b/src/gui/kernel/qwidget_qpa.cpp
@@ -44,6 +44,7 @@
#include "QtGui/qapplication.h"
#include "QtGui/private/qbackingstore_p.h"
#include "QtGui/private/qwidget_p.h"
+#include "QtGui/private/qwidgetwindow_qpa_p.h"
#include "QtGui/private/qgraphicssystem_p.h"
#include "QtGui/private/qapplication_p.h"
#include "QtGui/qdesktopwidget.h"
@@ -102,6 +103,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (!surface ) {
if (win) {
surface = QApplicationPrivate::platformIntegration()->createWindowSurface(win, win->winId());
+ q->setWindowSurface(surface);
} else {
q->setAttribute(Qt::WA_PaintOnScreen,true);
}
@@ -700,8 +702,7 @@ void QWidgetPrivate::createTLSysExtra()
{
Q_Q(QWidget);
extra->topextra->screenIndex = 0;
- extra->topextra->window = new QWindow;
- extra->topextra->window->setWidget(q);
+ extra->topextra->window = new QWidgetWindow(q);
}
void QWidgetPrivate::deleteTLSysExtra()
diff --git a/src/gui/kernel/qwidgetwindow_qpa.cpp b/src/gui/kernel/qwidgetwindow_qpa.cpp
new file mode 100644
index 0000000000..8ab6c9cec3
--- /dev/null
+++ b/src/gui/kernel/qwidgetwindow_qpa.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qwidgetwindow_qpa_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWidgetWindow::QWidgetWindow(QWidget *widget)
+ : m_widget(widget)
+{
+}
+
+bool QWidgetWindow::event(QEvent *event)
+{
+ if (m_widget->event(event))
+ return true;
+
+ return QWindow::event(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidgetwindow_qpa_p.h b/src/gui/kernel/qwidgetwindow_qpa_p.h
new file mode 100644
index 0000000000..3768d655b7
--- /dev/null
+++ b/src/gui/kernel/qwidgetwindow_qpa_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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 QWIDGETWINDOW_QPA_P_H
+#define QWIDGETWINDOW_QPA_P_H
+
+#include <QtGui/qwindow_qpa.h>
+
+#include <QtCore/private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidgetWindow : public QWindow
+{
+ Q_OBJECT
+public:
+ QWidgetWindow(QWidget *widget);
+
+ QWidget *widget() const { return m_widget; }
+
+protected:
+ bool event(QEvent *);
+
+private:
+ QWidget *m_widget;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWIDGETWINDOW_QPA_P_H
diff --git a/src/gui/kernel/qwindow_qpa.cpp b/src/gui/kernel/qwindow_qpa.cpp
index 6822664664..67eeb94e72 100644
--- a/src/gui/kernel/qwindow_qpa.cpp
+++ b/src/gui/kernel/qwindow_qpa.cpp
@@ -66,18 +66,6 @@ QWindow::~QWindow()
destroy();
}
-QWidget *QWindow::widget() const
-{
- Q_D(const QWindow);
- return d->widget;
-}
-
-void QWindow::setWidget(QWidget *widget)
-{
- Q_D(QWindow);
- d->widget = widget;
-}
-
void QWindow::setVisible(bool visible)
{
Q_D(QWindow);
diff --git a/src/gui/kernel/qwindow_qpa.h b/src/gui/kernel/qwindow_qpa.h
index 2e9de57cb6..b13cf9165b 100644
--- a/src/gui/kernel/qwindow_qpa.h
+++ b/src/gui/kernel/qwindow_qpa.h
@@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QWindowPrivate;
-class QWidget;
class QResizeEvent;
class QShowEvent;
@@ -84,18 +83,18 @@ public:
QWindow(QWindow *parent = 0);
virtual ~QWindow();
- // to be removed at some point in the future
- QWidget *widget() const;
- void setWidget(QWidget *widget);
-
void setVisible(bool visible);
bool visible() const;
void create();
WId winId() const;
+
+ QWindow *parent() const;
void setParent(QWindow *parent);
+ QWindow *topLevelWindow() const;
+
void setWindowFormat(const QWindowFormat &format);
QWindowFormat requestedWindowFormat() const;
QWindowFormat actualWindowFormat() const;
diff --git a/src/gui/kernel/qwindow_qpa_p.h b/src/gui/kernel/qwindow_qpa_p.h
index 5a1b8cdcdd..06458290f1 100644
--- a/src/gui/kernel/qwindow_qpa_p.h
+++ b/src/gui/kernel/qwindow_qpa_p.h
@@ -62,7 +62,6 @@ public:
, platformWindow(0)
, visible(false)
, glContext(0)
- , widget(0)
{
isWindow = true;
}
@@ -81,7 +80,6 @@ public:
QString windowTitle;
QRect geometry;
QWindowContext *glContext;
- QWidget *widget;
};
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 42c1c354b6..7ec878c39d 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -114,9 +114,9 @@ static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurfa
}
}
if (widget != tlw)
- windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint()));
+ windowSurface->flush(widget->windowHandle(), region, tlwOffset + widget->mapTo(tlw, QPoint()));
else
- windowSurface->flush(widget, region, tlwOffset);
+ windowSurface->flush(widget->windowHandle(), region, tlwOffset);
}
#ifndef QT_NO_PAINT_DEBUG
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
index 0f99a311a6..2271d4dba6 100644
--- a/src/gui/painting/qgraphicssystem_p.h
+++ b/src/gui/painting/qgraphicssystem_p.h
@@ -69,7 +69,7 @@ class Q_GUI_EXPORT QGraphicsSystem
public:
virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
virtual QPixmapData *createPixmapData(QPixmapData *origin);
- virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0;
+ virtual QWindowSurface *createWindowSurface(QWindow *window) const = 0;
virtual ~QGraphicsSystem();
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index 0fb9bf78a9..97fb7a9972 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include <private/qwindowsurface_p.h>
-#include <qwidget.h>
-#include <private/qwidget_p.h>
+#include <qwindow_qpa.h>
+#include <private/qwindow_qpa_p.h>
#include <private/qbackingstore_p.h>
#include <private/qapplication_p.h>
@@ -50,19 +50,18 @@ QT_BEGIN_NAMESPACE
class QWindowSurfacePrivate
{
public:
- QWindowSurfacePrivate(QWidget *w)
+ QWindowSurfacePrivate(QWindow *w)
: window(w)
{
}
- QWidget *window;
+ QWindow *window;
#if !defined(Q_WS_QPA)
QRect geometry;
#else
QSize size;
#endif //Q_WS_QPA
QRegion staticContents;
- QList<QImage*> bufferImages;
};
/*!
@@ -96,10 +95,10 @@ public:
*/
/*!
- \fn void QWindowSurface::flush(QWidget *widget, const QRegion &region,
+ \fn void QWindowSurface::flush(QWindow *window, const QRegion &region,
const QPoint &offset)
- Flushes the given \a region from the specified \a widget onto the
+ Flushes the given \a region from the specified \a window onto the
screen.
Note that the \a offset parameter is currently unused.
@@ -114,13 +113,15 @@ public:
/*!
Constructs an empty surface for the given top-level \a window.
*/
-QWindowSurface::QWindowSurface(QWidget *window, bool setDefaultSurface)
+QWindowSurface::QWindowSurface(QWindow *window, bool /*setDefaultSurface*/)
: d_ptr(new QWindowSurfacePrivate(window))
{
+#if 0
if (!QApplicationPrivate::runtime_graphics_system) {
- if(setDefaultSurface && window)
+ if (setDefaultSurface && window)
window->setWindowSurface(this);
}
+#endif
}
/*!
@@ -128,8 +129,8 @@ QWindowSurface::QWindowSurface(QWidget *window, bool setDefaultSurface)
*/
QWindowSurface::~QWindowSurface()
{
- if (d_ptr->window)
- d_ptr->window->d_func()->extra->topextra->windowSurface = 0;
+// if (d_ptr->window)
+// d_ptr->window->d_func()->extra->topextra->windowSurface = 0;
delete d_ptr;
}
@@ -137,7 +138,7 @@ QWindowSurface::~QWindowSurface()
Returns a pointer to the top-level window associated with this
surface.
*/
-QWidget* QWindowSurface::window() const
+QWindow* QWindowSurface::window() const
{
return d_ptr->window;
}
@@ -149,8 +150,6 @@ void QWindowSurface::beginPaint(const QRegion &)
void QWindowSurface::endPaint(const QRegion &)
{
// QApplication::syncX();
- qDeleteAll(d_ptr->bufferImages);
- d_ptr->bufferImages.clear();
}
#if !defined(Q_WS_QPA)
@@ -211,67 +210,35 @@ bool QWindowSurface::scroll(const QRegion &area, int dx, int dy)
}
/*!
- Returns a QImage pointer which represents the actual buffer the \a widget
- is drawn into or 0 if this is unavailable.
-
- You must call beginPaint() before you call this function and the returned
- pointer is only valid until endPaint() is called.
-*/
-QImage* QWindowSurface::buffer(const QWidget *widget)
-{
- if (widget->window() != window())
- return 0;
-
- QPaintDevice *pdev = paintDevice();
- if (!pdev || pdev->devType() != QInternal::Image)
- return 0;
-
- const QPoint off = offset(widget);
- QImage *img = static_cast<QImage*>(pdev);
-
- QRect rect(off, widget->size());
- rect &= QRect(QPoint(), img->size());
-
- if (rect.isEmpty())
- return 0;
-
- img = new QImage(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
- rect.width(), rect.height(),
- img->bytesPerLine(), img->format());
- d_ptr->bufferImages.append(img);
-
- return img;
-}
-
-/*!
Returns a QPixmap generated from the part of the backing store
- corresponding to \a widget. Returns a null QPixmap if an error
+ corresponding to \a window. Returns a null QPixmap if an error
occurs. The contents of the pixmap are only defined for the regions
- of \a widget that have received paint events since the last resize
+ of \a window that have received paint events since the last resize
of the backing store.
- If \a rectangle is a null rectangle (the default), the entire widget
+ If \a rectangle is a null rectangle (the default), the entire window
is grabbed. Otherwise, the grabbed area is limited to \a rectangle.
The default implementation uses QWindowSurface::buffer().
- \sa QPixmap::grabWidget()
+ \sa QPixmap::grabWindow()
*/
-QPixmap QWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle) const
+QPixmap QWindowSurface::grabWindow(const QWindow *, const QRect &) const
{
QPixmap result;
- if (widget->window() != window())
+#if 0
+ if (window->window() != window())
return result;
- const QImage *img = const_cast<QWindowSurface *>(this)->buffer(widget->window());
+ const QImage *img = const_cast<QWindowSurface *>(this)->buffer(window->window());
if (!img || img->isNull())
return result;
- QRect rect = rectangle.isEmpty() ? widget->rect() : (widget->rect() & rectangle);
+ QRect rect = rectangle.isEmpty() ? window->rect() : (window->rect() & rectangle);
- rect.translate(offset(widget) - offset(widget->window()));
+ rect.translate(offset(window) - offset(window->window()));
rect &= QRect(QPoint(), img->size());
if (rect.isEmpty())
@@ -283,27 +250,28 @@ QPixmap QWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle
subimg.detach(); //### expensive -- maybe we should have a real SubImage that shares reference count
result = QPixmap::fromImage(subimg);
+#endif
return result;
}
/*!
- Returns the offset of \a widget in the coordinates of this
+ Returns the offset of \a window in the coordinates of this
window surface.
*/
-QPoint QWindowSurface::offset(const QWidget *widget) const
+QPoint QWindowSurface::offset(const QWindow *) const
{
- QWidget *window = d_ptr->window;
- QPoint offset = widget->mapTo(window, QPoint());
-#ifdef Q_WS_QWS
- offset += window->geometry().topLeft() - window->frameGeometry().topLeft();
+ QPoint offset;
+#if 0
+ QWindow *window = d_ptr->window;
+ QPoint offset = window->mapTo(window, QPoint());
#endif
return offset;
}
/*!
- \fn QRect QWindowSurface::rect(const QWidget *widget) const
+ \fn QRect QWindowSurface::rect(const QWindow *window) const
- Returns the rectangle for \a widget in the coordinates of this
+ Returns the rectangle for \a window in the coordinates of this
window surface.
*/
diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h
index a3fea67f24..9d3e95e1ca 100644
--- a/src/gui/painting/qwindowsurface_p.h
+++ b/src/gui/painting/qwindowsurface_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtGui/qwidget.h>
+#include <QtGui/qwindow_qpa.h>
QT_BEGIN_NAMESPACE
@@ -76,18 +76,18 @@ public:
};
Q_DECLARE_FLAGS(WindowSurfaceFeatures, WindowSurfaceFeature)
- QWindowSurface(QWidget *window, bool setDefaultSurface = true);
+ QWindowSurface(QWindow *window, bool setDefaultSurface = true);
virtual ~QWindowSurface();
- QWidget *window() const;
+ QWindow *window() const;
virtual QPaintDevice *paintDevice() = 0;
- // 'widget' can be a child widget, in which case 'region' is in child widget coordinates and
- // offset is the (child) widget's offset in relation to the window surface. On QWS, 'offset'
- // can be larger than just the offset from the top-level widget as there may also be window
+ // 'window' can be a child window, in which case 'region' is in child window coordinates and
+ // offset is the (child) window's offset in relation to the window surface. On QWS, 'offset'
+ // can be larger than just the offset from the top-level window as there may also be window
// decorations which are painted into the window surface.
- virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset) = 0;
+ virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) = 0;
#if !defined(Q_WS_QPA)
virtual void setGeometry(const QRect &rect);
QRect geometry() const;
@@ -102,11 +102,10 @@ public:
virtual void beginPaint(const QRegion &);
virtual void endPaint(const QRegion &);
- virtual QImage* buffer(const QWidget *widget);
- virtual QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const;
+ virtual QPixmap grabWindow(const QWindow *window, const QRect& rectangle = QRect()) const;
- virtual QPoint offset(const QWidget *widget) const;
- inline QRect rect(const QWidget *widget) const;
+ virtual QPoint offset(const QWindow *window) const;
+ inline QRect rect(const QWindow *window) const;
bool hasFeature(WindowSurfaceFeature feature) const;
virtual WindowSurfaceFeatures features() const;
@@ -123,9 +122,9 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowSurface::WindowSurfaceFeatures)
-inline QRect QWindowSurface::rect(const QWidget *widget) const
+inline QRect QWindowSurface::rect(const QWindow *window) const
{
- return widget->rect().translated(offset(widget));
+ return window->geometry().translated(offset(window));
}
inline bool QWindowSurface::hasFeature(WindowSurfaceFeature feature) const
diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp
index 0aa3c2e6c7..662fa56cb5 100644
--- a/src/opengl/qgraphicssystem_gl.cpp
+++ b/src/opengl/qgraphicssystem_gl.cpp
@@ -70,28 +70,14 @@ QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) co
return new QGLPixmapData(type);
}
-QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
+QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWindow *window) const
{
#ifdef Q_WS_WIN
// On Windows the QGLWindowSurface class can't handle
// drop shadows and native effects, e.g. fading a menu in/out using
// top level window opacity.
- if (widget->windowType() == Qt::Popup)
- return new QRasterWindowSurface(widget);
-#endif
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (m_useX11GL && QX11GLPixmapData::hasX11GLPixmaps()) {
- // If the widget is a QGraphicsView which will be re-drawing the entire
- // scene each frame anyway, we should use QGLWindowSurface as this may
- // provide proper buffer flipping, which should be faster than QX11GL's
- // blitting approach:
- QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget);
- if (qgv && qgv->viewportUpdateMode() == QGraphicsView::FullViewportUpdate)
- return new QGLWindowSurface(widget);
- else
- return new QX11GLWindowSurface(widget);
- }
+ if (window->windowType() == Qt::Popup)
+ return new QRasterWindowSurface(window);
#endif
#if defined(Q_OS_SYMBIAN)
@@ -102,7 +88,7 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
}
#endif
- return new QGLWindowSurface(widget);
+ return new QGLWindowSurface(window);
}
#ifdef QGL_USE_TEXTURE_POOL
void QGLGraphicsSystem::releaseCachedResources()
diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h
index 5829dccea9..40c6013d14 100644
--- a/src/opengl/qgraphicssystem_gl_p.h
+++ b/src/opengl/qgraphicssystem_gl_p.h
@@ -65,7 +65,7 @@ public:
QGLGraphicsSystem(bool useX11GL);
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
+ QWindowSurface *createWindowSurface(QWindow *window) const;
#ifdef QGL_USE_TEXTURE_POOL
void releaseCachedResources();
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 56e2c3b517..c73172784a 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -86,6 +86,10 @@
#include <private/qeglcontext_p.h>
#endif
+#ifdef Q_WS_QPA
+#include <qplatformscreen_qpa.h>
+#endif
+
QT_BEGIN_NAMESPACE
//
@@ -353,7 +357,31 @@ QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
{
- return qt_paint_device_metric(d->q_ptr->window(), m);
+ QWindow *window = d->q_ptr->window();
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(window);
+ if (!screen) {
+ if (m == PdmDpiX || m == PdmDpiY)
+ return 72;
+ }
+ int val;
+ if (m == PdmWidth) {
+ val = window->geometry().width();
+ } else if (m == PdmWidthMM) {
+ val = window->geometry().width() * screen->physicalSize().width() / screen->geometry().width();
+ } else if (m == PdmHeight) {
+ val = window->geometry().height();
+ } else if (m == PdmHeightMM) {
+ val = window->geometry().height() * screen->physicalSize().height() / screen->geometry().height();
+ } else if (m == PdmDepth) {
+ val = screen->depth();
+ } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
+ val = qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
+ } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
+ val = qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
+ } else {
+ val = 1 << qMax(24, screen->depth());
+ }
+ return val;
}
QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
@@ -361,7 +389,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
return qt_qgl_paint_engine();
}
-QGLWindowSurface::QGLWindowSurface(QWidget *window)
+QGLWindowSurface::QGLWindowSurface(QWindow *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
// Q_ASSERT(window->isTopLevel());
@@ -422,6 +450,7 @@ QGLWindowSurface::~QGLWindowSurface()
void QGLWindowSurface::deleted(QObject *object)
{
+#if 0
QWidget *widget = qobject_cast<QWidget *>(object);
if (widget) {
if (widget == window()) {
@@ -444,10 +473,12 @@ void QGLWindowSurface::deleted(QObject *object)
}
#endif
}
+#endif
}
-void QGLWindowSurface::hijackWindow(QWidget *widget)
+void QGLWindowSurface::hijackWindow(QWindow *window)
{
+#if 0
QWidgetPrivate *widgetPrivate = widget->d_func();
widgetPrivate->createExtra();
if (widgetPrivate->extraData()->glContext)
@@ -505,6 +536,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
#ifndef Q_OS_SYMBIAN
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
#endif
+#endif
}
QGLContext *QGLWindowSurface::context() const
@@ -522,8 +554,10 @@ QPaintDevice *QGLWindowSurface::paintDevice()
if (d_ptr->ctx)
return &d_ptr->glDevice;
+#if 0
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
ctx->makeCurrent();
+#endif
Q_ASSERT(d_ptr->fbo);
return d_ptr->fbo;
@@ -594,8 +628,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport,
}
-void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
+void QGLWindowSurface::flush(QWindow *window, const QRegion &rgn, const QPoint &offset)
{
+#if 0
//### Find out why d_ptr->geometry_updated isn't always false.
// flush() should not be called when d_ptr->geometry_updated is true. It assumes that either
// d_ptr->fbo or d_ptr->pb is allocated and has the correct size.
@@ -847,7 +882,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
ctx->swapBuffers();
else
glFlush();
-
+#endif
d_ptr->did_paint = false;
}
@@ -867,6 +902,7 @@ void QGLWindowSurface::resize(const QSize &size)
#endif
void QGLWindowSurface::updateGeometry() {
+#if 0
if (!d_ptr->geometry_updated)
return;
d_ptr->geometry_updated = false;
@@ -1001,6 +1037,7 @@ void QGLWindowSurface::updateGeometry() {
#endif
d_ptr->ctx = ctx;
d_ptr->ctx->d_ptr->internal_context = true;
+#endif
}
bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
@@ -1022,6 +1059,7 @@ bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
+#if 0
// this code randomly fails currently for unknown reasons
return false;
@@ -1050,7 +1088,7 @@ bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
glBindTexture(target, 0);
drawTexture(br.translated(dx, dy), d_ptr->tex_id, window()->size());
-
+#endif
return true;
}
@@ -1115,26 +1153,6 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
#endif
}
-QImage *QGLWindowSurface::buffer(const QWidget *widget)
-{
- QImage image;
-
- if (d_ptr->pb)
- image = d_ptr->pb->toImage();
- else if (d_ptr->fbo)
- image = d_ptr->fbo->toImage();
-
- if (image.isNull())
- return 0;
-
- QRect rect = widget->rect();
- rect.translate(widget->mapTo(widget->window(), QPoint()));
-
- QImage subImage = image.copy(rect);
- d_ptr->buffers << subImage;
- return &d_ptr->buffers.last();
-}
-
QWindowSurface::WindowSurfaceFeatures QGLWindowSurface::features() const
{
WindowSurfaceFeatures features = 0;
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index c71ce59c4d..8dc3a4583a 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QPaintDevice;
class QPoint;
class QRegion;
-class QWidget;
+class QWindow;
struct QGLWindowSurfacePrivate;
Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget();
@@ -84,11 +84,11 @@ class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface /
{
Q_OBJECT
public:
- QGLWindowSurface(QWidget *window);
+ QGLWindowSurface(QWindow *window);
~QGLWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
#if !defined(Q_WS_QPA)
void setGeometry(const QRect &rect);
@@ -102,8 +102,6 @@ public:
void beginPaint(const QRegion &region);
void endPaint(const QRegion &region);
- QImage *buffer(const QWidget *widget);
-
WindowSurfaceFeatures features() const;
QGLContext *context() const;
@@ -117,7 +115,7 @@ private slots:
void deleted(QObject *object);
private:
- void hijackWindow(QWidget *widget);
+ void hijackWindow(QWindow *window);
bool initializeOffscreenTexture(const QSize &size);
QGLWindowSurfacePrivate *d_ptr;
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 80f375c6b2..7aa3b3f1ba 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -95,7 +95,7 @@ QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
QWindowSurface *QXcbIntegration::createWindowSurface(QWindow *window, WId winId) const
{
Q_UNUSED(winId);
- return new QXcbWindowSurface(window->widget());
+ return new QXcbWindowSurface(window);
}
QList<QPlatformScreen *> QXcbIntegration::screens() const
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index fa8ab0aa22..4d420e36a0 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -89,7 +89,6 @@ QXcbWindow::QXcbWindow(QWindow *window)
: QPlatformWindow(window)
, m_context(0)
{
- QWidget *tlw = window->widget();
m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0));
setConnection(m_screen->connection());
@@ -209,6 +208,7 @@ QXcbWindow::QXcbWindow(QWindow *window)
&m_syncCounter));
}
+#if 0
if (tlw && isTransient(tlw) && tlw->parentWidget()) {
// ICCCM 4.1.2.6
QWidget *p = tlw->parentWidget()->window();
@@ -218,6 +218,7 @@ QXcbWindow::QXcbWindow(QWindow *window)
1, &parentWindow));
}
+#endif
// set the PID to let the WM kill the application if unresponsive
long pid = getpid();
@@ -527,6 +528,7 @@ QPlatformGLContext *QXcbWindow::glContext() const
void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
{
+#if 0
QWidget *widget = window()->widget();
if (!widget)
return;
@@ -537,6 +539,7 @@ void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
surface->flush(widget, rect, QPoint());
}
+#endif
}
void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event)
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
index 89e6bd7ed7..a371d2dd06 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
@@ -167,12 +167,12 @@ void QXcbShmImage::preparePaint(const QRegion &region)
}
}
-QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface)
- : QWindowSurface(widget, setDefaultSurface)
+QXcbWindowSurface::QXcbWindowSurface(QWindow *window, bool setDefaultSurface)
+ : QWindowSurface(window, setDefaultSurface)
, m_image(0)
, m_syncingResize(false)
{
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window));
setConnection(screen->connection());
}
@@ -195,7 +195,7 @@ void QXcbWindowSurface::endPaint(const QRegion &)
{
}
-void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QXcbWindowSurface::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
QRect bounds = region.boundingRect();
@@ -204,14 +204,11 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
Q_XCB_NOOP(connection());
- QXcbWindow *window = static_cast<QXcbWindow *>(widget->windowHandle()->handle());
-
- extern QWidgetData* qt_widget_data(QWidget *);
- QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
+ QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle());
QVector<QRect> rects = region.rects();
for (int i = 0; i < rects.size(); ++i)
- m_image->put(window->xcb_window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
+ m_image->put(platformWindow->xcb_window(), rects.at(i).topLeft(), rects.at(i).translated(offset));
Q_XCB_NOOP(connection());
@@ -219,7 +216,7 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
xcb_flush(xcb_connection());
connection()->sync();
m_syncingResize = false;
- window->updateSyncRequestCounter();
+ platformWindow->updateSyncRequestCounter();
}
}
@@ -231,7 +228,7 @@ void QXcbWindowSurface::resize(const QSize &size)
Q_XCB_NOOP(connection());
QWindowSurface::resize(size);
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window()));
delete m_image;
m_image = new QXcbShmImage(screen, size);
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h
index 23d32ef445..60ed7497db 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.h
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h
@@ -53,11 +53,11 @@ class QXcbShmImage;
class QXcbWindowSurface : public QXcbObject, public QWindowSurface
{
public:
- QXcbWindowSurface(QWidget *widget, bool setDefaultSurface = true);
+ QXcbWindowSurface(QWindow *widget, bool setDefaultSurface = true);
~QXcbWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
bool scroll(const QRegion &area, int dx, int dy);