Closed Bug 711486 Opened 13 years ago Closed 7 years ago

[b2g] Add a key-events permission to authorize a web application to send trusted key events

Categories

(Core :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: vingtetun, Unassigned)

Details

Attachments

(1 file)

In b2g/gaia there is a keyboard application that needs to be able to send key events to the focused window.

Because the platform often checks if the event is trusted we need to have a way to send trusted events or equivalent.

The keyboard application is an HTML based web application.

Today B2G/Gaia temporarily expose a window,navigator.mozKeyboard API that let the web application send trusted key events via a sendKey method.

This bug is about adding a 'key-events' permission to let a web application send trusted key events - with an attached patch.

This is scarying so I wonder if there is an other/better way to achieve the same thing without exposing such power?
Attachment #582282 - Flags: feedback?(bugs)
For a full ime don't we want to be able to query text, set text, etc?  I'm thinking here of something like autocomllete where we want to be able to insert a word atomically.  But I guess we can have both interfaces.
(In reply to Chris Jones [:cjones] [:warhammer] from comment #1)
> For a full ime don't we want to be able to query text, set text, etc?  I'm
> thinking here of something like autocomllete where we want to be able to
> insert a word atomically.  But I guess we can have both interfaces.

I'm not a IME expert but I think composition events (https://developer.mozilla.org/en/DOM/CompositionEvent) are what we want to achieve this. I was thinking of using the same hackery mechanism for them.

Cc'ing Masayuki.
How about asking Keyboard applications postMessages the keys to Gaia, and have Gaia to send key events to other apps? In this way Gaia can decide whether or not to accept the keys base on the currently visibility of the keyboard layout.

As of the Composition event, does send compositionend event to input element results the string actually being inserted into it? If so the hypothesized "sendString" function can be done like this instead.
composition events are just notification for the listeners at starting, changing and ending composition. We're using NS_TEXT_TEXT event for dispatching the detail of composition string internally. It contains composition string, information about clauses in the composition string and caret position.
(but we should get rid of text event eventually, if possible)
@masayuki So sending composition events does not result text being inserted. Got it. Is the W3C IME API currently present in Gecko? Need to rethink how to do IME in B2G if so (or soon).

@vingtetun Sorry for asking basic questions but I need to make sure we are on the same page: so if this bugs gets resolved, virtual keyboards apps gets to synthesize their own keyboard events to generate keys to the apps right? If this is the plan, there virtual keyboards/IMEs would also need to send out composition events (and text event to Gecko) to completely mimic the behavior of a desktop OS. Does the key-events permission also cover that?
(In reply to Olli Pettay [:smaug] from comment #6)
> (but we should get rid of text event eventually, if possible)

Yeah, but it's not now.

(In reply to Tim Guan-tin Chien [:timdream] from comment #7)
> @masayuki So sending composition events does not result text being inserted.
> Got it. Is the W3C IME API currently present in Gecko? Need to rethink how
> to do IME in B2G if so (or soon).

The IME APIs are just an idea of Bono-san (Google) for now (I mean it's not stable spec). If we need to implement some new IME APIs, we should make same (or similar) APIs.
And the document describes the IME on desktop environments. So, it might help you to understand the complex behavior of IME for East Asian languages.
Comment on attachment 582282 [details] [diff] [review]
Add a key-events permission

I have played a bit more with that and in practice it doesn't work as I've expected first.
The key events generated in the app and dispatched with window.dispatchEvent(keyEvent) are not sent to the window that has the focus.
Attachment #582282 - Flags: feedback?(bugs)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: