QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
#endif
+QWindowList QGuiApplicationPrivate::window_list;
+
Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
QFont *QGuiApplicationPrivate::app_font = 0;
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);
QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
virtual ~QGuiApplication();
+ static QWindowList topLevelWindows();
+
#ifndef QT_NO_CURSOR
static QCursor *overrideCursor();
static void setOverrideCursor(const QCursor &);
static QClipboard *qt_clipboard;
#endif
+ static QWindowList window_list;
+
#ifndef QT_NO_CURSOR
QList<QCursor> cursor_list;
#endif
{
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();
QWidget *w = list.at(i);
qt_sendSpontaneousEvent(w, &e);
}
+#endif
}
Q_GLOBAL_STATIC(QKeyMapper, keymapper)
#include <QWidget>
#include <QPainter>
#include <QBitmap>
-#include <QApplication>
+#include <QGuiApplication>
#include <QDebug>
*/
/*!
- \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
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.
class QPlatformWindow;
class QWindow;
class QBlittable;
-class QWidget;
class QPlatformEventLoopIntegration;
class QPlatformFontDatabase;
class QPlatformClipboard;
// 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;
****************************************************************************/
#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;
}
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);
#include <QtGui/qcursor.h>
#include <QtGui/qimage.h>
-#include <QtGui/qwidget.h>
+#include <QtGui/qwindowdefs.h>
QT_BEGIN_HEADER
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);
};
#include "qplatformwindow_qpa.h"
#include <QtGui/qwindowsysteminterface_qpa.h>
-#include <QtGui/qwidget.h>
+#include <QtGui/qwindow.h>
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)
}
/*!
- 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
{
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)
{
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.
*/
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()
{
\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.
The only way to retrieve a QPlatformGLContext in QPA is by calling the glContext() function
on QPlatformWindow.
- \sa QWindowSurface, QWidget
+ \sa QWindowSurface, QWindow
*/
class QPaintDevice;
class QWidget;
+class QWindow;
class QDialog;
class QColor;
class QPalette;
template<typename T> class QList;
typedef QList<QWidget *> QWidgetList;
+typedef QList<QWindow *> QWindowList;
QT_END_NAMESPACE
QT_END_HEADER
#include <QPlatformIntegration>
#include "qdesktopwidget_qpa_p.h"
+#include "qwidgetwindow_qpa_p.h"
QT_BEGIN_NAMESPACE
// 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;
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);
// 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();
}
// 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);
}
}
}
{
Q_D(const QWidget);
- QPlatformScreen *screen = QPlatformScreen::platformScreenForWidget(this);
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(windowHandle());
if (!screen) {
if (m == PdmDpiX || m == PdmDpiY)
return 72;