Open pms1 opened 4 months ago
We are currently experiencing the same issue. I tested the fix #1187 from @eneufeld and noticed the same issue as @fedejeanne. So for me this is not fixed.
I dug a bit into this and noticed a few tings, please be aware that these are just my observations from an outside perspective and maybe not how things actually work as I could have missed something.
To activate a Part by clicking into it, a few things and events have to happen;
The fix from @eneufeld tries to solve this by triggering this focus event by calling forceFocus(). But then we run into the issue that forceFocus() checks if the target control is already in focus, with "isFocusControl()" and later down with "hasFocus()". For me this is already the case when forceFocus() is called, so the manually set focus is never triggered as the Browser has already the focus, which leads to the whole chain not being triggered correctly.
I tried to play around with the focus gained and focus lost callback of Edge, but easily end up in an endless activation and deactivation loop or with a solution that works only in 60% of the cases. I have the feeling that we have here some issue with race conditions.
I also have the feeling that I am missing something, maybe curtail between step 2 and 3 in my observation.
(fyi @HeikoKlare)
Thank you @N1k145 for your analysis! I'm going to reopen this issue since it has been created with the title "Browser control with SWT.EDGE does not emit Activate/Decactivate events [...]", which tells me that the issue you described in https://github.com/eclipse-platform/eclipse.platform.swt/issues/1139#issuecomment-2136552473 and I observed in https://github.com/eclipse-platform/eclipse.platform.swt/pull/1187#issuecomment-2090125163 should be fixed before closing the issue.
Sadly, I can't address this issue right now since I have other topics to work on, but maybe @eneufeld / @N1k145 would like to dig deeper into it?
Describe the bug In an Eclipse RCP application with a Browser control with SWT.EDGE in a view, that view does not get activated when another view is activate and a left click in the view with the browser is performed. It works as expected when SWT.NONE is used instead of SWT.EDGE.
An event listener on SWT.Activate and SWT.Deactivate is never called for a Browser with SWT.EDGE, and even if I don't know if this is related, it would be my guess.
To Reproduce There is an example RCP application at https://github.com/pms1/swt-browser-activate that can be used to reproduce the problem. It opens 3 views, one with Browser SWT.NONE, one with Browser SWT.EDGE and one with a button. Clicking into those views shows that the view with the EDGE browser never becomes activated and that no events are emitted (debug output on System.out).
Expected behavior Browser with SWT.EDGE behaves like a Browser with SWT.NONE regarding activation and deactivation.
Screenshots n.a.
Environment:
Select the platform(s) on which the behavior is seen:
Additional OS info (e.g. OS version, Linux Desktop, etc) Windows 10 22H2 (Build 19045.4170) WebView2 runtime 122.0.2365.92
JRE/JDK version Java 17.0.10 (version included in Eclipse 2024-03)
Version since Observed in SWT 3.125 from Eclipse 2024-03 (4.31.0). Not checked with older versions.
Workaround (or) Additional context n.a.