diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /widget/gtk/WakeLockListener.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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]); |