diff options
Diffstat (limited to 'widget/gtk/WakeLockListener.cpp')
-rw-r--r-- | widget/gtk/WakeLockListener.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/widget/gtk/WakeLockListener.cpp b/widget/gtk/WakeLockListener.cpp index b2c43cb485..33bb374cef 100644 --- a/widget/gtk/WakeLockListener.cpp +++ b/widget/gtk/WakeLockListener.cpp @@ -137,6 +137,7 @@ class WakeLockTopic { bool UninhibitWaylandIdle(); #endif + bool IsNativeWakeLock(int aWakeLockType); bool IsWakeLockTypeAvailable(int aWakeLockType); bool SwitchToNextWakeLockType(); @@ -779,8 +780,14 @@ nsresult WakeLockTopic::InhibitScreensaver() { mShouldInhibit = true; // Iterate through wake lock types in case of failure. - while (!SendInhibit() && SwitchToNextWakeLockType()) { - ; + while (!SendInhibit()) { + // We don't switch away from native locks. Just try again. + if (IsNativeWakeLock(sWakeLockType)) { + return NS_ERROR_FAILURE; + } + if (!SwitchToNextWakeLockType()) { + return NS_ERROR_FAILURE; + } } return (sWakeLockType != Unsupported) ? NS_OK : NS_ERROR_FAILURE; @@ -850,6 +857,21 @@ bool WakeLockTopic::IsWakeLockTypeAvailable(int aWakeLockType) { } } +bool WakeLockTopic::IsNativeWakeLock(int aWakeLockType) { + switch (aWakeLockType) { +#if defined(MOZ_X11) + case XScreenSaver: + return true; +#endif +#if defined(MOZ_WAYLAND) + case WaylandIdleInhibit: + return true; +#endif + default: + return false; + } +} + bool WakeLockTopic::SwitchToNextWakeLockType() { WAKE_LOCK_LOG("WakeLockTopic::SwitchToNextWakeLockType() WakeLockType %s", WakeLockTypeNames[sWakeLockType]); |