Inconsistent behavior of SendKeyEvent on Win vs Linux

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby akaltar » Sat Oct 08, 2016 8:06 pm

I am using the latest CEF3 binary release from the spotify site.

I am using CEF3 for offscreen rendering. The window creation is handled by a cross-platform library, that sends consistent key events on all platforms.

In what format should I fill the CefKeyEvent struct to make it behave consistently on all platforms?

Currently I tried mapping everything to windows key codes, and sending text as utf16 characters in the char member. This works on Linux, but on window it seems that the character code is ignored even though I set the event type as KEYEVENT_CHAR.
akaltar
Techie
 
Posts: 11
Joined: Wed Jun 22, 2016 7:48 am

Re: Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby Czarek » Sun Oct 09, 2016 12:12 am

Sending windows key codes on Linux is what I do as well. Are you setting both "character" and "unmodified_character"? Are you sending both RAWKEYDOWN and CHAR events?
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby akaltar » Mon Oct 10, 2016 8:26 am

I am sending KEYDOWN / KEYUP and CHAR events only.

If I get text input from the library I am using I send CHAR events, otherwise KEYDOWN / KEYUP.

I am only filling the windows_key_code, character, modifiers fields in the struct.

What else should I fill(Hopefully without having to use separate lookup tables for win/linux?
Or just what do they mean? The documentation is very sparse about this :/
akaltar
Techie
 
Posts: 11
Joined: Wed Jun 22, 2016 7:48 am

Re: Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby Czarek » Mon Oct 10, 2016 9:18 am

Implement CefKeyboardHandler and listen to keyboard events. See which events and what values are sent for given key presses. Do this in a non-OSR example.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby akaltar » Mon Oct 10, 2016 4:36 pm

I have delved into the source code to see how things are handled. It seems there is no solution to my problem. I would have to map a UTF8 character back to a Windows keycode AND a native keycode, which depends on locale too.

The keyboard input system currently employed is horrible to be used with OSR and cross-platform libraries that abstract away the operating system.

The saddest thing in it all is that CEF abstracts away the OS too, so it could use a uniform input system.

I wish I had the knowledge to make the necessary changes to add an option for sending UTF8 data on all platforms, but I don't. (Especially since unit testing is required).

Anyways thanks for your help.
akaltar
Techie
 
Posts: 11
Joined: Wed Jun 22, 2016 7:48 am

Re: Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby magreenblatt » Tue Oct 11, 2016 1:29 pm

magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Inconsistent behavior of SendKeyEvent on Win vs Linux

Postby akaltar » Tue Oct 11, 2016 3:29 pm

I managed to solve this partially, by using UTF16 character codes for windows_key_code and character, unmodified character values.(and of course set modifiers properly).

This is a nice simple work-around, but still prints some warning about character codes occasionally.

If there would be a change, UTF8 string input would be good. As many frameworks handle IME on their own, resulting in a UTF8 string(most commonly). So if we could just add that as a "pure-text" input and have a separate event type for keystrokes, that would be great. I don't know chromium limitations, so sorry if what I am supposing is not possible.
akaltar
Techie
 
Posts: 11
Joined: Wed Jun 22, 2016 7:48 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 107 guests