eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
117 stars 134 forks source link

Edge Browser: Replace BrowserInformationControl dosn't work on hover #1540

Open amartya4256 opened 5 days ago

amartya4256 commented 5 days ago

Describe the bug When using Edge Browser as the default browser, the BrowserInformationControl for the JavaDoc hover tooltip doesn't replace with navihation buttons on hovering.

To Reproduce

Expected behavior The BrowserInformationControl should be replaced with the ones with navigation buttons with any action on the tooltip.

Note: With WebView2, it doesn't seem possible to capture hover events and one possible proposal could be to trigger this event on Mouse Click and other Mouse Events which can be captured.

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

  1. Select the platform(s) on which the behavior is seen:

      • [ ] All OS
      • [x] Windows
      • [ ] Linux
      • [ ] macOS
  2. Additional OS info (e.g. OS version, Linux Desktop, etc)

  3. JRE/JDK version

Version since Eclipse or SWT version since when the behavior is seen [e.g. 4.23]

Workaround (or) Additional context Add any other context about the problem here. Any known workarounds for the problem?

fedejeanne commented 5 days ago

I added this issue to the roadmap.

@amartya4256 please provide a screenshot to better understand the issue.

sratz commented 4 days ago

I looked into mouse events in general.

WebView2 does not offer any native API for this.

However, it should be possible to use a BrowserFunction or a host object + some mouse event listeners on the DOM to react on those.

I got a PoC partially(*) working locally which I need to clean up and will submit a draft PR when I find some time.

HeikoKlare commented 3 days ago

However, it should be possible to use a BrowserFunction or a host object + some mouse event listeners on the DOM to react on those.

I got a PoC partially(*) working locally which I need to clean up and will submit a draft PR when I find some time.

That sounds great! So if I understand correctly, that would render #1499 with https://github.com/eclipse-platform/eclipse.platform.ui/pull/2408 obsolete, as it will allow to restore the "original" hovering behavior, won't it? Do think we should thus hold those back those PRs and wait for your draft PR, @sratz?

merks commented 3 days ago

Just a random thought: I also wondered if org.eclipse.swt.widgets.Display.addFilter(int, Listener) might help see events one might not otherwise see...

HeikoKlare commented 3 days ago

Just a random thought: I also wondered if org.eclipse.swt.widgets.Display.addFilter(int, Listener) might help see events one might not otherwise see...

As far as I understood the analysis results, once the cursor is on top of the (embedded) WebView component, no mouse events will reach the Eclipse/SWT process (and thus the Display class) anymore. They are already processed by the WebView process. That why this PR proposes, as a first step, to notify about focus events (implicitly triggered by clicking into the WebView component) and Sebastian's proposal would capture the mouse events within the WebView process and explicitly pass them to the Eclipse/SWT process via callback.

merks commented 3 days ago

Yes, if the embedded view can do the proper work, that would ideal and better. I just randomly wondered if say via a timer event one could trigger determining the location of the mouse position to know it is over the area of the display in which the browser component exists and could determine when hovering is occurring because the mouse point remains in that area without moving. Anyway, it's just a random thought...

HeikoKlare commented 3 days ago

Yes, interesting idea/"tweak" 👍 We discussed similar approaches but I am not sure whether we had that exact one on the list. @amartya4256 do you remember if you already tried something like that or if that may be feasible?

amartya4256 commented 3 days ago

It was one of the ideas we talked about but I didn't try implementing it so far since my thoughts were that we need to check for this in a loop and validate the posititon of the cursor against the bounds of the browser. Do you have any other idea which is more efficient than just running a loop, i.e. polling for such event as a listener? Not sure if it is possible.

merks commented 3 days ago

You couldn't just loop and block the event queue. You'd need to use org.eclipse.swt.widgets.Display.timerExec(int, Runnable) and from the Runnable you can call timerExec again to test again later, detect that the hover has happened, or detect that it's time to stop checking for whatever reason, i.e., the browser control has disappeared. A bit like what this does:

https://github.com/eclipse-oomph/oomph/blob/aec695021ac7dae8811c371cd1df5583c09b4f47/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/UIUtil.java#L1271-L1341