Merge pull request #4702 from 21pages/cm

show cm after receiving textchat when cm hidden
This commit is contained in:
RustDesk 2023-06-20 13:27:52 +08:00 committed by GitHub
commit af309096c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 21 deletions

View File

@ -224,15 +224,16 @@ void runConnectionManagerScreen(bool hide) async {
MyTheme.currentThemeMode(), MyTheme.currentThemeMode(),
); );
if (hide) { if (hide) {
hideCmWindow(); await hideCmWindow(isStartup: true);
} else { } else {
showCmWindow(); await showCmWindow(isStartup: true);
} }
// Start the uni links handler and redirect links to Native, not for Flutter. // Start the uni links handler and redirect links to Native, not for Flutter.
_uniLinkSubscription = listenUniLinks(handleByFlutter: false); _uniLinkSubscription = listenUniLinks(handleByFlutter: false);
} }
void showCmWindow() { showCmWindow({bool isStartup = false}) async {
if (isStartup) {
WindowOptions windowOptions = getHiddenTitleBarWindowOptions( WindowOptions windowOptions = getHiddenTitleBarWindowOptions(
size: kConnectionManagerWindowSizeClosedChat); size: kConnectionManagerWindowSizeClosedChat);
windowManager.waitUntilReadyToShow(windowOptions, () async { windowManager.waitUntilReadyToShow(windowOptions, () async {
@ -243,9 +244,20 @@ void showCmWindow() {
await windowManager.setSizeAlignment( await windowManager.setSizeAlignment(
kConnectionManagerWindowSizeClosedChat, Alignment.topRight); kConnectionManagerWindowSizeClosedChat, Alignment.topRight);
}); });
} else {
if (await windowManager.getOpacity() != 1) {
await windowManager.setOpacity(1);
await windowManager.focus();
await windowManager.minimize(); //needed
await windowManager.setSizeAlignment(
kConnectionManagerWindowSizeClosedChat, Alignment.topRight);
window_on_top(null);
}
}
} }
void hideCmWindow() { hideCmWindow({bool isStartup = false}) async {
if (isStartup) {
WindowOptions windowOptions = getHiddenTitleBarWindowOptions( WindowOptions windowOptions = getHiddenTitleBarWindowOptions(
size: kConnectionManagerWindowSizeClosedChat); size: kConnectionManagerWindowSizeClosedChat);
windowManager.setOpacity(0); windowManager.setOpacity(0);
@ -254,6 +266,12 @@ void hideCmWindow() {
await windowManager.minimize(); await windowManager.minimize();
await windowManager.hide(); await windowManager.hide();
}); });
} else {
await windowManager.setOpacity(0);
bind.mainHideDocker();
await windowManager.minimize();
await windowManager.hide();
}
} }
void _runApp( void _runApp(

View File

@ -13,6 +13,7 @@ import 'package:flutter_svg/flutter_svg.dart';
import '../consts.dart'; import '../consts.dart';
import '../common.dart'; import '../common.dart';
import '../common/widgets/overlay.dart'; import '../common/widgets/overlay.dart';
import '../main.dart';
import 'model.dart'; import 'model.dart';
class MessageBody { class MessageBody {
@ -288,6 +289,10 @@ class ChatModel with ChangeNotifier {
return; return;
} }
if (text.isEmpty) return; if (text.isEmpty) return;
if (desktopType == DesktopType.cm) {
await showCmWindow();
}
// mobile: first message show overlay icon // mobile: first message show overlay icon
if (!isDesktop && chatIconOverlayEntry == null) { if (!isDesktop && chatIconOverlayEntry == null) {
showChatIconOverlay(); showChatIconOverlay();

View File

@ -224,9 +224,9 @@ class ServerModel with ChangeNotifier {
_hideCm = hideCm; _hideCm = hideCm;
if (desktopType == DesktopType.cm) { if (desktopType == DesktopType.cm) {
if (hideCm) { if (hideCm) {
hideCmWindow(); await hideCmWindow();
} else { } else {
showCmWindow(); await showCmWindow();
} }
} }
update = true; update = true;