Merge pull request #1726 from Heap-Hop/window_maximize
flutter desktop window un/maximize
This commit is contained in:
commit
c67c55f74b
@ -38,7 +38,6 @@ var isWeb = false;
|
|||||||
var isWebDesktop = false;
|
var isWebDesktop = false;
|
||||||
var version = "";
|
var version = "";
|
||||||
int androidVersion = 0;
|
int androidVersion = 0;
|
||||||
const windowPrefix = "wm_";
|
|
||||||
DesktopType? desktopType;
|
DesktopType? desktopType;
|
||||||
|
|
||||||
typedef F = String Function(String);
|
typedef F = String Function(String);
|
||||||
@ -957,16 +956,18 @@ class LastWindowPosition {
|
|||||||
double? height;
|
double? height;
|
||||||
double? offsetWidth;
|
double? offsetWidth;
|
||||||
double? offsetHeight;
|
double? offsetHeight;
|
||||||
|
bool? isMaximized;
|
||||||
|
|
||||||
LastWindowPosition(
|
LastWindowPosition(this.width, this.height, this.offsetWidth,
|
||||||
this.width, this.height, this.offsetWidth, this.offsetHeight);
|
this.offsetHeight, this.isMaximized);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
"width": width,
|
"width": width,
|
||||||
"height": height,
|
"height": height,
|
||||||
"offsetWidth": offsetWidth,
|
"offsetWidth": offsetWidth,
|
||||||
"offsetHeight": offsetHeight
|
"offsetHeight": offsetHeight,
|
||||||
|
"isMaximized": isMaximized,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,8 +982,8 @@ class LastWindowPosition {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final m = jsonDecode(content);
|
final m = jsonDecode(content);
|
||||||
return LastWindowPosition(
|
return LastWindowPosition(m["width"], m["height"], m["offsetWidth"],
|
||||||
m["width"], m["height"], m["offsetWidth"], m["offsetHeight"]);
|
m["offsetHeight"], m["isMaximized"]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint(e.toString());
|
debugPrint(e.toString());
|
||||||
return null;
|
return null;
|
||||||
@ -999,22 +1000,29 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
|
|||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WindowType.Main:
|
case WindowType.Main:
|
||||||
List resp = await Future.wait(
|
final position = await windowManager.getPosition();
|
||||||
[windowManager.getPosition(), windowManager.getSize()]);
|
final sz = await windowManager.getSize();
|
||||||
Offset position = resp[0];
|
final isMaximized = await windowManager.isMaximized();
|
||||||
Size sz = resp[1];
|
final pos = LastWindowPosition(
|
||||||
final pos =
|
sz.width, sz.height, position.dx, position.dy, isMaximized);
|
||||||
LastWindowPosition(sz.width, sz.height, position.dx, position.dy);
|
|
||||||
await Get.find<SharedPreferences>()
|
await Get.find<SharedPreferences>()
|
||||||
.setString(windowPrefix + type.name, pos.toString());
|
.setString(kWindowPrefix + type.name, pos.toString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: implement window
|
final wc = WindowController.fromWindowId(windowId!);
|
||||||
|
final frame = await wc.getFrame();
|
||||||
|
final position = frame.topLeft;
|
||||||
|
final sz = frame.size;
|
||||||
|
final isMaximized = await wc.isMaximized();
|
||||||
|
final pos = LastWindowPosition(
|
||||||
|
sz.width, sz.height, position.dx, position.dy, isMaximized);
|
||||||
|
await Get.find<SharedPreferences>()
|
||||||
|
.setString(kWindowPrefix + type.name, pos.toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_adjustRestoreMainWindowSize(double? width, double? height) async {
|
Future<Size> _adjustRestoreMainWindowSize(double? width, double? height) async {
|
||||||
const double minWidth = 600;
|
const double minWidth = 600;
|
||||||
const double minHeight = 100;
|
const double minHeight = 100;
|
||||||
double maxWidth = (((isDesktop || isWebDesktop)
|
double maxWidth = (((isDesktop || isWebDesktop)
|
||||||
@ -1055,10 +1063,12 @@ _adjustRestoreMainWindowSize(double? width, double? height) async {
|
|||||||
if (restoreHeight > maxHeight) {
|
if (restoreHeight > maxHeight) {
|
||||||
restoreWidth = maxHeight;
|
restoreWidth = maxHeight;
|
||||||
}
|
}
|
||||||
await windowManager.setSize(Size(restoreWidth, restoreHeight));
|
return Size(restoreWidth, restoreHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
_adjustRestoreMainWindowOffset(double? left, double? top) async {
|
/// return null means center
|
||||||
|
Future<Offset?> _adjustRestoreMainWindowOffset(
|
||||||
|
double? left, double? top) async {
|
||||||
if (left == null || top == null) {
|
if (left == null || top == null) {
|
||||||
await windowManager.center();
|
await windowManager.center();
|
||||||
} else {
|
} else {
|
||||||
@ -1090,40 +1100,68 @@ _adjustRestoreMainWindowOffset(double? left, double? top) async {
|
|||||||
windowLeft > frameRight ||
|
windowLeft > frameRight ||
|
||||||
windowTop < frameTop ||
|
windowTop < frameTop ||
|
||||||
windowTop > frameBottom) {
|
windowTop > frameBottom) {
|
||||||
await windowManager.center();
|
return null;
|
||||||
} else {
|
} else {
|
||||||
await windowManager.setPosition(Offset(windowLeft, windowTop));
|
return Offset(windowLeft, windowTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save window position and size on exit
|
/// Restore window position and size on start
|
||||||
/// Note that windowId must be provided if it's subwindow
|
/// Note that windowId must be provided if it's subwindow
|
||||||
Future<bool> restoreWindowPosition(WindowType type, {int? windowId}) async {
|
Future<bool> restoreWindowPosition(WindowType type, {int? windowId}) async {
|
||||||
if (type != WindowType.Main && windowId == null) {
|
if (type != WindowType.Main && windowId == null) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"Error: windowId cannot be null when saving positions for sub window");
|
"Error: windowId cannot be null when saving positions for sub window");
|
||||||
}
|
}
|
||||||
|
final pos =
|
||||||
|
Get.find<SharedPreferences>().getString(kWindowPrefix + type.name);
|
||||||
|
|
||||||
|
if (pos == null) {
|
||||||
|
debugPrint("no window position saved, ignore restore");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var lpos = LastWindowPosition.loadFromString(pos);
|
||||||
|
if (lpos == null) {
|
||||||
|
debugPrint("window position saved, but cannot be parsed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WindowType.Main:
|
case WindowType.Main:
|
||||||
var pos =
|
if (lpos.isMaximized == true) {
|
||||||
Get.find<SharedPreferences>().getString(windowPrefix + type.name);
|
await windowManager.maximize();
|
||||||
if (pos == null) {
|
} else {
|
||||||
debugPrint("no window position saved, ignore restore");
|
final size =
|
||||||
return false;
|
await _adjustRestoreMainWindowSize(lpos.width, lpos.height);
|
||||||
|
final offset = await _adjustRestoreMainWindowOffset(
|
||||||
|
lpos.offsetWidth, lpos.offsetHeight);
|
||||||
|
await windowManager.setSize(size);
|
||||||
|
if (offset == null) {
|
||||||
|
await windowManager.center();
|
||||||
|
} else {
|
||||||
|
await windowManager.setPosition(offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var lpos = LastWindowPosition.loadFromString(pos);
|
|
||||||
if (lpos == null) {
|
|
||||||
debugPrint("window position saved, but cannot be parsed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _adjustRestoreMainWindowSize(lpos.width, lpos.height);
|
|
||||||
await _adjustRestoreMainWindowOffset(lpos.offsetWidth, lpos.offsetHeight);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
// TODO: implement subwindow
|
final wc = WindowController.fromWindowId(windowId!);
|
||||||
|
if (lpos.isMaximized == true) {
|
||||||
|
await wc.maximize();
|
||||||
|
} else {
|
||||||
|
final size =
|
||||||
|
await _adjustRestoreMainWindowSize(lpos.width, lpos.height);
|
||||||
|
final offset = await _adjustRestoreMainWindowOffset(
|
||||||
|
lpos.offsetWidth, lpos.offsetHeight);
|
||||||
|
if (offset == null) {
|
||||||
|
await wc.center();
|
||||||
|
} else {
|
||||||
|
final frame =
|
||||||
|
Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height);
|
||||||
|
await wc.setFrame(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1150,7 +1188,7 @@ void checkArguments() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse `rustdesk://` unilinks
|
/// Parse `rustdesk://` unilinks
|
||||||
///
|
///
|
||||||
/// [Functions]
|
/// [Functions]
|
||||||
/// 1. New Connection: rustdesk://connection/new/your_peer_id
|
/// 1. New Connection: rustdesk://connection/new/your_peer_id
|
||||||
void parseRustdeskUri(String uriPath) {
|
void parseRustdeskUri(String uriPath) {
|
||||||
|
@ -15,6 +15,8 @@ const String kActionNewConnection = "connection/new/";
|
|||||||
const String kTabLabelHomePage = "Home";
|
const String kTabLabelHomePage = "Home";
|
||||||
const String kTabLabelSettingPage = "Settings";
|
const String kTabLabelSettingPage = "Settings";
|
||||||
|
|
||||||
|
const String kWindowPrefix = "wm_";
|
||||||
|
|
||||||
const Color kColorWarn = Color.fromARGB(255, 245, 133, 59);
|
const Color kColorWarn = Color.fromARGB(255, 245, 133, 59);
|
||||||
|
|
||||||
const int kMobileDefaultDisplayWidth = 720;
|
const int kMobileDefaultDisplayWidth = 720;
|
||||||
|
@ -289,57 +289,48 @@ class DesktopTab extends StatelessWidget {
|
|||||||
Widget _buildBar() {
|
Widget _buildBar() {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Row(
|
||||||
child: Row(
|
children: [
|
||||||
children: [
|
Offstage(
|
||||||
Offstage(
|
offstage: !Platform.isMacOS,
|
||||||
offstage: !Platform.isMacOS,
|
child: const SizedBox(
|
||||||
child: const SizedBox(
|
width: 78,
|
||||||
width: 78,
|
)),
|
||||||
)),
|
GestureDetector(
|
||||||
Row(children: [
|
onDoubleTap: () =>
|
||||||
Offstage(
|
showMaximize ? toggleMaximize(isMainWindow) : null,
|
||||||
offstage: !showLogo,
|
onPanStart: (_) => startDragging(isMainWindow),
|
||||||
child: SvgPicture.asset(
|
child: Row(children: [
|
||||||
'assets/logo.svg',
|
Offstage(
|
||||||
width: 16,
|
offstage: !showLogo,
|
||||||
height: 16,
|
child: SvgPicture.asset(
|
||||||
)),
|
'assets/logo.svg',
|
||||||
Offstage(
|
width: 16,
|
||||||
offstage: !showTitle,
|
height: 16,
|
||||||
child: const Text(
|
)),
|
||||||
"RustDesk",
|
Offstage(
|
||||||
style: TextStyle(fontSize: 13),
|
offstage: !showTitle,
|
||||||
).marginOnly(left: 2))
|
child: const Text(
|
||||||
]).marginOnly(
|
"RustDesk",
|
||||||
left: 5,
|
style: TextStyle(fontSize: 13),
|
||||||
right: 10,
|
).marginOnly(left: 2))
|
||||||
),
|
]).marginOnly(
|
||||||
Expanded(
|
left: 5,
|
||||||
child: GestureDetector(
|
right: 10,
|
||||||
onPanStart: (_) {
|
)),
|
||||||
if (isMainWindow) {
|
_ListView(
|
||||||
windowManager.startDragging();
|
controller: controller,
|
||||||
} else {
|
onTabClose: onTabClose,
|
||||||
WindowController.fromWindowId(windowId!)
|
tabBuilder: tabBuilder,
|
||||||
.startDragging();
|
labelGetter: labelGetter,
|
||||||
}
|
),
|
||||||
},
|
],
|
||||||
child: _ListView(
|
|
||||||
controller: controller,
|
|
||||||
onTabClose: onTabClose,
|
|
||||||
tabBuilder: tabBuilder,
|
|
||||||
labelGetter: labelGetter,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Offstage(offstage: tail == null, child: tail),
|
|
||||||
WindowActionPanel(
|
WindowActionPanel(
|
||||||
mainTab: isMainWindow,
|
isMainWindow: isMainWindow,
|
||||||
tabType: tabType,
|
tabType: tabType,
|
||||||
state: state,
|
state: state,
|
||||||
|
tail: tail,
|
||||||
showMinimize: showMinimize,
|
showMinimize: showMinimize,
|
||||||
showMaximize: showMaximize,
|
showMaximize: showMaximize,
|
||||||
showClose: showClose,
|
showClose: showClose,
|
||||||
@ -350,38 +341,106 @@ class DesktopTab extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WindowActionPanel extends StatelessWidget {
|
class WindowActionPanel extends StatefulWidget {
|
||||||
final bool mainTab;
|
final bool isMainWindow;
|
||||||
final DesktopTabType tabType;
|
final DesktopTabType tabType;
|
||||||
final Rx<DesktopTabState> state;
|
final Rx<DesktopTabState> state;
|
||||||
|
|
||||||
final bool showMinimize;
|
final bool showMinimize;
|
||||||
final bool showMaximize;
|
final bool showMaximize;
|
||||||
final bool showClose;
|
final bool showClose;
|
||||||
|
final Widget? tail;
|
||||||
final Future<bool> Function()? onClose;
|
final Future<bool> Function()? onClose;
|
||||||
|
|
||||||
const WindowActionPanel(
|
const WindowActionPanel(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
required this.mainTab,
|
required this.isMainWindow,
|
||||||
required this.tabType,
|
required this.tabType,
|
||||||
required this.state,
|
required this.state,
|
||||||
|
this.tail,
|
||||||
this.showMinimize = true,
|
this.showMinimize = true,
|
||||||
this.showMaximize = true,
|
this.showMaximize = true,
|
||||||
this.showClose = true,
|
this.showClose = true,
|
||||||
this.onClose})
|
this.onClose})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return WindowActionPanelState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WindowActionPanelState extends State<WindowActionPanel>
|
||||||
|
with MultiWindowListener, WindowListener {
|
||||||
|
bool isMaximized = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
DesktopMultiWindow.addListener(this);
|
||||||
|
windowManager.addListener(this);
|
||||||
|
|
||||||
|
if (widget.isMainWindow) {
|
||||||
|
windowManager.isMaximized().then((maximized) {
|
||||||
|
if (isMaximized != maximized) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
|
(_) => setState(() => isMaximized = maximized));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
final wc = WindowController.fromWindowId(windowId!);
|
||||||
|
wc.isMaximized().then((maximized) {
|
||||||
|
if (isMaximized != maximized) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
|
(_) => setState(() => isMaximized = maximized));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
DesktopMultiWindow.removeListener(this);
|
||||||
|
windowManager.removeListener(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onWindowMaximize() {
|
||||||
|
// catch maximize from system
|
||||||
|
if (!isMaximized) {
|
||||||
|
setState(() => isMaximized = true);
|
||||||
|
}
|
||||||
|
super.onWindowMaximize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onWindowUnmaximize() {
|
||||||
|
// catch unmaximize from system
|
||||||
|
if (isMaximized) {
|
||||||
|
setState(() => isMaximized = false);
|
||||||
|
}
|
||||||
|
super.onWindowUnmaximize();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Expanded(
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: GestureDetector(
|
||||||
|
onDoubleTap: widget.showMaximize ? _toggleMaximize : null,
|
||||||
|
onPanStart: (_) => startDragging(widget.isMainWindow),
|
||||||
|
)),
|
||||||
|
Offstage(offstage: widget.tail == null, child: widget.tail),
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !showMinimize,
|
offstage: !widget.showMinimize,
|
||||||
child: ActionIcon(
|
child: ActionIcon(
|
||||||
message: 'Minimize',
|
message: 'Minimize',
|
||||||
icon: IconFont.min,
|
icon: IconFont.min,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (mainTab) {
|
if (widget.isMainWindow) {
|
||||||
windowManager.minimize();
|
windowManager.minimize();
|
||||||
} else {
|
} else {
|
||||||
WindowController.fromWindowId(windowId!).minimize();
|
WindowController.fromWindowId(windowId!).minimize();
|
||||||
@ -389,56 +448,23 @@ class WindowActionPanel extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
isClose: false,
|
isClose: false,
|
||||||
)),
|
)),
|
||||||
// TODO: drag makes window restore
|
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !showMaximize,
|
offstage: !widget.showMaximize,
|
||||||
child: FutureBuilder(builder: (context, snapshot) {
|
child: ActionIcon(
|
||||||
RxBool isMaximized = false.obs;
|
message: isMaximized ? "Restore" : "Maximize",
|
||||||
if (mainTab) {
|
icon: isMaximized ? IconFont.restore : IconFont.max,
|
||||||
windowManager.isMaximized().then((maximized) {
|
onTap: _toggleMaximize,
|
||||||
isMaximized.value = maximized;
|
isClose: false,
|
||||||
});
|
)),
|
||||||
} else {
|
|
||||||
final wc = WindowController.fromWindowId(windowId!);
|
|
||||||
wc.isMaximized().then((maximized) {
|
|
||||||
isMaximized.value = maximized;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return Obx(
|
|
||||||
() => ActionIcon(
|
|
||||||
message: isMaximized.value ? "Restore" : "Maximize",
|
|
||||||
icon: isMaximized.value ? IconFont.restore : IconFont.max,
|
|
||||||
onTap: () {
|
|
||||||
if (mainTab) {
|
|
||||||
if (isMaximized.value) {
|
|
||||||
windowManager.unmaximize();
|
|
||||||
} else {
|
|
||||||
windowManager.maximize();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO: subwindow is maximized but first query result is not maximized.
|
|
||||||
final wc = WindowController.fromWindowId(windowId!);
|
|
||||||
if (isMaximized.value) {
|
|
||||||
wc.unmaximize();
|
|
||||||
} else {
|
|
||||||
wc.maximize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isMaximized.value = !isMaximized.value;
|
|
||||||
},
|
|
||||||
isClose: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
})),
|
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !showClose,
|
offstage: !widget.showClose,
|
||||||
child: ActionIcon(
|
child: ActionIcon(
|
||||||
message: 'Close',
|
message: 'Close',
|
||||||
icon: IconFont.close,
|
icon: IconFont.close,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final res = await onClose?.call() ?? true;
|
final res = await widget.onClose?.call() ?? true;
|
||||||
if (res) {
|
if (res) {
|
||||||
if (mainTab) {
|
if (widget.isMainWindow) {
|
||||||
windowManager.close();
|
windowManager.close();
|
||||||
} else {
|
} else {
|
||||||
// only hide for multi window, not close
|
// only hide for multi window, not close
|
||||||
@ -451,7 +477,47 @@ class WindowActionPanel extends StatelessWidget {
|
|||||||
isClose: true,
|
isClose: true,
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
);
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _toggleMaximize() {
|
||||||
|
toggleMaximize(widget.isMainWindow).then((maximize) {
|
||||||
|
if (isMaximized != maximize) {
|
||||||
|
// setState for sub window, wc.unmaximize/maximize() will not invoke onWindowMaximize/Unmaximize
|
||||||
|
setState(() => isMaximized = !isMaximized);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void startDragging(bool isMainWindow) {
|
||||||
|
if (isMainWindow) {
|
||||||
|
windowManager.startDragging();
|
||||||
|
} else {
|
||||||
|
WindowController.fromWindowId(windowId!).startDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return true -> window will be maximize
|
||||||
|
/// return false -> window will be unmaximize
|
||||||
|
Future<bool> toggleMaximize(bool isMainWindow) async {
|
||||||
|
if (isMainWindow) {
|
||||||
|
if (await windowManager.isMaximized()) {
|
||||||
|
windowManager.unmaximize();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
windowManager.maximize();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
final wc = WindowController.fromWindowId(windowId!);
|
||||||
|
if (await wc.isMaximized()) {
|
||||||
|
wc.unmaximize();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
wc.maximize();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ Future<void> main(List<String> args) async {
|
|||||||
int type = argument['type'] ?? -1;
|
int type = argument['type'] ?? -1;
|
||||||
argument['windowId'] = windowId;
|
argument['windowId'] = windowId;
|
||||||
WindowType wType = type.windowType;
|
WindowType wType = type.windowType;
|
||||||
restoreWindowPosition(wType, windowId: windowId);
|
|
||||||
switch (wType) {
|
switch (wType) {
|
||||||
case WindowType.RemoteDesktop:
|
case WindowType.RemoteDesktop:
|
||||||
desktopType = DesktopType.remote;
|
desktopType = DesktopType.remote;
|
||||||
@ -118,6 +117,7 @@ void runMobileApp() async {
|
|||||||
|
|
||||||
void runRemoteScreen(Map<String, dynamic> argument) async {
|
void runRemoteScreen(Map<String, dynamic> argument) async {
|
||||||
await initEnv(kAppTypeDesktopRemote);
|
await initEnv(kAppTypeDesktopRemote);
|
||||||
|
await restoreWindowPosition(WindowType.RemoteDesktop, windowId: windowId);
|
||||||
runApp(GetMaterialApp(
|
runApp(GetMaterialApp(
|
||||||
navigatorKey: globalKey,
|
navigatorKey: globalKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
@ -143,6 +143,7 @@ void runRemoteScreen(Map<String, dynamic> argument) async {
|
|||||||
|
|
||||||
void runFileTransferScreen(Map<String, dynamic> argument) async {
|
void runFileTransferScreen(Map<String, dynamic> argument) async {
|
||||||
await initEnv(kAppTypeDesktopFileTransfer);
|
await initEnv(kAppTypeDesktopFileTransfer);
|
||||||
|
await restoreWindowPosition(WindowType.FileTransfer, windowId: windowId);
|
||||||
runApp(
|
runApp(
|
||||||
GetMaterialApp(
|
GetMaterialApp(
|
||||||
navigatorKey: globalKey,
|
navigatorKey: globalKey,
|
||||||
@ -168,6 +169,7 @@ void runFileTransferScreen(Map<String, dynamic> argument) async {
|
|||||||
|
|
||||||
void runPortForwardScreen(Map<String, dynamic> argument) async {
|
void runPortForwardScreen(Map<String, dynamic> argument) async {
|
||||||
await initEnv(kAppTypeDesktopPortForward);
|
await initEnv(kAppTypeDesktopPortForward);
|
||||||
|
await restoreWindowPosition(WindowType.PortForward, windowId: windowId);
|
||||||
runApp(
|
runApp(
|
||||||
GetMaterialApp(
|
GetMaterialApp(
|
||||||
navigatorKey: globalKey,
|
navigatorKey: globalKey,
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_hbb/common.dart';
|
||||||
|
|
||||||
/// must keep the order
|
/// must keep the order
|
||||||
enum WindowType { Main, RemoteDesktop, FileTransfer, PortForward, Unknown }
|
enum WindowType { Main, RemoteDesktop, FileTransfer, PortForward, Unknown }
|
||||||
@ -153,6 +154,7 @@ class RustDeskMultiWindowManager {
|
|||||||
int? wId = findWindowByType(type);
|
int? wId = findWindowByType(type);
|
||||||
if (wId != null) {
|
if (wId != null) {
|
||||||
debugPrint("closing multi window: ${type.toString()}");
|
debugPrint("closing multi window: ${type.toString()}");
|
||||||
|
saveWindowPosition(type, windowId: wId);
|
||||||
try {
|
try {
|
||||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||||
if (!ids.contains(wId)) {
|
if (!ids.contains(wId)) {
|
||||||
|
@ -243,8 +243,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "0019311e8aba4e84ffd44c57ba1834cc76924f2a"
|
ref: f25487b8aacfcc9d22b86a84e97eda1a5c07ccaf
|
||||||
resolved-ref: "0019311e8aba4e84ffd44c57ba1834cc76924f2a"
|
resolved-ref: f25487b8aacfcc9d22b86a84e97eda1a5c07ccaf
|
||||||
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
|
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user