Software buttons are broken in mulet and simulator

RESOLVED FIXED in 2.2 S1 (5dec)

Status

Firefox OS
Simulator
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: ochameau, Assigned: ochameau)

Tracking

unspecified
2.2 S1 (5dec)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 3 obsolete attachments)

(Assignee)

Description

4 years ago
Bug 1014418 most likely regressed these features. It looks like we need to send other kinds of events to gaia now (don't know yet what?).
We used to send mozChromeEvent to the system app.
Hi Alexandre,

Did you mean software home buttons or software buttons you simulate in mulet and simulator?

If you mean the latter, this is because after bug 1014418 landed, system app no longer listens to mozChromeEvent.
Bug 989198 made KeyboardEvents dispatched across browser elements. System app now listens to KeyboardEvent and BeforeAfterKeyboardEvent introduced in bug 989198.

This page describe the whole scenario:   https://wiki.mozilla.org/WebAPI/BrowserAPI/KeyboardEvent#Dispatch_KeyboardEvent_across_BrowserElements

BeforeAfterKeyboardEvent is currently enabled in b2g only, with the pref 'dom.beforeAfterKeyboardEvent.enabled' set to true.
(Assignee)

Comment 2

4 years ago
(In reply to Tzu-Lin Huang [:dwi2][:tzhuang] from comment #1)
> Did you mean software home buttons or software buttons you simulate in mulet
> and simulator?

Yes, the ones in mulet, simulator and fx nightly mode.
(Assignee)

Comment 3

4 years ago
It's not really clear how we can implement software buttons now.
Before all these patches, pressing the HOME or END key of your keyboard was like pressing your home button and power button of your device.
Now it no longer works.

We used to send mozChromeEvent.
I tried dispatching fake KeyboardEvent and/or BeforeAfterKeyboardEvent, but nothing appear to work.
What precise kind of event should I dispatch on the system app to make it work??

Here is what I tried:
  let systemAppContentWindow;
  let KeyEvent = systemAppContentWindow.KeyEvent;
  var e = new systemAppContentWindow.KeyboardEvent("keydown", {keyCode: KeyEvent.DOM_VK_HOME});
  // Replacing KeyboardEvent with BeforeAfterKeyboardEvent doesn't change anything
  // Dispatching keydown, keyup or keypress doesn't work
  systemAppContentWindow.dispatchEvent(e); 

Or should I directly fake some mozbrowserbeforekeydown events?!
Flags: needinfo?(tzhuang)
Hi Alexandre, 

What you tried is almost right, except that you need to change {keyCode: KeyEvent.DOM_VK_HOME} to {key: 'Home'}. This is because we try to follow DOM level 3 definition.

Here is the key mapping:
  Home key: 'Home'
  Power key: 'Power'
  Volume up key: 'VolumeUp'
  Volume down key: 'VolumeDown'

I tried your code snippet with key definition above. And it works on mulet.

  let systemAppContentWindow;
  let KeyEvent = systemAppContentWindow.KeyEvent;
  var e = new systemAppContentWindow.KeyboardEvent("keydown", {key: "Home"});
  systemAppContentWindow.dispatchEvent(e); 

Also I press the HOME key on my physical keyboard when I use mulet, it also works.
Flags: needinfo?(tzhuang)
(Assignee)

Updated

4 years ago
Assignee: nobody → poirot.alex
Summary: Sofware buttons are broken in mulet and simulator → Software buttons are broken in mulet and simulator
Comment on attachment 8524143 [details] [diff] [review]
b2g desktop patch

Review of attachment 8524143 [details] [diff] [review]:
-----------------------------------------------------------------

::: b2g/chrome/content/desktop.js
@@ +30,5 @@
>    // so that click events are delayed and it is better to
>    // listen for touch events.
>    homeButton.addEventListener('touchstart', function() {
> +    let window = shell.contentBrowser.contentWindow;
> +    let e = new window.KeyboardEvent("keydown", {key: "Home"});

As much as I prefer double quotes for strings, it looks like this file foolishly mixes quote style but uses single quotes in the functions touched by this patch.
Attachment #8524143 - Flags: review?(fabrice) → review+
(Assignee)

Comment 7

4 years ago
Created attachment 8524396 [details] [diff] [review]
responsive design patch for mulet

I had to expose the system app frame from SystemAppProxy
in order to dispatch the KeyboardEvents... (instead of mozChromeEvent)
(Assignee)

Updated

4 years ago
Attachment #8524396 - Flags: review?(paul)
Attachment #8524396 - Flags: review?(21)
(Assignee)

Comment 8

4 years ago
Created attachment 8524507 [details] [diff] [review]
b2g desktop patch

Fixed quotes.
Attachment #8524143 - Attachment is obsolete: true
Attachment #8524507 - Flags: review+
(Assignee)

Comment 9

4 years ago
Created attachment 8524567 [details] [diff] [review]
b2g desktop patch

Really fix them...
Attachment #8524507 - Attachment is obsolete: true
Attachment #8524567 - Flags: review+
(Assignee)

Comment 10

4 years ago
Checkin needed for attachment 8524567 [details] [diff] [review].
Keywords: checkin-needed, leave-open

Updated

4 years ago
Attachment #8524396 - Flags: review?(paul) → review+
(Assignee)

Comment 11

4 years ago
Created attachment 8526178 [details] [diff] [review]
responsive design patch for mulet

No longer expose system app frame.
Exposes a helper on SystemAppProxy instead.
Attachment #8524396 - Attachment is obsolete: true
Attachment #8524396 - Flags: review?(21)
Attachment #8526178 - Flags: review?(21)
(Assignee)

Comment 14

4 years ago
Comment on attachment 8526178 [details] [diff] [review]
responsive design patch for mulet

Review of attachment 8526178 [details] [diff] [review]:
-----------------------------------------------------------------

Carry over review from paul and got offline r+ from vivien.
Attachment #8526178 - Flags: review?(21) → review+
(Assignee)

Comment 15

4 years ago
Checking needed for the second patch.
Keywords: leave-open → checkin-needed
https://hg.mozilla.org/mozilla-central/rev/dcdd75b0017f
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.2 S1 (5dec)
You need to log in before you can comment on or make changes to this bug.