Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 529009

Summary: [Win32] Embedded Browser does not forward '<' character to client code
Product: [Eclipse Project] Platform Reporter: Thomas Schindl <tom.schindl>
Component: SWTAssignee: Thomas Schindl <tom.schindl>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, jhelming, lufimtse, niraj.modi
Version: 4.8Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
See Also: https://git.eclipse.org/r/114484
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=b8601fd3fd49a926d02f70b729a3752acbecae21
Whiteboard:
Attachments:
Description Flags
Austrian / german keyboard. My English keyboard doesn't have that button. none

Description Thomas Schindl CLA 2017-12-20 07:31:25 EST
We have an application who has a keybinding assigned to CTRL+< but if the embedded browser has the focus it can not be triggered because < is not passed on to the client code.

Patch to follow!
Comment 1 Eclipse Genie CLA 2017-12-20 08:41:04 EST
New Gerrit change created: https://git.eclipse.org/r/114484
Comment 2 Leo Ufimtsev CLA 2017-12-20 12:51:35 EST
No objections to patch from gtk side. If someone from windows side could verify, that'd be great.
Comment 3 Niraj Modi CLA 2017-12-21 06:32:06 EST
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created: https://git.eclipse.org/r/114484

Code changes look fine:
- Suggest we add both forward '<' and backward '>' characters in the 'KeyTable'

