Changeset View
Changeset View
Standalone View
Standalone View
src/kwindowsystem.cpp
Show First 20 Lines • Show All 449 Lines • ▼ Show 20 Line(s) | |||||
450 | } | 450 | } | ||
451 | 451 | | |||
452 | void KWindowSystem::demandAttention(WId win, bool set) | 452 | void KWindowSystem::demandAttention(WId win, bool set) | ||
453 | { | 453 | { | ||
454 | Q_D(KWindowSystem); | 454 | Q_D(KWindowSystem); | ||
455 | d->demandAttention(win, set); | 455 | d->demandAttention(win, set); | ||
456 | } | 456 | } | ||
457 | 457 | | |||
458 | static QWindow* setMainWindowHelper(QWindow *subWindow, WId mainWindowId) | ||||
zzag: Coding style: For pointers or references, use a single space before '*' or '&', but not after. | |||||
459 | { | ||||
460 | QWindow *mainWindow = QWindow::fromWinId(mainWindowId); | ||||
461 | if (mainWindow) { // foreign windows not supported on all platforms | ||||
462 | subWindow->setTransientParent(mainWindow); | ||||
463 | } | ||||
464 | return mainWindow; | ||||
465 | } | ||||
466 | | ||||
458 | #ifndef KWINDOWSYSTEM_NO_DEPRECATED | 467 | #ifndef KWINDOWSYSTEM_NO_DEPRECATED | ||
459 | WId KWindowSystem::transientFor(WId win) | 468 | WId KWindowSystem::transientFor(WId win) | ||
460 | { | 469 | { | ||
461 | Q_D(KWindowSystem); | 470 | Q_D(KWindowSystem); | ||
462 | return d->transientFor(win); | 471 | return d->transientFor(win); | ||
463 | } | 472 | } | ||
464 | #endif | | |||
465 | 473 | | |||
466 | void KWindowSystem::setMainWindow(QWidget *subWidget, WId mainWindowId) | 474 | void KWindowSystem::setMainWindow(QWidget *subWidget, WId mainWindowId) | ||
467 | { | 475 | { | ||
468 | // Set the WA_NativeWindow attribute to force the creation of the QWindow. | 476 | // Set the WA_NativeWindow attribute to force the creation of the QWindow. | ||
469 | // Without this QWidget::windowHandle() returns 0. | 477 | // Without this QWidget::windowHandle() returns 0. | ||
470 | subWidget->setAttribute(Qt::WA_NativeWindow, true); | 478 | subWidget->setAttribute(Qt::WA_NativeWindow, true); | ||
471 | QWindow *subWindow = subWidget->windowHandle(); | 479 | QWindow *subWindow = subWidget->windowHandle(); | ||
472 | Q_ASSERT(subWindow); | 480 | Q_ASSERT(subWindow); | ||
481 | QWindow *mainWindow = setMainWindowHelper(subWindow, mainWindowId); | ||||
473 | 482 | | |||
474 | QWindow *mainWindow = QWindow::fromWinId(mainWindowId); | | |||
475 | if (!mainWindow) { | | |||
476 | // foreign windows not supported on all platforms | | |||
477 | return; | | |||
478 | } | | |||
479 | // mainWindow is not the child of any object, so make sure it gets deleted at some point | 483 | // mainWindow is not the child of any object, so make sure it gets deleted at some point | ||
480 | connect(subWidget, &QObject::destroyed, mainWindow, &QObject::deleteLater); | 484 | connect(subWidget, &QObject::destroyed, mainWindow, &QObject::deleteLater); | ||
481 | subWindow->setTransientParent(mainWindow); | 485 | } | ||
486 | #endif | ||||
487 | | ||||
488 | void KWindowSystem::setMainWindow(QWindow *subWindow, WId mainWindowId) | ||||
489 | { | ||||
490 | (void) setMainWindowHelper(subWindow, mainWindowId); | ||||
Each time this method is called a new foreign QWindow object will be created. Can you please explain why leaking those objects is okay? zzag: Each time this method is called a new foreign QWindow object will be created. Can you please… | |||||
Ah I didn't realize that QWindow::fromWinId was allocating a QWindow [IMHO it should have been called createFromWinId, then], but indeed it's logical. Fixed. dfaure: Ah I didn't realize that QWindow::fromWinId was allocating a QWindow [IMHO it should have been… | |||||
482 | } | 491 | } | ||
483 | 492 | | |||
484 | #ifndef KWINDOWSYSTEM_NO_DEPRECATED | 493 | #ifndef KWINDOWSYSTEM_NO_DEPRECATED | ||
485 | WId KWindowSystem::groupLeader(WId win) | 494 | WId KWindowSystem::groupLeader(WId win) | ||
486 | { | 495 | { | ||
487 | Q_D(KWindowSystem); | 496 | Q_D(KWindowSystem); | ||
488 | return d->groupLeader(win); | 497 | return d->groupLeader(win); | ||
489 | } | 498 | } | ||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |
Coding style: For pointers or references, use a single space before '*' or '&', but not after.
https://techbase.kde.org/Policies/Frameworks_Coding_Style#Whitespace