cancel cm hidden timer when active

This commit is contained in:
csf
2022-10-26 21:39:28 +09:00
parent e759b62f5d
commit 5a905174e7
3 changed files with 62 additions and 54 deletions

View File

@@ -107,6 +107,13 @@ class ConnectionManagerState extends State<ConnectionManager> {
@override
Widget build(BuildContext context) {
final serverModel = Provider.of<ServerModel>(context);
final pointerHandler = serverModel.cmHiddenTimer != null
? (PointerEvent e) {
serverModel.cmHiddenTimer!.cancel();
serverModel.cmHiddenTimer = null;
debugPrint("CM hidden timer has been canceled");
}
: null;
return serverModel.clients.isEmpty
? Column(
children: [
@@ -118,35 +125,38 @@ class ConnectionManagerState extends State<ConnectionManager> {
),
],
)
: DesktopTab(
showTitle: false,
showMaximize: false,
showMinimize: true,
showClose: true,
controller: serverModel.tabController,
maxLabelWidth: 100,
tail: buildScrollJumper(),
selectedTabBackgroundColor:
Theme.of(context).hintColor.withOpacity(0.2),
tabBuilder: (key, icon, label, themeConf) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
icon,
Tooltip(
message: key,
waitDuration: Duration(seconds: 1),
child: label),
],
);
},
pageViewBuilder: (pageView) => Row(children: [
Expanded(child: pageView),
Consumer<ChatModel>(
builder: (_, model, child) => model.isShowChatPage
? Expanded(child: Scaffold(body: ChatPage()))
: Offstage())
]));
: Listener(
onPointerDown: pointerHandler,
onPointerMove: pointerHandler,
child: DesktopTab(
showTitle: false,
showMaximize: false,
showMinimize: true,
showClose: true,
controller: serverModel.tabController,
maxLabelWidth: 100,
tail: buildScrollJumper(),
selectedTabBackgroundColor:
Theme.of(context).hintColor.withOpacity(0.2),
tabBuilder: (key, icon, label, themeConf) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
icon,
Tooltip(
message: key,
waitDuration: Duration(seconds: 1),
child: label),
],
);
},
pageViewBuilder: (pageView) => Row(children: [
Expanded(child: pageView),
Consumer<ChatModel>(
builder: (_, model, child) => model.isShowChatPage
? Expanded(child: Scaffold(body: ChatPage()))
: Offstage())
])));
}
Widget buildTitleBar() {

View File

@@ -73,7 +73,7 @@ class DesktopTabController {
int get length => state.value.tabs.length;
void add(TabInfo tab, {bool authorized = false}) {
void add(TabInfo tab) {
if (!isDesktop) return;
final index = state.value.tabs.indexWhere((e) => e.key == tab.key);
int toIndex;
@@ -87,16 +87,6 @@ class DesktopTabController {
toIndex = state.value.tabs.length - 1;
assert(toIndex >= 0);
}
if (tabType == DesktopTabType.cm) {
Future.delayed(Duration.zero, () async {
window_on_top(null);
});
if (authorized) {
Future.delayed(const Duration(seconds: 3), () {
windowManager.minimize();
});
}
}
try {
jumpTo(toIndex);
} catch (e) {