mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1207221 - Do not prevent the system app from vibrating when it is hidden. r=bz r=dhylands
This commit is contained in:
parent
7073bdf44e
commit
16de81782e
@ -774,13 +774,25 @@ NS_IMPL_ISUPPORTS(VibrateWindowListener, nsIDOMEventListener)
|
||||
|
||||
StaticRefPtr<VibrateWindowListener> gVibrateWindowListener;
|
||||
|
||||
static bool
|
||||
MayVibrate(nsIDocument* doc) {
|
||||
#if MOZ_WIDGET_GONK
|
||||
if (XRE_IsParentProcess()) {
|
||||
return true; // The system app can always vibrate
|
||||
}
|
||||
#endif // MOZ_WIDGET_GONK
|
||||
|
||||
// Hidden documents cannot start or stop a vibration.
|
||||
return (doc && !doc->Hidden());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
|
||||
|
||||
if (!doc || doc->Hidden()) {
|
||||
if (!MayVibrate(doc)) {
|
||||
// It's important that we call CancelVibrate(), not Vibrate() with an
|
||||
// empty list, because Vibrate() will fail if we're no longer focused, but
|
||||
// CancelVibrate() will succeed, so long as nobody else has started a new
|
||||
@ -853,12 +865,8 @@ Navigator::Vibrate(const nsTArray<uint32_t>& aPattern)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
|
||||
if (!doc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doc->Hidden()) {
|
||||
// Hidden documents cannot start or stop a vibration.
|
||||
if (!MayVibrate(doc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,8 @@ AssertMainProcess()
|
||||
MOZ_ASSERT(GeckoProcessType_Default == XRE_GetProcessType());
|
||||
}
|
||||
|
||||
#if !defined(MOZ_WIDGET_GONK)
|
||||
|
||||
bool
|
||||
WindowIsActive(nsIDOMWindow* aWindow)
|
||||
{
|
||||
@ -103,6 +105,8 @@ WindowIsActive(nsIDOMWindow* aWindow)
|
||||
return !document->Hidden();
|
||||
}
|
||||
|
||||
#endif // !defined(MOZ_WIDGET_GONK)
|
||||
|
||||
StaticAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate;
|
||||
|
||||
void InitLastIDToVibrate()
|
||||
@ -124,6 +128,7 @@ Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
|
||||
{
|
||||
AssertMainThread();
|
||||
|
||||
#if !defined(MOZ_WIDGET_GONK)
|
||||
// Only active windows may start vibrations. If |id| hasn't gone
|
||||
// through the IPC layer -- that is, if our caller is the outside
|
||||
// world, not hal_proxy -- check whether the window is active. If
|
||||
@ -134,6 +139,7 @@ Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
|
||||
HAL_LOG("Vibrate: Window is inactive, dropping vibrate.");
|
||||
return;
|
||||
}
|
||||
#endif // !defined(MOZ_WIDGET_GONK)
|
||||
|
||||
if (!InSandbox()) {
|
||||
if (!gLastIDToVibrate) {
|
||||
|
Loading…
Reference in New Issue
Block a user