mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-07 12:20:03 +03:00
fix(desktop): wakelock issue with multiple tabs in same window (#13956)
Each desktop isolate now independently tracks wakelock state. WakelockPlus.disable() is only called when all tabs within the same isolate are closed/minimized. WakelockPlus ensures screen stays awake as long as any isolate has wakelock enabled. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:uni_links/uni_links.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:window_size/window_size.dart' as window_size;
|
||||
|
||||
@@ -2676,6 +2677,31 @@ class SimpleWrapper<T> {
|
||||
SimpleWrapper(this.value);
|
||||
}
|
||||
|
||||
/// Wakelock manager with reference counting for desktop.
|
||||
/// Ensures wakelock is only disabled when all sessions are closed/minimized.
|
||||
///
|
||||
/// Note: Each isolate has its own WakelockPlus instance with independent assertion.
|
||||
/// As long as one isolate has wakelock enabled, the screen stays awake.
|
||||
/// This manager handles multiple tabs within the same isolate.
|
||||
class WakelockManager {
|
||||
static final Set<UniqueKey> _enabledKeys = {};
|
||||
|
||||
static void enable(UniqueKey key) {
|
||||
if (isLinux) return;
|
||||
_enabledKeys.add(key);
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
|
||||
static void disable(UniqueKey key) {
|
||||
if (isLinux) return;
|
||||
if (_enabledKeys.remove(key)) {
|
||||
if (_enabledKeys.isEmpty) {
|
||||
WakelockPlus.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// call this to reload current window.
|
||||
///
|
||||
/// [Note]
|
||||
|
||||
Reference in New Issue
Block a user