-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#450/Bug 578929 - Control.setFocus brings windows to front #553
#450/Bug 578929 - Control.setFocus brings windows to front #553
Conversation
393c42d
to
4c4b239
Compare
@elsazac @deepika-u Can you please verify the PR? |
4c4b239
to
25efc17
Compare
@tmssngr As per my understanding, expected behavior is : Before the fix : After the fix : This fix looks fine for me on windows 11. Please correct/add if my understanding is fine. |
@tmssngr As per my understanding, Expected Behavior is: Without PR : With PR: The behaviour in Mac is totally different from that in windows. |
To what |
The first snippet that was provided along with the issue. |
Sorry for the delay. On my Mac mini M1 (macOS 13.2.1) the |
25efc17
to
7aa5920
Compare
Are these failing builds caused by my pull request? |
What else is needed from my side to merge this PR? |
A positive review from @SyntevoAlex? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support the idea of this change, but I feel uneasy about potential regressions. I guess the only way to move forward here is trial&error - merge, see what happens, revert/fix/reapply as needed.
I would really like to see a set of UnitTests here (one per each fixed problem and discovered regression). Because
- there was a number of regressions
- multiple platforms are affected
- the change has potentially far-reaching consequences
- I find it likely that there will be some future tweaks to this logic
In your testing snippet, there are 1000ms pauses. Try to fix that when converting to unit test.
Maybe you will need to add SwtTestUtil.processEvents()
somewhere instead of those sleeps.
bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
Show resolved
Hide resolved
7aa5920
to
1c20ec8
Compare
I would still very much like to see unit tests here. |
1c20ec8
to
a29ee88
Compare
Please look at this unit test. It reliably produces an NPE which might be caused by the disposing of the display inside the shell's dispose listener. I'm quite sure this NPE is independent of the patch. |
…front If the application is in the background and the GUI is updated, especially a different control is getting focused, it might happen that the shell will be brought to front. This patch should fix that. To get the previous behavior (activate the shell on control.forceFocus(), set the system property "org.eclipse.swt.internal.activateShellOnForceFocus" to "true"). If you want an application window be brought to front, instead of relying on control.forceFocus() to bring the shell to front, use shell.setActive(). Shell.open: an explicit bringToTop() is needed now, because the implicit one from setFocus/forceFocus() is not happening any more. It needs to be forced, because otherwise it won't do anything (display.activeShell is null). If a shell is activated, restore the focus which has been set when it was inactive.
1895a35
to
9e43c26
Compare
Let's give it a try. In master now. @iloveeclipse @lshanmug this PR is kind of breaking change. When app sets focus to a control and relies (incorrectly) that Shell will also become active, this will no longer be the case. Explicit |
There is a test failure in the build pertaining to this PR. |
@elsazac Where can the stacktrace be found? |
See latest nightly build root page: Go from there to Mac swt results
Please also check the windows fail in a different test (which I haven't seen failing before):
|
Note, there is also now a fail in org.eclipse.jface.tests.databinding
that seem be directly related to this PR. |
Is anyone aware of the cause of the windows failure? seeing for the first time. Else please let me know if i might have to open new issue for it if it is unrelated. |
I wonder what is different for this test machine than for the one which ran yesterday successfully for this (unmerged) pull request. |
Attempted with FocusToFrontTest.java snippet. Expected behavior is : This is how it is exactly working for me even. I have verified on below environment |
Going to investigate test failures now. |
@deepika-u sorry failed to parse. Do you mean that it's good after the patch? |
|
Fails for a long time, unrelated to this Issue, see #106 |
The problem is in test only. And here (old logs before patch) it can be seen that this never worked on Windows:
So the test was always kind of broken. I think that test needs to wait for |
From the past iteration of testing, i have understood that expected behavior is like that. So it is working as per that after the fix is delivered into master(leaving the junit failures aside). |
Unfortunately not:
|
I've created dedicated issue for the fail, we don't need to abuse this PR anymore: #727 |
Thanks for analysis
But now it consistently fail, which is not nice... Anyway, moving to dedicated issue: eclipse-platform/eclipse.platform.ui#910 |
Due to the revert of eclipse-platform/eclipse.platform.swt/pull/553, the utilities added in eclipse-platform#933 became obsolete. The utilities are code duplications from the SWT repository, which are faulty and have already been updated in the SWT repository. This change thus reverts the addition of the duplicated and now unnecessary utilities. It reverts commit 4194b8f from PR eclipse-platform#933 for issue eclipse-platform#910.
Due to the revert of eclipse-platform/eclipse.platform.swt/pull/553, the utilities added in eclipse-platform#933 became obsolete. The utilities are code duplications from the SWT repository, which are faulty and have already been updated in the SWT repository. This change thus reverts the addition of the duplicated and now unnecessary utilities. It reverts commit 4194b8f from PR eclipse-platform#933 for issue eclipse-platform#910.
Due to the revert of eclipse-platform/eclipse.platform.swt/pull/553, the utilities added in #933 became obsolete. The utilities are code duplications from the SWT repository, which are faulty and have already been updated in the SWT repository. This change thus reverts the addition of the duplicated and now unnecessary utilities. It reverts commit 4194b8f from PR #933 for issue #910.
Due to the revert of eclipse-platform/eclipse.platform.swt/pull/553, the utilities added in eclipse-platform#933 became obsolete. The utilities are code duplications from the SWT repository, which are faulty and have already been updated in the SWT repository. This change thus reverts the addition of the duplicated and now unnecessary utilities. It reverts commit 4194b8f from PR eclipse-platform#933 for issue eclipse-platform#910.
If the application is in the background and the GUI is updated, especially a different control is getting focused, it might happen that the shell will be brought to front. This patch should fix that.
To get the previous behavior (activate the shell on control.forceFocus(), set the system property
"org.eclipse.swt.internal.activateShellOnForceFocus" to "true").
If you want an application window be brought to front, instead of relying on control.forceFocus() to bring the shell to front, use shell.forceActive().
Shell.open: an explicit bringToTop() is needed now, because the implicit one from setFocus/forceFocus() is not happening any more. For the first shell it needs to be forced, because otherwise it won't do anything (display.activeShell is null).