Follow-up issue to https://github.com/openjdk/jfx/pull/1804#discussion_r2153809248
On Windows, Stage can sometimes not receive focus due to Windows' anti-focus-stealing mechanisms, SetForegroundWindow() API will then fail and return FALSE. JavaFX never observes if SetForegroundWindow() actually succeeded (return value is ignored) - it assumes the call was successful and the Stage received focus, despite Windows refusing to do so, which causes a state mismatch. See native-glass/win/GlassWindow.cpp @ 1644
This was observed on Windows when running system tests via Gradle daemon (with --daemon flag or its default behavior). Not sure if other platforms also have this behavior, or have a way of triggering it.
Also worth noting, some tests do rely on Stage being focused after calling show(). These tests do not check whether Stage is actually focused before executing, so it might be a good idea to add assertions to those tests to prevent any spurious inputs being sent to other programs:
- MenuDoubleShortcutTest
- TextAreaBehaviorRobotTest
And others that might require it (check by running system tests with --daemon flag)
On Windows, Stage can sometimes not receive focus due to Windows' anti-focus-stealing mechanisms, SetForegroundWindow() API will then fail and return FALSE. JavaFX never observes if SetForegroundWindow() actually succeeded (return value is ignored) - it assumes the call was successful and the Stage received focus, despite Windows refusing to do so, which causes a state mismatch. See native-glass/win/GlassWindow.cpp @ 1644
This was observed on Windows when running system tests via Gradle daemon (with --daemon flag or its default behavior). Not sure if other platforms also have this behavior, or have a way of triggering it.
Also worth noting, some tests do rely on Stage being focused after calling show(). These tests do not check whether Stage is actually focused before executing, so it might be a good idea to add assertions to those tests to prevent any spurious inputs being sent to other programs:
- MenuDoubleShortcutTest
- TextAreaBehaviorRobotTest
And others that might require it (check by running system tests with --daemon flag)
- relates to
-
JDK-8351357 Add canary system test checking if Stage receives focus on show
-
- In Progress
-