If handy, please share a code snippet for this use-case for verification.
Comment 4 Thomas Schindl CLA 2017-12-21 07:01:50 EST
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Test {

	public static void main(String[] args) {
		Display d = new Display();
		d.addFilter(SWT.KeyDown, e -> {
			System.err.println(e.character);
		});
		Shell s = new Shell();
		s.setLayout(new FillLayout());
		
		Browser b = new Browser(s, SWT.NONE);
		b.setUrl("http://www.google.at");
		
		s.open();
		while( ! s.isDisposed() ) {
			if( ! d.readAndDispatch() ) {
				d.sleep();
			}
		}
		d.dispose();
	}

}
Comment 5 Thomas Schindl CLA 2017-12-21 07:02:33 EST
and "NO" i don't think > needs to be added because this > is created with a modifier key.
Comment 6 Leo Ufimtsev CLA 2017-12-21 09:34:33 EST
Btw, tested with snippet. The issue doesn't occur on Gtk/Webkit2. Dom is handled differently so the patch only affects win/cocoa.
Comment 7 Thomas Schindl CLA 2017-12-21 09:41:09 EST
I guess it only affects win32 at least on OS-X the '<' '>' are forwarded already today although what is interesting is the the key-code for '<' on cocoa is "188" who is mapped to ';'!
Comment 8 Niraj Modi CLA 2018-01-10 09:43:05 EST
(In reply to Thomas Schindl from comment #4)

Hi Thomas,
Tested with the snippet shared in comment 4, I am not seeing any behavior difference with and without the patch as tested on Win7 or is it Win10 only issue. Have few related queries:
1. To press '<' Shift is required, so how exactly you type CTRL+< ?
Please share more detailed steps to try out ?

2. Seeing the KeyCode list on below site:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode

On above page the '<' key is mapped to int value 60 and where-as your patch has mapped '<' to 226, please clarify on this.

(In reply to Thomas Schindl from comment #7)
> I guess it only affects win32 at least on OS-X the '<' '>' are forwarded
> already today although what is interesting is the the key-code for '<' on
> cocoa is "188" who is mapped to ';'!

3. WebBrowser.java is a common class for all platforms, and if '<' has different value mapping for different platforms, it might be a problem. We should try and put this character key mapping to platform specific files. e.g. for Windows in IE.java
Comment 9 Thomas Schindl CLA 2018-02-27 09:50:10 EST
Could it be keyboard layout related, we are using a german layout you probably an english one.
Comment 10 Jonas Helming CLA 2018-04-24 12:07:40 EDT
I can reproduce the Bug on Windows (it does not occur on Linux) and confirm that the fix works for me. It would be really great to get this into Photon!
Comment 11 Leo Ufimtsev CLA 2018-04-24 13:27:19 EDT
(In reply to Jonas Helming from comment #10)
> I can reproduce the Bug on Windows (it does not occur on Linux) and confirm
> that the fix works for me. It would be really great to get this into Photon!

What about adding '>'  in addition to '<' ?

Is '>' affected by the issue or only '<'?
Comment 12 Thomas Schindl CLA 2018-04-24 13:35:57 EDT
(In reply to Leo Ufimtsev from comment #11)
> (In reply to Jonas Helming from comment #10)
> > I can reproduce the Bug on Windows (it does not occur on Linux) and confirm
> > that the fix works for me. It would be really great to get this into Photon!
> 
> What about adding '>'  in addition to '<' ?
> 
> Is '>' affected by the issue or only '<'?

See my comment 5
Comment 13 Thomas Schindl CLA 2018-04-25 03:02:04 EDT
Dani, can you confirm this problem your windows as well?
Comment 14 Leo Ufimtsev CLA 2018-04-25 09:52:09 EDT
(In reply to Thomas Schindl from comment #5)
> and "NO" i don't think > needs to be added because this > is created with a
> modifier key.

What's the reasoning here?
for me both < > can only be typed if I hold the 'shift' moddifier and press . ,
Comment 15 Leo Ufimtsev CLA 2018-04-25 09:53:14 EDT
(In reply to Leo Ufimtsev from comment #14)
> (In reply to Thomas Schindl from comment #5)
> > and "NO" i don't think > needs to be added because this > is created with a
> > modifier key.
> 
> What's the reasoning here?
> for me both < > can only be typed if I hold the 'shift' moddifier and press
> . ,

Btw, if no objections, I intend to merge the patch. But would be beneficial to understand why not also add '>'.
Comment 16 Leo Ufimtsev CLA 2018-04-25 09:58:01 EDT
(In reply to Thomas Schindl from comment #4)
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.browser.Browser;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> 
> public class Test {
> 
> 	public static void main(String[] args) {
> 		Display d = new Display();
> 		d.addFilter(SWT.KeyDown, e -> {
> 			System.err.println(e.character);
> 		});
> 		Shell s = new Shell();
> 		s.setLayout(new FillLayout());
> 		
> 		Browser b = new Browser(s, SWT.NONE);
> 		b.setUrl("http://www.google.at");
> 		
> 		s.open();
> 		while( ! s.isDisposed() ) {
> 			if( ! d.readAndDispatch() ) {
> 				d.sleep();
> 			}
> 		}
> 		d.dispose();
> 	}
> 
> }

So with this snippet, is it suppose to demonstrate that Ctrl+< is not being filtered properly? I.e, pressing Ctrl+< inside browser doesn't have desired effect?

(It's usually good to list detailed steps to reproduce, detailed expected behavior and actual behavior with snippet tests to avoid ambiguity. The context is that we're using different OS's (win/cocoa/linux) and different keyboard layouts (German, English) (I use Colemak keyboard layout for example). It's easy for tester to assume wrong things if no detailed steps are given.
Comment 17 Dani Megert CLA 2018-04-25 10:01:07 EDT
(In reply to Thomas Schindl from comment #13)
> Dani, can you confirm this problem your windows as well?

No problem here. I have a Swiss German keyboard where the '<' key can just be pressed to enter '<' (no Shift or other modifier required). And hence Ctrl+< works just fine even when the Internal Browser is active (tested with Open Type command).


(In reply to Leo Ufimtsev from comment #14)
> (In reply to Thomas Schindl from comment #5)
> > and "NO" i don't think > needs to be added because this > is created with a
> > modifier key.
> 
> What's the reasoning here?
> for me both < > can only be typed if I hold the 'shift' moddifier and press
> . ,

The reasoning is that there exist many different keyboard (layouts) ;-).
Comment 18 Thomas Schindl CLA 2018-04-25 10:28:14 EDT
Dani, so if you run the snippet does it really print "<" on the console? We don't talk about the fact that < is shown in the Browser itself, the problem is that the browser does not forward the key-event to SWT.
Comment 19 Leo Ufimtsev CLA 2018-04-25 10:30:16 EDT
(In reply to Dani Megert from comment #17)
> (In reply to Thomas Schindl from comment #13)
> > 
> > What's the reasoning here?
> > for me both < > can only be typed if I hold the 'shift' moddifier and press
> > . ,
> 
> The reasoning is that there exist many different keyboard (layouts) ;-).

I see. So this is specific to German Layout?

What I'm interested in is how does this fix relate in the context of all users with many different layouts, not just those with a specific layout. Can you elaborate?
- How does this affect regular qwerty users, 
- How does this affect German/Swiss users,
- Detailed steps to reproduce so I can test the functionality (with relevant keyboard layout info) before/after the patch.

In short, has this patch any potential to break anything or is all good. I'm probably being overly paranoid ha ha. I'm just curious how things are impacted.

Danke schoen.
Comment 20 Dani Megert CLA 2018-04-25 10:31:19 EDT
(In reply to Thomas Schindl from comment #18)
> Dani, so if you run the snippet does it really print "<" on the console? We
> don't talk about the fact that < is shown in the Browser itself, the problem
> is that the browser does not forward the key-event to SWT.

I did not fiddle with the snippet. I tested comment 0 by changing the key binding for Open Type to Ctrl+<.
Comment 21 Dani Megert CLA 2018-04-25 10:34:36 EDT
(In reply to Leo Ufimtsev from comment #19)
> Danke schoen.

Should be "Danke schön" ;-).
Comment 22 Thomas Schindl CLA 2018-04-25 10:36:18 EDT
The purpose of the snippet is that if you have the focus is on the Browser-Widget the KeyDown-Filter is not triggered.

To test:
* Start Snippet
* Type <
* Type >

Expectation:
* the SWT.KeyDown filter is triggered twice

Result (windows with german keyboard layout):
* Filter is not triggered at all

At least on my german keyboard only the '<' character needs to be added, for me adding '<' is enough to make the above test succeed.
Comment 23 Dani Megert CLA 2018-04-25 11:14:56 EDT
(In reply to Thomas Schindl from comment #22)
> The purpose of the snippet is that if you have the focus is on the
> Browser-Widget the KeyDown-Filter is not triggered.
> 
> To test:
> * Start Snippet
> * Type <
> * Type >
> 
> Expectation:
> * the SWT.KeyDown filter is triggered twice
> 
> Result (windows with german keyboard layout):
> * Filter is not triggered at all
> 
> At least on my german keyboard only the '<' character needs to be added, for
> me adding '<' is enough to make the above test succeed.

On my Swiss German keyboard [1] < and > are triggered twice.

[1] https://en.wikipedia.org/wiki/QWERTZ#Switzerland_(German,_French,_Italian,_Romansh),_Liechtenstein,_Luxembourg
Comment 24 Leo Ufimtsev CLA 2018-04-25 11:25:49 EDT
(In reply to Thomas Schindl from comment #22)
> The purpose of the snippet is that if you have the focus is on the
> Browser-Widget the KeyDown-Filter is not triggered.
> 
> To test:
> * Start Snippet
> * Type <
> * Type >
> 
> Expectation:
> * the SWT.KeyDown filter is triggered twice
> 
> Result (windows with german keyboard layout):
> * Filter is not triggered at all
> 
> At least on my german keyboard only the '<' character needs to be added, for
> me adding '<' is enough to make the above test succeed.

(In reply to Dani Megert from comment #23)
> (In reply to Thomas Schindl from comment #22)
> > The purpose of the snippet is that if you have the focus is on the
> > Browser-Widget the KeyDown-Filter is not triggered.
> > 
> > To test:
> > * Start Snippet
> > * Type <
> > * Type >
> > 
> > Expectation:
> > * the SWT.KeyDown filter is triggered twice
> > 
> > Result (windows with german keyboard layout):
> > * Filter is not triggered at all
> > 
> > At least on my german keyboard only the '<' character needs to be added, for
> > me adding '<' is enough to make the above test succeed.
> 
> On my Swiss German keyboard [1] < and > are triggered twice.
> 
> [1]
> https://en.wikipedia.org/wiki/QWERTZ#Switzerland_(German,_French,_Italian,
> _Romansh),_Liechtenstein,_Luxembourg

Ok, so I tested on my linux and Windows box with regular English layout. '< & >' continue to work as before without visible change.

I cannot verify the fix for Austrian keyboard because my English keyboard seems to lack the '<>' button that can be found on Austrian keyboards (I'll attach picture) and none of the other buttons on my keyboard map onto the '<>' button.

Based on the fact that this patch doesn't seem to break anything, keycode 226 being used for some random greek letter in ascii table (i.e, not useful in English), but '<' is useful in German/Austrian layout, I don't mind merging this patch.

I suppose I could experiment with on-screen keyboards, but based on the fact that it doesn't seem to break anything and fix something, I don't mind just merging the patch in.

If there's no objections, I'll merge the patch on Monday.
Comment 25 Leo Ufimtsev CLA 2018-04-25 11:27:08 EDT
Created attachment 273777 [details]
Austrian / german keyboard. My English keyboard doesn't have that button.
Comment 26 Thomas Schindl CLA 2018-04-25 16:43:06 EDT
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class Test {

	public static void main(String[] args) {
		Display d = new Display();
		d.addFilter(SWT.KeyDown, e -> {
			System.err.println("keyCode: " + e.keyCode + "; stateMask: " + e.stateMask);
		});
		Shell s = new Shell();
		s.setLayout(new GridLayout());

		Text t = new Text(s, SWT.BORDER);
		t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

		Browser b = new Browser(s, SWT.NONE);
		b.setLayoutData(new GridData(GridData.FILL_BOTH));
		b.setUrl("http://www.google.at");

		s.open();
		while (!s.isDisposed()) {
			if (!d.readAndDispatch()) {
				d.sleep();
			}
		}
		d.dispose();
	}

}

Sorry for the confusion my previous desciption and the sample was invalid. The above one shows the problem:

* Launch
* Put Fokus on SWT-Textfield
* Hit CTRL+A
* Hit CTRL+,
* Hit CTRL+<
* Put Fokus on Browser-Textfield
* Hit CTRL+A
* Hit CTRL+,
* Hit CTRL+<

This yields:

# CTRL+A
keyCode: 262144; stateMask: 0
keyCode: 97; stateMask: 262144

# CTRL+,
keyCode: 262144; stateMask: 0
keyCode: 44; stateMask: 262144

# CTRL+<
keyCode: 262144; stateMask: 0
keyCode: 60; stateMask: 262144

--------------

# CTRL+A
keyCode: 262144; stateMask: 0
keyCode: 0; stateMask: 262144
keyCode: 97; stateMask: 262144

# CTRL+,
keyCode: 262144; stateMask: 0
keyCode: 44; stateMask: 262144

# CTRL+<
keyCode: 262144; stateMask: 0
keyCode: 0; stateMask: 262144


The following things are interesting:
* CTRL+A in Browser leads to an extra event 
* CTRL+< in Browser never transports the correct keyCode

With the patch I get (only the browser output):

# CTRL+A
keyCode: 262144; stateMask: 0
keyCode: 0; stateMask: 262144
keyCode: 97; stateMask: 262144

# CTRL+,
keyCode: 262144; stateMask: 0
keyCode: 44; stateMask: 262144

# CTRL+<
keyCode: 262144; stateMask: 0
keyCode: 60; stateMask: 262144
Comment 27 Leo Ufimtsev CLA 2018-04-30 11:02:21 EDT
(In reply to Thomas Schindl from comment #26)

> public class Test {
> ...

Hello Thomas,

I haven't looked into the technical details of the issue above. Is there a simple way to amend the patch to address your issue also?
Is it good to merge the patch and work on the above as a separate issue or does the patch cause the issue above?
Comment 28 Thomas Schindl CLA 2018-04-30 11:47:38 EDT
The patch solves exactly what present here!
Comment 29 Thomas Schindl CLA 2018-04-30 11:49:24 EDT
(In reply to Thomas Schindl from comment #28)
> The patch solves exactly what present here!

Just to repeat:

The expectation is that one gets on CTRL+< ====> keyCode: 60; stateMask: 262144
Comment 30 Leo Ufimtsev CLA 2018-04-30 11:53:17 EDT
(In reply to Thomas Schindl from comment #28)
> The patch solves exactly what present here!

Ok.

So we're good to merge? Feel free to +1 the patch if you think it's good and I'll merge in time for photon release.

Does the patch resolve all problems or is there still something that's not working?
Comment 31 Thomas Schindl CLA 2018-04-30 11:54:52 EDT
yes
Comment 33 Leo Ufimtsev CLA 2018-04-30 11:57:42 EDT
Cool, danke schön for patch!
Comment 34 Leo Ufimtsev CLA 2018-05-08 10:31:42 EDT
I don't have the keyboard to verify this bug. Could someone confirm that this issue is fixed in today's iBuild?
Comment 35 Thomas Schindl CLA 2018-05-08 10:41:11 EDT
Earliest on Friday because I don't have my Windows laptop with me
Comment 36 Leo Ufimtsev CLA 2018-05-08 10:47:08 EDT
(In reply to Thomas Schindl from comment #35)
> Earliest on Friday because I don't have my Windows laptop with me

ok.