42 #include "QtGui/qwidget.h" 43 #include "QtGui/qevent.h" 44 #include "QtGui/qapplication.h" 45 #include "QtGui/private/qbackingstore_p.h" 46 #include "QtGui/private/qwidget_p.h" 47 #include "QtGui/private/qgraphicssystem_p.h" 48 #include "QtGui/private/qapplication_p.h" 49 #include "QtGui/qdesktopwidget.h" 50 #include "QtGui/qplatformwindow_qpa.h" 51 #include "QtGui/qplatformglcontext_qpa.h" 53 #include <QtGui/QPlatformCursor> 60 for (
int i = 0; i < children.
size(); i++) {
65 if (!childWidget->platformWindow())
68 if (childWidget->platformWindow()) {
69 childWidget->platformWindow()->
setParent(parentWindow);
95 if (!platformWindow) {
96 platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q);
101 if (platformWindow && q->platformWindowFormat().hasWindowSurface()) {
102 surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->
winId());
110 setWinId(q->platformWindow()->winId());
116 if (!q->isWindow()) {
118 if (nativeParent->platformWindow()) {
119 platformWindow->
setParent(nativeParent->platformWindow());
124 QApplicationPrivate::platformIntegration()->moveToScreen(q,
topData()->screenIndex);
134 parentWidget()->d_func()->invalidateBuffer(
d->effectiveRectFor(geometry()));
135 d->deactivateWidgetCleanup();
138 qApp->d_func()->closePopup(
this);
147 if (destroySubWindows) {
149 for (
int i = 0; i < childList.
size(); i++) {
152 if (widget->platformWindow()) {
159 d->deleteTLSysExtra();
176 int targetScreen = -1;
183 targetScreen = newparent->
window()->d_func()->topData()->screenIndex;
187 if (
parent != newparent) {
189 if (q->platformWindow() && newparent) {
191 if (parentWithWindow && parentWithWindow->platformWindow()) {
192 q->platformWindow()->
setParent(parentWithWindow->platformWindow());
200 if (targetScreen == -1) {
202 targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
219 if (f & Qt::Window) {
225 if (q->isWindow() || (!newparent || newparent->
isVisible()) || explicitlyHidden)
230 if (!newparent && targetScreen != -1) {
243 int x=pos.
x(), y=pos.
y();
255 int x=pos.
x(), y=pos.
y();
283 void QWidgetPrivate::updateCursor()
const 288 #endif //QT_NO_CURSOR 297 window->setWindowTitle(caption);
344 if (qt_mouseGrb ==
this) {
362 if (keyboardGrb ==
this) {
383 if (platformWindow())
384 platformWindow()->requestActivateWindow();
400 QRect geomRect = q->geometry();
401 if (!q->isWindow()) {
402 QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),
QPoint());
406 if (windowRect != geomRect) {
410 if (windowRect.
size() != geomRect.
size()) {
411 surface->resize(geomRect.
size());
425 if (!q->isWindow()) {
432 window->setVisible(
false);
441 void QWidgetPrivate::setMaxWindowState_helper()
448 const QRect desktop =
qApp->desktop()->availableGeometry(
qApp->desktop()->screenNumber(q));
449 q->setGeometry(desktop);
454 void QWidgetPrivate::setFullScreenSize_helper()
461 const QRect screen =
qApp->desktop()->screenGeometry(
qApp->desktop()->screenNumber(q));
463 q->setFixedSize(screen.
size());
482 Qt::WindowStates
oldstate = windowState();
483 if (oldstate == newstate)
490 bool needShow =
false;
493 if (isWindow() && newEffectiveState != oldEffectiveState) {
496 d->topData()->normalGeometry = geometry();
498 setParent(0,
d->topData()->savedFlags);
509 d->topData()->savedFlags = windowFlags();
511 d->setFullScreenSize_helper();
516 d->setMaxWindowState_helper();
518 QRect r =
d->topData()->normalGeometry;
519 if (r.
width() >= 0) {
520 d->topData()->normalGeometry =
QRect(0,0,-1,-1);
546 q->platformWindow()->raise();
555 q->platformWindow()->lower();
581 QPoint oldp = q->geometry().topLeft();
582 QSize olds = q->size();
585 bool isResize = olds != r.
size();
604 if (q->isVisible()) {
605 if (q->platformWindow()) {
607 q->platformWindow()->setGeometry(q->geometry());
609 QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),
QPoint());
610 q->platformWindow()->setGeometry(
QRect(posInNativeParent,r.
size()));
618 if (isMove && !isResize)
631 if (q->platformWindow())
635 if (isMove && q->pos() != oldPos)
665 if (m == PdmDpiX || m == PdmDpiY)
672 }
else if (m == PdmWidthMM) {
674 }
else if (m == PdmHeight) {
676 }
else if (m == PdmHeightMM) {
678 }
else if (m == PdmDepth) {
679 return screen->
depth();
680 }
else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
681 if (
d->extra &&
d->extra->customDpiX)
682 return d->extra->customDpiX;
684 return static_cast<QWidget *
>(
d->parent)->metric(m);
686 }
else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
687 if (
d->extra &&
d->extra->customDpiY)
688 return d->extra->customDpiY;
690 return static_cast<QWidget *
>(
d->parent)->metric(m);
715 if (topData->platformWindow == window)
718 delete topData->platformWindow;
719 topData->platformWindow =
window;
735 if (extra && extra->platformWindow)
736 return extra->platformWindow;
754 topData->platformWindowFormat =
format;
758 d->create_sys(0,
true,
true);
760 topData->platformWindow->setVisible(
true);
781 format = extra->platformWindowFormat;
814 context->deleteQGLContext();
842 q->platformWindow()->setOpacity(level);
845 void QWidgetPrivate::setWSGeometry(
bool dontShow,
const QRect &oldRect)
854 qWarning(
"QWidget::paintEngine: Should no longer be called");
861 if (q->platformWindowFormat().hasWindowSurface())
862 return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0);
879 if (
override && w != 0)
888 cursorCursor = *
override;
902 cursorCursor = arrowCursor;
916 cursorCursor = w->
cursor();
923 #endif //QT_NO_CURSOR
T qobject_cast(QObject *object)
The QCursor class provides a mouse cursor with an arbitrary shape.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
int width() const
Returns the width of the rectangle.
static QWidget * active_window
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
void setParent_helper(QObject *)
int width() const
Returns the width.
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QMoveEvent class contains event parameters for move events.
QSize size() const
Returns the size of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
The QResizeEvent class contains event parameters for resize events.
Q_CORE_EXPORT void qWarning(const char *,...)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QRegion class specifies a clip region for a painter.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
The QWindowSurface class provides the drawing area for top-level windows.
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
static QWidget * parentWidget(const QWidget *w)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
The QPlatformGLContext class provides an abstraction for native GL contexts.
The QWindowStateChangeEvent class provides the window state before a window state change...
int y() const
Returns the y-coordinate of the rectangle's top edge.
int x() const
Returns the x-coordinate of the rectangle's left edge.
The QPoint class defines a point in the plane using integer precision.
int size() const
Returns the number of items in the list.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
const QObjectList & children() const
Returns a list of child objects.
virtual int metric(PaintDeviceMetric metric) const
int y() const
Returns the y coordinate of this point.
The QSize class defines the size of a two-dimensional object using integer point precision.
int x() const
Returns the x coordinate of this point.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Q_DECL_CONSTEXPR int qRound(qreal d)
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
The QWeakPointer class holds a weak reference to a shared pointer.
static Qt::KeyboardModifiers oldstate
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.