Browse Source

Add window manager

pull/40/head
Neo Sun 2 years ago
parent
commit
ef8a2019cc
  1. 18
      lib/main.dart
  2. 3
      lib/rpc.dart
  3. 8
      linux/flutter/generated_plugin_registrant.cc
  4. 2
      linux/flutter/generated_plugins.cmake
  5. 4
      macos/Flutter/GeneratedPluginRegistrant.swift
  6. 12
      macos/Podfile.lock
  7. 4
      macos/Runner/DebugProfile.entitlements
  8. 4
      macos/Runner/Release.entitlements
  9. 14
      pubspec.lock
  10. 1
      pubspec.yaml
  11. 6
      windows/flutter/generated_plugin_registrant.cc
  12. 2
      windows/flutter/generated_plugins.cmake

18
lib/main.dart

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:window_manager/window_manager.dart';
import 'package:esse_core/esse_core.dart';
import 'package:esse/l10n/localizations.dart';
@ -27,9 +28,24 @@ void coreServer() async { @@ -27,9 +28,24 @@ void coreServer() async {
}
}
void main() {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
coreServer(); // daemon running.
// fix the window size
await windowManager.ensureInitialized();
WindowOptions windowOptions = WindowOptions(
size: Size(1024, 768),
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
});
runApp(MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) {

3
lib/rpc.dart

@ -25,10 +25,11 @@ class Response { @@ -25,10 +25,11 @@ class Response {
Future<Response> httpPost(String method, List params) async {
jsonrpc['method'] = method;
jsonrpc['params'] = params;
//print(json.encode(jsonrpc));
print(json.encode(jsonrpc));
try {
final response = await http.post(Uri.http(Global.httpRpc, ''), body: json.encode(jsonrpc));
print(response);
Map data = json.decode(utf8.decode(response.bodyBytes));
if (data['result'] != null) {

8
linux/flutter/generated_plugin_registrant.cc

@ -10,7 +10,9 @@ @@ -10,7 +10,9 @@
#include <file_selector_linux/file_selector_plugin.h>
#include <pasteboard/pasteboard_plugin.h>
#include <record_linux/record_linux_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) esse_core_registrar =
@ -25,7 +27,13 @@ void fl_register_plugins(FlPluginRegistry* registry) { @@ -25,7 +27,13 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) record_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "RecordLinuxPlugin");
record_linux_plugin_register_with_registrar(record_linux_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
g_autoptr(FlPluginRegistrar) window_manager_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
window_manager_plugin_register_with_registrar(window_manager_registrar);
}

2
linux/flutter/generated_plugins.cmake

@ -7,7 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST @@ -7,7 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
pasteboard
record_linux
screen_retriever
url_launcher_linux
window_manager
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

4
macos/Flutter/GeneratedPluginRegistrant.swift

@ -13,8 +13,10 @@ import just_audio @@ -13,8 +13,10 @@ import just_audio
import pasteboard
import path_provider_macos
import record_macos
import screen_retriever
import shared_preferences_macos
import url_launcher_macos
import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
@ -25,6 +27,8 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -25,6 +27,8 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
RecordMacosPlugin.register(with: registry.registrar(forPlugin: "RecordMacosPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}

12
macos/Podfile.lock

@ -16,10 +16,14 @@ PODS: @@ -16,10 +16,14 @@ PODS:
- FlutterMacOS
- record_macos (0.2.0):
- FlutterMacOS
- screen_retriever (0.0.1):
- FlutterMacOS
- shared_preferences_macos (0.0.1):
- FlutterMacOS
- url_launcher_macos (0.0.1):
- FlutterMacOS
- window_manager (0.2.0):
- FlutterMacOS
DEPENDENCIES:
- audio_session (from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos`)
@ -31,8 +35,10 @@ DEPENDENCIES: @@ -31,8 +35,10 @@ DEPENDENCIES:
- pasteboard (from `Flutter/ephemeral/.symlinks/plugins/pasteboard/macos`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
- record_macos (from `Flutter/ephemeral/.symlinks/plugins/record_macos/macos`)
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
- shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
EXTERNAL SOURCES:
audio_session:
@ -53,10 +59,14 @@ EXTERNAL SOURCES: @@ -53,10 +59,14 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
record_macos:
:path: Flutter/ephemeral/.symlinks/plugins/record_macos/macos
screen_retriever:
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
shared_preferences_macos:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
window_manager:
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
SPEC CHECKSUMS:
audio_session: dea1f41890dbf1718f04a56f1d6150fd50039b72
@ -68,8 +78,10 @@ SPEC CHECKSUMS: @@ -68,8 +78,10 @@ SPEC CHECKSUMS:
pasteboard: 9b69dba6fedbb04866be632205d532fe2f6b1d99
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
record_macos: 937889e0f2a7a12b6fc14e97a3678e5a18943de6
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0

4
macos/Runner/DebugProfile.entitlements

@ -3,10 +3,12 @@ @@ -3,10 +3,12 @@
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<false/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

4
macos/Runner/Release.entitlements

@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<false/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

14
pubspec.lock

@ -813,6 +813,13 @@ packages: @@ -813,6 +813,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.7"
screen_retriever:
dependency: transitive
description:
name: screen_retriever
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
shared_preferences:
dependency: "direct main"
description:
@ -1063,6 +1070,13 @@ packages: @@ -1063,6 +1070,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.2"
window_manager:
dependency: "direct main"
description:
name: window_manager
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.8"
xdg_directories:
dependency: transitive
description:

1
pubspec.yaml

@ -38,6 +38,7 @@ dependencies: @@ -38,6 +38,7 @@ dependencies:
bottom_navy_bar: ^6.0.0
flutter_quill: ^6.1.6
fluttertoast: ^8.1.1
window_manager: ^0.2.8
dev_dependencies:
flutter_test:

6
windows/flutter/generated_plugin_registrant.cc

@ -11,7 +11,9 @@ @@ -11,7 +11,9 @@
#include <pasteboard/pasteboard_plugin.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <record_windows/record_windows_plugin_c_api.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
#include <window_manager/window_manager_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
EsseCorePluginRegisterWithRegistrar(
@ -24,6 +26,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -24,6 +26,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
RecordWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("RecordWindowsPluginCApi"));
ScreenRetrieverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WindowManagerPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
}

2
windows/flutter/generated_plugins.cmake

@ -8,7 +8,9 @@ list(APPEND FLUTTER_PLUGIN_LIST @@ -8,7 +8,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
pasteboard
permission_handler_windows
record_windows
screen_retriever
url_launcher_windows
window_manager
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

Loading…
Cancel
Save