Skip to content

Commit 81d9314

Browse files
committed
Edge browser sends KeyEvent asynchronously
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.
1 parent 8b10d1c commit 81d9314

File tree

4 files changed

+42
-3
lines changed
  • bundles/org.eclipse.swt

4 files changed

+42
-3
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,9 +1573,12 @@ int handleAcceleratorKeyPressed(long pView, long pArgs) {
15731573
return COM.S_OK;
15741574
}
15751575

1576-
if (!sendKeyEvent(keyEvent)) {
1577-
args.put_Handled(true);
1578-
}
1576+
asyncExec(() -> {
1577+
sendKeyEvent(keyEvent);
1578+
});
1579+
1580+
boolean hasListener = browser.getListeners(keyEvent.type).length != 0 || browser.filters(keyEvent.type);
1581+
args.put_Handled(hasListener);
15791582
} else {
15801583
keyEvent.type = SWT.KeyUp;
15811584
browser.notifyListeners (keyEvent.type, keyEvent);

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,18 @@ NSRect expansionFrameWithFrame_inView(long id, long sel, NSRect cellRect, long v
870870
return result;
871871
}
872872

873+
/**
874+
* Checks for if there exists a listener in the collection of listeners who will
875+
* be notified when an event of the given type occurs anywhere in a widget.
876+
*
877+
* Needs to be public as the extended classes of widget should primarily use and
878+
* these classes can be in different packages.
879+
*
880+
* @param eventType
881+
* @return if there exists a listener which reacts to the eventType
882+
*
883+
* @since 3.133
884+
*/
873885
public boolean filters (int eventType) {
874886
return display.filters (eventType);
875887
}

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,18 @@ long filterProc(long xEvent, long gdkEvent, long data2) {
11941194
return 0;
11951195
}
11961196

1197+
/**
1198+
* Checks for if there exists a listener in the collection of listeners who will
1199+
* be notified when an event of the given type occurs anywhere in a widget.
1200+
*
1201+
* Needs to be public as the extended classes of widget should primarily use and
1202+
* these classes can be in different packages.
1203+
*
1204+
* @param eventType
1205+
* @return if there exists a listener which reacts to the eventType
1206+
*
1207+
* @since 3.133
1208+
*/
11971209
public boolean filters (int eventType) {
11981210
return display.filters (eventType);
11991211
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,18 @@ void error (int code) {
510510
SWT.error(code);
511511
}
512512

513+
/**
514+
* Checks for if there exists a listener in the collection of listeners who will
515+
* be notified when an event of the given type occurs anywhere in a widget.
516+
*
517+
* Needs to be public as the extended classes of widget should primarily use and
518+
* these classes can be in different packages.
519+
*
520+
* @param eventType
521+
* @return if there exists a listener which reacts to the eventType
522+
*
523+
* @since 3.133
524+
*/
513525
public boolean filters (int eventType) {
514526
return display.filters (eventType);
515527
}

0 commit comments

Comments
 (0)