Closed xeruf closed 5 years ago
That is a weird issue. Never experienced anything like this, but I have a rough idea why this happens (javafx popups have broken focus) as well as no idea how to fix it (except one, so lets pray). I will try to reproduce.
I think none of the popups should always be in the foreground. It is annoying me all the time.
Can not reproduce.
I provided an impromptu fix in this branch. The fix changes owner window for the file dialog from the popup to the popup's owner. This could in theory fix the problem. Another possible solution would be to try passing null as window owner or possible newly created, invisible and focused window.
Seems like a JDK bug to me.
I think none of the popups should always be in the foreground. It is annoying me all the time.
That is how javafx behaves and it is indeed troubling. I am thinking about possible solutions. Like hiding popup when owner looses focus, then restoring visibility when the focus is regained. I think it would also be possible to tweak the native window style. I have already managed to do that in the past.
I have discovered that JavaFX sets popups to be ALWAYS_ON_TOP. Bypassing this 'feature' will solve the issue of popups always being on top and potentially the reported issue as well.
This is proving very difficult. None of my attempts work. I can disable on top feature of the popup with external program, but not from the Java application.
Relevant: https://stackoverflow.com/questions/21204881/how-to-remove-ws-ex-topmost-style-from-window https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setwindowpos https://docs.microsoft.com/en-us/windows/desktop/winmsg/extended-window-styles
Fixed on Windows with sghpjuikit@8f38b0dbcb55f957ba5250abca61c311f914a5f5
So far, the solution is platform dependent and Windows only. I will need your help to fix this on Linux. I laid down the ground work, so it should not be that hard. I'll push this to master once I clean up the code.
Testing:
accidentaly edited
https://bugs.openjdk.java.net/browse/JDK-8091566 6 years old. What is happening at Java? They put out a decent framework but leave annoyances everywhere and expose just not enough for the developer to able to work around these annoyances...
I have accidentally edited your comment instead of mine and effectivelly deleted its content, I very much apologize! Can you pls write it back?
PopupWindow.java to find the relevant code...
It's in com.sun.stage.Window I think, look for getPeer(), which then has getPlatformWindow(). There are setAlwaysOnTop() and setLevel() methods. Unfortunately none of them seemed to work for me. I have left those solutions in comment so you can try playing around with them and see for yourself. I suspect those solutions do not work for me because on windows ALWAYS_ON_TOP is applied not using setStyle() but setPos() and Im guessing when I call those methods on peer I need to invoke some kind of update() meothod. The one I found did not help me.
I am also starting to wonder if it wouldn't be easier to simply use a Stage. Same. I'd rather not though. For multitude of reasons. Among those are:
- we would need to handle window ownership, z order and focus ourselves
- PopOver would kinda not be a Control anymore. I do not want to go there... On the other hand, it would make resizing, positioning, focusing fine-grained and controllable.
6 years old. What is happening at Java? They put out a decent framework but leave annoyances everywhere and expose just not enough for the developer to able to work around these annoyances...
Java != JavaFX JavaFX has been abandoned before it was finished, that's why.
I have fixed this on Windows using JNA by setting the appropriate window style. I'm sure one can do the same on Linux.
I'm working on a proof of concept popups backed by Stage
instead of PopupControl
. Should solve all troublesome problems like z-ordering and focusing. Working with popups is very troublesome and I simply give up trying to make them work.
I made a proof of concept. Using TRANSPARENT
Stage
with UTILITY
Stage
owner will work as popup substitute.
Fixed in 53da6a4
When I try to change a folder configuration by browsing, the FileChooser opens behind the Settings and the Settings become immovable. My only choice is to close the FileChooser from the taskbar.