137QMargins QPlatformWindow::safeAreaMargins()
const
143
144
145
146
147
148void QPlatformWindow::setVisible(
bool visible)
151 QRect rect(QPoint(), geometry().size());
152 QWindowSystemInterface::handleExposeEvent(window(), rect);
153 QWindowSystemInterface::flushWindowSystemEvents();
157
158
159
160void QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
166
167
168
169
171bool QPlatformWindow::isExposed()
const
173 return window()->isVisible();
177
178
179
180
181
182bool QPlatformWindow::isActive()
const
188
189
190
191
192
193
194bool QPlatformWindow::isAncestorOf(
const QPlatformWindow *child)
const
196 for (
const QPlatformWindow *parent = child->parent(); parent; parent = parent->parent()) {
205
206
207
208
209
210bool QPlatformWindow::isEmbedded()
const
216
217
218
219
220
221
222QPoint QPlatformWindow::mapToGlobal(
const QPoint &pos)
const
224 const QPlatformWindow *p =
this;
227 result += p->geometry().topLeft();
233QPointF QPlatformWindow::mapToGlobalF(
const QPointF &pos)
const
235 const QPoint posPt = pos.toPoint();
236 const QPointF delta = pos - posPt;
237 return mapToGlobal(posPt) + delta;
240QPointF QPlatformWindow::mapFromGlobalF(
const QPointF &pos)
const
242 const QPoint posPt = pos.toPoint();
243 const QPointF delta = pos - posPt;
244 return mapFromGlobal(posPt) + delta;
248
249
250
251
252
253
254QPoint QPlatformWindow::mapFromGlobal(
const QPoint &pos)
const
256 const QPlatformWindow *p =
this;
259 result -= p->geometry().topLeft();
266
267
268
269
270
271void QPlatformWindow::setWindowState(Qt::WindowStates)
276
277
278WId QPlatformWindow::winId()
const
290
291
292
293
294void QPlatformWindow::setParent(
const QPlatformWindow *parent)
297 qWarning(
"This plugin does not support setParent!");
301
302
303
304
305
306
307
308
309
310
311
312void QPlatformWindow::setWindowTitle(
const QString &title) { Q_UNUSED(title); }
315
316
317
318
319
320
321
322
323
324QString QPlatformWindow::windowTitle()
const
326 return window()->title();
330
331
332void QPlatformWindow::setWindowFilePath(
const QString &filePath) { Q_UNUSED(filePath); }
335
336
337void QPlatformWindow::setWindowIcon(
const QIcon &icon) { Q_UNUSED(icon); }
340
341
342
343
344
345
346bool QPlatformWindow::close()
348 return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window());
352
353
354void QPlatformWindow::raise() { qWarning(
"This plugin does not support raise()"); }
357
358
359void QPlatformWindow::lower() { qWarning(
"This plugin does not support lower()"); }
362
363
364
365
366
367void QPlatformWindow::propagateSizeHints() {qWarning(
"This plugin does not support propagateSizeHints()"); }
370
371
372void QPlatformWindow::setOpacity(qreal level)
375 qWarning(
"This plugin does not support setting window opacity");
379
380
382void QPlatformWindow::setMask(
const QRegion ®ion)
385 qWarning(
"This plugin does not support setting window masks");
389
390
391
392
393
394
395
396
397
398
399
400
401void QPlatformWindow::requestActivateWindow()
403 QWindowSystemInterface::handleFocusWindowChanged(window());
407
408
409
410
411
412
413
414
415void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
417 Q_UNUSED(orientation);
421
422
423
424
425
426
427qreal QPlatformWindow::devicePixelRatio()
const
432bool QPlatformWindow::setKeyboardGrabEnabled(
bool grab)
435 qWarning(
"This plugin does not support grabbing the keyboard");
439bool QPlatformWindow::setMouseGrabEnabled(
bool grab)
442 qWarning(
"This plugin does not support grabbing the mouse");
447
448
449
450
451bool QPlatformWindow::setWindowModified(
bool modified)
458
459
460
461
462
463
464
465
466bool QPlatformWindow::windowEvent(QEvent *event)
468 Q_D(QPlatformWindow);
470 if (event->type() == QEvent::Timer) {
471 if (
static_cast<QTimerEvent *>(event)->timerId() == d->updateTimer.timerId()) {
472 deliverUpdateRequest();
477 if (!hasPendingUpdateRequest())
478 d->updateTimer.stop();
487
488
489
490
491
492
493
495bool QPlatformWindow::startSystemResize(Qt::Edges edges)
502
503
504
505
506
507
508
510bool QPlatformWindow::startSystemMove()
516
517
518
519
520
522void QPlatformWindow::setFrameStrutEventsEnabled(
bool enabled)
528
529
530
532bool QPlatformWindow::frameStrutEventsEnabled()
const
538
539
540
541
542
543
544
545QString QPlatformWindow::formatWindowTitle(
const QString &title,
const QString &separator)
547 QString fullTitle = title;
548 if (QGuiApplicationPrivate::displayName && !title.endsWith(*QGuiApplicationPrivate::displayName)) {
550 if (!fullTitle.isEmpty())
551 fullTitle += separator;
552 fullTitle += *QGuiApplicationPrivate::displayName;
553 }
else if (fullTitle.isEmpty()) {
555 fullTitle = QCoreApplication::applicationName();
561
562
563
564
565
566
567
568
569
570
571QPlatformScreen *QPlatformWindow::screenForGeometry(
const QRect &newGeometry)
const
573 QPlatformScreen *currentScreen = screen();
574 QPlatformScreen *fallback = currentScreen;
577 QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center();
578 if (isForeignWindow())
579 center = mapToGlobal(center - newGeometry.topLeft());
581 if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
582 const auto screens = currentScreen->virtualSiblings();
583 for (QPlatformScreen *screen : screens) {
584 const QRect screenGeometry = screen->geometry();
585 if (screenGeometry.contains(center))
587 if (screenGeometry.intersects(newGeometry))
636 return QGuiApplication::primaryScreen();
637 const QScreen *screen = window->screen();
639 return QGuiApplication::primaryScreen();
640 if (screen != QGuiApplication::primaryScreen())
643 const QList<QScreen *> siblings = screen->virtualSiblings();
644 if (siblings.size() > 1) {
645 const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
646 for (
const QScreen *sibling : siblings) {
647 if (sibling->geometry().contains(referencePoint))
670 int deviceIndependentDefaultHeight)
672 if (size.width() == 0) {
673 const int minWidth = w->minimumWidth();
674 size.setWidth(minWidth > 0 ? minWidth : deviceIndependentDefaultWidth);
676 if (size.height() == 0) {
677 const int minHeight = w->minimumHeight();
678 size.setHeight(minHeight > 0 ? minHeight : deviceIndependentDefaultHeight);
696QRect QPlatformWindow::initialGeometry(
const QWindow *w,
const QRect &initialGeometry,
697 int defaultWidth,
int defaultHeight,
698 const QScreen **resultingScreenReturn)
700 if (resultingScreenReturn)
701 *resultingScreenReturn = w->screen();
702 if (!w->isTopLevel()) {
703 const qreal factor = QHighDpiScaling::factor(w);
704 const QSize deviceIndependentSize =
705 fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), w,
706 defaultWidth, defaultHeight);
707 return QRect(initialGeometry.topLeft(), QHighDpi::toNative(deviceIndependentSize, factor));
709 const auto *wp = qt_window_private(
const_cast<QWindow*>(w));
710 const bool positionAutomatic = wp->positionAutomatic && w->type() != Qt::Popup;
711 if (!positionAutomatic && !wp->resizeAutomatic)
712 return initialGeometry;
713 const QScreen *screen = positionAutomatic
715 : QGuiApplication::screenAt(initialGeometry.center());
717 return initialGeometry;
718 if (resultingScreenReturn)
719 *resultingScreenReturn = screen;
721 QRect deviceIndependentRect(QHighDpi::fromNativePixels(initialGeometry, w));
722 if (wp->resizeAutomatic)
723 deviceIndependentRect.setSize(
724 fixInitialSize(deviceIndependentRect.size(), w, defaultWidth, defaultHeight));
725 if (positionAutomatic) {
726 const QRect availableDeviceIndependentGeometry = screen->availableGeometry();
728 if (deviceIndependentRect.height() < (availableDeviceIndependentGeometry.height() * 8) / 9
729 && deviceIndependentRect.width()
730 < (availableDeviceIndependentGeometry.width() * 8) / 9) {
731 const QWindow *tp = w->transientParent();
734 deviceIndependentRect.moveCenter(tp->geometry().center());
738 deviceIndependentRect.moveCenter(availableDeviceIndependentGeometry.center());
742 return QHighDpi::toNativePixels(deviceIndependentRect, screen);
761void QPlatformWindow::requestUpdate()
763 Q_D(QPlatformWindow);
765 static bool customUpdateIntervalValid =
false;
766 static int customUpdateInterval = qEnvironmentVariableIntValue(
"QT_QPA_UPDATE_IDLE_TIME",
767 &customUpdateIntervalValid);
768 int updateInterval = customUpdateInterval;
769 if (!customUpdateIntervalValid) {
771 if (QPlatformScreen *currentScreen = screen()) {
772 const qreal refreshRate = currentScreen->refreshRate();
773 if (refreshRate > 60.0)
774 updateInterval /= refreshRate / 60.0;
780 d->updateTimer.start(updateInterval, Qt::PreciseTimer, window());
814void QPlatformWindow::deliverUpdateRequest()
816 Q_ASSERT(hasPendingUpdateRequest());
818 QWindow *w = window();
819 QWindowPrivate *wp = qt_window_private(w);
824 if (wp->updateDevicePixelRatio()) {
825 qWarning() <<
"The cached device pixel ratio value was stale on window update. "
826 <<
"Please file a QTBUG which explains how to reproduce.";
829 wp->updateRequestPending =
false;
830 QEvent request(QEvent::UpdateRequest);
831 QCoreApplication::sendEvent(w, &request);
861QSize QPlatformWindow::windowSizeIncrement()
const
863 QSize increment = window()->sizeIncrement();
864 if (!QHighDpiScaling::isActive())
869 if (increment.isEmpty())
870 increment = QSize(1, 1);
872 return QHighDpi::toNativePixels(increment, window());
897QRectF QPlatformWindow::closestAcceptableGeometry(
const QWindow *qWindow,
const QRectF &nativeRect)
899 const QRectF rectF = QHighDpi::fromNativeWindowGeometry(nativeRect, qWindow);
900 const QRectF correctedGeometryF = qt_window_private(
const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF);
901 return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF
902 ? QHighDpi::toNativeWindowGeometry(correctedGeometryF, qWindow) : nativeRect;