eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
81 stars 188 forks source link

Detached view behind main window #2184

Open jrpajr-dev opened 2 months ago

jrpajr-dev commented 2 months ago

I noticed that if I open a view that was detached in the previous run, and then put focus on the main window, the detached view will be placed behind the main window.

To reproduce:

Now, if you click on the main Eclipse window, the Package Explorer dialog will be placed behind the main window.

If you restart Eclipse again, the detached window will be restored to its normal behavior.

When debugging the view creation, in WBWRenderer.createWidget, we can see that the parent shell of this detached window is the "PartRenderingEngine limbo".

Tested under this environment:

jrpajr-dev commented 2 months ago

In my project, I just implemented a local solution, which involves changing the order of 2 calls: setVisible and setToBeRendered.

I discovered this while debugging to try to figure out who was responsible for selecting the view's parent.

So I arrived at this line of code, from PartRenderingEngine.safeCreateGui: image

Going back to whom called this, I realized that is called when the view's container is setted to be rendered, on CleanupAddon.subscribeRenderingChanged: image

In my project, I already have a CustomCleanupAddon, with pretty much the same code as CleanupAddon, but with some changes.

I changed the order of the calls, to set the container's visibility before the to be rendered value, like this: image

I don't know if this will have any collateral effects, but, on my tests, everything worked well.