Skip to content

[desktop_multi_window] Is there any way to take over the three control buttons of the title bar? #71

@MoonBlueSky

Description

@MoonBlueSky

question

I'm having a problem using this plugin with bitsdojo_window
1.The three control buttons are only effective in the first window
2.The three control buttons of the newly opened window are not proxied
3.The proxy button click in the new window will make the first window react, such as closing

Is there any documentation or solution that supports this library, or this library will add functions like window proxy

code

pubspec.yaml

dependencies:
flutter:
sdk: flutter

bitsdojo_window: ^0.1.1+1
flutter_acrylic: ^1.0.0

main.cpp

#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <windows.h>

#include "flutter_window.h"
#include "utils.h"
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
...

main.dart

import 'dart:convert';

import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:collection/collection.dart';
import 'package:desktop_lifecycle/desktop_lifecycle.dart';
import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart';

import 'event_widget.dart';

void main(List args) async {
WidgetsFlutterBinding.ensureInitialized();

if (args.firstOrNull == 'multi_window') {
final windowId = int.parse(args[1]);
final argument = args[2].isEmpty
? const {}
: jsonDecode(args[2]) as Map<String, dynamic>;
// await Window.initialize();
runApp(_ExampleMainWindow());
} else {
// await Window.initialize();
runApp(const _ExampleMainWindow());
}
// Add this code below

doWhenWindowReady(() {
final initialSize = Size(600, 450);
appWindow.minSize = initialSize;
appWindow.size = initialSize;
appWindow.alignment = Alignment.center;
appWindow.title = "test";
appWindow.show();
});
}

class _ExampleMainWindow extends StatefulWidget {
const _ExampleMainWindow({Key? key}) : super(key: key);

@OverRide
State<_ExampleMainWindow> createState() => _ExampleMainWindowState();
}

class _ExampleMainWindowState extends State<_ExampleMainWindow> {
@OverRide
void initState() {
// TODO: implement initState
super.initState();
}

final buttonColors = WindowButtonColors(
iconNormal: Color(0xFF805306),
mouseOver: Color(0xFFF6A00C),
mouseDown: Color(0xFF805306),
iconMouseOver: Color(0xFF805306),
iconMouseDown: Color(0xFFFFD500));

final closeButtonColors = WindowButtonColors(
mouseOver: Color(0xFFD32F2F),
mouseDown: Color(0xFFB71C1C),
iconNormal: Color(0xFF805306),
iconMouseOver: Colors.white);
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.transparent,
body: WindowBorder(
color: const Color(0xFFF6A00C),
child: Column(
children: [
SizedBox(
height: 30,
child: Container(
color: const Color(0xFFF6A00C),
child: WindowTitleBarBox(
child: Row(children: [
Expanded(child: MoveWindow()),
Row(
children: [
MinimizeWindowButton(colors: buttonColors),
MaximizeWindowButton(colors: buttonColors),
CloseWindowButton(colors: closeButtonColors),
],
)
])),
),
),
TextButton(
onPressed: () async {
final window =
await DesktopMultiWindow.createWindow(jsonEncode({
'args1': 'Sub window',
'args2': 100,
'args3': true,
'bussiness': 'bussiness_test',
}));
window
..setFrame(const Offset(0, 0) & const Size(1280, 720))
..center()
..setTitle('Another window')
..show();
},
child: const Text('Create a new World!'),
),
Expanded(
child:
EventWidget(controller: WindowController.fromWindowId(0)),
)
],
),
),
),
);
}
}

class _ExampleSubWindow extends StatelessWidget {
const _ExampleSubWindow({
Key? key,
required this.windowController,
required this.args,
}) : super(key: key);

final WindowController windowController;
final Map? args;

@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
if (args != null)
Text(
'Arguments: ${args.toString()}',
style: const TextStyle(fontSize: 20),
),
ValueListenableBuilder(
valueListenable: DesktopLifecycle.instance.isActive,
builder: (context, active, child) {
if (active) {
return const Text('Window Active');
} else {
return const Text('Window Inactive');
}
},
),
TextButton(
onPressed: () async {
windowController.close();
},
child: const Text('Close this window'),
),
Expanded(child: EventWidget(controller: windowController)),
],
),
),
);
}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions