Skip to content

Commit c5ef2b7

Browse files
committed
core/window: setTransientParent in postComplete for FloatingWindow
1 parent 673f10e commit c5ef2b7

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

src/window/floatingwindow.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ void ProxyFloatingWindow::connectWindow() {
1515
this->window->setTitle(this->bTitle);
1616
this->window->setMinimumSize(this->bMinimumSize);
1717
this->window->setMaximumSize(this->bMaximumSize);
18+
}
19+
20+
void ProxyFloatingWindow::postCompleteWindow() {
21+
auto* parentBacking =
22+
this->mParentProxyWindow ? this->mParentProxyWindow->backingWindow() : nullptr;
1823

19-
// Apply transient parent now that our backing window exists
20-
this->updateTransientParent();
24+
this->window->setTransientParent(parentBacking);
2125
}
2226

2327
void ProxyFloatingWindow::trySetWidth(qint32 implicitWidth) {
@@ -75,37 +79,20 @@ void ProxyFloatingWindow::setParentWindow(QObject* window) {
7579
&ProxyFloatingWindow::onParentDestroyed
7680
);
7781

78-
QObject::connect(
79-
this->mParentProxyWindow,
80-
&ProxyWindowBase::backerVisibilityChanged,
81-
this,
82-
&ProxyFloatingWindow::updateTransientParent
83-
);
8482
} else {
8583
this->mParentWindow = nullptr;
8684
this->mParentProxyWindow = nullptr;
8785
}
8886

89-
this->updateTransientParent();
9087
emit this->parentWindowChanged();
9188
}
9289

9390
void ProxyFloatingWindow::onParentDestroyed() {
9491
this->mParentWindow = nullptr;
9592
this->mParentProxyWindow = nullptr;
96-
this->updateTransientParent();
9793
emit this->parentWindowChanged();
9894
}
9995

100-
void ProxyFloatingWindow::updateTransientParent() {
101-
if (!this->window) return;
102-
103-
auto* parentBacking =
104-
this->mParentProxyWindow ? this->mParentProxyWindow->backingWindow() : nullptr;
105-
106-
this->window->setTransientParent(parentBacking);
107-
}
108-
10996
// FloatingWindowInterface
11097

11198
FloatingWindowInterface::FloatingWindowInterface(QObject* parent)

src/window/floatingwindow.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ProxyFloatingWindow: public ProxyWindowBase {
1818
explicit ProxyFloatingWindow(QObject* parent = nullptr): ProxyWindowBase(parent) {}
1919

2020
void connectWindow() override;
21+
void postCompleteWindow() override;
2122

2223
[[nodiscard]] QObject* parentWindow() const;
2324
void setParentWindow(QObject* window);
@@ -40,7 +41,6 @@ private slots:
4041
void onMinimumSizeChanged();
4142
void onMaximumSizeChanged();
4243
void onTitleChanged();
43-
void updateTransientParent();
4444

4545
QObject* mParentWindow = nullptr;
4646
ProxyWindowBase* mParentProxyWindow = nullptr;

src/window/proxywindow.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ void ProxyWindowBase::onReload(QObject* oldInstance) {
8181

8282
this->reloadComplete = true;
8383

84-
emit this->backingWindowChanged();
8584
emit this->windowConnected();
8685
this->postCompleteWindow();
8786

@@ -149,16 +148,11 @@ void ProxyWindowBase::createWindow() {
149148
this->ensureQWindow();
150149
this->connectWindow();
151150
this->completeWindow();
152-
emit this->backingWindowChanged();
153151
emit this->windowConnected();
154152
}
155153

156154
void ProxyWindowBase::deleteWindow(bool keepItemOwnership) {
157-
if (this->window != nullptr) {
158-
emit this->windowDestroyed();
159-
emit this->backingWindowChanged();
160-
}
161-
155+
if (this->window != nullptr) emit this->windowDestroyed();
162156
if (auto* window = this->disownWindow(keepItemOwnership)) window->deleteLater();
163157
}
164158

src/window/proxywindow.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class ProxyWindowBase: public Reloadable {
145145
void resourcesLost();
146146
void windowConnected();
147147
void windowDestroyed();
148-
void backingWindowChanged();
149148
void visibleChanged();
150149
void backerVisibilityChanged();
151150
void xChanged();

0 commit comments

Comments
 (0)