Skip to content

Conversation

@amartya4256
Copy link
Contributor

This PR does the following:

  1. Makes Widget:filters public: This method is used by many clients which are primarily a widget - child of Widget class. Arguably, there can be Child classes of Widget outside the package, such as, Browser which also heavily use Event based norms. Hence, this method should be made public. Additionally, it is a getter and doesn't do any harm in any way upon exposing.
  2. Edge Browser KeyEvent fix: This is a direct reference to [Edge] Eclipse freezes when opening more than 2 png files in internal web browser via Ctrl+Shift+R eclipse.platform.ui#3104. The freezing of edge browser happens because the KeyEvent Listener (which is a display filter) calls for another Edge Browser instance which won't complete as it is called in a callback, causing deadlocks. Hence, the KeyEvent listeners should be executed asynchronously in the methodEdge:handleAcceleratorKeyPressed. However, args.set_handled in the method must set the value to true only if the shortcut is handled by SWT, i.e., if there's a listener and handles the key combo. Since we cannot check that and set the value while executing asyncly, we needed to find another way to handle it.

Solution: set the Handled to true when there's a listener for key event.

Drawbacks: Of course that means that it will set Handled to true for every Key Event regardless of whatever combination of keys pressed.

The method Widget:filters is made public in this commit as it is used by
many children classes implementing it and having it package protected
prevents the children outside the package to use it.
@amartya4256 amartya4256 changed the title Amartya4256/edge key event Edge Browser Key Event Async Handling Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Test Results

  174 files   -  2    174 suites   - 2   20m 38s ⏱️ - 6m 25s
4 670 tests ± 0  4 648 ✅ ± 0  22 💤 ±0  0 ❌ ±0 
  464 runs   - 17    459 ✅  - 16   5 💤  - 1  0 ❌ ±0 

Results for commit a7c24df. ± Comparison against base commit 9412c36.

♻️ This comment has been updated with latest results.

}

boolean filters (int eventType) {
public boolean filters (int eventType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced that this should become public at all. It would help if you add javadoc (mandatory if its to become public!) that explains why/what/how/when this should be used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it even necessary to do this?

  1. Couldn't you also just create a package-protected method in Browser that is accessed by Edge to get the information, or ...
  2. couldn't you even just use browser.getDisplay().filters... here?

Note that I have not tried to understand the overall intent of the PR yet, so I cannot judge whether the proposal as a whole makes sense. The comment is just about making this method public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display:filters is also package protected. At first I thought we could make this public but then I saw all the widget children classes which use filters they use Widget#filters so for a better convenience, I made that public instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made that public instead.

Note, if this is supposed to be public API, it should provide also a proper javadoc clearly explaining the API contract (beside the usual rules that since tag is needed, bundle version bump etc).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so it's 100% clear - no version bump should be needed as minor version is already bumped for this release via #2824

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the javadoc. Does that look alright or should it be different?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that look alright or should it be different?

Just read the method name and try to imagine you would as a user need to use it.
Here expected reaction looking at the API proposed:

"filters"... What is that?
Filter what?
What kind of "eventType" should be given as argument?
Why filters says anything about listeners: "if there exists a listener"?
Where is there? On the current widget? All widgets in the hierarchy? Display?

If you would try to answer to the questions above, you would realize that this method helps to check whether there are filters registered on the display for given event type.

So I believe if it should be API, it should be named "hasFilters(eventType)" and located at Display, next to addFilter() and "removeFilter()". And of course javadoc should match the javadoc provided by two other methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming-wise, I think its fine. filters here is used as a verb, as in, if it filters the event. I think, that was the intention of naming it like that here. So convenience wise the methods mean, add a filter to display, remove a filter from display and if display filters an event. hasFilter is also correct but so is filter. But if we name it hasFilter, either we need to provide a new method which is a copy of filters or we need to rename filters to hasFilter for which we need to adapt all its consumers. I think we can go with the name filter and provide more in-depth explanation in the javadoc just the way it is done is addFilter.
I'll re-adapt the javadoc and push.

});

boolean hasListener = browser.getListeners(keyEvent.type).length != 0 || browser.filters(keyEvent.type);
System.out.println(hasListener);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a draft PR, so please remove all debug code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh thanks, missed that one out.

@amartya4256 amartya4256 force-pushed the amartya4256/edge_key_event branch 2 times, most recently from 1079f40 to 81d9314 Compare December 9, 2025 13:17
Edge:handleAcceleratorKeyPressed must handle Browser:sendKeyEvent
asynchronously as KeyEvent's Listeners can cause deadlock. Hence, the
Handled of this event is set if there exists a listener for the event or
a Display filter.
@amartya4256 amartya4256 force-pushed the amartya4256/edge_key_event branch from 81d9314 to a7c24df Compare December 9, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Freeze on Edge instantiation via BrowserViewer

4 participants