summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-05-04 16:43:45 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-05-04 16:59:33 +0200
commit6229ef2dcec19e28ad0dd5772f2e144523ccf475 (patch)
tree6929cd8608180e26de7bc40b361bb4d007e6804e /src
parentd7b91f613d648cad0883ff4d03c445b4eefebd1e (diff)
Get rid of more QWidget / QApplication dependencies.
Diffstat (limited to 'src')
-rw-r--r--src/gui/guikernel/qguiapplication.cpp7
-rw-r--r--src/gui/guikernel/qguiapplication.h2
-rw-r--r--src/gui/guikernel/qguiapplication_p.h2
-rw-r--r--src/gui/guikernel/qkeymapper.cpp3
-rw-r--r--src/gui/guikernel/qplatformcursor_qpa.cpp2
-rw-r--r--src/gui/guikernel/qplatformintegration_qpa.cpp18
-rw-r--r--src/gui/guikernel/qplatformintegration_qpa.h3
-rw-r--r--src/gui/guikernel/qplatformscreen_qpa.cpp35
-rw-r--r--src/gui/guikernel/qplatformscreen_qpa.h9
-rw-r--r--src/gui/guikernel/qplatformwindow_qpa.cpp28
-rw-r--r--src/gui/guikernel/qwindowdefs.h2
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp11
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp6
14 files changed, 64 insertions, 66 deletions
diff --git a/src/gui/guikernel/qguiapplication.cpp b/src/gui/guikernel/qguiapplication.cpp
index 0962e62e85..d7fe14534f 100644
--- a/src/gui/guikernel/qguiapplication.cpp
+++ b/src/gui/guikernel/qguiapplication.cpp
@@ -105,6 +105,8 @@ QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
#endif
+QWindowList QGuiApplicationPrivate::window_list;
+
Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
QFont *QGuiApplicationPrivate::app_font = 0;
@@ -158,6 +160,11 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
self = this;
}
+QWindowList QGuiApplication::topLevelWindows()
+{
+ return QGuiApplicationPrivate::window_list;
+}
+
static void init_platform(const QString &name, const QString &platformPluginPath)
{
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
diff --git a/src/gui/guikernel/qguiapplication.h b/src/gui/guikernel/qguiapplication.h
index 980e275a61..74c1034baf 100644
--- a/src/gui/guikernel/qguiapplication.h
+++ b/src/gui/guikernel/qguiapplication.h
@@ -78,6 +78,8 @@ public:
QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
virtual ~QGuiApplication();
+ static QWindowList topLevelWindows();
+
#ifndef QT_NO_CURSOR
static QCursor *overrideCursor();
static void setOverrideCursor(const QCursor &);
diff --git a/src/gui/guikernel/qguiapplication_p.h b/src/gui/guikernel/qguiapplication_p.h
index fc6c69748c..505440b66c 100644
--- a/src/gui/guikernel/qguiapplication_p.h
+++ b/src/gui/guikernel/qguiapplication_p.h
@@ -149,6 +149,8 @@ public:
static QClipboard *qt_clipboard;
#endif
+ static QWindowList window_list;
+
#ifndef QT_NO_CURSOR
QList<QCursor> cursor_list;
#endif
diff --git a/src/gui/guikernel/qkeymapper.cpp b/src/gui/guikernel/qkeymapper.cpp
index e6ba3ce142..e38a905ca5 100644
--- a/src/gui/guikernel/qkeymapper.cpp
+++ b/src/gui/guikernel/qkeymapper.cpp
@@ -91,6 +91,8 @@ void QKeyMapper::changeKeyboard()
{
instance()->d_func()->clearMappings();
+ // ## TODO: Support KeyboardLayoutChange on QPA
+#if 0
// inform all toplevel widgets of the change
QEvent e(QEvent::KeyboardLayoutChange);
QWidgetList list = QApplication::topLevelWidgets();
@@ -98,6 +100,7 @@ void QKeyMapper::changeKeyboard()
QWidget *w = list.at(i);
qt_sendSpontaneousEvent(w, &e);
}
+#endif
}
Q_GLOBAL_STATIC(QKeyMapper, keymapper)
diff --git a/src/gui/guikernel/qplatformcursor_qpa.cpp b/src/gui/guikernel/qplatformcursor_qpa.cpp
index 2ea8332ecc..6b4f9152ce 100644
--- a/src/gui/guikernel/qplatformcursor_qpa.cpp
+++ b/src/gui/guikernel/qplatformcursor_qpa.cpp
@@ -43,7 +43,7 @@
#include <QWidget>
#include <QPainter>
#include <QBitmap>
-#include <QApplication>
+#include <QGuiApplication>
#include <QDebug>
diff --git a/src/gui/guikernel/qplatformintegration_qpa.cpp b/src/gui/guikernel/qplatformintegration_qpa.cpp
index 8ff12ebf9c..9967a444c2 100644
--- a/src/gui/guikernel/qplatformintegration_qpa.cpp
+++ b/src/gui/guikernel/qplatformintegration_qpa.cpp
@@ -145,7 +145,7 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
*/
/*!
- \fn QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const
+ \fn QPlatformWindow *createPlatformWindow(QWindow *window, WId winId = 0) const
Factory function for QPlatformWindow. The widget parameter is a pointer to the top level
widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually
@@ -158,27 +158,27 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
created.
\sa QPlatformWindow, QPlatformWindowFormat
- \sa createWindowSurface(QWidget *widget, WId winId) const
+ \sa createWindowSurface(QWindow *window, WId winId) const
*/
/*!
- \fn QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const
+ \fn QWindowSurface *createWindowSurface(QWindow *window, WId winId) const
- Factory function for QWindowSurface. The QWidget parameter is a pointer to the
+ Factory function for QWindowSurface. The QWindow parameter is a pointer to the
top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
before the QWindowSurface for tlw where the widget also requires a WindowSurface. It is
- possible to create top level QWidgets without a QWindowSurface by specifying
+ possible to create top level QWindow without a QWindowSurface by specifying
QPlatformWindowFormat::setWindowSurface(false) for the tlw QPlatformWindowFormat.
\sa QWindowSurface
- \sa createPlatformWindow(QWidget *widget, WId winId = 0) const
+ \sa createPlatformWindow(QWindow *window, WId winId = 0) const
*/
/*!
- \fn void moveToScreen(QWidget *window, int screen)
+ \fn void moveToScreen(QWindow *window, int screen)
- This function is called when a QWidget is displayed on screen, or the QWidget is to be
- displayed on a new screen. The QWidget parameter is a pointer to the top level widget and
+ This function is called when a QWindow is displayed on screen, or the QWindow is to be
+ displayed on a new screen. The QWindow parameter is a pointer to the top level widget and
the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.
Default implementation does nothing.
diff --git a/src/gui/guikernel/qplatformintegration_qpa.h b/src/gui/guikernel/qplatformintegration_qpa.h
index 43080d297a..eb29a4bd0d 100644
--- a/src/gui/guikernel/qplatformintegration_qpa.h
+++ b/src/gui/guikernel/qplatformintegration_qpa.h
@@ -56,7 +56,6 @@ QT_MODULE(Gui)
class QPlatformWindow;
class QWindow;
class QBlittable;
-class QWidget;
class QPlatformEventLoopIntegration;
class QPlatformFontDatabase;
class QPlatformClipboard;
@@ -82,7 +81,7 @@ public:
// Window System functions
virtual QList<QPlatformScreen *> screens() const = 0;
- virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
+ virtual void moveToScreen(QWindow *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
virtual bool isVirtualDesktop() { return false; }
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
diff --git a/src/gui/guikernel/qplatformscreen_qpa.cpp b/src/gui/guikernel/qplatformscreen_qpa.cpp
index 8b686781ab..8759aa4a88 100644
--- a/src/gui/guikernel/qplatformscreen_qpa.cpp
+++ b/src/gui/guikernel/qplatformscreen_qpa.cpp
@@ -40,26 +40,23 @@
****************************************************************************/
#include "qplatformscreen_qpa.h"
-#include <QtGui/qapplication.h>
-#include <QtGui/private/qapplication_p.h>
-#include <QtGui/qdesktopwidget.h>
+#include <QtGui/qguiapplication.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qplatformintegration_qpa.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/private/qwidget_p.h>
+#include <QtGui/qwindow.h>
/*!
- Return the given top level widget for a given position.
+ Return the given top level window for a given position.
- Default implementation retrieves a list of all top level widgets and finds the first widget
+ Default implementation retrieves a list of all top level windows and finds the first window
which contains point \a pos
*/
-QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const
+QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
{
- QWidgetList list = QApplication::topLevelWidgets();
+ QWindowList list = QGuiApplication::topLevelWindows();
for (int i = list.size()-1; i >= 0; --i) {
- QWidget *w = list[i];
- //### mask is ignored
- if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos))
+ QWindow *w = list[i];
+ if (w->visible() && w->geometry().contains(pos))
return w;
}
@@ -81,20 +78,6 @@ QSize QPlatformScreen::physicalSize() const
return QSize(width,height);
}
-Q_GUI_EXPORT extern QWidgetPrivate *qt_widget_private(QWidget *widget);
-QPlatformScreen * QPlatformScreen::platformScreenForWidget(const QWidget *widget)
-{
- int screenIndex = 0;
- QWidget *window = widget->window();
- QWidgetPrivate *windowPrivate = qt_widget_private(window);
- QTLWExtra * topData = windowPrivate->maybeTopData();
- if (topData)
- screenIndex = topData->screenIndex;
- QPlatformIntegration *integration =
- QGuiApplicationPrivate::platformIntegration();
- return integration->screens()[screenIndex];
-}
-
QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *)
{
return QGuiApplicationPrivate::platformIntegration()->screens().at(0);
diff --git a/src/gui/guikernel/qplatformscreen_qpa.h b/src/gui/guikernel/qplatformscreen_qpa.h
index cbaf5b9c47..9492788b4f 100644
--- a/src/gui/guikernel/qplatformscreen_qpa.h
+++ b/src/gui/guikernel/qplatformscreen_qpa.h
@@ -51,7 +51,7 @@
#include <QtGui/qcursor.h>
#include <QtGui/qimage.h>
-#include <QtGui/qwidget.h>
+#include <QtGui/qwindowdefs.h>
QT_BEGIN_HEADER
@@ -72,13 +72,10 @@ public:
virtual QSize physicalSize() const;
//jl: should setDirty be removed.
virtual void setDirty(const QRect &) {}
- virtual QWidget *topLevelAt(const QPoint &point) const;
+ virtual QWindow *topLevelAt(const QPoint &point) const;
//jl: should this function be in QPlatformIntegration
- //jl: maybe screenForWidget is a better name?
- static QPlatformScreen *platformScreenForWidget(const QWidget *widget);
-
- // temporary convenience
+ //jl: maybe screenForWindow is a better name?
static QPlatformScreen *platformScreenForWindow(const QWindow *window);
};
diff --git a/src/gui/guikernel/qplatformwindow_qpa.cpp b/src/gui/guikernel/qplatformwindow_qpa.cpp
index 7ec5221840..24c337cf57 100644
--- a/src/gui/guikernel/qplatformwindow_qpa.cpp
+++ b/src/gui/guikernel/qplatformwindow_qpa.cpp
@@ -42,7 +42,7 @@
#include "qplatformwindow_qpa.h"
#include <QtGui/qwindowsysteminterface_qpa.h>
-#include <QtGui/qwidget.h>
+#include <QtGui/qwindow.h>
class QPlatformWindowPrivate
{
@@ -52,7 +52,7 @@ class QPlatformWindowPrivate
};
/*!
- Constructs a platform window with the given top level widget.
+ Constructs a platform window with the given top level window.
*/
QPlatformWindow::QPlatformWindow(QWindow *window)
@@ -63,14 +63,14 @@ QPlatformWindow::QPlatformWindow(QWindow *window)
}
/*!
- Virtual destructor does not delete its top level widget.
+ Virtual destructor does not delete its top level window.
*/
QPlatformWindow::~QPlatformWindow()
{
}
/*!
- Returnes the widget which belongs to the QPlatformWindow
+ Returnes the window which belongs to the QPlatformWindow
*/
QWindow *QPlatformWindow::window() const
{
@@ -82,7 +82,7 @@ QWindow *QPlatformWindow::window() const
This function is called by Qt whenever a window is moved or the window is resized. The resize
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(QWidget *w, const QRect &newRect);
+ call QWindowSystemInterface::handleGeometryChange(QWindow *w, const QRect &newRect);
*/
void QPlatformWindow::setGeometry(const QRect &rect)
{
@@ -122,7 +122,7 @@ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
WId QPlatformWindow::winId() const { return WId(0); }
/*!
- This function is called to enable native child widgets in QPA. It is common not to support this
+ This function is called to enable native child window in QPA. It is common not to support this
feature in Window systems, but can be faked. When this function is called all geometry of this
platform window will be relative to the parent.
*/
@@ -162,14 +162,14 @@ void QPlatformWindow::setOpacity(qreal level)
Reimplement to let Qt be able to request activation/focus for a window
Some window systems will probably not have callbacks for this functionality,
- and then calling QWindowSystemInterface::handleWindowActivated(QWidget *w)
+ and then calling QWindowSystemInterface::handleWindowActivated(QWindow *w)
would be sufficient.
If the window system has some event handling/callbacks then call
- QWindowSystemInterface::handleWindowActivated(QWidget *w) when the window system
+ QWindowSystemInterface::handleWindowActivated(QWindow *w) when the window system
gives the notification.
- Default implementation calls QWindowSystem::handleWindowActivated(QWidget *w)
+ Default implementation calls QWindowSystem::handleWindowActivated(QWindow *w)
*/
void QPlatformWindow::requestActivateWindow()
{
@@ -193,16 +193,16 @@ QPlatformGLContext *QPlatformWindow::glContext() const
\brief The QPlatformWindow class provides an abstraction for top-level windows.
- The QPlatformWindow abstraction is used by QWidget for all its top level widgets. It is being
+ The QPlatformWindow abstraction is used by QWindow for all its top level windows. It is being
created by calling the createPlatformWindow function in the loaded QPlatformIntegration
instance.
QPlatformWindow is used to signal to the windowing system, how Qt persieves its frame.
However, it is not concerned with how Qt renders into the window it represents.
- Top level QWidgets(tlw) will always have a QPlatformWindow. However, it is not necessary for
- all tlw to have a QWindowSurface. This is the case for QGLWidget. And could be the case for
- widgets where some 3.party renders into it.
+ Visible QWindows will always have a QPlatformWindow. However, it is not necessary for
+ all windows to have a QWindowSurface. This is the case for QGLWidget. And could be the case for
+ windows where some 3.party renders into it.
The platform specific window handle can be retrieved by the winId function.
@@ -212,5 +212,5 @@ QPlatformGLContext *QPlatformWindow::glContext() const
The only way to retrieve a QPlatformGLContext in QPA is by calling the glContext() function
on QPlatformWindow.
- \sa QWindowSurface, QWidget
+ \sa QWindowSurface, QWindow
*/
diff --git a/src/gui/guikernel/qwindowdefs.h b/src/gui/guikernel/qwindowdefs.h
index dd6d13a338..b9fea38da8 100644
--- a/src/gui/guikernel/qwindowdefs.h
+++ b/src/gui/guikernel/qwindowdefs.h
@@ -54,6 +54,7 @@ QT_MODULE(Gui)
class QPaintDevice;
class QWidget;
+class QWindow;
class QDialog;
class QColor;
class QPalette;
@@ -85,6 +86,7 @@ class QApplication;
template<typename T> class QList;
typedef QList<QWidget *> QWidgetList;
+typedef QList<QWindow *> QWindowList;
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
index e1876e41a9..f3e033c787 100644
--- a/src/gui/kernel/qapplication_qpa.cpp
+++ b/src/gui/kernel/qapplication_qpa.cpp
@@ -65,6 +65,7 @@
#include <QPlatformIntegration>
#include "qdesktopwidget_qpa_p.h"
+#include "qwidgetwindow_qpa_p.h"
QT_BEGIN_NAMESPACE
@@ -343,13 +344,15 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
// The first screen in a virtual environment should know about all top levels
if (pi->isVirtualDesktop()) {
- QWidget *w = (*screen)->topLevelAt(pos);
- return w;
+ QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->topLevelAt(pos));
+ return w ? w->widget() : 0;
}
while (screen != end) {
- if ((*screen)->geometry().contains(pos))
- return (*screen)->topLevelAt(pos);
+ if ((*screen)->geometry().contains(pos)) {
+ QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->topLevelAt(pos));
+ return w ? w->widget() : 0;
+ }
++screen;
}
return 0;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 0c9e523951..b6e6a56f4a 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1302,7 +1302,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (desktopWidget) {
int screen = desktopWidget->d_func()->topData()->screenIndex;
QPlatformIntegration *platform = QGuiApplicationPrivate::platformIntegration();
- platform->moveToScreen(q, screen);
+ platform->moveToScreen(q->windowHandle(), screen);
}
#else
Q_UNUSED(desktopWidget);
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
index 5ef3b8960e..d239e6d652 100644
--- a/src/gui/kernel/qwidget_qpa.cpp
+++ b/src/gui/kernel/qwidget_qpa.cpp
@@ -119,7 +119,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
// first check children. and create them if necessary
// q_createNativeChildrenAndSetParent(q->windowHandle(),q);
- QGuiApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex);
+ QGuiApplicationPrivate::platformIntegration()->moveToScreen(win, topData()->screenIndex);
// qDebug() << "create_sys" << q << q->internalWinId();
}
@@ -216,7 +216,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
// only if it is already created
if (q->testAttribute(Qt::WA_WState_Created)) {
QPlatformIntegration *platform = QGuiApplicationPrivate::platformIntegration();
- platform->moveToScreen(q, targetScreen);
+ platform->moveToScreen(q->windowHandle(), targetScreen);
}
}
}
@@ -638,7 +638,7 @@ int QWidget::metric(PaintDeviceMetric m) const
{
Q_D(const QWidget);
- QPlatformScreen *screen = QPlatformScreen::platformScreenForWidget(this);
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(windowHandle());
if (!screen) {
if (m == PdmDpiX || m == PdmDpiY)
return 72;