138QMargins QPlatformWindow::safeAreaMargins()
const
144
145
146
147
148
149void QPlatformWindow::setVisible(
bool visible)
152 QRect rect(QPoint(), geometry().size());
153 QWindowSystemInterface::handleExposeEvent(window(), rect);
154 QWindowSystemInterface::flushWindowSystemEvents();
158
159
160
161void QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
167
168
169
170
172bool QPlatformWindow::isExposed()
const
174 return window()->isVisible();
178
179
180
181
182
183bool QPlatformWindow::isActive()
const
189
190
191
192
193
194
195bool QPlatformWindow::isAncestorOf(
const QPlatformWindow *child)
const
197 for (
const QPlatformWindow *parent = child->parent(); parent; parent = parent->parent()) {
206
207
208
209
210
211bool QPlatformWindow::isEmbedded()
const
217
218
219
220
221
222
223QPoint QPlatformWindow::mapToGlobal(
const QPoint &pos)
const
225 const QPlatformWindow *p =
this;
228 result += p->geometry().topLeft();
234QPointF QPlatformWindow::mapToGlobalF(
const QPointF &pos)
const
236 const QPoint posPt = pos.toPoint();
237 const QPointF delta = pos - posPt;
238 return mapToGlobal(posPt) + delta;
241QPointF QPlatformWindow::mapFromGlobalF(
const QPointF &pos)
const
243 const QPoint posPt = pos.toPoint();
244 const QPointF delta = pos - posPt;
245 return mapFromGlobal(posPt) + delta;
249
250
251
252
253
254
255QPoint QPlatformWindow::mapFromGlobal(
const QPoint &pos)
const
257 const QPlatformWindow *p =
this;
260 result -= p->geometry().topLeft();
267
268
269
270
271
272void QPlatformWindow::setWindowState(Qt::WindowStates)
277
278
279WId QPlatformWindow::winId()
const
291
292
293
294
295void QPlatformWindow::setParent(
const QPlatformWindow *parent)
298 qWarning(
"This plugin does not support setParent!");
302
303
304
305
306
307
308
309
310
311
312
313void QPlatformWindow::setWindowTitle(
const QString &title) { Q_UNUSED(title); }
316
317
318
319
320
321
322
323
324
325QString QPlatformWindow::windowTitle()
const
327 return window()->title();
331
332
333void QPlatformWindow::setWindowFilePath(
const QString &filePath) { Q_UNUSED(filePath); }
336
337
338void QPlatformWindow::setWindowIcon(
const QIcon &icon) { Q_UNUSED(icon); }
341
342
343
344
345
346
347bool QPlatformWindow::close()
349 return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window());
353
354
355void QPlatformWindow::raise() { qWarning(
"This plugin does not support raise()"); }
358
359
360void QPlatformWindow::lower() { qWarning(
"This plugin does not support lower()"); }
363
364
365
366
367
368void QPlatformWindow::propagateSizeHints() {qWarning(
"This plugin does not support propagateSizeHints()"); }
371
372
373void QPlatformWindow::setOpacity(qreal level)
376 qWarning(
"This plugin does not support setting window opacity");
380
381
383void QPlatformWindow::setMask(
const QRegion ®ion)
386 qWarning(
"This plugin does not support setting window masks");
390
391
392
393
394
395
396
397
398
399
400
401
402void QPlatformWindow::requestActivateWindow()
404 QWindowSystemInterface::handleFocusWindowChanged(window());
408
409
410
411
412
413
414
415
416void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
418 Q_UNUSED(orientation);
422
423
424
425
426
427
428qreal QPlatformWindow::devicePixelRatio()
const
433bool QPlatformWindow::setKeyboardGrabEnabled(
bool grab)
436 qWarning(
"This plugin does not support grabbing the keyboard");
440bool QPlatformWindow::setMouseGrabEnabled(
bool grab)
443 qWarning(
"This plugin does not support grabbing the mouse");
448
449
450
451
452bool QPlatformWindow::setWindowModified(
bool modified)
459
460
461
462
463
464
465
466
467bool QPlatformWindow::windowEvent(QEvent *event)
469 Q_D(QPlatformWindow);
471 if (event->type() == QEvent::Timer) {
472 if (
static_cast<QTimerEvent *>(event)->timerId() == d->updateTimer.timerId()) {
473 deliverUpdateRequest();
478 if (!hasPendingUpdateRequest())
479 d->updateTimer.stop();
488
489
490
491
492
493
494
496bool QPlatformWindow::startSystemResize(Qt::Edges edges)
503
504
505
506
507
508
509
511bool QPlatformWindow::startSystemMove()
517
518
519
520
521
523void QPlatformWindow::setFrameStrutEventsEnabled(
bool enabled)
529
530
531
533bool QPlatformWindow::frameStrutEventsEnabled()
const
539
540
541
542
543
544
545
546QString QPlatformWindow::formatWindowTitle(
const QString &title,
const QString &separator)
548 QString fullTitle = title;
549 if (QGuiApplicationPrivate::displayName && !title.endsWith(*QGuiApplicationPrivate::displayName)) {
551 if (!fullTitle.isEmpty())
552 fullTitle += separator;
553 fullTitle += *QGuiApplicationPrivate::displayName;
554 }
else if (fullTitle.isEmpty()) {
556 fullTitle = QCoreApplication::applicationName();
562
563
564
565
566
567
568
569
570
571
572QPlatformScreen *QPlatformWindow::screenForGeometry(
const QRect &newGeometry)
const
574 QPlatformScreen *currentScreen = screen();
575 QPlatformScreen *fallback = currentScreen;
578 QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center();
579 if (isForeignWindow())
580 center = mapToGlobal(center - newGeometry.topLeft());
582 if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
583 const auto screens = currentScreen->virtualSiblings();
584 for (QPlatformScreen *screen : screens) {
585 const QRect screenGeometry = screen->geometry();
586 if (screenGeometry.contains(center))
588 if (screenGeometry.intersects(newGeometry))
637 return QGuiApplication::primaryScreen();
638 const QScreen *screen = window->screen();
640 return QGuiApplication::primaryScreen();
641 if (screen != QGuiApplication::primaryScreen())
644 const QList<QScreen *> siblings = screen->virtualSiblings();
645 if (siblings.size() > 1) {
646 const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
647 for (
const QScreen *sibling : siblings) {
648 if (sibling->geometry().contains(referencePoint))
671 int deviceIndependentDefaultHeight)
673 if (size.width() == 0) {
674 const int minWidth = w->minimumWidth();
675 size.setWidth(minWidth > 0 ? minWidth : deviceIndependentDefaultWidth);
677 if (size.height() == 0) {
678 const int minHeight = w->minimumHeight();
679 size.setHeight(minHeight > 0 ? minHeight : deviceIndependentDefaultHeight);
697QRect QPlatformWindow::initialGeometry(
const QWindow *w,
const QRect &initialGeometry,
698 int defaultWidth,
int defaultHeight,
699 const QScreen **resultingScreenReturn)
701 if (resultingScreenReturn)
702 *resultingScreenReturn = w->screen();
703 if (!w->isTopLevel()) {
704 const qreal factor = QHighDpiScaling::factor(w);
705 const QSize deviceIndependentSize =
706 fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), w,
707 defaultWidth, defaultHeight);
708 return QRect(initialGeometry.topLeft(), QHighDpi::toNative(deviceIndependentSize, factor));
710 const auto *wp = qt_window_private(
const_cast<QWindow*>(w));
711 const bool positionAutomatic = wp->positionAutomatic && w->type() != Qt::Popup;
712 if (!positionAutomatic && !wp->resizeAutomatic)
713 return initialGeometry;
714 const QScreen *screen = positionAutomatic
716 : QGuiApplication::screenAt(initialGeometry.center());
718 return initialGeometry;
719 if (resultingScreenReturn)
720 *resultingScreenReturn = screen;
722 QRect deviceIndependentRect(QHighDpi::fromNativePixels(initialGeometry, w));
723 if (wp->resizeAutomatic)
724 deviceIndependentRect.setSize(
725 fixInitialSize(deviceIndependentRect.size(), w, defaultWidth, defaultHeight));
726 if (positionAutomatic) {
727 const QRect availableDeviceIndependentGeometry = screen->availableGeometry();
729 if (deviceIndependentRect.height() < (availableDeviceIndependentGeometry.height() * 8) / 9
730 && deviceIndependentRect.width()
731 < (availableDeviceIndependentGeometry.width() * 8) / 9) {
732 const QWindow *tp = w->transientParent();
735 deviceIndependentRect.moveCenter(tp->geometry().center());
739 deviceIndependentRect.moveCenter(availableDeviceIndependentGeometry.center());
743 return QHighDpi::toNativePixels(deviceIndependentRect, screen);
762void QPlatformWindow::requestUpdate()
764 Q_D(QPlatformWindow);
766 static bool customUpdateIntervalValid =
false;
767 static int customUpdateInterval = qEnvironmentVariableIntValue(
"QT_QPA_UPDATE_IDLE_TIME",
768 &customUpdateIntervalValid);
769 int updateInterval = customUpdateInterval;
770 if (!customUpdateIntervalValid) {
772 if (QPlatformScreen *currentScreen = screen()) {
773 const qreal refreshRate = currentScreen->refreshRate();
774 if (refreshRate > 60.0)
775 updateInterval /= refreshRate / 60.0;
781 d->updateTimer.start(updateInterval, Qt::PreciseTimer, window());
815void QPlatformWindow::deliverUpdateRequest()
817 Q_ASSERT(hasPendingUpdateRequest());
819 QWindow *w = window();
820 QWindowPrivate *wp = qt_window_private(w);
825 if (wp->updateDevicePixelRatio()) {
826 qWarning() <<
"The cached device pixel ratio value was stale on window update. "
827 <<
"Please file a QTBUG which explains how to reproduce.";
830 wp->updateRequestPending =
false;
831 QEvent request(QEvent::UpdateRequest);
832 QCoreApplication::sendEvent(w, &request);
862QSize QPlatformWindow::windowSizeIncrement()
const
864 QSize increment = window()->sizeIncrement();
865 if (!QHighDpiScaling::isActive())
870 if (increment.isEmpty())
871 increment = QSize(1, 1);
873 return QHighDpi::toNativePixels(increment, window());
898QRectF QPlatformWindow::closestAcceptableGeometry(
const QWindow *qWindow,
const QRectF &nativeRect)
900 const QRectF rectF = QHighDpi::fromNativeWindowGeometry(nativeRect, qWindow);
901 const QRectF correctedGeometryF = qt_window_private(
const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF);
902 return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF
903 ? QHighDpi::toNativeWindowGeometry(correctedGeometryF, qWindow) : nativeRect;