mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-12 19:06:13 +02:00
fix: synchronize macOS window theme on flutter theme changed.
This commit is contained in:
parent
76adc8de20
commit
6119e04006
6 changed files with 94 additions and 1 deletions
|
@ -9,6 +9,7 @@ import 'package:back_button_interceptor/back_button_interceptor.dart';
|
|||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_hbb/utils/platform_channel.dart';
|
||||
import 'package:win32/win32.dart' as win32;
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -235,6 +236,12 @@ class MyTheme {
|
|||
}
|
||||
bind.mainChangeTheme(dark: mode.toShortString());
|
||||
}
|
||||
// Synchronize the window theme of the system.
|
||||
if (Platform.isMacOS) {
|
||||
final isDark = mode == ThemeMode.dark;
|
||||
RdPlatformChannel.instance.changeSystemWindowTheme(
|
||||
isDark ? SystemWindowTheme.dark : SystemWindowTheme.light);
|
||||
}
|
||||
}
|
||||
|
||||
static ThemeMode currentThemeMode() {
|
||||
|
@ -1686,3 +1693,16 @@ String getWindowName({WindowType? overrideType}) {
|
|||
String getWindowNameWithId(String id, {WindowType? overrideType}) {
|
||||
return "${DesktopTab.labelGetterAlias(id).value} - ${getWindowName(overrideType: overrideType)}";
|
||||
}
|
||||
|
||||
void updateSystemWindowTheme() {
|
||||
// Set system window theme for macOS
|
||||
final userPreference = MyTheme.getThemeModePreference();
|
||||
if (userPreference != ThemeMode.system) {
|
||||
if (Platform.isMacOS) {
|
||||
RdPlatformChannel.instance.changeSystemWindowTheme(
|
||||
userPreference == ThemeMode.light
|
||||
? SystemWindowTheme.light
|
||||
: SystemWindowTheme.dark);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue