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;
|
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
|
NS_IMETHODIMP
|
||||||
VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent)
|
VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDocument> doc =
|
nsCOMPtr<nsIDocument> doc =
|
||||||
do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
|
do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
|
||||||
|
|
||||||
if (!doc || doc->Hidden()) {
|
if (!MayVibrate(doc)) {
|
||||||
// It's important that we call CancelVibrate(), not Vibrate() with an
|
// It's important that we call CancelVibrate(), not Vibrate() with an
|
||||||
// empty list, because Vibrate() will fail if we're no longer focused, but
|
// 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
|
// 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();
|
nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
|
||||||
if (!doc) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc->Hidden()) {
|
if (!MayVibrate(doc)) {
|
||||||
// Hidden documents cannot start or stop a vibration.
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +91,8 @@ AssertMainProcess()
|
|||||||
MOZ_ASSERT(GeckoProcessType_Default == XRE_GetProcessType());
|
MOZ_ASSERT(GeckoProcessType_Default == XRE_GetProcessType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(MOZ_WIDGET_GONK)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WindowIsActive(nsIDOMWindow* aWindow)
|
WindowIsActive(nsIDOMWindow* aWindow)
|
||||||
{
|
{
|
||||||
@ -103,6 +105,8 @@ WindowIsActive(nsIDOMWindow* aWindow)
|
|||||||
return !document->Hidden();
|
return !document->Hidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !defined(MOZ_WIDGET_GONK)
|
||||||
|
|
||||||
StaticAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate;
|
StaticAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate;
|
||||||
|
|
||||||
void InitLastIDToVibrate()
|
void InitLastIDToVibrate()
|
||||||
@ -124,6 +128,7 @@ Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
|
|||||||
{
|
{
|
||||||
AssertMainThread();
|
AssertMainThread();
|
||||||
|
|
||||||
|
#if !defined(MOZ_WIDGET_GONK)
|
||||||
// Only active windows may start vibrations. If |id| hasn't gone
|
// Only active windows may start vibrations. If |id| hasn't gone
|
||||||
// through the IPC layer -- that is, if our caller is the outside
|
// through the IPC layer -- that is, if our caller is the outside
|
||||||
// world, not hal_proxy -- check whether the window is active. If
|
// 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.");
|
HAL_LOG("Vibrate: Window is inactive, dropping vibrate.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // !defined(MOZ_WIDGET_GONK)
|
||||||
|
|
||||||
if (!InSandbox()) {
|
if (!InSandbox()) {
|
||||||
if (!gLastIDToVibrate) {
|
if (!gLastIDToVibrate) {
|
||||||
|
Loading…
Reference in New Issue
Block a user