From 3af62888dc91c30ea868dd5d6afb3d2dcf4e5f36 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 14 Feb 2025 09:43:34 -0500 Subject: [PATCH] Remove wake lock on desktop --- .../main/java/forge/util/OperatingSystem.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/forge-gui/src/main/java/forge/util/OperatingSystem.java b/forge-gui/src/main/java/forge/util/OperatingSystem.java index 2f1cba9c999..1988d4c687b 100644 --- a/forge-gui/src/main/java/forge/util/OperatingSystem.java +++ b/forge-gui/src/main/java/forge/util/OperatingSystem.java @@ -1,9 +1,5 @@ package forge.util; -import forge.gui.FThreads; - -import java.awt.event.KeyEvent; - public class OperatingSystem { private static String os = System.getProperty("os.name").toLowerCase(); @@ -24,10 +20,16 @@ public class OperatingSystem { } //utility for preventing system from sleeping - private static boolean preventSleep; - private static java.util.concurrent.ScheduledFuture delayedKeepAwakeTask; + //private static boolean preventSleep; + //private static java.util.concurrent.ScheduledFuture delayedKeepAwakeTask; public static void preventSystemSleep(boolean preventSleep0) { + //Disabling this for now. Mashing a key every 30 seconds has become a problematic solution for preventing sleep + //on modern devices which sometimes do handle keys like "F15". + //We could possibly implement the mouse-movement based solution here as an alternative: https://stackoverflow.com/a/53419439 + //It's possible though that we don't actually need it. Supposedly modern OSes can use network traffic as + //an indication that the computer shouldn't put the CPU to sleep. + /* if (preventSleep == preventSleep0) { return; } preventSleep = preventSleep0; @@ -38,9 +40,10 @@ public class OperatingSystem { if (preventSleep) { //ensure task scheduled from EDT thread FThreads.invokeInEdtNowOrLater(keepSystemAwake); - } + }*/ } + /* private static Runnable keepSystemAwake = new Runnable() { @Override public void run() { @@ -63,4 +66,5 @@ public class OperatingSystem { } } }; + */ }