From 1502b844b95d82faf0a551f8b9f681ee0b63c34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=81=A5=E8=8E=B9?= Date: Sun, 27 Oct 2024 10:51:39 +0800 Subject: [PATCH] wip --- .../macos/Flutter/GeneratedPluginRegistrant.swift | 2 +- packages/window_manager/example/macos/Podfile.lock | 10 +++++----- .../example/macos/Runner/MainFlutterWindow.swift | 2 +- .../lib/src/widgets/drag_to_resize_area.dart | 2 +- .../lib/src/widgets/virtual_window_frame.dart | 3 +-- .../window_manager/lib/src/widgets/window_caption.dart | 3 +-- packages/window_manager/lib/src/window_manager.dart | 6 +----- packages/window_manager/lib/window_manager.dart | 7 ++----- packages/window_manager/pubspec.yaml | 10 +++++++--- .../linux/CMakeLists.txt | 4 ++-- .../include/window_manager/window_manager_plugin.h | 0 .../linux/window_manager_linux_plugin.cc} | 0 packages/window_manager_linux/pubspec.yaml | 3 ++- .../macos/Classes/WindowManager.swift | 0 .../macos/Classes/WindowManagerPlugin.swift | 0 .../macos/window_manager_macos.podspec} | 8 ++++---- packages/window_manager_macos/pubspec.yaml | 3 ++- .../window_manager_platform_interface/.flutter-plugins | 5 +++++ .../.flutter-plugins-dependencies | 1 + .../lib/src/resize_edge.dart | 0 .../lib/src/title_bar_style.dart | 0 .../lib/src/utils/calc_window_position.dart | 0 .../lib/src/window_listener.dart | 0 .../lib/src/window_options.dart | 2 +- .../lib/window_manager_platform_interface.dart | 5 +++++ .../window_manager_platform_interface/pubspec.yaml | 1 + packages/window_manager_windows/pubspec.yaml | 3 ++- .../windows/.gitignore | 0 .../windows/CMakeLists.txt | 4 ++-- .../include/window_manager/window_manager_plugin.h | 0 .../windows/window_manager.cpp | 0 .../windows/window_manager_windows_plugin.cpp} | 0 32 files changed, 47 insertions(+), 37 deletions(-) rename packages/{window_manager => window_manager_linux}/linux/CMakeLists.txt (90%) rename packages/{window_manager => window_manager_linux}/linux/include/window_manager/window_manager_plugin.h (100%) rename packages/{window_manager/linux/window_manager_plugin.cc => window_manager_linux/linux/window_manager_linux_plugin.cc} (100%) rename packages/{window_manager => window_manager_macos}/macos/Classes/WindowManager.swift (100%) rename packages/{window_manager => window_manager_macos}/macos/Classes/WindowManagerPlugin.swift (100%) rename packages/{window_manager/macos/window_manager.podspec => window_manager_macos/macos/window_manager_macos.podspec} (73%) create mode 100644 packages/window_manager_platform_interface/.flutter-plugins create mode 100644 packages/window_manager_platform_interface/.flutter-plugins-dependencies rename packages/{window_manager => window_manager_platform_interface}/lib/src/resize_edge.dart (100%) rename packages/{window_manager => window_manager_platform_interface}/lib/src/title_bar_style.dart (100%) rename packages/{window_manager => window_manager_platform_interface}/lib/src/utils/calc_window_position.dart (100%) rename packages/{window_manager => window_manager_platform_interface}/lib/src/window_listener.dart (100%) rename packages/{window_manager => window_manager_platform_interface}/lib/src/window_options.dart (89%) rename packages/{window_manager => window_manager_windows}/windows/.gitignore (100%) rename packages/{window_manager => window_manager_windows}/windows/CMakeLists.txt (90%) rename packages/{window_manager => window_manager_windows}/windows/include/window_manager/window_manager_plugin.h (100%) rename packages/{window_manager => window_manager_windows}/windows/window_manager.cpp (100%) rename packages/{window_manager/windows/window_manager_plugin.cpp => window_manager_windows/windows/window_manager_windows_plugin.cpp} (100%) diff --git a/packages/window_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/window_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift index 641dc94f..0d491525 100644 --- a/packages/window_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/window_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,7 +7,7 @@ import Foundation import screen_retriever_macos import tray_manager -import window_manager +import window_manager_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin")) diff --git a/packages/window_manager/example/macos/Podfile.lock b/packages/window_manager/example/macos/Podfile.lock index f7e4c3ee..77546c30 100644 --- a/packages/window_manager/example/macos/Podfile.lock +++ b/packages/window_manager/example/macos/Podfile.lock @@ -4,14 +4,14 @@ PODS: - FlutterMacOS - tray_manager (0.0.1): - FlutterMacOS - - window_manager (0.2.0): + - window_manager_macos (0.2.0): - FlutterMacOS DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`) - tray_manager (from `Flutter/ephemeral/.symlinks/plugins/tray_manager/macos`) - - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) + - window_manager_macos (from `Flutter/ephemeral/.symlinks/plugins/window_manager_macos/macos`) EXTERNAL SOURCES: FlutterMacOS: @@ -20,14 +20,14 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos tray_manager: :path: Flutter/ephemeral/.symlinks/plugins/tray_manager/macos - window_manager: - :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos + window_manager_macos: + :path: Flutter/ephemeral/.symlinks/plugins/window_manager_macos/macos SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 screen_retriever_macos: 776e0fa5d42c6163d2bf772d22478df4b302b161 tray_manager: 9064e219c56d75c476e46b9a21182087930baf90 - window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 + window_manager_macos: c5e0ae4310f93c7150a72509f4169e3053527a49 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 diff --git a/packages/window_manager/example/macos/Runner/MainFlutterWindow.swift b/packages/window_manager/example/macos/Runner/MainFlutterWindow.swift index 872ba9cf..4f05c823 100644 --- a/packages/window_manager/example/macos/Runner/MainFlutterWindow.swift +++ b/packages/window_manager/example/macos/Runner/MainFlutterWindow.swift @@ -1,6 +1,6 @@ import Cocoa import FlutterMacOS -import window_manager +import window_manager_macos class MainFlutterWindow: NSPanel { override func awakeFromNib() { diff --git a/packages/window_manager/lib/src/widgets/drag_to_resize_area.dart b/packages/window_manager/lib/src/widgets/drag_to_resize_area.dart index 15237e14..d5999248 100644 --- a/packages/window_manager/lib/src/widgets/drag_to_resize_area.dart +++ b/packages/window_manager/lib/src/widgets/drag_to_resize_area.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:window_manager/src/resize_edge.dart'; import 'package:window_manager/src/window_manager.dart'; +import 'package:window_manager_platform_interface/window_manager_platform_interface.dart'; /// A widget for drag to resize window. /// diff --git a/packages/window_manager/lib/src/widgets/virtual_window_frame.dart b/packages/window_manager/lib/src/widgets/virtual_window_frame.dart index 2cac2f7e..a17c77d1 100644 --- a/packages/window_manager/lib/src/widgets/virtual_window_frame.dart +++ b/packages/window_manager/lib/src/widgets/virtual_window_frame.dart @@ -2,10 +2,9 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:window_manager/src/resize_edge.dart'; import 'package:window_manager/src/widgets/drag_to_resize_area.dart'; -import 'package:window_manager/src/window_listener.dart'; import 'package:window_manager/src/window_manager.dart'; +import 'package:window_manager_platform_interface/window_manager_platform_interface.dart'; final _kIsLinux = !kIsWeb && Platform.isLinux; final _kIsWindows = !kIsWeb && Platform.isWindows; diff --git a/packages/window_manager/lib/src/widgets/window_caption.dart b/packages/window_manager/lib/src/widgets/window_caption.dart index 101d4476..a3473bbf 100644 --- a/packages/window_manager/lib/src/widgets/window_caption.dart +++ b/packages/window_manager/lib/src/widgets/window_caption.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; - import 'package:window_manager/src/widgets/drag_to_move_area.dart'; import 'package:window_manager/src/widgets/window_caption_button.dart'; -import 'package:window_manager/src/window_listener.dart'; import 'package:window_manager/src/window_manager.dart'; +import 'package:window_manager_platform_interface/window_manager_platform_interface.dart'; const double kWindowCaptionHeight = 32; diff --git a/packages/window_manager/lib/src/window_manager.dart b/packages/window_manager/lib/src/window_manager.dart index dcfa1c8c..5970019d 100644 --- a/packages/window_manager/lib/src/window_manager.dart +++ b/packages/window_manager/lib/src/window_manager.dart @@ -6,11 +6,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:path/path.dart' as path; -import 'package:window_manager/src/resize_edge.dart'; -import 'package:window_manager/src/title_bar_style.dart'; -import 'package:window_manager/src/utils/calc_window_position.dart'; -import 'package:window_manager/src/window_listener.dart'; -import 'package:window_manager/src/window_options.dart'; +import 'package:window_manager_platform_interface/window_manager_platform_interface.dart'; const kWindowEventClose = 'close'; const kWindowEventFocus = 'focus'; diff --git a/packages/window_manager/lib/window_manager.dart b/packages/window_manager/lib/window_manager.dart index de9a6095..53829902 100644 --- a/packages/window_manager/lib/window_manager.dart +++ b/packages/window_manager/lib/window_manager.dart @@ -1,11 +1,8 @@ -export 'src/resize_edge.dart'; -export 'src/title_bar_style.dart'; -export 'src/utils/calc_window_position.dart'; +export 'package:window_manager_platform_interface/window_manager_platform_interface.dart'; + export 'src/widgets/drag_to_move_area.dart'; export 'src/widgets/drag_to_resize_area.dart'; export 'src/widgets/virtual_window_frame.dart'; export 'src/widgets/window_caption.dart'; export 'src/widgets/window_caption_button.dart'; -export 'src/window_listener.dart'; export 'src/window_manager.dart'; -export 'src/window_options.dart'; diff --git a/packages/window_manager/pubspec.yaml b/packages/window_manager/pubspec.yaml index a881ece3..af3fbb34 100644 --- a/packages/window_manager/pubspec.yaml +++ b/packages/window_manager/pubspec.yaml @@ -24,6 +24,10 @@ dependencies: sdk: flutter path: ^1.8.2 screen_retriever: ^0.2.0 + window_manager_linux: ^1.0.1 + window_manager_macos: ^1.0.1 + window_manager_platform_interface: ^1.0.1 + window_manager_windows: ^1.0.1 dev_dependencies: dependency_validator: ^3.0.0 @@ -35,8 +39,8 @@ flutter: plugin: platforms: linux: - pluginClass: WindowManagerPlugin + default_package: window_manager_linux macos: - pluginClass: WindowManagerPlugin + default_package: window_manager_macos windows: - pluginClass: WindowManagerPlugin + default_package: window_manager_windows diff --git a/packages/window_manager/linux/CMakeLists.txt b/packages/window_manager_linux/linux/CMakeLists.txt similarity index 90% rename from packages/window_manager/linux/CMakeLists.txt rename to packages/window_manager_linux/linux/CMakeLists.txt index 9cd938d9..90e35810 100644 --- a/packages/window_manager/linux/CMakeLists.txt +++ b/packages/window_manager_linux/linux/CMakeLists.txt @@ -4,10 +4,10 @@ project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed -set(PLUGIN_NAME "window_manager_plugin") +set(PLUGIN_NAME "window_manager_linux_plugin") add_library(${PLUGIN_NAME} SHARED - "window_manager_plugin.cc" + "window_manager_linux_plugin.cc" ) apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES diff --git a/packages/window_manager/linux/include/window_manager/window_manager_plugin.h b/packages/window_manager_linux/linux/include/window_manager/window_manager_plugin.h similarity index 100% rename from packages/window_manager/linux/include/window_manager/window_manager_plugin.h rename to packages/window_manager_linux/linux/include/window_manager/window_manager_plugin.h diff --git a/packages/window_manager/linux/window_manager_plugin.cc b/packages/window_manager_linux/linux/window_manager_linux_plugin.cc similarity index 100% rename from packages/window_manager/linux/window_manager_plugin.cc rename to packages/window_manager_linux/linux/window_manager_linux_plugin.cc diff --git a/packages/window_manager_linux/pubspec.yaml b/packages/window_manager_linux/pubspec.yaml index a7f39989..5f825637 100644 --- a/packages/window_manager_linux/pubspec.yaml +++ b/packages/window_manager_linux/pubspec.yaml @@ -21,5 +21,6 @@ flutter: plugin: platforms: linux: - pluginClass: WindowManagerLinuxPlugin + pluginClass: WindowManagerPlugin + # pluginClass: WindowManagerLinuxPlugin \ No newline at end of file diff --git a/packages/window_manager/macos/Classes/WindowManager.swift b/packages/window_manager_macos/macos/Classes/WindowManager.swift similarity index 100% rename from packages/window_manager/macos/Classes/WindowManager.swift rename to packages/window_manager_macos/macos/Classes/WindowManager.swift diff --git a/packages/window_manager/macos/Classes/WindowManagerPlugin.swift b/packages/window_manager_macos/macos/Classes/WindowManagerPlugin.swift similarity index 100% rename from packages/window_manager/macos/Classes/WindowManagerPlugin.swift rename to packages/window_manager_macos/macos/Classes/WindowManagerPlugin.swift diff --git a/packages/window_manager/macos/window_manager.podspec b/packages/window_manager_macos/macos/window_manager_macos.podspec similarity index 73% rename from packages/window_manager/macos/window_manager.podspec rename to packages/window_manager_macos/macos/window_manager_macos.podspec index fdaa7def..65479737 100644 --- a/packages/window_manager/macos/window_manager.podspec +++ b/packages/window_manager_macos/macos/window_manager_macos.podspec @@ -3,13 +3,13 @@ # Run `pod lib lint window_manager.podspec` to validate before publishing. # Pod::Spec.new do |s| - s.name = 'window_manager' + s.name = 'window_manager_macos' s.version = '0.2.0' - s.summary = 'A new flutter plugin project.' + s.summary = 'macOS implementation of the window_manager plugin.' s.description = <<-DESC -A new flutter plugin project. +macOS implementation of the window_manager plugin. DESC - s.homepage = 'https://leanflutter.org' + s.homepage = 'https://leanflutter.dev' s.license = { :file => '../LICENSE' } s.author = { 'LiJianying' => 'lijy91@foxmail.com' } s.source = { :path => '.' } diff --git a/packages/window_manager_macos/pubspec.yaml b/packages/window_manager_macos/pubspec.yaml index a50b723a..0ccf28fb 100644 --- a/packages/window_manager_macos/pubspec.yaml +++ b/packages/window_manager_macos/pubspec.yaml @@ -21,4 +21,5 @@ flutter: plugin: platforms: macos: - pluginClass: WindowManagerMacosPlugin + pluginClass: WindowManagerPlugin + # pluginClass: WindowManagerMacosPlugin diff --git a/packages/window_manager_platform_interface/.flutter-plugins b/packages/window_manager_platform_interface/.flutter-plugins new file mode 100644 index 00000000..a4a453d9 --- /dev/null +++ b/packages/window_manager_platform_interface/.flutter-plugins @@ -0,0 +1,5 @@ +# This is a generated file; do not edit or check into version control. +screen_retriever=/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever-0.2.0/ +screen_retriever_linux=/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever_linux-0.2.0/ +screen_retriever_macos=/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever_macos-0.2.0/ +screen_retriever_windows=/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever_windows-0.2.0/ diff --git a/packages/window_manager_platform_interface/.flutter-plugins-dependencies b/packages/window_manager_platform_interface/.flutter-plugins-dependencies new file mode 100644 index 00000000..718aef19 --- /dev/null +++ b/packages/window_manager_platform_interface/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[],"android":[],"macos":[{"name":"screen_retriever_macos","path":"/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever_macos-0.2.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"screen_retriever_linux","path":"/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever_linux-0.2.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"screen_retriever_windows","path":"/Users/lijy91/.pub-cache/hosted/pub.dev/screen_retriever_windows-0.2.0/","native_build":true,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"screen_retriever","dependencies":["screen_retriever_linux","screen_retriever_macos","screen_retriever_windows"]},{"name":"screen_retriever_linux","dependencies":[]},{"name":"screen_retriever_macos","dependencies":[]},{"name":"screen_retriever_windows","dependencies":[]}],"date_created":"2024-10-27 10:51:10.413309","version":"3.24.3","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/packages/window_manager/lib/src/resize_edge.dart b/packages/window_manager_platform_interface/lib/src/resize_edge.dart similarity index 100% rename from packages/window_manager/lib/src/resize_edge.dart rename to packages/window_manager_platform_interface/lib/src/resize_edge.dart diff --git a/packages/window_manager/lib/src/title_bar_style.dart b/packages/window_manager_platform_interface/lib/src/title_bar_style.dart similarity index 100% rename from packages/window_manager/lib/src/title_bar_style.dart rename to packages/window_manager_platform_interface/lib/src/title_bar_style.dart diff --git a/packages/window_manager/lib/src/utils/calc_window_position.dart b/packages/window_manager_platform_interface/lib/src/utils/calc_window_position.dart similarity index 100% rename from packages/window_manager/lib/src/utils/calc_window_position.dart rename to packages/window_manager_platform_interface/lib/src/utils/calc_window_position.dart diff --git a/packages/window_manager/lib/src/window_listener.dart b/packages/window_manager_platform_interface/lib/src/window_listener.dart similarity index 100% rename from packages/window_manager/lib/src/window_listener.dart rename to packages/window_manager_platform_interface/lib/src/window_listener.dart diff --git a/packages/window_manager/lib/src/window_options.dart b/packages/window_manager_platform_interface/lib/src/window_options.dart similarity index 89% rename from packages/window_manager/lib/src/window_options.dart rename to packages/window_manager_platform_interface/lib/src/window_options.dart index 1fd6e61c..85ce0d3b 100644 --- a/packages/window_manager/lib/src/window_options.dart +++ b/packages/window_manager_platform_interface/lib/src/window_options.dart @@ -1,6 +1,6 @@ import 'dart:ui'; -import 'package:window_manager/src/title_bar_style.dart'; +import 'package:window_manager_platform_interface/src/title_bar_style.dart'; /// WindowOptions class WindowOptions { diff --git a/packages/window_manager_platform_interface/lib/window_manager_platform_interface.dart b/packages/window_manager_platform_interface/lib/window_manager_platform_interface.dart index 57bbf8cc..9ab1b70f 100644 --- a/packages/window_manager_platform_interface/lib/window_manager_platform_interface.dart +++ b/packages/window_manager_platform_interface/lib/window_manager_platform_interface.dart @@ -1,4 +1,9 @@ library window_manager_platform_interface; +export 'src/resize_edge.dart'; +export 'src/title_bar_style.dart'; +export 'src/utils/calc_window_position.dart'; +export 'src/window_listener.dart'; export 'src/window_manager_method_channel.dart'; export 'src/window_manager_platform_interface.dart'; +export 'src/window_options.dart'; diff --git a/packages/window_manager_platform_interface/pubspec.yaml b/packages/window_manager_platform_interface/pubspec.yaml index 17529dd1..cb8efbae 100644 --- a/packages/window_manager_platform_interface/pubspec.yaml +++ b/packages/window_manager_platform_interface/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter plugin_platform_interface: ^2.0.2 + screen_retriever: ^0.2.0 dev_dependencies: flutter_test: diff --git a/packages/window_manager_windows/pubspec.yaml b/packages/window_manager_windows/pubspec.yaml index 6278e9f2..ca8e63b9 100644 --- a/packages/window_manager_windows/pubspec.yaml +++ b/packages/window_manager_windows/pubspec.yaml @@ -21,4 +21,5 @@ flutter: plugin: platforms: windows: - pluginClass: WindowManagerWindowsPlugin + pluginClass: WindowManagerPlugin + # pluginClass: WindowManagerWindowsPlugin diff --git a/packages/window_manager/windows/.gitignore b/packages/window_manager_windows/windows/.gitignore similarity index 100% rename from packages/window_manager/windows/.gitignore rename to packages/window_manager_windows/windows/.gitignore diff --git a/packages/window_manager/windows/CMakeLists.txt b/packages/window_manager_windows/windows/CMakeLists.txt similarity index 90% rename from packages/window_manager/windows/CMakeLists.txt rename to packages/window_manager_windows/windows/CMakeLists.txt index cb09c10a..f2b357cf 100644 --- a/packages/window_manager/windows/CMakeLists.txt +++ b/packages/window_manager_windows/windows/CMakeLists.txt @@ -4,11 +4,11 @@ project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed -set(PLUGIN_NAME "window_manager_plugin") +set(PLUGIN_NAME "window_manager_windows_plugin") add_library(${PLUGIN_NAME} SHARED "window_manager.cpp" - "window_manager_plugin.cpp" + "window_manager_windows_plugin.cpp" ) apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES diff --git a/packages/window_manager/windows/include/window_manager/window_manager_plugin.h b/packages/window_manager_windows/windows/include/window_manager/window_manager_plugin.h similarity index 100% rename from packages/window_manager/windows/include/window_manager/window_manager_plugin.h rename to packages/window_manager_windows/windows/include/window_manager/window_manager_plugin.h diff --git a/packages/window_manager/windows/window_manager.cpp b/packages/window_manager_windows/windows/window_manager.cpp similarity index 100% rename from packages/window_manager/windows/window_manager.cpp rename to packages/window_manager_windows/windows/window_manager.cpp diff --git a/packages/window_manager/windows/window_manager_plugin.cpp b/packages/window_manager_windows/windows/window_manager_windows_plugin.cpp similarity index 100% rename from packages/window_manager/windows/window_manager_plugin.cpp rename to packages/window_manager_windows/windows/window_manager_windows_plugin.cpp