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
289
290
291
292
293
294
295
296void QPlatformWindow::setParent(
const QPlatformWindow *parent)
299 Q_ASSERT(!QGuiApplicationPrivate::platformIntegration()->hasCapability(
300 QPlatformIntegration::Capability::ChildWindows));
301 qWarning(
"This plugin does not support setParent!");
305
306
307
308
309
310
311
312
313
314
315
316void QPlatformWindow::setWindowTitle(
const QString &title) { Q_UNUSED(title); }
319
320
321
322
323
324
325
326
327
328QString QPlatformWindow::windowTitle()
const
330 return window()->title();
334
335
336void QPlatformWindow::setWindowFilePath(
const QString &filePath) { Q_UNUSED(filePath); }
339
340
341void QPlatformWindow::setWindowIcon(
const QIcon &icon) { Q_UNUSED(icon); }
344
345
346
347
348
349
350bool QPlatformWindow::close()
352 return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window());
356
357
358void QPlatformWindow::raise() { qWarning(
"This plugin does not support raise()"); }
361
362
363void QPlatformWindow::lower() { qWarning(
"This plugin does not support lower()"); }
366
367
368
369
370
371void QPlatformWindow::propagateSizeHints() {qWarning(
"This plugin does not support propagateSizeHints()"); }
374
375
376void QPlatformWindow::setOpacity(qreal level)
379 qWarning(
"This plugin does not support setting window opacity");
383
384
386void QPlatformWindow::setMask(
const QRegion ®ion)
389 qWarning(
"This plugin does not support setting window masks");
393
394
395
396
397
398
399
400
401
402
403
404
405void QPlatformWindow::requestActivateWindow()
407 QWindowSystemInterface::handleFocusWindowChanged(window());
411
412
413
414
415
416
417
418
419void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
421 Q_UNUSED(orientation);
425
426
427
428
429
430
431qreal QPlatformWindow::devicePixelRatio()
const
436bool QPlatformWindow::setKeyboardGrabEnabled(
bool grab)
439 qWarning(
"This plugin does not support grabbing the keyboard");
443bool QPlatformWindow::setMouseGrabEnabled(
bool grab)
446 qWarning(
"This plugin does not support grabbing the mouse");
451
452
453
454
455bool QPlatformWindow::setWindowModified(
bool modified)
462
463
464
465
466
467
468
469
470bool QPlatformWindow::windowEvent(QEvent *event)
472 Q_D(QPlatformWindow);
474 if (event->type() == QEvent::Timer) {
475 if (
static_cast<QTimerEvent *>(event)->timerId() == d->updateTimer.timerId()) {
476 deliverUpdateRequest();
481 if (!hasPendingUpdateRequest())
482 d->updateTimer.stop();
491
492
493
494
495
496
497
499bool QPlatformWindow::startSystemResize(Qt::Edges edges)
506
507
508
509
510
511
512
514bool QPlatformWindow::startSystemMove()
520
521
522
523
524
526void QPlatformWindow::setFrameStrutEventsEnabled(
bool enabled)
532
533
534
536bool QPlatformWindow::frameStrutEventsEnabled()
const
542
543
544
545
546
547
548
549QString QPlatformWindow::formatWindowTitle(
const QString &title,
const QString &separator)
551 QString fullTitle = title;
552 if (QGuiApplicationPrivate::displayName && !title.endsWith(*QGuiApplicationPrivate::displayName)) {
554 if (!fullTitle.isEmpty())
555 fullTitle += separator;
556 fullTitle += *QGuiApplicationPrivate::displayName;
557 }
else if (fullTitle.isEmpty()) {
559 fullTitle = QCoreApplication::applicationName();
565
566
567
568
569
570
571
572
573
574
575QPlatformScreen *QPlatformWindow::screenForGeometry(
const QRect &newGeometry)
const
577 QPlatformScreen *currentScreen = screen();
578 QPlatformScreen *fallback = currentScreen;
581 QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center();
582 if (isForeignWindow())
583 center = mapToGlobal(center - newGeometry.topLeft());
585 if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
586 const auto screens = currentScreen->virtualSiblings();
587 for (QPlatformScreen *screen : screens) {
588 const QRect screenGeometry = screen->geometry();
589 if (screenGeometry.contains(center))
591 if (screenGeometry.intersects(newGeometry))
640 return QGuiApplication::primaryScreen();
641 const QScreen *screen = window->screen();
643 return QGuiApplication::primaryScreen();
644 if (screen != QGuiApplication::primaryScreen())
647 const QList<QScreen *> siblings = screen->virtualSiblings();
648 if (siblings.size() > 1) {
649 const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
650 for (
const QScreen *sibling : siblings) {
651 if (sibling->geometry().contains(referencePoint))
674 int deviceIndependentDefaultHeight)
676 if (size.width() == 0) {
677 const int minWidth = w->minimumWidth();
678 size.setWidth(minWidth > 0 ? minWidth : deviceIndependentDefaultWidth);
680 if (size.height() == 0) {
681 const int minHeight = w->minimumHeight();
682 size.setHeight(minHeight > 0 ? minHeight : deviceIndependentDefaultHeight);
700QRect QPlatformWindow::initialGeometry(
const QWindow *w,
const QRect &initialGeometry,
701 int defaultWidth,
int defaultHeight,
702 const QScreen **resultingScreenReturn)
704 if (resultingScreenReturn)
705 *resultingScreenReturn = w->screen();
708 const bool isTopLevel = w->isTopLevel() && !isSubWindow(w);
710 const qreal factor = QHighDpiScaling::factor(w);
711 const QSize deviceIndependentSize =
712 fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), w,
713 defaultWidth, defaultHeight);
714 return QRect(initialGeometry.topLeft(), QHighDpi::toNative(deviceIndependentSize, factor));
716 const auto *wp = qt_window_private(
const_cast<QWindow*>(w));
717 const bool positionAutomatic = wp->positionAutomatic && w->type() != Qt::Popup;
718 if (!positionAutomatic && !wp->resizeAutomatic)
719 return initialGeometry;
720 const QScreen *screen = positionAutomatic
722 : QGuiApplication::screenAt(initialGeometry.center());
724 return initialGeometry;
725 if (resultingScreenReturn)
726 *resultingScreenReturn = screen;
728 QRect deviceIndependentRect(QHighDpi::fromNativePixels(initialGeometry, w));
729 if (wp->resizeAutomatic)
730 deviceIndependentRect.setSize(
731 fixInitialSize(deviceIndependentRect.size(), w, defaultWidth, defaultHeight));
732 if (positionAutomatic) {
733 const QRect availableDeviceIndependentGeometry = screen->availableGeometry();
735 if (deviceIndependentRect.height() < (availableDeviceIndependentGeometry.height() * 8) / 9
736 && deviceIndependentRect.width()
737 < (availableDeviceIndependentGeometry.width() * 8) / 9) {
738 const QWindow *tp = w->transientParent();
741 deviceIndependentRect.moveCenter(tp->geometry().center());
745 deviceIndependentRect.moveCenter(availableDeviceIndependentGeometry.center());
749 return QHighDpi::toNativePixels(deviceIndependentRect, screen);
784void QPlatformWindow::requestUpdate()
786 Q_D(QPlatformWindow);
788 static bool customUpdateIntervalValid =
false;
789 static int customUpdateInterval = qEnvironmentVariableIntValue(
"QT_QPA_UPDATE_IDLE_TIME",
790 &customUpdateIntervalValid);
791 int updateInterval = customUpdateInterval;
792 if (!customUpdateIntervalValid) {
794 if (QPlatformScreen *currentScreen = screen()) {
795 const qreal refreshRate = currentScreen->refreshRate();
796 if (refreshRate > 60.0)
797 updateInterval /= refreshRate / 60.0;
803 d->updateTimer.start(updateInterval, Qt::PreciseTimer, window());
837void QPlatformWindow::deliverUpdateRequest()
839 Q_ASSERT(hasPendingUpdateRequest());
841 QWindow *w = window();
842 QWindowPrivate *wp = qt_window_private(w);
847 if (wp->updateDevicePixelRatio()) {
848 qWarning() <<
"The cached device pixel ratio value was stale on window update. "
849 <<
"Please file a QTBUG which explains how to reproduce.";
852 wp->updateRequestPending =
false;
853 QEvent request(QEvent::UpdateRequest);
854 QCoreApplication::sendEvent(w, &request);
884QSize QPlatformWindow::windowSizeIncrement()
const
886 QSize increment = window()->sizeIncrement();
887 if (!QHighDpiScaling::isActive())
892 if (increment.isEmpty())
893 increment = QSize(1, 1);
895 return QHighDpi::toNativePixels(increment, window());
920QRectF QPlatformWindow::closestAcceptableGeometry(
const QWindow *qWindow,
const QRectF &nativeRect)
922 const QRectF rectF = QHighDpi::fromNativeWindowGeometry(nativeRect, qWindow);
923 const QRectF correctedGeometryF = qt_window_private(
const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF);
924 return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF
925 ? QHighDpi::toNativeWindowGeometry(correctedGeometryF, qWindow) : nativeRect;