@@ -34,7 +34,8 @@ ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) {
3434 auto * window = old == nullptr ? nullptr : old->disownWindow ();
3535
3636 if (window != nullptr ) {
37- this ->bridge = LayerSurfaceBridge::init (window, this ->computeState ());
37+ this ->connectBridge (LayerSurfaceBridge::init (window, this ->computeState ()));
38+
3839 if (this ->bridge ) {
3940 return window;
4041 } else {
@@ -48,7 +49,7 @@ ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) {
4849ProxiedWindow* WlrLayershell::createQQuickWindow () {
4950 auto * window = this ->ProxyWindowBase ::createQQuickWindow ();
5051
51- this ->bridge = LayerSurfaceBridge::init (window, this ->computeState ());
52+ this ->connectBridge ( LayerSurfaceBridge::init (window, this ->computeState () ));
5253 if (!this ->bridge ) {
5354 qWarning () << " Could not attach Layershell extension to new QQuickWindow. Layer will not "
5455 " behave correctly." ;
@@ -72,6 +73,30 @@ void WlrLayershell::connectWindow() {
7273 this ->updateAutoExclusion ();
7374}
7475
76+ ProxiedWindow* WlrLayershell::disownWindow (bool keepItemOwnership) {
77+ auto * window = this ->ProxyWindowBase ::disownWindow (keepItemOwnership);
78+
79+ if (this ->bridge ) {
80+ this ->connectBridge (nullptr );
81+ }
82+
83+ return window;
84+ }
85+
86+ void WlrLayershell::connectBridge (LayerSurfaceBridge* bridge) {
87+ if (this ->bridge ) {
88+ QObject::disconnect (this ->bridge , nullptr , this , nullptr );
89+ }
90+
91+ this ->bridge = bridge;
92+
93+ if (bridge) {
94+ QObject::connect (this ->bridge , &QObject::destroyed, this , &WlrLayershell::onBridgeDestroyed);
95+ }
96+ }
97+
98+ void WlrLayershell::onBridgeDestroyed () { this ->bridge = nullptr ; }
99+
75100bool WlrLayershell::deleteOnInvisible () const {
76101 // Qt windows behave weirdly when geometry is modified and setVisible(false)
77102 // is subsequently called in the same frame.
0 commit comments