From 3850bc6799649e048ee065c376fe02d71ace674a Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 15 Sep 2026 14:47:58 -0400 Subject: [PATCH] Fix dead/ghost panel references when pinning/unpinning under X11 --- .../src/bibliothek/gui/dock/FlapDockStation.java | 4 ++-- .../src/bibliothek/gui/dock/ScreenDockStation.java | 1 + .../bibliothek/gui/dock/station/flap/DefaultFlapWindow.java | 4 ++++ .../gui/dock/station/screen/window/ScreenDockFrame.java | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docking-frames-core/src/bibliothek/gui/dock/FlapDockStation.java b/docking-frames-core/src/bibliothek/gui/dock/FlapDockStation.java index 40dcd3d98..1a3b38745 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/FlapDockStation.java +++ b/docking-frames-core/src/bibliothek/gui/dock/FlapDockStation.java @@ -1212,8 +1212,8 @@ private void setDropInfo( FlapDropInfo info ){ */ private void setFlapWindow( FlapWindow window ){ if( this.window != null ){ - getRootHandler().removeRoot( window.getComponent() ); - this.window.setController( null ); + getRootHandler().removeRoot( this.window.getComponent() ); + this.window.setController( null ); this.window.destroy(); } diff --git a/docking-frames-core/src/bibliothek/gui/dock/ScreenDockStation.java b/docking-frames-core/src/bibliothek/gui/dock/ScreenDockStation.java index 60c70b62b..253780b6c 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/ScreenDockStation.java +++ b/docking-frames-core/src/bibliothek/gui/dock/ScreenDockStation.java @@ -1903,6 +1903,7 @@ protected void deregister( Dockable dockable, ScreenDockWindow window ){ dockables.remove( index ); getRootHandler().removeRoot( window.getComponent() ); + window.setVisible( false ); window.setDockable( null ); window.setPaintCombining( null ); window.setController( null ); diff --git a/docking-frames-core/src/bibliothek/gui/dock/station/flap/DefaultFlapWindow.java b/docking-frames-core/src/bibliothek/gui/dock/station/flap/DefaultFlapWindow.java index 95c0c2d78..ce6382ccc 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/station/flap/DefaultFlapWindow.java +++ b/docking-frames-core/src/bibliothek/gui/dock/station/flap/DefaultFlapWindow.java @@ -256,6 +256,10 @@ public void setWindowVisible( boolean flag ){ updateBounds(); } window.setVisible( flag ); + if( !flag && window instanceof DialogParent ) { + // Recreate the native peer on the next show to avoid stale X11 state. + window.destroy(); + } } public boolean isWindowVisible(){ diff --git a/docking-frames-core/src/bibliothek/gui/dock/station/screen/window/ScreenDockFrame.java b/docking-frames-core/src/bibliothek/gui/dock/station/screen/window/ScreenDockFrame.java index 9c975ccf2..770870a1f 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/station/screen/window/ScreenDockFrame.java +++ b/docking-frames-core/src/bibliothek/gui/dock/station/screen/window/ScreenDockFrame.java @@ -25,6 +25,7 @@ */ package bibliothek.gui.dock.station.screen.window; +import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -94,8 +95,10 @@ public JFrame getFrame() { } public void destroy() { - super.destroy(); + frame.setVisible(false); + super.destroy(); frame.dispose(); + Toolkit.getDefaultToolkit().sync(); } public void toFront() {