Qt 4.8
qwidget_qpa.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
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"
52 
53 #include <QtGui/QPlatformCursor>
54 
56 
58 {
59  QObjectList children = parentWidget->children();
60  for (int i = 0; i < children.size(); i++) {
61  if (children.at(i)->isWidgetType()) {
62  const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i));
63  if (childWidget) { // should not be necessary
64  if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
65  if (!childWidget->platformWindow())
66  childWidget->winId();
67  }
68  if (childWidget->platformWindow()) {
69  childWidget->platformWindow()->setParent(parentWindow);
70  } else {
71  q_createNativeChildrenAndSetParent(parentWindow,childWidget);
72  }
73  }
74  }
75  }
76 
77 }
78 
79 void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
80 {
81  Q_Q(QWidget);
82 
84  Q_UNUSED(initializeWindow);
85  Q_UNUSED(destroyOldWindow);
86 
87  Qt::WindowFlags flags = data.window_flags;
88 
89  if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop )
90  return; // we only care about real toplevels
91 
92  QWindowSurface *surface = q->windowSurface();
93  QPlatformWindow *platformWindow = q->platformWindow();
94 
95  if (!platformWindow) {
96  platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q);
97  }
98  Q_ASSERT(platformWindow);
99 
100  if (!surface ) {
101  if (platformWindow && q->platformWindowFormat().hasWindowSurface()) {
102  surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId());
103  } else {
104  q->setAttribute(Qt::WA_PaintOnScreen,true);
105  }
106  }
107 
108  data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags);
109 
110  setWinId(q->platformWindow()->winId());
111 
112  //first check children. and create them if necessary
113  q_createNativeChildrenAndSetParent(q->platformWindow(),q);
114 
115  //if we we have a parent, then set correct parent;
116  if (!q->isWindow()) {
117  if (QWidget *nativeParent = q->nativeParentWidget()) {
118  if (nativeParent->platformWindow()) {
119  platformWindow->setParent(nativeParent->platformWindow());
120  }
121  }
122  }
123 
124  QApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex);
125 // qDebug() << "create_sys" << q << q->internalWinId();
126 }
127 
128 void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
129 {
130  Q_D(QWidget);
131 
132  d->aboutToDestroy();
133  if (!isWindow() && parentWidget())
134  parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
135  d->deactivateWidgetCleanup();
136 
137  if ((windowType() == Qt::Popup))
138  qApp->d_func()->closePopup(this);
139 
140  //### we don't have proper focus event handling yet
143 
144  setAttribute(Qt::WA_WState_Created, false);
145 
146  if (windowType() != Qt::Desktop) {
147  if (destroySubWindows) {
148  QObjectList childList(children());
149  for (int i = 0; i < childList.size(); i++) {
150  QWidget *widget = qobject_cast<QWidget *>(childList.at(i));
151  if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
152  if (widget->platformWindow()) {
153  widget->destroy();
154  }
155  }
156  }
157  }
158  if (destroyWindow) {
159  d->deleteTLSysExtra();
160  } else {
161  if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
162  d->hide_sys();
163  }
164  }
165 
166  d->setWinId(0);
167  }
168 }
169 
170 void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
171 {
172  Q_Q(QWidget);
173 
174  Qt::WindowFlags oldFlags = data.window_flags;
175 
176  int targetScreen = -1;
177  // Handle a request to move the widget to a particular screen
178  if (newparent && newparent->windowType() == Qt::Desktop) {
179  // make sure the widget is created on the same screen as the
180  // programmer specified desktop widget
181 
182  // get the desktop's screen number
183  targetScreen = newparent->window()->d_func()->topData()->screenIndex;
184  newparent = 0;
185  }
186 
187  if (parent != newparent) {
188  QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
189  if (q->platformWindow() && newparent) {
190  QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget();
191  if (parentWithWindow && parentWithWindow->platformWindow()) {
192  q->platformWindow()->setParent(parentWithWindow->platformWindow());
193  }
194  }
195 
196  }
197 
198  if (!newparent) {
199  f |= Qt::Window;
200  if (targetScreen == -1) {
201  if (parent)
202  targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
203  }
204  }
205 
206  bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
207 
208  // Reparenting toplevel to child
209  if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
210  //qDebug() << "setParent_sys() change from toplevel";
211  q->destroy();
212  }
213 
214  data.window_flags = f;
215  q->setAttribute(Qt::WA_WState_Created, false);
216  q->setAttribute(Qt::WA_WState_Visible, false);
217  q->setAttribute(Qt::WA_WState_Hidden, false);
218 
219  if (f & Qt::Window) {
220  //qDebug() << "setParent_sys" << q << newparent << hex << f;
221  if (QPlatformWindow *window = q->platformWindow())
222  data.window_flags = window->setWindowFlags(data.window_flags);
223  }
224 
225  if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
226  q->setAttribute(Qt::WA_WState_Hidden);
227  q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
228 
229  // move the window to the selected screen
230  if (!newparent && targetScreen != -1) {
231  if (maybeTopData())
232  maybeTopData()->screenIndex = targetScreen;
233  // only if it is already created
234  if (q->testAttribute(Qt::WA_WState_Created)) {
235  QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
236  platform->moveToScreen(q, targetScreen);
237  }
238  }
239 }
240 
241 QPoint QWidget::mapToGlobal(const QPoint &pos) const
242 {
243  int x=pos.x(), y=pos.y();
244  const QWidget* w = this;
245  while (w) {
246  x += w->data->crect.x();
247  y += w->data->crect.y();
248  w = w->isWindow() ? 0 : w->parentWidget();
249  }
250  return QPoint(x, y);
251 }
252 
253 QPoint QWidget::mapFromGlobal(const QPoint &pos) const
254 {
255  int x=pos.x(), y=pos.y();
256  const QWidget* w = this;
257  while (w) {
258  x -= w->data->crect.x();
259  y -= w->data->crect.y();
260  w = w->isWindow() ? 0 : w->parentWidget();
261  }
262  return QPoint(x, y);
263 }
264 
266 
267 #ifndef QT_NO_CURSOR
268 void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
269 {
270  Q_UNUSED(cursor);
271  Q_Q(QWidget);
272  if (q->isVisible())
273  qt_qpa_set_cursor(q, false);
274 }
275 
277 {
278  Q_Q(QWidget);
279  if (q->isVisible())
280  qt_qpa_set_cursor(q, false);
281 }
282 
283 void QWidgetPrivate::updateCursor() const
284 {
285  // XXX
286 }
287 
288 #endif //QT_NO_CURSOR
289 
290 void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
291 {
292  Q_Q(QWidget);
293  if (!q->isWindow())
294  return;
295 
296  if (QPlatformWindow *window = q->platformWindow())
297  window->setWindowTitle(caption);
298 
299 }
300 
301 void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
302 {
303 }
304 
306 {
307  Q_UNUSED(iconText);
308 }
309 
312 static QWidget *keyboardGrb = 0;
313 
314 void QWidget::grabMouse()
315 {
316  if (qt_mouseGrb)
317  qt_mouseGrb->releaseMouse();
318 
319  // XXX
320  //qwsDisplay()->grabMouse(this,true);
321 
322  qt_mouseGrb = this;
323  qt_pressGrab = 0;
324 }
325 
326 #ifndef QT_NO_CURSOR
327 void QWidget::grabMouse(const QCursor &cursor)
328 {
329  Q_UNUSED(cursor);
330 
331  if (qt_mouseGrb)
332  qt_mouseGrb->releaseMouse();
333 
334  // XXX
335  //qwsDisplay()->grabMouse(this,true);
336  //qwsDisplay()->selectCursor(this, cursor.handle());
337  qt_mouseGrb = this;
338  qt_pressGrab = 0;
339 }
340 #endif
341 
343 {
344  if (qt_mouseGrb == this) {
345  // XXX
346  //qwsDisplay()->grabMouse(this,false);
347  qt_mouseGrb = 0;
348  }
349 }
350 
352 {
353  if (keyboardGrb)
354  keyboardGrb->releaseKeyboard();
355  // XXX
356  //qwsDisplay()->grabKeyboard(this, true);
357  keyboardGrb = this;
358 }
359 
361 {
362  if (keyboardGrb == this) {
363  // XXX
364  //qwsDisplay()->grabKeyboard(this, false);
365  keyboardGrb = 0;
366  }
367 }
368 
370 {
371  if (qt_mouseGrb)
372  return qt_mouseGrb;
373  return qt_pressGrab;
374 }
375 
377 {
378  return keyboardGrb;
379 }
380 
382 {
383  if (platformWindow())
384  platformWindow()->requestActivateWindow();
385 }
386 
388 {
389  Q_Q(QWidget);
390  q->setAttribute(Qt::WA_Mapped);
391  if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
392  invalidateBuffer(q->rect());
393  return;
394  }
395 
396  QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
397 
398  QPlatformWindow *window = q->platformWindow();
399  if (window) {
400  QRect geomRect = q->geometry();
401  if (!q->isWindow()) {
402  QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
403  geomRect.moveTopLeft(topLeftOfWindow);
404  }
405  const QRect windowRect = window->geometry();
406  if (windowRect != geomRect) {
407  window->setGeometry(geomRect);
408  }
409  if (QWindowSurface *surface = q->windowSurface()) {
410  if (windowRect.size() != geomRect.size()) {
411  surface->resize(geomRect.size());
412  }
413  }
414  if (window)
415  window->setVisible(true);
416  }
417 }
418 
419 
421 {
422  Q_Q(QWidget);
423  q->setAttribute(Qt::WA_Mapped, false);
425  if (!q->isWindow()) {
426  QWidget *p = q->parentWidget();
427  if (p &&p->isVisible()) {
428  invalidateBuffer(q->rect());
429  }
430  }
431  if (QPlatformWindow *window = q->platformWindow()) {
432  window->setVisible(false);
433  }
434 
435  //### we don't yet have proper focus event handling
438 
439 }
440 
441 void QWidgetPrivate::setMaxWindowState_helper()
442 {
443  Q_Q(QWidget);
444 
445  const uint old_state = data.in_set_window_state;
447 
448  const QRect desktop = qApp->desktop()->availableGeometry(qApp->desktop()->screenNumber(q));
449  q->setGeometry(desktop);
450 
451  data.in_set_window_state = old_state;
452 }
453 
454 void QWidgetPrivate::setFullScreenSize_helper()
455 {
456  Q_Q(QWidget);
457 
458  const uint old_state = data.in_set_window_state;
460 
461  const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
462  q->move(screen.topLeft());
463  q->setFixedSize(screen.size());
464 
465  data.in_set_window_state = old_state;
466 }
467 
468 static Qt::WindowStates effectiveState(Qt::WindowStates state)
469  {
470  if (state & Qt::WindowMinimized)
471  return Qt::WindowMinimized;
472  else if (state & Qt::WindowFullScreen)
473  return Qt::WindowFullScreen;
474  else if (state & Qt::WindowMaximized)
475  return Qt::WindowMaximized;
476  return Qt::WindowNoState;
477  }
478 
479 void QWidget::setWindowState(Qt::WindowStates newstate)
480 {
481  Q_D(QWidget);
482  Qt::WindowStates oldstate = windowState();
483  if (oldstate == newstate)
484  return;
485  if (isWindow() && !testAttribute(Qt::WA_WState_Created))
486  create();
487 
488  data->window_state = newstate;
490  bool needShow = false;
491  Qt::WindowStates newEffectiveState = effectiveState(newstate);
492  Qt::WindowStates oldEffectiveState = effectiveState(oldstate);
493  if (isWindow() && newEffectiveState != oldEffectiveState) {
494  d->createTLExtra();
495  if (oldEffectiveState == Qt::WindowNoState) { //normal
496  d->topData()->normalGeometry = geometry();
497  } else if (oldEffectiveState == Qt::WindowFullScreen) {
498  setParent(0, d->topData()->savedFlags);
499  needShow = true;
500  } else if (oldEffectiveState == Qt::WindowMinimized) {
501  needShow = true;
502  }
503 
504  if (newEffectiveState == Qt::WindowMinimized) {
505  //### not ideal...
506  hide();
507  needShow = false;
508  } else if (newEffectiveState == Qt::WindowFullScreen) {
509  d->topData()->savedFlags = windowFlags();
510  setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
511  d->setFullScreenSize_helper();
512  raise();
513  needShow = true;
514  } else if (newEffectiveState == Qt::WindowMaximized) {
515  createWinId();
516  d->setMaxWindowState_helper();
517  } else { //normal
518  QRect r = d->topData()->normalGeometry;
519  if (r.width() >= 0) {
520  d->topData()->normalGeometry = QRect(0,0,-1,-1);
521  setGeometry(r);
522  }
523  }
524  }
526 
527  if (needShow)
528  show();
529 
530  if (newstate & Qt::WindowActive)
531  activateWindow();
532 
533  QWindowStateChangeEvent e(oldstate);
534  QApplication::sendEvent(this, &e);
535 }
536 
538 {
539 
540 }
541 
543 {
544  Q_Q(QWidget);
545  if (q->isWindow()) {
546  q->platformWindow()->raise();
547  }
548 }
549 
551 {
552  Q_Q(QWidget);
553  if (q->isWindow()) {
554  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
555  q->platformWindow()->lower();
556  } else if (QWidget *p = q->parentWidget()) {
558  p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
559  }
560 }
561 
563 {
564  Q_Q(QWidget);
565  if (QWidget *p = q->parentWidget()) {
567  p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
568  }
569 }
570 
571 void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
572 {
573  Q_Q(QWidget);
574  if (extra) { // any size restrictions?
575  w = qMin(w,extra->maxw);
576  h = qMin(h,extra->maxh);
577  w = qMax(w,extra->minw);
578  h = qMax(h,extra->minh);
579  }
580 
581  QPoint oldp = q->geometry().topLeft();
582  QSize olds = q->size();
583  QRect r(x, y, w, h);
584 
585  bool isResize = olds != r.size();
586  isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
587 
588 
589  // We only care about stuff that changes the geometry, or may
590  // cause the window manager to change its state
591  if (r.size() == olds && oldp == r.topLeft())
592  return;
593 
594  if (!data.in_set_window_state) {
595  q->data->window_state &= ~Qt::WindowMaximized;
596  q->data->window_state &= ~Qt::WindowFullScreen;
597  if (q->isWindow())
598  topData()->normalGeometry = QRect(0, 0, -1, -1);
599  }
600 
601  QPoint oldPos = q->pos();
602  data.crect = r;
603 
604  if (q->isVisible()) {
605  if (q->platformWindow()) {
606  if (q->isWindow()) {
607  q->platformWindow()->setGeometry(q->geometry());
608  } else {
609  QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
610  q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size()));
611  }
613  if (bs->windowSurface) {
614  if (isResize)
615  bs->windowSurface->resize(r.size());
616  }
617  } else {
618  if (isMove && !isResize)
619  moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
620  else
621  invalidateBuffer_resizeHelper(oldPos, olds);
622  }
623 
624  if (isMove) {
625  QMoveEvent e(q->pos(), oldPos);
627  }
628  if (isResize) {
629  QResizeEvent e(r.size(), olds);
631  if (q->platformWindow())
632  q->update();
633  }
634  } else { // not visible
635  if (isMove && q->pos() != oldPos)
636  q->setAttribute(Qt::WA_PendingMoveEvent, true);
637  if (isResize)
638  q->setAttribute(Qt::WA_PendingResizeEvent, true);
639  }
640 
641 }
642 
644 {
645 }
646 
647 void QWidgetPrivate::scroll_sys(int dx, int dy)
648 {
649  Q_Q(QWidget);
650  scrollChildren(dx, dy);
651  scrollRect(q->rect(), dx, dy);
652 }
653 
654 void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
655 {
656  scrollRect(r, dx, dy);
657 }
658 
659 int QWidget::metric(PaintDeviceMetric m) const
660 {
661  Q_D(const QWidget);
662 
664  if (!screen) {
665  if (m == PdmDpiX || m == PdmDpiY)
666  return 72;
667  return QPaintDevice::metric(m);
668  }
669  int val;
670  if (m == PdmWidth) {
671  val = data->crect.width();
672  } else if (m == PdmWidthMM) {
673  val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width();
674  } else if (m == PdmHeight) {
675  val = data->crect.height();
676  } else if (m == PdmHeightMM) {
677  val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height();
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;
683  else if (d->parent)
684  return static_cast<QWidget *>(d->parent)->metric(m);
685  return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
686  } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
687  if (d->extra && d->extra->customDpiY)
688  return d->extra->customDpiY;
689  else if (d->parent)
690  return static_cast<QWidget *>(d->parent)->metric(m);
691  return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
692  } else {
693  val = QPaintDevice::metric(m);// XXX
694  }
695  return val;
696 }
697 
710 void QWidget::setPlatformWindow(QPlatformWindow *window)
711 {
712  Q_D(QWidget);
713 
714  QTLWExtra *topData = d->topData();
715  if (topData->platformWindow == window)
716  return;
717 
718  delete topData->platformWindow;
719  topData->platformWindow = window;
720 }
721 
731 QPlatformWindow *QWidget::platformWindow() const
732 {
733  Q_D(const QWidget);
734  QTLWExtra *extra = d->maybeTopData();
735  if (extra && extra->platformWindow)
736  return extra->platformWindow;
737 
738  return 0;
739 }
740 
749 void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format)
750 {
751  if (isWindow() || testAttribute(Qt::WA_NativeWindow)) {
752  Q_D(QWidget);
753  QTLWExtra *topData = d->topData();
754  topData->platformWindowFormat = format;
755  if (testAttribute(Qt::WA_WState_Created)) {
756  bool wasVisible = testAttribute(Qt::WA_WState_Visible);
757  destroy();
758  d->create_sys(0,true,true);
759  if (wasVisible)
760  topData->platformWindow->setVisible(true);
761  }
762  }
763 }
764 
773 QPlatformWindowFormat QWidget::platformWindowFormat() const
774 {
775  Q_D(const QWidget);
776 
778 
779  QTLWExtra *extra = d->maybeTopData();
780  if (extra){
781  format = extra->platformWindowFormat;
782  } else {
784  }
785 
786  if (testAttribute(Qt::WA_TranslucentBackground))
787  format.setAlpha(true);
788 
789  return format;
790 }
791 
793 {
794 }
795 
797 {
798 
799 }
800 
802 {
803 }
804 
806 {
807  if (extra && extra->topextra) {
808  //the toplevel might have a context with a "qglcontext associated with it. We need to
809  //delete the qglcontext before we delete the qplatformglcontext.
810  //One unfortunate thing about this is that we potentially create a glContext just to
811  //delete it straight afterwards.
812  if (extra->topextra->platformWindow) {
813  if (QPlatformGLContext *context = extra->topextra->platformWindow->glContext()) {
814  context->deleteQGLContext();
815  }
816  }
817  setWinId(0);
818  delete extra->topextra->platformWindow;
819  extra->topextra->platformWindow = 0;
820  }
821 }
822 
824 {
825  Q_UNUSED(on);
826 }
827 
828 void QWidgetPrivate::setMask_sys(const QRegion &region)
829 {
830  Q_UNUSED(region);
831  // XXX
832 }
833 
835 {
836  // XXX
837 }
838 
840 {
841  Q_Q(QWidget);
842  q->platformWindow()->setOpacity(level);
843 }
844 
845 void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
846 {
847  Q_UNUSED(dontShow);
848  Q_UNUSED(oldRect);
849  // XXX
850 }
851 
853 {
854  qWarning("QWidget::paintEngine: Should no longer be called");
855  return 0; //##### @@@
856 }
857 
859 {
860  Q_Q(QWidget);
861  if (q->platformWindowFormat().hasWindowSurface())
862  return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0);
863  else
864  return 0;
865 }
866 
868 {
869 }
870 
871 #ifndef QT_NO_CURSOR
872 void qt_qpa_set_cursor(QWidget * w, bool force)
873 {
874  static QCursor arrowCursor(Qt::ArrowCursor);
875  static QPointer<QWidget> lastUnderMouse = 0;
876 
877  QCursor * override = QApplication::overrideCursor();
878 
879  if (override && w != 0)
880  return;
881 
882  QWidget *cursorWidget;
883  QCursor cursorCursor;
884 
885  do {
886  if (w == 0) {
887  if (override) {
888  cursorCursor = *override;
889  cursorWidget = QApplication::topLevelAt(QCursor::pos());
890  break;
891  }
893  if (w == 0) // clear the override cursor while over empty space
894  w = QApplication::desktop();
895  } else if (force) {
896  lastUnderMouse = w;
897  } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
898  && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
899  w = lastUnderMouse;
900  }
901  if (w == QApplication::desktop() && !override) {
902  cursorCursor = arrowCursor;
903  cursorWidget = w;
904  break;
905  }
906 
908  if (!curWin && w && w->internalWinId())
909  return;
910  QWidget* cW = w && !w->internalWinId() ? w : curWin;
911 
912  if (!cW || cW->window() != w->window() ||
913  !cW->isVisible() || !cW->underMouse() || override)
914  return;
915 
916  cursorCursor = w->cursor();
917  cursorWidget = w;
918  } while (0);
920  if (cursor)
921  cursor.data()->changeCursor(&cursorCursor, cursorWidget);
922 }
923 #endif //QT_NO_CURSOR
924 
T qobject_cast(QObject *object)
Definition: qobject.h:375
void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget)
Definition: qwidget_qpa.cpp:57
double d
Definition: qnumeric_p.h:62
void setParent_sys(QWidget *parent, Qt::WindowFlags)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
unsigned long WId
Definition: qwindowdefs.h:119
void grabMouse()
Grabs the mouse input.
void setWindowIcon_sys(bool forceReset=false)
double qreal
Definition: qglobal.h:1193
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int metric(PaintDeviceMetric) const
Internal implementation of the virtual QPaintDevice::metric() function.
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
QPointer< QWidget > widget
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
The QPlatformScreen class provides an abstraction for visual displays.
QRect crect
Definition: qwidget.h:131
QWindowSurface * windowSurface
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
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...
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or the window is resized.
bool isVisible() const
Definition: qwidget.h:1005
virtual QRect geometry() const
Returnes the current geometry of a window.
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...
static QPlatformWindowFormat defaultFormat()
Returns the default QPlatformWindowFormat for the application.
void setWindowTitle_sys(const QString &cap)
void moveRect(const QRect &, int dx, int dy)
uint window_state
Definition: qwidget.h:120
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context and if po...
virtual void setParent(const QPlatformWindow *window)
This function is called to enable native child widgets in QPA.
QWidget * qt_pressGrab
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void deleteTLSysExtra()
static QWidget * active_window
virtual WId winId() const
Reimplement in subclasses to return a handle to the native window.
bool underMouse() const
Returns true if the widget is under the mouse cursor; otherwise returns false.
Definition: qwidget.h:996
void show_sys()
Platform-specific part of QWidget::show().
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QPlatformWindow class provides an abstraction for top-level windows.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTLWExtra * maybeTopData() const
Definition: qwidget_p.h:1010
#define Q_D(Class)
Definition: qglobal.h:2482
T * data() const
void scrollChildren(int dx, int dy)
Definition: qwidget.cpp:421
QObjectList children
Definition: qobject.h:93
void setCursor_sys(const QCursor &cursor)
uint in_set_window_state
Definition: qwidget.h:125
qint32 minw
Definition: qwidget_p.h:264
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void registerDropSite(bool)
static HWND curWin
QWidget * qt_mouseGrb
#define Q_Q(Class)
Definition: qglobal.h:2483
QWidgetData data
Definition: qwidget_p.h:755
void deactivateWidgetCleanup()
Definition: qwidget.cpp:2496
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
static QWidget * keyboardGrb
void setParent_helper(QObject *)
Definition: qobject.cpp:1974
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
void unsetCursor_sys()
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.
Definition: qglobal.h:89
QRect normalGeometry
Definition: qwidget_p.h:181
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
void qt_qpa_set_cursor(QWidget *w, bool force)
void destroy(bool destroyWindow=true, bool destroySubWindows=true)
Frees up window system resources.
void setDirtyOpaqueRegion()
Definition: qwidget.cpp:2075
void releaseMouse()
Releases the mouse grab.
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
qint32 maxw
Definition: qwidget_p.h:266
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
Qt::WindowFlags window_flags
Definition: qwidget.h:119
virtual int depth() const =0
Reimplement in subclass to return current depth of the screen.
qint32 maxh
Definition: qwidget_p.h:267
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void hide_sys()
Platform-specific part of QWidget::hide().
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void setConstraints_sys()
virtual void changeCursor(QCursor *widgetCursor, QWidget *widget)=0
This method is called by Qt whenever the cursor graphic should be changed.
QWidgetData * data
Definition: qwidget.h:815
void updateFrameStrut()
Computes the frame rectangle when needed.
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)
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.
Definition: qregion.h:68
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
QTLWExtra * topData() const
Definition: qwidget_p.h:1004
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
void deleteSysExtra()
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
virtual QSize physicalSize() const
Reimplement this function in subclass to return the physical size of the screen.
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.
Definition: qrect.h:368
static QWidget * parentWidget(const QWidget *w)
void invalidateBuffer(const QRegion &)
Invalidates the rgn (in widget&#39;s coordinates) of the backing store, i.e.
The QPlatformIntegration class is the entry for WindowSystem specific functionality.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void grabKeyboard()
Grabs the keyboard input.
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
The QPlatformGLContext class provides an abstraction for native GL contexts.
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
QTLWExtra * topextra
Definition: qwidget_p.h:249
QWindowSurface * createDefaultWindowSurface_sys()
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QPaintEngine * paintEngine() const
Returns the widget&#39;s paint engine.
void setMask_sys(const QRegion &)
void createWinId(WId id=0)
Definition: qwidget.cpp:2574
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
void scroll_sys(int dx, int dy)
void setWindowOpacity_sys(qreal opacity)
int height() const
Returns the height.
Definition: qsize.h:129
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false...
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
QWExtra * extra
Definition: qwidget_p.h:700
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
void releaseKeyboard()
Releases the keyboard grab.
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
virtual int metric(PaintDeviceMetric metric) const
void scrollRect(const QRect &, int dx, int dy)
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QObject * parent
Definition: qobject.h:92
qint32 minh
Definition: qwidget_p.h:265
void setWinId(WId)
Definition: qwidget.cpp:1726
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
virtual void moveToScreen(QWidget *window, int screen)
This function is called when a QWidget is displayed on screen, or the QWidget is to be displayed on a...
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
void createSysExtra()
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize)
Invalidates the buffer when the widget is resized.
void createTLSysExtra()
QWidgetBackingStore * maybeBackingStore() const
Definition: qwidget_p.h:1036
void updateSystemBackground()
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void setGeometry_sys(int, int, int, int, bool)
void stackUnder_sys(QWidget *)
static Qt::WindowStates effectiveState(Qt::WindowStates state)
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QRect effectiveRectFor(const QRect &rect) const
Definition: qwidget_p.h:658
static QList< QWeakPointer< QPlatformCursor > > getInstances()
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
The QWeakPointer class holds a weak reference to a shared pointer.
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void setWindowIconText_sys(const QString &cap)