├── .github
├── FUNDING.yml
└── workflows
│ └── build_test.yaml
├── bitsdojo_window
├── example
│ ├── linux
│ │ ├── .gitignore
│ │ ├── main.cc
│ │ ├── flutter
│ │ │ ├── generated_plugin_registrant.h
│ │ │ ├── generated_plugin_registrant.cc
│ │ │ ├── generated_plugins.cmake
│ │ │ └── CMakeLists.txt
│ │ ├── my_application.h
│ │ ├── my_application.cc
│ │ └── CMakeLists.txt
│ ├── macos
│ │ ├── .gitignore
│ │ ├── Runner
│ │ │ ├── Configs
│ │ │ │ ├── Debug.xcconfig
│ │ │ │ ├── Release.xcconfig
│ │ │ │ ├── Warnings.xcconfig
│ │ │ │ └── AppInfo.xcconfig
│ │ │ ├── Assets.xcassets
│ │ │ │ └── AppIcon.appiconset
│ │ │ │ │ ├── app_icon_1024.png
│ │ │ │ │ ├── app_icon_128.png
│ │ │ │ │ ├── app_icon_16.png
│ │ │ │ │ ├── app_icon_256.png
│ │ │ │ │ ├── app_icon_32.png
│ │ │ │ │ ├── app_icon_512.png
│ │ │ │ │ ├── app_icon_64.png
│ │ │ │ │ └── Contents.json
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Release.entitlements
│ │ │ ├── DebugProfile.entitlements
│ │ │ ├── MainFlutterWindow.swift
│ │ │ └── Info.plist
│ │ ├── Flutter
│ │ │ ├── Flutter-Debug.xcconfig
│ │ │ ├── Flutter-Release.xcconfig
│ │ │ └── GeneratedPluginRegistrant.swift
│ │ ├── Runner.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ ├── Runner.xcodeproj
│ │ │ ├── project.xcworkspace
│ │ │ │ └── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ ├── Podfile.lock
│ │ └── Podfile
│ ├── windows
│ │ ├── runner
│ │ │ ├── resources
│ │ │ │ └── app_icon.ico
│ │ │ ├── resource.h
│ │ │ ├── CMakeLists.txt
│ │ │ ├── utils.h
│ │ │ ├── runner.exe.manifest
│ │ │ ├── run_loop.h
│ │ │ ├── flutter_window.h
│ │ │ ├── main.cpp
│ │ │ ├── utils.cpp
│ │ │ ├── flutter_window.cpp
│ │ │ ├── run_loop.cpp
│ │ │ ├── Runner.rc
│ │ │ └── win32_window.h
│ │ ├── .gitignore
│ │ ├── flutter
│ │ │ ├── generated_plugin_registrant.h
│ │ │ ├── generated_plugin_registrant.cc
│ │ │ ├── generated_plugins.cmake
│ │ │ └── CMakeLists.txt
│ │ └── CMakeLists.txt
│ ├── .metadata
│ ├── README.md
│ ├── .gitignore
│ ├── analysis_options.yaml
│ ├── pubspec.yaml
│ └── lib
│ │ └── main.dart
├── .gitignore
├── lib
│ ├── bitsdojo_window.dart
│ └── src
│ │ ├── app_window.dart
│ │ ├── widgets
│ │ ├── window_border.dart
│ │ ├── window_caption.dart
│ │ └── mouse_state_builder.dart
│ │ └── icons
│ │ └── icons.dart
├── LICENSE
├── pubspec.yaml
└── CHANGELOG.md
├── bitsdojo_window_linux
├── linux
│ ├── .gitignore
│ ├── window_impl.h
│ ├── debug_helper.h
│ ├── flutter
│ │ ├── generated_plugin_registrant.h
│ │ ├── generated_plugin_registrant.cc
│ │ └── generated_plugins.cmake
│ ├── common.h
│ ├── api.cpp
│ ├── window_info.h
│ ├── gtk_utils.h
│ ├── CMakeLists.txt
│ ├── window_info.cpp
│ ├── api.h
│ ├── include
│ │ └── bitsdojo_window_linux
│ │ │ └── bitsdojo_window_plugin.h
│ ├── api_impl.h
│ ├── debug_helper.cpp
│ ├── bitsdojo_window_plugin.cpp
│ ├── gtk_utils.cpp
│ └── api_impl.cpp
├── README.md
├── lib
│ ├── bitsdojo_window_linux.dart
│ └── src
│ │ ├── bitsdojo_window_linux_stub.dart
│ │ ├── app_window.dart
│ │ ├── bitsdojo_window_linux_real.dart
│ │ ├── gtk.dart
│ │ └── native_api.dart
├── .gitignore
├── .metadata
├── CHANGELOG.md
├── pubspec.yaml
└── LICENSE
├── bitsdojo_window_macos
├── .gitignore
├── macos
│ ├── .gitignore
│ ├── Flutter
│ │ └── GeneratedPluginRegistrant.swift
│ ├── Classes
│ │ ├── bitsdojo_window_controller.h
│ │ ├── BitsdojoWindowPlugin.swift
│ │ ├── bitsdojo_window_api.mm
│ │ ├── bitsdojo_window_common.h
│ │ ├── bitsdojo_window_api.h
│ │ ├── BitsdojoWindow.swift
│ │ ├── bitsdojo_window_controller.mm
│ │ ├── bitsdojo_window.h
│ │ └── bitsdojo_window.mm
│ └── bitsdojo_window_macos.podspec
├── README.md
├── lib
│ ├── bitsdojo_window_macos.dart
│ └── src
│ │ ├── bitsdojo_window_macos_stub.dart
│ │ ├── app_window.dart
│ │ ├── plugin_channel.dart
│ │ ├── bitsdojo_window_macos_real.dart
│ │ ├── native_struct.dart
│ │ └── window_util.dart
├── .metadata
├── CHANGELOG.md
├── pubspec.yaml
├── bitsdojo_window_macos.iml
└── LICENSE
├── resources
└── screenshot.png
├── .gitignore
├── bitsdojo_window_windows
├── README.md
├── lib
│ ├── bitsdojo_window_windows.dart
│ └── src
│ │ ├── plugin_channel.dart
│ │ ├── window_interface.dart
│ │ ├── win32_plus.dart
│ │ ├── bitsdojo_window_windows_stub.dart
│ │ ├── app_window.dart
│ │ ├── bitsdojo_window_windows_real.dart
│ │ ├── window_util.dart
│ │ └── native_api.dart
├── .gitignore
├── .metadata
├── windows
│ ├── .gitignore
│ ├── bitsdojo_window_common.h
│ ├── window_util.h
│ ├── include
│ │ └── bitsdojo_window_windows
│ │ │ └── bitsdojo_window_plugin.h
│ ├── bitsdojo_window_api.cpp
│ ├── bitsdojo_window.h
│ ├── bitsdojo_window_api.h
│ ├── CMakeLists.txt
│ └── bitsdojo_window_plugin.cpp
├── CHANGELOG.md
├── pubspec.yaml
└── LICENSE
├── bitsdojo_window_platform_interface
├── .gitignore
├── CHANGELOG.md
├── lib
│ ├── method_channel_bitsdojo_window.dart
│ ├── platform_not_implemented.dart
│ ├── window.dart
│ ├── bitsdojo_window_platform_interface.dart
│ ├── window_common.dart
│ └── window_not_implemented.dart
├── pubspec.yaml
├── README.md
└── LICENSE
├── .vscode
├── launch.json
└── c_cpp_properties.json
└── LICENSE
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [bitsdojo]
2 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 |
--------------------------------------------------------------------------------
/resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/resources/screenshot.png
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/xcuserdata/
7 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/xcuserdata/
7 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | .flutter-plugins-dependencies
9 | .flutter-plugins
10 | pubspec.lock
11 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/README.md:
--------------------------------------------------------------------------------
1 | # bitsdojo_window_linux
2 |
3 | The Linux implementation of [`bitsdojo_window`][1].
4 |
5 | [1]: https://pub.dev/packages/bitsdojo_window
--------------------------------------------------------------------------------
/bitsdojo_window_linux/lib/bitsdojo_window_linux.dart:
--------------------------------------------------------------------------------
1 | export 'src/bitsdojo_window_linux_stub.dart'
2 | if (dart.library.ffi) 'src/bitsdojo_window_linux_real.dart';
3 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/README.md:
--------------------------------------------------------------------------------
1 | # bitsdojo_window_macos
2 |
3 | The macOS implementation of [`bitsdojo_window`][1].
4 |
5 | [1]: https://pub.dev/packages/bitsdojo_window
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/bitsdojo_window_macos.dart:
--------------------------------------------------------------------------------
1 | export 'src/bitsdojo_window_macos_stub.dart'
2 | if (dart.library.ffi) 'src/bitsdojo_window_macos_real.dart';
3 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/README.md:
--------------------------------------------------------------------------------
1 | # bitsdojo_window_windows
2 |
3 | The Windows implementation of [`bitsdojo_window`][1].
4 |
5 | [1]: https://pub.dev/packages/bitsdojo_window
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/bitsdojo_window_windows.dart:
--------------------------------------------------------------------------------
1 | export 'src/bitsdojo_window_windows_stub.dart'
2 | if (dart.library.ffi) 'src/bitsdojo_window_windows_real.dart';
3 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/bitsdojo_window/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | .flutter-plugins-dependencies
9 | .flutter-plugins
10 | pubspec.lock
11 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | .flutter-plugins-dependencies
9 | .flutter-plugins
10 | pubspec.lock
11 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | .flutter-plugins-dependencies
9 | .flutter-plugins
10 | pubspec.lock
11 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.2
2 | - Flutter 3.0 support
3 | ## 0.1.0
4 | - Added null safety support
5 | ## 0.0.2
6 | - New release for macOS support
7 | ## 0.0.1
8 | - Initial release
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/plugin_channel.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/services.dart';
2 |
3 | const String _channelName = "bitsdojo/window";
4 |
5 | MethodChannel bitsDojoWindowChannel = const MethodChannel(_channelName);
6 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitsdojo/bitsdojo_window/HEAD/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/window_impl.h:
--------------------------------------------------------------------------------
1 | #ifndef _BDW_WINDOW_IMPL_
2 | #define _BDW_WINDOW_IMPL_
3 |
4 | void startWindowDrag(GtkWindow* window);
5 | void enhanceFlutterView(GtkWidget* flutterView);
6 |
7 | #endif //_BDW_WINDOW_IMPL_
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/bitsdojo_window/lib/bitsdojo_window.dart:
--------------------------------------------------------------------------------
1 | export 'src/widgets/window_border.dart';
2 | export 'src/widgets/window_button.dart';
3 | export 'src/widgets/window_caption.dart';
4 | export 'src/icons/icons.dart';
5 | export 'src/app_window.dart';
6 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | .flutter-plugins-dependencies
9 | .flutter-plugins
10 | pubspec.lock
11 | # IntelliJ related
12 | *.iml
13 | *.ipr
14 | *.iws
15 | .idea/
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/window_interface.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
2 |
3 | abstract class WinDesktopWindow extends DesktopWindow {
4 | void setWindowCutOnMaximize(int value);
5 | }
6 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: a706cd211240f27be3b61f06d70f958c7a4156fe
8 | channel: dev
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 81e1f7d1ed78120d0ab5efb31545b3a5fa0774cd
8 | channel: master
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f8750b16bb9d7d51abe59a7695ffcbf506045202
8 | channel: master
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f8750b16bb9d7d51abe59a7695ffcbf506045202
8 | channel: master
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.4
2 | - Various fixes to work with latest Flutter version
3 | ## 0.1.3
4 | - Updated ffi to 2.0.0
5 | ## 0.1.2
6 | - Flutter 3.0 support
7 | ## 0.1.1
8 | - Linux support now stable
9 | ## 0.1.0+1
10 | - Fix gtk library name
11 | ## 0.1.0
12 | - Added null safety support
13 | ## 0.0.1
14 |
15 | * Initial Linux release
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import bitsdojo_window_macos
9 |
10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11 | BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
12 | }
13 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import bitsdojo_window_macos
9 |
10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11 | BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
12 | }
13 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/debug_helper.h:
--------------------------------------------------------------------------------
1 | #ifndef _BDW_DEBUG_HELPER_
2 | #define _BDW_DEBUG_HELPER_
3 |
4 | #include
5 |
6 | namespace bitsdojo_window {
7 |
8 | void printWindowStateMask(const char *description, GdkWindowState state);
9 | void printGdkEvent(const char *description, GdkEventType state);
10 |
11 | } // namespace bitsdojo_window
12 |
13 | #endif //_BDW_DEBUG_HELPER_
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | #ifndef GENERATED_PLUGIN_REGISTRANT_
6 | #define GENERATED_PLUGIN_REGISTRANT_
7 |
8 | #include
9 |
10 | // Registers Flutter plugins.
11 | void fl_register_plugins(FlPluginRegistry* registry);
12 |
13 | #endif // GENERATED_PLUGIN_REGISTRANT_
14 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.4
2 | - Various fixes to work with latest Flutter version
3 | ## 0.1.3
4 | - Updated ffi to 2.0.0
5 | ## 0.1.2
6 | - Flutter 3.0 support
7 | ## 0.1.0
8 | - Added null safety support
9 | ## 0.0.3
10 |
11 | * macOS support on pair with Windows support
12 | ## 0.0.2
13 |
14 | * Upgraded to ffi 1.0.0
15 |
16 | ## 0.0.1
17 |
18 | * Inital macOS release.
19 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void RegisterPlugins(flutter::PluginRegistry* registry) {
12 | BitsdojoWindowPluginRegisterWithRegistrar(
13 | registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
14 | }
15 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/bitsdojo_window_common.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_COMMON
2 | #define BITSDOJO_WINDOW_COMMON
3 |
4 | #if defined(__cplusplus)
5 | #define BDW_EXTERN extern "C"
6 | #else
7 | #define BDW_EXTERN extern
8 | #endif
9 |
10 | #if !defined(BDW_VISIBLE)
11 | #define BDW_VISIBLE __declspec(dllexport)
12 | #endif
13 |
14 | #if !defined(BDW_EXPORT)
15 | #define BDW_EXPORT BDW_EXTERN BDW_VISIBLE
16 | #endif
17 |
18 | #endif
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/common.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_COMMON
2 | #define BITSDOJO_WINDOW_COMMON
3 |
4 | #if defined(__cplusplus)
5 | #define BDW_EXTERN extern "C"
6 | #else
7 | #define BDW_EXTERN extern
8 | #endif
9 |
10 | #if !defined(BDW_VISIBLE)
11 | #define BDW_VISIBLE __attribute__((visibility("default")))
12 | #endif
13 |
14 | #if !defined(BDW_EXPORT)
15 | #define BDW_EXPORT BDW_EXTERN BDW_VISIBLE
16 | #endif
17 |
18 |
19 | #endif
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/win32_plus.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: non_constant_identifier_names
2 |
3 | import 'dart:ui';
4 | import 'package:win32/win32.dart';
5 |
6 | extension RECTtoRect on RECT {
7 | Rect get toRect => Rect.fromLTRB(this.left.toDouble(), this.top.toDouble(),
8 | this.right.toDouble(), this.bottom.toDouble());
9 | }
10 |
11 | extension SIZEtoSize on SIZE {
12 | Size get toSize => Size(this.cx.toDouble(), this.cy.toDouble());
13 | }
14 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/lib/src/bitsdojo_window_linux_stub.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
2 | import 'dart:ui';
3 |
4 | class BitsdojoWindowLinux extends BitsdojoWindowPlatform {
5 | BitsdojoWindowLinux() {
6 | assert(false);
7 | }
8 |
9 | @override
10 | void doWhenWindowReady(VoidCallback callback) {}
11 |
12 | @override
13 | DesktopWindow get appWindow {
14 | return AppWindowNotImplemented();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/src/bitsdojo_window_macos_stub.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
2 | import 'dart:ui';
3 |
4 | class BitsdojoWindowMacOS extends BitsdojoWindowPlatform {
5 | BitsdojoWindowMacOS() {
6 | assert(false);
7 | }
8 |
9 | @override
10 | void doWhenWindowReady(VoidCallback callback) {}
11 |
12 | @override
13 | DesktopWindow get appWindow {
14 | return AppWindowNotImplemented();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/src/app_window.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_macos;
2 |
3 | import './window.dart';
4 | import './native_api.dart';
5 |
6 | class MacAppWindow extends MacOSWindow {
7 | MacAppWindow._() {
8 | super.handle = getAppWindow();
9 | if (handle == null) {
10 | print("Could not get Flutter window");
11 | }
12 | }
13 |
14 | static final MacAppWindow _instance = MacAppWindow._();
15 |
16 | factory MacAppWindow() {
17 | return _instance;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.6
2 | - Various fixes to work with latest Flutter version
3 | ## 0.1.5
4 | - Runs on Windows 7
5 | ## 0.1.4
6 | - Updated win32 to 3.0.0
7 | ## 0.1.3
8 | - Updated ffi to 2.0.0
9 | ## 0.1.2
10 | - Flutter 3.0 support
11 | ## 0.1.0
12 | - Added null safety support
13 | ## 0.0.3
14 |
15 | * Deprecated some methods
16 | ## 0.0.2
17 |
18 | * Upgraded to ffi 1.0.0 and win32 2.0.0
19 | ## 0.0.1
20 |
21 | * Initial Windows release as federated plugin
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/window_util.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_UTIL_H_
2 | #define BITSDOJO_WINDOW_UTIL_H_
3 |
4 | #define WM_BDW_ACTION 0x7FFE
5 |
6 | #define BDW_SETWINDOWPOS 1
7 | #define BDW_SETWINDOWTEXT 2
8 | #define BDW_FORCECHILDREFRESH 3
9 |
10 | typedef struct _SWPParam {
11 | int x;
12 | int y;
13 | int cx;
14 | int cy;
15 | UINT uFlags;
16 | } SWPParam;
17 |
18 | typedef struct _SWTParam {
19 | LPCWSTR text;
20 | } SWTParam;
21 |
22 | #endif /* BITSDOJO_WINDOW_UTIL_H_ */
23 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | #include "generated_plugin_registrant.h"
6 |
7 | #include
8 |
9 | void fl_register_plugins(FlPluginRegistry* registry) {
10 | g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
11 | fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
12 | bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
13 | }
14 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/bitsdojo_window_windows_stub.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
2 | import 'dart:ui';
3 | export './window_interface.dart';
4 |
5 | class BitsdojoWindowWindows extends BitsdojoWindowPlatform {
6 | BitsdojoWindowWindows() {
7 | assert(false);
8 | }
9 |
10 | @override
11 | void doWhenWindowReady(VoidCallback callback) {}
12 |
13 | @override
14 | DesktopWindow get appWindow {
15 | return AppWindowNotImplemented();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void fl_register_plugins(FlPluginRegistry* registry) {
12 | g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
13 | fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
14 | bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
15 | }
16 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/bitsdojo_window_controller.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface BitsdojoWindowController : NSObject
4 |
5 | @property (assign) CGSize windowSize;
6 | @property (assign) bool isVisible;
7 | @property (assign) bool isZoomed;
8 | @property (assign) double titleBarHeight;
9 | @property (nonatomic, weak) NSWindow *window;
10 | @property (assign) NSRect workingScreenRect;
11 | @property (assign) NSRect fullScreenRect;
12 | @property (assign) NSRect windowFrame;
13 |
14 | - (instancetype)initWithWindow:(NSWindow *)window;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | bitsdojo_window_linux
7 | )
8 |
9 | set(PLUGIN_BUNDLED_LIBRARIES)
10 |
11 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
16 | endforeach(plugin)
17 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/lib/method_channel_bitsdojo_window.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/services.dart';
2 |
3 | import 'bitsdojo_window_platform_interface.dart';
4 |
5 | const MethodChannel _channel = MethodChannel('bitsdojo/window');
6 |
7 | /// An implementation of [BitsdojoWindowPlatform] that uses method channels.
8 | class MethodChannelBitsdojoWindow extends BitsdojoWindowPlatform {
9 | @override
10 | void dragAppWindow() async {
11 | try {
12 | await _channel.invokeMethod('dragAppWindow');
13 | } catch (e) {
14 | print("Could not start draggging -> $e");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/api.cpp:
--------------------------------------------------------------------------------
1 | #include "./api.h"
2 |
3 | namespace bitsdojo_window {
4 |
5 | BDWAPI _theAPI = {
6 | getAppWindowHandle,
7 | getScreenRect,
8 | getScaleFactor,
9 | getPosition,
10 | setPosition,
11 | getSize,
12 | setSize,
13 | setRect,
14 | setMinSize,
15 | setMaxSize,
16 | showWindow,
17 | hideWindow,
18 | minimizeWindow,
19 | maximizeWindow,
20 | unmaximizeWindow,
21 | setWindowTitle
22 | };
23 |
24 | } // namespace bitsdojo_window
25 |
26 | BDW_EXPORT bitsdojo_window::BDWAPI* bitsdojo_window_api() {
27 | return &bitsdojo_window::_theAPI;
28 | }
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/src/plugin_channel.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'package:flutter/services.dart';
3 |
4 | class BitsdojoWindowMacOS {
5 | static const MethodChannel _channel = const MethodChannel('bitsdojo/window');
6 |
7 | static Future maximizeOrRestoreWindow(int window) async {
8 | await _channel.invokeMethod('maximizeOrRestoreWindow', {
9 | 'window': window,
10 | });
11 | }
12 |
13 | static Future getAppWindow() async {
14 | int? _appWindow;
15 | await _channel.invokeMethod('getAppWindow').then((value) {
16 | _appWindow = value;
17 | });
18 | return _appWindow;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/README.md:
--------------------------------------------------------------------------------
1 | # bitsdojo_window_example
2 |
3 | Demonstrates how to use the bitsdojo_window plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/window_info.h:
--------------------------------------------------------------------------------
1 | #ifndef _BDW_WINDOW_INFO_
2 | #define _BDW_WINDOW_INFO_
3 |
4 | #include
5 |
6 | namespace bitsdojo_window {
7 | typedef struct _WindowInfo{
8 | int x;
9 | int y;
10 | int width;
11 | int height;
12 | int screenX;
13 | int screenY;
14 | int screenWidth;
15 | int screenHeight;
16 | int minWidth;
17 | int minHeight;
18 | int maxWidth;
19 | int maxHeight;
20 | int scaleFactor;
21 | int gripSize;
22 | } WindowInfo;
23 |
24 | WindowInfo* getWindowInfo(GtkWindow *window);
25 | }
26 | #endif //_BDW_WINDOW_INFO_
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/include/bitsdojo_window_windows/bitsdojo_window_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_BITSDOJO_WINDOW_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_BITSDOJO_WINDOW_PLUGIN_H_
3 |
4 | #include
5 |
6 | #if defined(__cplusplus)
7 | extern "C" {
8 | #endif
9 |
10 | void BitsdojoWindowPluginRegisterWithRegistrar(
11 | FlutterDesktopPluginRegistrarRef registrar);
12 |
13 | #define BDW_CUSTOM_FRAME 0x1
14 | #define BDW_HIDE_ON_STARTUP 0x2
15 |
16 | int bitsdojo_window_configure(unsigned int flags);
17 |
18 | #if defined(__cplusplus)
19 | } // extern "C"
20 | #endif
21 |
22 | #endif // FLUTTER_PLUGIN_BITSDOJO_WINDOW_PLUGIN_H_
23 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 | import bitsdojo_window_macos
4 |
5 | class MainFlutterWindow: BitsdojoWindow {
6 |
7 | override func bitsdojo_window_configure() -> UInt {
8 | return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
9 | }
10 |
11 | override func awakeFromNib() {
12 | let flutterViewController = FlutterViewController.init()
13 | let windowFrame = self.frame
14 | self.contentViewController = flutterViewController
15 | self.setFrame(windowFrame, display: true)
16 |
17 | RegisterGeneratedPlugins(registry: flutterViewController)
18 |
19 | super.awakeFromNib()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: bitsdojo_window_linux
2 | description: Linux implementation of the bitsdojo_window plugin.
3 | version: 0.1.4
4 | homepage: https://www.bitsdojo.com
5 | repository: https://github.com/bitsdojo/bitsdojo_window
6 |
7 | environment:
8 | sdk: ">=2.17.0 <4.0.0"
9 | flutter: ">=1.20.0"
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 | bitsdojo_window_platform_interface:
15 | ^0.1.2
16 | #path: ../bitsdojo_window_platform_interface
17 | ffi: ^2.0.0
18 |
19 | dev_dependencies:
20 | flutter_test:
21 | sdk: flutter
22 |
23 | flutter:
24 | plugin:
25 | platforms:
26 | linux:
27 | pluginClass: BitsdojoWindowPlugin
28 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: bitsdojo_window_macos
2 | description: macOS implementation of the bitsdojo_window plugin.
3 | version: 0.1.4
4 | homepage: https://www.bitsdojo.com
5 | repository: https://github.com/bitsdojo/bitsdojo_window
6 |
7 | environment:
8 | sdk: ">=2.17.0 <4.0.0"
9 | flutter: ">=1.20.0"
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 | bitsdojo_window_platform_interface:
15 | ^0.1.2
16 | #path: ../bitsdojo_window_platform_interface
17 | ffi: ^2.0.0
18 |
19 | dev_dependencies:
20 | flutter_test:
21 | sdk: flutter
22 |
23 | flutter:
24 | plugin:
25 | platforms:
26 | macos:
27 | pluginClass: BitsdojoWindowPlugin
28 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(runner LANGUAGES CXX)
3 |
4 | add_executable(${BINARY_NAME} WIN32
5 | "flutter_window.cpp"
6 | "main.cpp"
7 | "run_loop.cpp"
8 | "utils.cpp"
9 | "win32_window.cpp"
10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
11 | "Runner.rc"
12 | "runner.exe.manifest"
13 | )
14 | apply_standard_settings(${BINARY_NAME})
15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
18 | add_dependencies(${BINARY_NAME} flutter_assemble)
19 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/lib/src/app_window.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_linux;
2 |
3 | import './native_api.dart' as native;
4 | import './window.dart';
5 |
6 | const notInitializedMessage = """
7 | bitsdojo_window is not initalized.
8 | """;
9 |
10 | class BitsDojoNotInitializedException implements Exception {
11 | String errMsg() => notInitializedMessage;
12 | }
13 |
14 | class GtkAppWindow extends GtkWindow {
15 | GtkAppWindow._() {
16 | super.handle = native.getAppWindowHandle();
17 | assert(handle != null, "Could not get Flutter window");
18 | }
19 |
20 | static final GtkAppWindow _instance = GtkAppWindow._();
21 |
22 | factory GtkAppWindow() {
23 | return _instance;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/bitsdojo_window_api.cpp:
--------------------------------------------------------------------------------
1 | #include "bitsdojo_window_api.h"
2 | #include "bitsdojo_window.h"
3 | #include "bitsdojo_window_common.h"
4 |
5 | namespace bitsdojo_window {
6 | BDWPrivateAPI privateAPI = {
7 | dragAppWindow,
8 | };
9 |
10 | BDWPublicAPI publicAPI = {
11 | isBitsdojoWindowLoaded,
12 | getAppWindow,
13 | setWindowCanBeShown,
14 | setMinSize,
15 | setMaxSize,
16 | setWindowCutOnMaximize,
17 | isDPIAware,
18 | };
19 | }
20 |
21 | BDWAPI bdwAPI = {
22 | &bitsdojo_window::publicAPI,
23 | &bitsdojo_window::privateAPI
24 | };
25 |
26 | BDW_EXPORT BDWAPI* bitsdojo_window_api(){
27 | return &bdwAPI;
28 | }
--------------------------------------------------------------------------------
/bitsdojo_window_windows/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: bitsdojo_window_windows
2 | description: Windows implementation of the bitsdojo_window plugin.
3 | version: 0.1.6
4 | homepage: https://www.bitsdojo.com
5 | repository: https://github.com/bitsdojo/bitsdojo_window
6 |
7 | environment:
8 | sdk: ">=2.17.0 <4.0.0"
9 | flutter: ">=1.20.0"
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 | bitsdojo_window_platform_interface:
15 | ^0.1.2
16 | #path: ../bitsdojo_window_platform_interface
17 | win32: ^5.1.1
18 | ffi: ^2.0.0
19 |
20 | dev_dependencies:
21 | flutter_test:
22 | sdk: flutter
23 |
24 | flutter:
25 | plugin:
26 | platforms:
27 | windows:
28 | pluginClass: BitsdojoWindowPlugin
29 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = bitsdojo_window_example
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.bitsdojo-window-example
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: bitsdojo_window_platform_interface
2 | description: A common platform interface for the bitsdojo_window plugin.
3 | homepage: https://github.com/bitsdojo/bitsdojo_window/bitsdojo_window_platform_interface
4 | # NOTE: We strongly prefer non-breaking changes, even at the expense of a
5 | # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6 | version: 0.1.2
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 | meta: ^1.3.0
12 | plugin_platform_interface: ^2.0.0
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 | mockito: ^5.0.2
18 | pedantic: ^1.11.0
19 |
20 | environment:
21 | sdk: ">=2.17.0 <4.0.0"
22 | flutter: ">=1.22.0"
23 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - bitsdojo_window_macos (0.0.1):
3 | - FlutterMacOS
4 | - FlutterMacOS (1.0.0)
5 |
6 | DEPENDENCIES:
7 | - bitsdojo_window_macos (from `Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos`)
8 | - FlutterMacOS (from `Flutter/ephemeral`)
9 |
10 | EXTERNAL SOURCES:
11 | bitsdojo_window_macos:
12 | :path: Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos
13 | FlutterMacOS:
14 | :path: Flutter/ephemeral
15 |
16 | SPEC CHECKSUMS:
17 | bitsdojo_window_macos: 44e3b8fe3dd463820e0321f6256c5b1c16bb6a00
18 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
19 |
20 | PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
21 |
22 | COCOAPODS: 1.14.3
23 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "main example",
9 | "cwd": "bitsdojo_window/example",
10 | "request": "launch",
11 | "type": "dart",
12 | "program": "lib/main.dart"
13 | },
14 | {
15 | "name": "switch example",
16 | "cwd": "bitsdojo_window/example",
17 | "request": "launch",
18 | "type": "dart",
19 | "program": "lib/switch.dart"
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/BitsdojoWindowPlugin.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | public class BitsdojoWindowPlugin: NSObject, FlutterPlugin {
5 | public static func register(with registrar: FlutterPluginRegistrar) {
6 | let channel = FlutterMethodChannel(name: "bitsdojo/window", binaryMessenger: registrar.messenger)
7 | let instance = BitsdojoWindowPlugin()
8 | registrar.addMethodCallDelegate(instance, channel: channel)
9 | }
10 |
11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
12 | switch call.method {
13 | /*
14 | // TODO: implement this for channel methods
15 | case "getAppWindow":
16 | getAppWindow(call, result)
17 | */
18 | default:
19 | result(FlutterMethodNotImplemented)
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/gtk_utils.h:
--------------------------------------------------------------------------------
1 | #ifndef _BDW_GTK_UTILS_
2 | #define _BDW_GTK_UTILS_
3 | #include
4 | #include
5 |
6 | namespace bitsdojo_window {
7 | GList* gtk_container_get_all_children(GtkContainer* container);
8 | GdkCursorType edgeToCursor(GdkWindowEdge edge);
9 | const gchar* getCursorForEdge(GdkWindowEdge edge);
10 | bool getWindowEdge(int width, int height, gdouble x, double y,
11 | GdkWindowEdge* edge, int margin);
12 | void getMousePositionOnScreen(GtkWindow* window, gint* x, gint* y);
13 | void getScreenRectForWindow(GtkWindow* window, GdkRectangle* rect);
14 | void getScaleFactorForWindow(GtkWindow* window, gint* scaleFactor);
15 | void emitMouseMoveEvent(GtkWidget* widget, int x, int y);
16 | } // namespace bitsdojo_window
17 |
18 | #endif // _BDW_GTK_UTILS_
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/lib/platform_not_implemented.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
2 | import 'package:flutter/rendering.dart';
3 | import 'dart:ui';
4 | import 'package:flutter/widgets.dart';
5 |
6 | class AppWindowNotImplemented extends NotImplementedWindow {
7 | AppWindowNotImplemented._();
8 |
9 | static final AppWindowNotImplemented _instance = AppWindowNotImplemented._();
10 |
11 | factory AppWindowNotImplemented() {
12 | return _instance;
13 | }
14 | }
15 |
16 | class BitsdojoWindowPlatformNotImplemented extends BitsdojoWindowPlatform {
17 | @override
18 | void doWhenWindowReady(VoidCallback callback) {
19 | // do nothing on other platforms
20 | }
21 |
22 | @override
23 | DesktopWindow get appWindow {
24 | return AppWindowNotImplemented();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/app_window.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_windows;
2 |
3 | import './native_api.dart';
4 | import './window.dart';
5 |
6 | const notInitializedMessage = """
7 | bitsdojo_window is not initalized.
8 | """;
9 |
10 | class BitsDojoNotInitializedException implements Exception {
11 | String errMsg() => notInitializedMessage;
12 | }
13 |
14 | class WinAppWindow extends WinWindow {
15 | WinAppWindow._() {
16 | super.handle = getAppWindow();
17 | final isLoaded = isBitsdojoWindowLoaded();
18 | if (!isLoaded) {
19 | print(notInitializedMessage);
20 | throw BitsDojoNotInitializedException;
21 | }
22 | assert(handle != null, "Could not get Flutter window");
23 | }
24 |
25 | static final WinAppWindow _instance = WinAppWindow._();
26 |
27 | factory WinAppWindow() {
28 | return _instance;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/lib/src/bitsdojo_window_linux_real.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_linux;
2 |
3 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
4 | import './window.dart';
5 | import './app_window.dart';
6 | import 'package:flutter/widgets.dart';
7 |
8 | T? _ambiguate(T? value) => value;
9 |
10 | class BitsdojoWindowLinux extends BitsdojoWindowPlatform {
11 | BitsdojoWindowLinux() : super();
12 |
13 | @override
14 | void doWhenWindowReady(VoidCallback callback) {
15 | _ambiguate(WidgetsBinding.instance)!
16 | .waitUntilFirstFrameRasterized
17 | .then((value) {
18 | isInsideDoWhenWindowReady = true;
19 | callback();
20 | isInsideDoWhenWindowReady = false;
21 | });
22 | }
23 |
24 | @override
25 | DesktopWindow get appWindow {
26 | return GtkAppWindow();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | set(PROJECT_NAME "bitsdojo_window_linux")
3 | project(${PROJECT_NAME} LANGUAGES CXX)
4 |
5 | set(PLUGIN_NAME "${PROJECT_NAME}_plugin")
6 |
7 | add_library(${PLUGIN_NAME} SHARED
8 | "debug_helper.cpp"
9 | "gtk_utils.cpp"
10 | "window_info.cpp"
11 | "window_impl.cpp"
12 | "api_impl.cpp"
13 | "api.cpp"
14 | "bitsdojo_window_plugin.cpp"
15 | )
16 | apply_standard_settings(${PLUGIN_NAME})
17 | set_target_properties(${PLUGIN_NAME} PROPERTIES
18 | CXX_VISIBILITY_PRESET hidden)
19 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
20 | target_include_directories(${PLUGIN_NAME} INTERFACE
21 | "${CMAKE_CURRENT_SOURCE_DIR}/include")
22 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter PkgConfig::GTK)
23 |
24 | set(bitsdojo_window_bundled_libraries
25 | ""
26 | PARENT_SCOPE
27 | )
28 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | bitsdojo_window_linux
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/bitsdojo_window.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_H_
2 | #define BITSDOJO_WINDOW_H_
3 | #include
4 |
5 | namespace bitsdojo_window {
6 | typedef bool (*TIsBitsdojoWindowLoaded)();
7 | bool isBitsdojoWindowLoaded();
8 |
9 | typedef void (*TSetWindowCanBeShown)(bool);
10 | void setWindowCanBeShown(bool value);
11 |
12 | typedef bool (*TDragAppWindow)();
13 | bool dragAppWindow();
14 |
15 | typedef HWND (*TGetAppWindow)();
16 | HWND getAppWindow();
17 |
18 | typedef void (*TSetMinSize)(int, int);
19 | void setMinSize(int width, int height);
20 |
21 | typedef void (*TSetMaxSize)(int, int);
22 | void setMaxSize(int width, int height);
23 |
24 | typedef void (*TSetWindowCutOnMaximize)(int);
25 | void setWindowCutOnMaximize(int value);
26 |
27 | typedef bool (*TIsDPIAware)();
28 | bool isDPIAware();
29 | }
30 | #endif
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | bitsdojo_window_windows
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/window_info.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "./window_info.h"
3 |
4 | namespace bitsdojo_window {
5 |
6 | GHashTable* windows_table = nullptr;
7 |
8 | WindowInfo* getWindowInfo(GtkWindow* window) {
9 | if (nullptr == windows_table) {
10 | windows_table = g_hash_table_new(g_int_hash, g_int_equal);
11 | }
12 | WindowInfo* windowInfo;
13 | windowInfo = reinterpret_cast(
14 | g_hash_table_lookup(windows_table, window));
15 | if (nullptr != windowInfo) {
16 | return windowInfo;
17 | }
18 |
19 | windowInfo = new WindowInfo();
20 | windowInfo->minWidth = -1;
21 | windowInfo->minHeight = -1;
22 | windowInfo->maxWidth = -1;
23 | windowInfo->maxHeight = -1;
24 | windowInfo->gripSize = 6;
25 | g_hash_table_insert(windows_table, window, windowInfo);
26 | return windowInfo;
27 | }
28 |
29 | } // namespace bitsdojo_window
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/bitsdojo_window_api.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_API_H
2 | #define BITSDOJO_WINDOW_API_H
3 |
4 | #include "./bitsdojo_window_common.h"
5 | #include "./bitsdojo_window.h"
6 |
7 | namespace bitsdojo_window {
8 |
9 | typedef struct _BDWPrivateAPI{
10 | TDragAppWindow dragAppWindow;
11 | } BDWPrivateAPI;
12 |
13 | typedef struct _BDWPublicAPI {
14 | TIsBitsdojoWindowLoaded isBitsdojoWindowLoaded;
15 | TGetAppWindow getAppWindow;
16 | TSetWindowCanBeShown setWindowCanBeShown;
17 | TSetMinSize setMinSize;
18 | TSetMaxSize setMaxSize;
19 | TSetWindowCutOnMaximize setWindowCutOnMaximize;
20 | TIsDPIAware isDPIAware;
21 | } BDWPublicAPI;
22 |
23 | }
24 |
25 | typedef struct _BDWAPI {
26 | bitsdojo_window::BDWPublicAPI* publicAPI;
27 | bitsdojo_window::BDWPrivateAPI* privateAPI;
28 | } BDWAPI;
29 |
30 | BDW_EXPORT BDWAPI * bitsdojo_window_api();
31 | #endif
--------------------------------------------------------------------------------
/bitsdojo_window/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Android Studio will place build artifacts here
44 | /android/app/debug
45 | /android/app/profile
46 | /android/app/release
47 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/bitsdojo_window_api.mm:
--------------------------------------------------------------------------------
1 | #import "bitsdojo_window.h"
2 | #import "bitsdojo_window_api.h"
3 |
4 | BDWPrivateAPI privateAPI = {
5 | windowCanBeShown,
6 | setAppWindow,
7 | appWindowIsSet,
8 | };
9 |
10 | BDWPublicAPI publicAPI = {
11 | getAppWindow,
12 | setWindowCanBeShown,
13 | setInsideDoWhenWindowReady,
14 | showWindow,
15 | hideWindow,
16 | moveWindow,
17 | setSize,
18 | setMinSize,
19 | setMaxSize,
20 | getScreenInfoForWindow,
21 | setPositionForWindow,
22 | setRectForWindow,
23 | getRectForWindow,
24 | isWindowVisible,
25 | isWindowMaximized,
26 | maximizeOrRestoreWindow,
27 | maximizeWindow,
28 | minimizeWindow,
29 | closeWindow,
30 | setWindowTitle,
31 | getTitleBarHeight
32 | };
33 |
34 | BDWAPI bdwAPI = {
35 | &publicAPI,
36 | &privateAPI,
37 | };
38 |
39 | BDW_EXPORT BDWAPI* bitsdojo_window_api(){
40 | return &bdwAPI;
41 | }
42 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | set(PROJECT_NAME "bitsdojo_window_windows")
3 | set(PARENT_PROJECT_NAME,"bitsdojo_window")
4 | project(${PROJECT_NAME} LANGUAGES CXX)
5 |
6 | set(PLUGIN_NAME "${PROJECT_NAME}_plugin")
7 |
8 | add_library(${PLUGIN_NAME} STATIC
9 | "bitsdojo_window.cpp"
10 | "bitsdojo_window_api.cpp"
11 | "bitsdojo_window_plugin.cpp"
12 | )
13 | apply_standard_settings(${PLUGIN_NAME})
14 | set_target_properties(${PLUGIN_NAME} PROPERTIES
15 | CXX_VISIBILITY_PRESET hidden)
16 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
17 | target_include_directories(${PLUGIN_NAME} INTERFACE
18 | "${CMAKE_CURRENT_SOURCE_DIR}/include")
19 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin Dwmapi Comctl32)
20 |
21 | # List of absolute paths to libraries that should be bundled with the plugin
22 | set(bitsdojo_window_bundled_libraries
23 | ""
24 | PARENT_SCOPE
25 | )
26 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/bitsdojo_window_common.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_COMMON
2 | #define BITSDOJO_WINDOW_COMMON
3 |
4 | typedef struct _BDWRect {
5 | double left;
6 | double top;
7 | double right;
8 | double bottom;
9 | } BDWRect;
10 |
11 | typedef struct _BDWOffset {
12 | double x;
13 | double y;
14 | } BDWOffset;
15 |
16 | typedef struct _BDWScreenInfo {
17 | BDWRect* workingRect;
18 | BDWRect* fullRect;
19 | } BDWScreenInfo;
20 |
21 | // 1-byte return status type
22 | typedef signed char BDWStatus;
23 |
24 | #define BDW_FAILED 0
25 | #define BDW_SUCCESS 1
26 |
27 | #if defined(__cplusplus)
28 | #define BDW_EXTERN extern "C"
29 | #else
30 | #define BDW_EXTERN extern
31 | #endif
32 |
33 | #if !defined(BDW_VISIBLE)
34 | #define BDW_VISIBLE __attribute__((visibility("default")))
35 | #endif
36 |
37 | #if !defined(BDW_EXPORT)
38 | #define BDW_EXPORT BDW_EXTERN BDW_VISIBLE
39 | #endif
40 |
41 | #endif /* BITSDOJO_WINDOW_COMMON */
42 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/bitsdojo_window_windows_real.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_windows;
2 |
3 | import 'package:flutter/widgets.dart';
4 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
5 | import './window.dart';
6 | import './app_window.dart';
7 | import './native_api.dart';
8 |
9 | export './window_interface.dart';
10 |
11 | T? _ambiguate(T? value) => value;
12 |
13 | class BitsdojoWindowWindows extends BitsdojoWindowPlatform {
14 | BitsdojoWindowWindows() : super();
15 |
16 | @override
17 | void doWhenWindowReady(VoidCallback callback) {
18 | _ambiguate(WidgetsBinding.instance)!
19 | .waitUntilFirstFrameRasterized
20 | .then((value) {
21 | isInsideDoWhenWindowReady = true;
22 | setWindowCanBeShown(true);
23 | callback();
24 | isInsideDoWhenWindowReady = false;
25 | });
26 | }
27 |
28 | @override
29 | DesktopWindow get appWindow {
30 | return WinAppWindow();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/api.h:
--------------------------------------------------------------------------------
1 | #ifndef _BDW_API_
2 | #define _BDW_API_
3 |
4 | #include "./common.h"
5 | #include "./api_impl.h"
6 |
7 | typedef GtkWindow* (*TGetAppWindowHandle)();
8 | GtkWindow* getAppWindowHandle();
9 |
10 | namespace bitsdojo_window {
11 |
12 | typedef struct _BDWAPI {
13 | TGetAppWindowHandle getAppWindowHandle;
14 | TGetScreenRect getScreenRect;
15 | TGetScaleFactor getScaleFactor;
16 | TGetPosition getPosition;
17 | TSetPosition setPosition;
18 | TGetSize getSize;
19 | TSetSize setSize;
20 | TSetRect setRect;
21 | TSetMinSize setMinSize;
22 | TSetMaxSize setMaxSize;
23 | TShowWindow showWindow;
24 | THideWindow hideWindow;
25 | TMinimizeWindow minimizeWindow;
26 | TMaximizeWindow maximizeWindow;
27 | TUnmaximizeWindow unmaximizeWindow;
28 | TSetWindowTitle setWindowTitle;
29 | } BDWAPI;
30 |
31 | } // namespace bitsdojo_window
32 |
33 | BDW_EXPORT bitsdojo_window::BDWAPI* bitsdojo_window_api();
34 |
35 | #endif // _BDW_API_
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/src/bitsdojo_window_macos_real.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_macos;
2 |
3 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
4 | import 'package:flutter/widgets.dart';
5 | import './app_window.dart';
6 | import './native_api.dart';
7 |
8 | T? _ambiguate(T? value) => value;
9 |
10 | class BitsdojoWindowMacOS extends BitsdojoWindowPlatform {
11 | BitsdojoWindowMacOS() : super();
12 |
13 | @override
14 | void doWhenWindowReady(VoidCallback callback) {
15 | _ambiguate(WidgetsBinding.instance)!
16 | .waitUntilFirstFrameRasterized
17 | .then((value) {
18 | setWindowCanBeShown(true);
19 | setInsideDoWhenWindowReady(true);
20 | callback();
21 | setInsideDoWhenWindowReady(false);
22 | });
23 | }
24 |
25 | @override
26 | void dragAppWindow() async {
27 | print("We whould drag the window here");
28 | }
29 |
30 | @override
31 | DesktopWindow get appWindow {
32 | return MacAppWindow();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/bitsdojo_window_macos.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint bitsdojo_window_macos.podspec' to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'bitsdojo_window_macos'
7 | s.version = '0.0.1'
8 | s.summary = 'A new flutter plugin project.'
9 | s.description = <<-DESC
10 | A new flutter plugin project.
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Your Company' => 'email@example.com' }
15 | s.source = { :path => '.' }
16 | s.source_files = 'Classes/**/*.{swift,h,m,mm}'
17 | s.dependency 'FlutterMacOS'
18 |
19 | s.platform = :osx, '10.11'
20 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
21 | s.swift_version = '5.0'
22 |
23 | s.static_framework = false
24 | s.compiler_flags = '-fvisibility=hidden'
25 | end
26 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/bitsdojo_window_macos.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/lib/window.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/painting.dart';
2 |
3 | abstract class DesktopWindow {
4 | DesktopWindow();
5 | int? get handle;
6 | double get scaleFactor;
7 |
8 | Rect get rect;
9 | set rect(Rect newRect);
10 |
11 | Offset get position;
12 | set position(Offset newPosition);
13 |
14 | Size get size;
15 | set size(Size newSize);
16 |
17 | set minSize(Size? newSize);
18 | set maxSize(Size? newSize);
19 |
20 | Alignment? get alignment;
21 | set alignment(Alignment? newAlignment);
22 |
23 | set title(String newTitle);
24 |
25 | @Deprecated("use isVisible instead")
26 | bool get visible;
27 | bool get isVisible;
28 | @Deprecated("use show()/hide() instead")
29 | set visible(bool isVisible);
30 | void show();
31 | void hide();
32 | void close();
33 | void minimize();
34 | void maximize();
35 | void maximizeOrRestore();
36 | void restore();
37 |
38 | void startDragging();
39 |
40 | Size get titleBarButtonSize;
41 | double get titleBarHeight;
42 | double get borderSize;
43 | bool get isMaximized;
44 | }
45 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/README.md:
--------------------------------------------------------------------------------
1 | # bitsdojo_window_platform_interface
2 |
3 | A common platform interface for the [`bitsdojo_window`][1] plugin.
4 |
5 | This interface allows platform-specific implementations of the `bitsdojo_window`
6 | plugin, as well as the plugin itself, to ensure they are supporting the
7 | same interface.
8 |
9 | # Usage
10 |
11 | To implement a new platform-specific implementation of `bitsdojo_window`, extend
12 | [`BitsdojoWindowPlatform`][2] with an implementation that performs the
13 | platform-specific behavior, and when you register your plugin, set the default
14 | `BitsdojoWindowPlatform` by calling
15 | `BitsdojoWindowPlatform.instance = MyPlatformBitsdojoWindow()`.
16 |
17 | # Note on breaking changes
18 |
19 | Strongly prefer non-breaking changes (such as adding a method to the interface)
20 | over breaking changes for this package.
21 |
22 | See https://flutter.dev/go/platform-interface-breaking-changes for a discussion
23 | on why a less-clean interface is preferable to a breaking change.
24 |
25 | [1]: ../bitsdojo_window
26 | [2]: lib/bitsdojo_window_platform_interface.dart
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Bogdan Hobeanu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/window_util.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'package:win32/win32.dart';
3 | import 'package:ffi/ffi.dart';
4 |
5 | const WM_BDW_ACTION = 0x7FFE;
6 |
7 | const BDW_SETWINDOWPOS = 1;
8 | const BDW_SETWINDOWTEXT = 2;
9 | const BDW_FORCECHILDREFRESH = 3;
10 |
11 | class SWPParam extends Struct {
12 | @Int32()
13 | external int x, y, cx, cy, uFlags;
14 | }
15 |
16 | void setWindowPos(
17 | int hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int uFlags) {
18 | final param = calloc();
19 | param.ref
20 | ..x = x
21 | ..y = y
22 | ..cx = cx
23 | ..cy = cy
24 | ..uFlags = uFlags;
25 | PostMessage(hWnd, WM_BDW_ACTION, BDW_SETWINDOWPOS, param.address);
26 | }
27 |
28 | class SWTParam extends Struct {
29 | external Pointer text;
30 | }
31 |
32 | void setWindowText(int hWnd, String text) {
33 | final param = calloc();
34 | param.ref.text = text.toNativeUtf16();
35 | PostMessage(hWnd, WM_BDW_ACTION, BDW_SETWINDOWTEXT, param.address);
36 | }
37 |
38 | void forceChildRefresh(int hWnd) {
39 | PostMessage(hWnd, WM_BDW_ACTION, BDW_FORCECHILDREFRESH, 0);
40 | }
41 |
--------------------------------------------------------------------------------
/bitsdojo_window/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Bogdan Hobeanu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bitsdojo_window/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: bitsdojo_window
2 | description: A package to help with creating custom windows with Flutter desktop (custom border, titlebar and minimize/maximize/close buttons) and common desktop window operations (show/hide/position on screen) for Windows and macOS
3 | version: 0.1.6
4 | homepage: https://www.bitsdojo.com
5 | repository: https://github.com/bitsdojo/bitsdojo_window
6 |
7 | environment:
8 | sdk: ">=2.17.0 <4.0.0"
9 | flutter: ">=1.20.0"
10 |
11 | flutter:
12 | plugin:
13 | platforms:
14 | windows:
15 | default_package: bitsdojo_window_windows
16 | macos:
17 | default_package: bitsdojo_window_macos
18 | linux:
19 | default_package: bitsdojo_window_linux
20 |
21 | dependencies:
22 | flutter:
23 | sdk: flutter
24 | bitsdojo_window_platform_interface:
25 | ^0.1.2
26 | #path: ../bitsdojo_window_platform_interface
27 | bitsdojo_window_windows:
28 | ^0.1.6
29 | #path: ../bitsdojo_window_windows
30 | bitsdojo_window_macos:
31 | ^0.1.4
32 | #path: ../bitsdojo_window_macos
33 | bitsdojo_window_linux:
34 | ^0.1.4
35 | #path: ../bitsdojo_window_linux
36 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Bogdan Hobeanu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Bogdan Hobeanu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Bogdan Hobeanu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Bogdan Hobeanu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/run_loop.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_RUN_LOOP_H_
2 | #define RUNNER_RUN_LOOP_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | // A runloop that will service events for Flutter instances as well
10 | // as native messages.
11 | class RunLoop {
12 | public:
13 | RunLoop();
14 | ~RunLoop();
15 |
16 | // Prevent copying
17 | RunLoop(RunLoop const&) = delete;
18 | RunLoop& operator=(RunLoop const&) = delete;
19 |
20 | // Runs the run loop until the application quits.
21 | void Run();
22 |
23 | // Registers the given Flutter instance for event servicing.
24 | void RegisterFlutterInstance(
25 | flutter::FlutterEngine* flutter_instance);
26 |
27 | // Unregisters the given Flutter instance from event servicing.
28 | void UnregisterFlutterInstance(
29 | flutter::FlutterEngine* flutter_instance);
30 |
31 | private:
32 | using TimePoint = std::chrono::steady_clock::time_point;
33 |
34 | // Processes all currently pending messages for registered Flutter instances.
35 | TimePoint ProcessFlutterMessages();
36 |
37 | std::set flutter_instances_;
38 | };
39 |
40 | #endif // RUNNER_RUN_LOOP_H_
41 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/src/native_struct.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'package:ffi/ffi.dart';
3 |
4 | class BDWRect extends Struct {
5 | @Double()
6 | external double left, top, right, bottom;
7 | }
8 |
9 | Pointer newBDWRect() {
10 | final result = calloc();
11 | result.ref
12 | ..left = 0
13 | ..top = 0
14 | ..right = 0
15 | ..bottom = 0;
16 | return result;
17 | }
18 |
19 | class BDWScreenInfo extends Struct {
20 | external Pointer workingRect;
21 | external Pointer fullRect;
22 | }
23 |
24 | Pointer newBDWScreenInfo() {
25 | final result = calloc();
26 | result.ref
27 | ..workingRect = newBDWRect()
28 | ..fullRect = newBDWRect();
29 | return result;
30 | }
31 |
32 | extension FreeBDWScreenInfo on Pointer {
33 | void free() {
34 | calloc.free(this.ref.workingRect);
35 | calloc.free(this.ref.fullRect);
36 | calloc.free(this);
37 | }
38 | }
39 |
40 | class BDWOffset extends Struct {
41 | @Double()
42 | external double x, y;
43 | }
44 |
45 | Pointer newBDWOffset() {
46 | final result = calloc();
47 | result.ref
48 | ..x = 0
49 | ..y = 0;
50 | return result;
51 | }
52 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "run_loop.h"
10 | #include "win32_window.h"
11 |
12 | // A window that does nothing but host a Flutter view.
13 | class FlutterWindow : public Win32Window {
14 | public:
15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a
16 | // Flutter view running |project|.
17 | explicit FlutterWindow(RunLoop* run_loop,
18 | const flutter::DartProject& project);
19 | virtual ~FlutterWindow();
20 |
21 | protected:
22 | // Win32Window:
23 | bool OnCreate() override;
24 | void OnDestroy() override;
25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
26 | LPARAM const lparam) noexcept override;
27 |
28 | private:
29 | // The run loop driving events for this window.
30 | RunLoop* run_loop_;
31 |
32 | // The project to run.
33 | flutter::DartProject project_;
34 |
35 | // The Flutter instance hosted by this window.
36 | std::unique_ptr flutter_controller_;
37 | };
38 |
39 | #endif // RUNNER_FLUTTER_WINDOW_H_
40 |
--------------------------------------------------------------------------------
/bitsdojo_window/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.6
2 | - Various fixes to work with latest Flutter version
3 | ## 0.1.5
4 | - Runs on Windows 7
5 | ## 0.1.4
6 | - Updated win32 to 3.0.0
7 | ## 0.1.3
8 | - Updated ffi to 2.0.0
9 | ## 0.1.2
10 | - Flutter 3.0 support
11 | ## 0.1.1+1
12 | - Added Linux usage instructions
13 | ## 0.1.1
14 | - Linux support now stable
15 | ## 0.1.0+1
16 | - Fix gtk library name on Linux
17 | ## 0.1.0
18 | - Added null safety support
19 | ## 0.0.9
20 | - Linux support added
21 | ## 0.0.8
22 | - Added macOS readme instructions
23 | ## 0.0.7
24 | - macOS support added
25 | ## 0.0.6
26 | - Works with latest Flutter version (master channel)
27 | ## 0.0.5
28 | - Works with latest Flutter version (dev channel)
29 | ## 0.0.4
30 | - Better integration with other plugins
31 | ## 0.0.3
32 | - Using dpi-aware values for title bar and buttons dimensions
33 | - Dynamically calculating default button padding instead of fixed one
34 | ## 0.0.2
35 | - Added video tutorial link
36 | ## 0.0.1
37 |
38 | * Initial release
39 | - Custom window frame - remove standard Windows titlebar and buttons
40 | - Hide window on startup
41 | - Show/hide window
42 | - Minimize/Maximize/Restore/Close window
43 | - Move window using Flutter widget
44 | - Set window size, minimum size and maximum size
45 | - Set window position
46 | - Set window alignment on screen (center/topLeft/topRight/bottomLeft/bottomRight)
47 | - Set window title
48 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Podfile:
--------------------------------------------------------------------------------
1 | platform :osx, '10.14'
2 |
3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5 |
6 | project 'Runner', {
7 | 'Debug' => :debug,
8 | 'Profile' => :release,
9 | 'Release' => :release,
10 | }
11 |
12 | def flutter_root
13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14 | unless File.exist?(generated_xcode_build_settings_path)
15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16 | end
17 |
18 | File.foreach(generated_xcode_build_settings_path) do |line|
19 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
20 | return matches[1].strip if matches
21 | end
22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23 | end
24 |
25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26 |
27 | flutter_macos_podfile_setup
28 |
29 | target 'Runner' do
30 | use_frameworks!
31 | use_modular_headers!
32 |
33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34 | end
35 |
36 | post_install do |installer|
37 | installer.pods_project.targets.each do |target|
38 | flutter_additional_macos_build_settings(target)
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/bitsdojo_window_api.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSDOJO_WINDOW_API_H
2 | #define BITSDOJO_WINDOW_API_H
3 |
4 | #include "./bitsdojo_window.h"
5 | #include "./bitsdojo_window_common.h"
6 |
7 | typedef struct _BDWPublicAPI
8 | {
9 | TGetAppWindow getAppWindow;
10 | TSetWindowCanBeShown setWindowCanBeShown;
11 | TSetInsideDoWhenWindowReady setInsideDoWhenWindowReady;
12 | TShowWindow showWindow;
13 | THideWindow hideWindow;
14 | TMoveWindow moveWindow;
15 | TSetSize setSize;
16 | TSetMinSize setMinSize;
17 | TSetMaxSize setMaxSize;
18 | TGetScreenInfoForWindow getScreenInfoForWindow;
19 | TSetPositionForWindow setPositionForWindow;
20 | TSetRectForWindow setRectForWindow;
21 | TGetRectForWindow getRectForWindow;
22 | TIsWindowMaximized isWindowVisible;
23 | TIsWindowMaximized isWindowMaximized;
24 | TMaximizeOrRestoreWindow maximizeOrRestoreWindow;
25 | TMaximizeWindow maximizeWindow;
26 | TMinimizeWindow minimizeWindow;
27 | TCloseWindow closeWindow;
28 | TSetWindowTitle setWindowTitle;
29 | TGetTitleBarHeight getTitleBarHeight;
30 | } BDWPublicAPI;
31 |
32 | typedef struct _BDWPrivateAPI{
33 | TWindowCanBeShown windowCanBeShown;
34 | TSetAppWindow setAppWindow;
35 | TAppWindowIsSet appWindowIsSet;
36 | } BDWPrivateAPI;
37 |
38 | typedef struct _BDWAPI{
39 | BDWPublicAPI* publicAPI;
40 | BDWPrivateAPI* privateAPI;
41 | } BDWAPI;
42 |
43 | BDW_EXPORT BDWAPI* bitsdojo_window_api();
44 |
45 | #endif /* BITSDOJO_WINDOW_API_H */
46 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Linux",
5 | "includePath": [
6 | "/usr/include",
7 | "/usr/include/gtk-3.0",
8 | "/usr/include/glib-2.0",
9 | "/usr/include/pango-1.0",
10 | "/usr/include/harfbuzz",
11 | "/usr/include/cairo",
12 | "/usr/include/gdk-pixbuf-2.0",
13 | "/usr/lib/x86_64-linux-gnu/glib-2.0/include",
14 | "/usr/include/atk-1.0",
15 | "${workspaceFolder}/**",
16 | "${workspaceFolder}/bitsdojo_window_linux/linux",
17 | "${workspaceFolder}/bitsdojo_window/example/linux/flutter/ephemeral"
18 | ],
19 | "defines": [],
20 | "compilerPath": "/usr/bin/clang",
21 | "cStandard": "c11",
22 | "cppStandard": "c++14",
23 | "intelliSenseMode": "linux-clang-x64"
24 | },
25 | {
26 | "name": "Mac",
27 | "includePath": [
28 | "${workspaceFolder}/**"
29 | ],
30 | "defines": [],
31 | "macFrameworkPath": [
32 | "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks"
33 | ],
34 | "compilerPath": "/usr/bin/clang",
35 | "cStandard": "c11",
36 | "cppStandard": "c++98",
37 | "intelliSenseMode": "macos-clang-x64"
38 | }
39 | ],
40 | "version": 4
41 | }
--------------------------------------------------------------------------------
/bitsdojo_window/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "flutter_window.h"
9 | #include "run_loop.h"
10 | #include "utils.h"
11 |
12 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
13 | _In_ wchar_t *command_line, _In_ int show_command) {
14 | // Attach to console when present (e.g., 'flutter run') or create a
15 | // new console when running with a debugger.
16 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
17 | CreateAndAttachConsole();
18 | }
19 |
20 | // Initialize COM, so that it is available for use in the library and/or
21 | // plugins.
22 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
23 |
24 | RunLoop run_loop;
25 |
26 | flutter::DartProject project(L"data");
27 |
28 | std::vector command_line_arguments =
29 | GetCommandLineArguments();
30 |
31 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
32 |
33 | FlutterWindow window(&run_loop, project);
34 | Win32Window::Point origin(10, 10);
35 | Win32Window::Size size(1280, 720);
36 | if (!window.CreateAndShow(L"bitsdojo_window_example", origin, size)) {
37 | return EXIT_FAILURE;
38 | }
39 | window.SetQuitOnClose(true);
40 |
41 | run_loop.Run();
42 |
43 | ::CoUninitialize();
44 | return EXIT_SUCCESS;
45 | }
46 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/bitsdojo_window/lib/src/app_window.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_platform_interface/bitsdojo_window_platform_interface.dart';
2 | import 'package:bitsdojo_window_platform_interface/method_channel_bitsdojo_window.dart';
3 | import 'package:bitsdojo_window_windows/bitsdojo_window_windows.dart';
4 | import 'package:bitsdojo_window_macos/bitsdojo_window_macos.dart';
5 | import 'package:bitsdojo_window_linux/bitsdojo_window_linux.dart';
6 | import 'package:flutter/widgets.dart';
7 | import 'package:flutter/foundation.dart' show kIsWeb;
8 | import 'dart:io' show Platform;
9 |
10 | bool _platformInstanceNeedsInit = true;
11 |
12 | void initPlatformInstance() {
13 | if (!kIsWeb) {
14 | if (BitsdojoWindowPlatform.instance is MethodChannelBitsdojoWindow) {
15 | if (Platform.isWindows) {
16 | BitsdojoWindowPlatform.instance = BitsdojoWindowWindows();
17 | } else if (Platform.isMacOS) {
18 | BitsdojoWindowPlatform.instance = BitsdojoWindowMacOS();
19 | } else if (Platform.isLinux) {
20 | BitsdojoWindowPlatform.instance = BitsdojoWindowLinux();
21 | }
22 | }
23 | } else {
24 | BitsdojoWindowPlatform.instance = BitsdojoWindowPlatformNotImplemented();
25 | }
26 | }
27 |
28 | BitsdojoWindowPlatform get _platform {
29 | var needsInit = _platformInstanceNeedsInit;
30 | if (needsInit) {
31 | initPlatformInstance();
32 | _platformInstanceNeedsInit = false;
33 | }
34 | return BitsdojoWindowPlatform.instance;
35 | }
36 |
37 | void doWhenWindowReady(VoidCallback callback) {
38 | _platform.doWhenWindowReady(callback);
39 | }
40 |
41 | DesktopWindow get appWindow {
42 | return _platform.appWindow;
43 | }
44 |
--------------------------------------------------------------------------------
/bitsdojo_window/lib/src/widgets/window_border.dart:
--------------------------------------------------------------------------------
1 | import 'package:bitsdojo_window_windows/bitsdojo_window_windows.dart'
2 | show WinDesktopWindow;
3 | import 'package:flutter/foundation.dart';
4 | import 'package:flutter/widgets.dart';
5 | import '../app_window.dart';
6 |
7 | class WindowBorder extends StatelessWidget {
8 | final Widget child;
9 | final Color color;
10 | final double? width;
11 |
12 | WindowBorder({Key? key, required this.child, required this.color, this.width})
13 | : super(key: key);
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | bool isWindowsApp =
18 | (!kIsWeb) && (defaultTargetPlatform == TargetPlatform.windows);
19 | bool isLinuxApp =
20 | (!kIsWeb) && (defaultTargetPlatform == TargetPlatform.linux);
21 |
22 | // Only show border on Windows and Linux
23 | if (!(isWindowsApp || isLinuxApp)) {
24 | return child;
25 | }
26 |
27 | var borderWidth = width ?? 1;
28 | var topBorderWidth = width ?? 1;
29 |
30 | if (appWindow is WinDesktopWindow) {
31 | appWindow as WinDesktopWindow..setWindowCutOnMaximize(borderWidth.ceil());
32 | }
33 |
34 | if (isWindowsApp) {
35 | topBorderWidth += 1 / appWindow.scaleFactor;
36 | }
37 | final topBorderSide = BorderSide(color: this.color, width: topBorderWidth);
38 | final borderSide = BorderSide(color: this.color, width: borderWidth);
39 |
40 | return Container(
41 | child: child,
42 | decoration: BoxDecoration(
43 | border: Border(
44 | top: topBorderSide,
45 | left: borderSide,
46 | right: borderSide,
47 | bottom: borderSide)));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/bitsdojo_window/lib/src/widgets/window_caption.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 | import '../app_window.dart';
3 | import 'package:flutter/foundation.dart' show kIsWeb;
4 |
5 | class _MoveWindow extends StatelessWidget {
6 | _MoveWindow({Key? key, this.child, this.onDoubleTap}) : super(key: key);
7 | final Widget? child;
8 | final VoidCallback? onDoubleTap;
9 | @override
10 | Widget build(BuildContext context) {
11 | return GestureDetector(
12 | behavior: HitTestBehavior.translucent,
13 | onPanStart: (details) {
14 | appWindow.startDragging();
15 | },
16 | onDoubleTap: this.onDoubleTap ?? () => appWindow.maximizeOrRestore(),
17 | child: this.child ?? Container());
18 | }
19 | }
20 |
21 | class MoveWindow extends StatelessWidget {
22 | final Widget? child;
23 | final VoidCallback? onDoubleTap;
24 | MoveWindow({Key? key, this.child, this.onDoubleTap}) : super(key: key);
25 | @override
26 | Widget build(BuildContext context) {
27 | if (child == null) return _MoveWindow(onDoubleTap: this.onDoubleTap);
28 | return _MoveWindow(
29 | onDoubleTap: this.onDoubleTap,
30 | child: Column(
31 | crossAxisAlignment: CrossAxisAlignment.start,
32 | children: [Expanded(child: this.child!)]),
33 | );
34 | }
35 | }
36 |
37 | class WindowTitleBarBox extends StatelessWidget {
38 | final Widget? child;
39 | WindowTitleBarBox({Key? key, this.child}) : super(key: key);
40 | @override
41 | Widget build(BuildContext context) {
42 | if (kIsWeb) {
43 | return Container();
44 | }
45 | final titlebarHeight = appWindow.titleBarHeight;
46 | return SizedBox(height: titlebarHeight, child: this.child ?? Container());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/BitsdojoWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 |
3 | let bdwAPI = bitsdojo_window_api().pointee;
4 | let bdwPrivateAPI = bdwAPI.privateAPI.pointee;
5 | let bdwPublicAPI = bdwAPI.publicAPI.pointee;
6 |
7 | public let BDW_CUSTOM_FRAME: UInt = 0x1
8 | public let BDW_HIDE_ON_STARTUP: UInt = 0x2
9 |
10 | open class BitsdojoWindow: NSWindow {
11 |
12 | override public var canBecomeKey: Bool {
13 | get {
14 | return true
15 | }
16 | }
17 | open func bitsdojo_window_configure() -> UInt {
18 | return 0
19 | }
20 | override init(
21 | contentRect: NSRect, styleMask style: NSWindow.StyleMask,
22 | backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool
23 | ) {
24 | super.init(contentRect: contentRect, styleMask: style, backing: backingStoreType, defer: flag)
25 |
26 | }
27 | override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
28 | if (!bdwPrivateAPI.appWindowIsSet())
29 | {
30 | bdwPrivateAPI.setAppWindow(self);
31 | }
32 | let flags = self.bitsdojo_window_configure()
33 |
34 | let hideOnStartup:Bool = ((flags & BDW_HIDE_ON_STARTUP) != 0);
35 | let hasCustomFrame:Bool = ((flags & BDW_CUSTOM_FRAME) != 0);
36 |
37 | var localStyle = self.styleMask;
38 | if hasCustomFrame {
39 | localStyle.insert(.fullSizeContentView)
40 | self.styleMask = localStyle;
41 | self.titlebarAppearsTransparent = true
42 | self.titleVisibility = .hidden
43 | self.isOpaque = false
44 | self.isMovable = false
45 | }
46 | super.order(place, relativeTo: otherWin)
47 | let windowCanBeShown: Bool = bdwPrivateAPI.windowCanBeShown();
48 | if (!(windowCanBeShown) && hideOnStartup && self.isVisible) {
49 | self.setIsVisible(false)
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/include/bitsdojo_window_linux/bitsdojo_window_plugin.h:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #ifndef FLUTTER_PLUGIN_BITSDOJO_WINDOW_PLUGIN_H_
15 | #define FLUTTER_PLUGIN_BITSDOJO_WINDOW_PLUGIN_H_
16 |
17 | // A plugin to allow resizing the window.
18 |
19 | #include
20 |
21 | G_BEGIN_DECLS
22 |
23 | #if !defined(BDW_VISIBLE)
24 | #define BDW_VISIBLE __attribute__((visibility("default")))
25 | #endif
26 |
27 | #ifdef FLUTTER_PLUGIN_IMPL
28 | #define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
29 | #else
30 | #define FLUTTER_PLUGIN_EXPORT
31 | #endif
32 |
33 | G_DECLARE_FINAL_TYPE(FlBitsdojoWindowPlugin, bitsdojo_window_plugin, FL,
34 | BITSDOJO_WINDOW_PLUGIN, GObject)
35 |
36 | FLUTTER_PLUGIN_EXPORT FlBitsdojoWindowPlugin* bitsdojo_window_plugin_new(
37 | FlPluginRegistrar* registrar);
38 |
39 | FLUTTER_PLUGIN_EXPORT void bitsdojo_window_plugin_register_with_registrar(
40 | FlPluginRegistrar* registrar);
41 |
42 | class BitsdojoWindowGtk {
43 | public:
44 | virtual void setCustomFrame(gboolean){};
45 | };
46 |
47 | BDW_VISIBLE BitsdojoWindowGtk* bitsdojo_window_from(GtkWindow* window);
48 |
49 | G_END_DECLS
50 |
51 | #endif // FLUTTER_PLUGIN_BITSDOJO_WINDOW_PLUGIN_H_
52 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | if (target_length == 0) {
52 | return std::string();
53 | }
54 | std::string utf8_string;
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/lib/src/window_util.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import './native_struct.dart';
3 | import 'package:flutter/painting.dart';
4 | import './native_api.dart';
5 |
6 | class ScreenInfo {
7 | Rect? workingRect;
8 | Rect? fullRect;
9 | }
10 |
11 | ScreenInfo getScreenInfoForWindow(int window) {
12 | var result = ScreenInfo();
13 | final Pointer screenInfoPointer = newBDWScreenInfo();
14 | final bdwResult = getScreenInfoNative(window, screenInfoPointer);
15 | final Pointer workingRectPointer = screenInfoPointer.ref.workingRect;
16 | final Pointer fullRectPointer = screenInfoPointer.ref.fullRect;
17 | BDWRect workingRect = workingRectPointer.ref;
18 | BDWRect fullRect = fullRectPointer.ref;
19 |
20 | if (bdwResult == true) {
21 | result.workingRect = Rect.fromLTRB(workingRect.left, workingRect.top,
22 | workingRect.right, workingRect.bottom);
23 | result.fullRect = Rect.fromLTRB(
24 | fullRect.left, fullRect.top, fullRect.right, fullRect.bottom);
25 | } else {
26 | assert(false);
27 | result.workingRect = Rect.zero;
28 | result.fullRect = Rect.zero;
29 | }
30 | screenInfoPointer.free();
31 | return result;
32 | }
33 |
34 | Rect getRectForWindow(int window) {
35 | Rect result;
36 | final Pointer rectPointer = newBDWRect();
37 | final bdwResult = getRectForWindowNative(window, rectPointer);
38 | if (bdwResult == BDW_SUCCESS) {
39 | result = Rect.fromLTRB(rectPointer.ref.left, rectPointer.ref.top,
40 | rectPointer.ref.right, rectPointer.ref.bottom);
41 | } else {
42 | assert(false);
43 | result = Rect.zero;
44 | }
45 | //free(rectPointer);
46 | return result;
47 | }
48 |
49 | void setRectForWindow(int window, Rect newRect) {
50 | final Pointer rectPointer = newBDWRect();
51 | rectPointer.ref
52 | ..left = newRect.left
53 | ..top = newRect.top
54 | ..right = newRect.right
55 | ..bottom = newRect.bottom;
56 | setRectForWindowNative(window, rectPointer);
57 | //free(rectPointer);
58 | }
59 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/api_impl.h:
--------------------------------------------------------------------------------
1 | #ifndef _BDW_API_IMPL_
2 | #define _BDW_API_IMPL_
3 |
4 | #include
5 |
6 | namespace bitsdojo_window {
7 |
8 | typedef void (*TGetScreenRect)(GtkWindow*, int*, int*, int*, int*);
9 | void getScreenRect(GtkWindow* window, int* x, int* y, int* width, int* height );
10 |
11 | typedef void (*TGetScaleFactor)(GtkWindow*, int*);
12 | void getScaleFactor(GtkWindow* window, int* scaleFactor);
13 |
14 | typedef void (*TGetPosition)(GtkWindow*, int*, int*);
15 | void getPosition(GtkWindow* window, int* x, int* y);
16 |
17 | typedef void (*TSetPosition)(GtkWindow*, int, int);
18 | void setPosition(GtkWindow* window, int x, int y);
19 |
20 | typedef void (*TGetSize)(GtkWindow*, int*, int*);
21 | void getSize(GtkWindow* window, int* width, int* height);
22 |
23 | typedef void (*TSetSize)(GtkWindow*, int, int);
24 | void setSize(GtkWindow* window, int width, int height);
25 |
26 | typedef void (*TSetRect)(GtkWindow*, int, int, int, int);
27 | void setRect(GtkWindow* window, int x, int y, int width, int height);
28 |
29 | typedef void (*TSetMinSize)(GtkWindow*, int, int);
30 | void setMinSize(GtkWindow* window, int width, int height);
31 |
32 | typedef void (*TSetMaxSize)(GtkWindow*, int, int);
33 | void setMaxSize(GtkWindow* window, int width, int height);
34 |
35 | typedef void (*TShowWindow)(GtkWindow*);
36 | void showWindow(GtkWindow* window);
37 |
38 | typedef void (*THideWindow)(GtkWindow*);
39 | void hideWindow(GtkWindow* window);
40 |
41 | typedef void (*TMinimizeWindow)(GtkWindow*);
42 | void minimizeWindow(GtkWindow* window);
43 |
44 | typedef void (*TMaximizeWindow)(GtkWindow*);
45 | void maximizeWindow(GtkWindow* window);
46 |
47 | typedef void (*TUnmaximizeWindow)(GtkWindow*);
48 | void unmaximizeWindow(GtkWindow* window);
49 |
50 | typedef void (*TSetWindowTitle)(GtkWindow*, const gchar *);
51 | void setWindowTitle(GtkWindow* window, const gchar *title);
52 | }
53 |
54 | #endif // _BDW_API_IMPL_
55 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/lib/bitsdojo_window_platform_interface.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:plugin_platform_interface/plugin_platform_interface.dart';
4 |
5 | import 'method_channel_bitsdojo_window.dart';
6 | import './window.dart';
7 |
8 | export './window.dart';
9 | export './window_common.dart';
10 | export './window_not_implemented.dart';
11 | export './platform_not_implemented.dart';
12 |
13 | /// The interface that implementations of bitsdojo_window must implement.
14 | ///
15 | /// Platform implementations should extend this class rather than implement it as `bitsdojo_window`
16 | /// does not consider newly added methods to be breaking changes. Extending this class
17 | /// (using `extends`) ensures that the subclass will get the default implementation, while
18 | /// platform implementations that `implements` this interface will be broken by newly added
19 | /// [BitsdojoWindowPlatform] methods.
20 | abstract class BitsdojoWindowPlatform extends PlatformInterface {
21 | /// Constructs a BitsdojoWindowPlatform.
22 | BitsdojoWindowPlatform() : super(token: _token);
23 |
24 | static final Object _token = Object();
25 |
26 | static BitsdojoWindowPlatform _channelInstance =
27 | MethodChannelBitsdojoWindow();
28 | static BitsdojoWindowPlatform _instance = _channelInstance;
29 |
30 | /// The default instance of [BitsdojoWindowPlatform] to use.
31 | ///
32 | /// Defaults to [MethodChannelBitsdojoWindow].
33 | static BitsdojoWindowPlatform get instance => _instance;
34 |
35 | /// Platform-specific plugins should set this with their own platform-specific
36 | /// class that extends [BitsdojoWindowPlatform] when they register themselves.
37 | static set instance(BitsdojoWindowPlatform instance) {
38 | PlatformInterface.verifyToken(instance, _token);
39 | _instance = instance;
40 | }
41 |
42 | void doWhenWindowReady(VoidCallback callback) {
43 | throw UnimplementedError('doWhenWindowReady() has not been implemented.');
44 | }
45 |
46 | DesktopWindow get appWindow {
47 | throw UnimplementedError('appWindow has not been implemented.');
48 | }
49 |
50 | void dragAppWindow() async {
51 | _channelInstance.dragAppWindow();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/bitsdojo_window_controller.mm:
--------------------------------------------------------------------------------
1 | #import "bitsdojo_window_controller.h"
2 |
3 | @implementation BitsdojoWindowController
4 |
5 | - (instancetype)initWithWindow:(NSWindow *)window {
6 | self = [super init];
7 | if (self && window) {
8 | self.window = window;
9 | self.window.delegate = self;
10 | [self onScreenChange];
11 | }
12 | return self;
13 | }
14 |
15 | - (void)onScreenChange {
16 | self.isVisible = self.window.isVisible;
17 | self.isZoomed = self.window.isZoomed;
18 | [self setupScreenRects];
19 | [self setupWindowRects];
20 | }
21 |
22 | - (void)setupWindowRects {
23 | self.windowFrame = self.window.frame;
24 | double windowFrameHeight = self.window.contentView.frame.size.height;
25 | double contentLayoutHeight = self.window.contentLayoutRect.size.height;
26 | self.titleBarHeight = windowFrameHeight - contentLayoutHeight;
27 | }
28 |
29 | - (void)setupScreenRects {
30 | NSScreen *screen = self.window.screen;
31 | self.workingScreenRect = screen.visibleFrame;
32 | self.fullScreenRect = screen.frame;
33 | }
34 |
35 | - (void)windowDidResize:(NSNotification *)notification {
36 | NSWindow *resizedWindow = notification.object;
37 | if ([resizedWindow isKindOfClass:[NSWindow class]]) {
38 | [self setupWindowRects];
39 | self.windowSize = self.window.frame.size;
40 | }
41 | }
42 |
43 | -(void)handleWindowChanges {
44 | self.isZoomed = self.window.isZoomed;
45 | }
46 |
47 | - (void)windowDidBecomeVisible:(NSNotification *)notification {
48 | self.isVisible = YES;
49 | }
50 |
51 | - (void)windowDidBecomeHidden:(NSNotification *)notification {
52 | self.isVisible = NO;
53 | }
54 |
55 | - (void)windowDidChangeScreen:(NSNotification *)notification {
56 | [self onScreenChange];
57 | }
58 |
59 | - (void)windowDidChangeBackingProperties:(NSNotification *)notification {
60 | [self onScreenChange];
61 | }
62 |
63 | - (void)windowDidMiniaturize:(NSNotification *)notification { [self handleWindowChanges]; }
64 | - (void)windowDidDeminiaturize:(NSNotification *)notification { [self handleWindowChanges]; }
65 | - (void)windowDidEndLiveResize:(NSNotification *)notification { [self handleWindowChanges]; }
66 | @end
67 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(RunLoop* run_loop,
8 | const flutter::DartProject& project)
9 | : run_loop_(run_loop), project_(project) {}
10 |
11 | FlutterWindow::~FlutterWindow() {}
12 |
13 | bool FlutterWindow::OnCreate() {
14 | if (!Win32Window::OnCreate()) {
15 | return false;
16 | }
17 |
18 | RECT frame = GetClientArea();
19 |
20 | // The size here must match the window dimensions to avoid unnecessary surface
21 | // creation / destruction in the startup path.
22 | flutter_controller_ = std::make_unique(
23 | frame.right - frame.left, frame.bottom - frame.top, project_);
24 | // Ensure that basic setup of the controller was successful.
25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
26 | return false;
27 | }
28 | RegisterPlugins(flutter_controller_->engine());
29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
30 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
31 | return true;
32 | }
33 |
34 | void FlutterWindow::OnDestroy() {
35 | if (flutter_controller_) {
36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
37 | flutter_controller_ = nullptr;
38 | }
39 |
40 | Win32Window::OnDestroy();
41 | }
42 |
43 | LRESULT
44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
45 | WPARAM const wparam,
46 | LPARAM const lparam) noexcept {
47 | // Give Flutter, including plugins, an opporutunity to handle window messages.
48 | if (flutter_controller_) {
49 | std::optional result =
50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
51 | lparam);
52 | if (result) {
53 | return *result;
54 | }
55 | }
56 |
57 | switch (message) {
58 | case WM_FONTCHANGE:
59 | flutter_controller_->engine()->ReloadSystemFonts();
60 | break;
61 | }
62 |
63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
64 | }
65 |
--------------------------------------------------------------------------------
/bitsdojo_window/lib/src/widgets/mouse_state_builder.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 |
3 | typedef MouseStateBuilderCB = Widget Function(
4 | BuildContext context, MouseState mouseState);
5 |
6 | class MouseState {
7 | bool isMouseOver = false;
8 | bool isMouseDown = false;
9 | MouseState();
10 | @override
11 | String toString() {
12 | return "isMouseDown: ${this.isMouseDown} - isMouseOver: ${this.isMouseOver}";
13 | }
14 | }
15 |
16 | T? _ambiguate(T? value) => value;
17 |
18 | class MouseStateBuilder extends StatefulWidget {
19 | final MouseStateBuilderCB builder;
20 | final VoidCallback? onPressed;
21 | MouseStateBuilder({Key? key, required this.builder, this.onPressed})
22 | : super(key: key);
23 | @override
24 | _MouseStateBuilderState createState() => _MouseStateBuilderState();
25 | }
26 |
27 | class _MouseStateBuilderState extends State {
28 | late MouseState _mouseState;
29 | _MouseStateBuilderState() {
30 | _mouseState = MouseState();
31 | }
32 |
33 | @override
34 | Widget build(BuildContext context) {
35 | return MouseRegion(
36 | onEnter: (event) {
37 | setState(() {
38 | _mouseState.isMouseOver = true;
39 | });
40 | },
41 | onExit: (event) {
42 | setState(() {
43 | _mouseState.isMouseOver = false;
44 | });
45 | },
46 | child: GestureDetector(
47 | onTapDown: (_) {
48 | setState(() {
49 | _mouseState.isMouseDown = true;
50 | });
51 | },
52 | onTapCancel: () {
53 | setState(() {
54 | _mouseState.isMouseDown = false;
55 | });
56 | },
57 | onTap: () {
58 | setState(() {
59 | _mouseState.isMouseDown = false;
60 | _mouseState.isMouseOver = false;
61 | });
62 | _ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) {
63 | if (widget.onPressed != null) {
64 | widget.onPressed!();
65 | }
66 | });
67 | },
68 | onTapUp: (_) {},
69 | child: widget.builder(context, _mouseState)));
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/run_loop.cpp:
--------------------------------------------------------------------------------
1 | #include "run_loop.h"
2 |
3 | #include
4 |
5 | #include
6 |
7 | RunLoop::RunLoop() {}
8 |
9 | RunLoop::~RunLoop() {}
10 |
11 | void RunLoop::Run() {
12 | bool keep_running = true;
13 | TimePoint next_flutter_event_time = TimePoint::clock::now();
14 | while (keep_running) {
15 | std::chrono::nanoseconds wait_duration =
16 | std::max(std::chrono::nanoseconds(0),
17 | next_flutter_event_time - TimePoint::clock::now());
18 | ::MsgWaitForMultipleObjects(
19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000),
20 | QS_ALLINPUT);
21 | bool processed_events = false;
22 | MSG message;
23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects
24 | // won't return again for items left in the queue after PeekMessage.
25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) {
26 | processed_events = true;
27 | if (message.message == WM_QUIT) {
28 | keep_running = false;
29 | break;
30 | }
31 | ::TranslateMessage(&message);
32 | ::DispatchMessage(&message);
33 | // Allow Flutter to process messages each time a Windows message is
34 | // processed, to prevent starvation.
35 | next_flutter_event_time =
36 | std::min(next_flutter_event_time, ProcessFlutterMessages());
37 | }
38 | // If the PeekMessage loop didn't run, process Flutter messages.
39 | if (!processed_events) {
40 | next_flutter_event_time =
41 | std::min(next_flutter_event_time, ProcessFlutterMessages());
42 | }
43 | }
44 | }
45 |
46 | void RunLoop::RegisterFlutterInstance(
47 | flutter::FlutterEngine* flutter_instance) {
48 | flutter_instances_.insert(flutter_instance);
49 | }
50 |
51 | void RunLoop::UnregisterFlutterInstance(
52 | flutter::FlutterEngine* flutter_instance) {
53 | flutter_instances_.erase(flutter_instance);
54 | }
55 |
56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() {
57 | TimePoint next_event_time = TimePoint::max();
58 | for (auto instance : flutter_instances_) {
59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages();
60 | if (wait_duration != std::chrono::nanoseconds::max()) {
61 | next_event_time =
62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration);
63 | }
64 | }
65 | return next_event_time;
66 | }
67 |
--------------------------------------------------------------------------------
/bitsdojo_window_macos/macos/Classes/bitsdojo_window.h:
--------------------------------------------------------------------------------
1 | #ifndef bitsdojo_window_h
2 | #define bitsdojo_window_h
3 |
4 | #include "./bitsdojo_window_common.h"
5 |
6 | // Native private API
7 |
8 | typedef bool (*TWindowCanBeShown)();
9 | bool windowCanBeShown();
10 |
11 | typedef bool (*TAppWindowIsSet)();
12 | bool appWindowIsSet();
13 |
14 | typedef void (*TSetAppWindow)(NSWindow*);
15 | void setAppWindow(NSWindow* window);
16 |
17 | // Public API
18 |
19 | typedef NSWindow* (*TGetAppWindow)();
20 | NSWindow* getAppWindow();
21 |
22 | typedef void (*TSetWindowCanBeShown)(bool);
23 | void setWindowCanBeShown(bool value);
24 |
25 | typedef void (*TSetInsideDoWhenWindowReady)(bool);
26 | void setInsideDoWhenWindowReady(bool value);
27 |
28 | typedef void (*TShowWindow)(NSWindow*);
29 | void showWindow(NSWindow* window);
30 |
31 | typedef void (*THideWindow)(NSWindow*);
32 | void hideWindow(NSWindow* window);
33 |
34 | typedef void (*TMoveWindow)(NSWindow*);
35 | void moveWindow(NSWindow* window);
36 |
37 | typedef void (*TSetSize)(NSWindow*,int, int);
38 | void setSize(NSWindow* window, int width, int height);
39 |
40 | typedef void (*TSetMinSize)(NSWindow*,int, int);
41 | void setMinSize(NSWindow* window, int width, int height);
42 |
43 | typedef void (*TSetMaxSize)(NSWindow*,int, int);
44 | void setMaxSize(NSWindow* window, int width, int height);
45 |
46 | typedef BDWStatus (*TGetScreenInfoForWindow)(NSWindow*, BDWScreenInfo*);
47 | BDWStatus getScreenInfoForWindow(NSWindow*, BDWScreenInfo*);
48 |
49 | typedef BDWStatus (*TSetPositionForWindow)(NSWindow*, BDWOffset*);
50 | BDWStatus setPositionForWindow(NSWindow*, BDWOffset*);
51 |
52 | typedef BDWStatus (*TSetRectForWindow)(NSWindow*, BDWRect*);
53 | BDWStatus setRectForWindow(NSWindow*, BDWRect*);
54 |
55 | typedef BDWStatus (*TGetRectForWindow)(NSWindow*, BDWRect*);
56 | BDWStatus getRectForWindow(NSWindow*, BDWRect*);
57 |
58 | typedef bool (*TIsWindowVisible)(NSWindow* window);
59 | bool isWindowVisible(NSWindow* window);
60 |
61 | typedef bool (*TIsWindowMaximized)(NSWindow* window);
62 | bool isWindowMaximized(NSWindow* window);
63 |
64 | typedef void (*TMaximizeOrRestoreWindow)(NSWindow*);
65 | void maximizeOrRestoreWindow(NSWindow* window);
66 |
67 | typedef void (*TMaximizeWindow)(NSWindow*);
68 | void maximizeWindow(NSWindow* window);
69 |
70 | typedef void (*TMinimizeWindow)(NSWindow*);
71 | void minimizeWindow(NSWindow* window);
72 |
73 | typedef void (*TCloseWindow)(NSWindow*);
74 | void closeWindow(NSWindow* window);
75 |
76 | typedef void (*TSetWindowTitle)(NSWindow*, const char*);
77 | void setWindowTitle(NSWindow* window, const char* title);
78 |
79 | typedef double (*TGetTitleBarHeight)(NSWindow*);
80 | double getTitleBarHeight(NSWindow* window);
81 | #endif /* bitsdojo_window_h */
82 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/lib/src/native_api.dart:
--------------------------------------------------------------------------------
1 | library bitsdojo_window_windows;
2 |
3 | import 'dart:ffi';
4 |
5 | final DynamicLibrary _appExecutable = DynamicLibrary.executable();
6 |
7 | // isBitsdojoWindowLoaded
8 | typedef Int8 TIsBitsdojoWindowLoaded();
9 | typedef DTIsBitsdojoWindowLoaded = int Function();
10 | final DTIsBitsdojoWindowLoaded? _isBitsdojoWindowLoaded =
11 | _publicAPI.ref.isBitsdojoWindowLoaded.asFunction();
12 |
13 | bool isBitsdojoWindowLoaded() {
14 | if (_isBitsdojoWindowLoaded == null) {
15 | return false;
16 | }
17 | return _isBitsdojoWindowLoaded!() == 1 ? true : false;
18 | }
19 |
20 | // getAppWindow
21 | typedef IntPtr TGetAppWindow();
22 | typedef DGetAppWindow = int Function();
23 | final DGetAppWindow getAppWindow = _publicAPI.ref.getAppWindow.asFunction();
24 |
25 | // isDPIAware
26 | typedef Int8 TIsDPIAware();
27 | typedef DIsDPIAware = int Function();
28 | final DIsDPIAware _isDPIAware = _publicAPI.ref.isDPIAware.asFunction();
29 | bool isDPIAware() => _isDPIAware() != 0;
30 |
31 | // setWindowCanBeShown
32 | typedef Void TSetWindowCanBeShown(Int8 value);
33 | typedef DSetWindowCanBeShown = void Function(int value);
34 | final DSetWindowCanBeShown _setWindowCanBeShown =
35 | _publicAPI.ref.setWindowCanBeShown.asFunction();
36 | void setWindowCanBeShown(bool value) => _setWindowCanBeShown(value ? 1 : 0);
37 |
38 | // setMinSize
39 | typedef Void TSetMinSize(Int32 width, Int32 height);
40 | typedef DSetMinSize = void Function(int width, int height);
41 | final DSetMinSize setMinSize = _publicAPI.ref.setMinSize.asFunction();
42 |
43 | // setMaxSize
44 | typedef Void TSetMaxSize(Int32 width, Int32 height);
45 | typedef DSetMaxSize = void Function(int width, int height);
46 | final DSetMinSize setMaxSize = _publicAPI.ref.setMaxSize.asFunction();
47 |
48 | // setWindowCutOnMaximize
49 | typedef Void TSetWindowCutOnMaximize(Int32 width);
50 | typedef DSetWindowCutOnMaximize = void Function(int width);
51 | final DSetWindowCutOnMaximize setWindowCutOnMaximize =
52 | _publicAPI.ref.setWindowCutOnMaximize.asFunction();
53 |
54 | class BDWPublicAPI extends Struct {
55 | external Pointer>
56 | isBitsdojoWindowLoaded;
57 | external Pointer> getAppWindow;
58 | external Pointer> setWindowCanBeShown;
59 | external Pointer> setMinSize;
60 | external Pointer> setMaxSize;
61 | external Pointer>
62 | setWindowCutOnMaximize;
63 | external Pointer> isDPIAware;
64 | }
65 |
66 | class BDWAPI extends Struct {
67 | external Pointer publicAPI;
68 | }
69 |
70 | typedef Pointer TBitsdojoWindowAPI();
71 |
72 | final TBitsdojoWindowAPI bitsdojoWindowAPI = _appExecutable
73 | .lookup>("bitsdojo_window_api")
74 | .asFunction();
75 |
76 | final Pointer _publicAPI = bitsdojoWindowAPI().ref.publicAPI;
77 |
--------------------------------------------------------------------------------
/.github/workflows/build_test.yaml:
--------------------------------------------------------------------------------
1 | name: build-test
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | paths-ignore:
8 | - ".vscode/**"
9 | - "CHANGELOG.md"
10 | - "LICENSE"
11 | - "README.md"
12 | - "resources/**"
13 | - "**/CHANGELOG.md"
14 | - "**/LICENSE"
15 | - "**/README.md"
16 | pull_request:
17 | paths-ignore:
18 | - ".vscode/**"
19 | - "CHANGELOG.md"
20 | - "LICENSE"
21 | - "README.md"
22 | - "resources/**"
23 | - "**/CHANGELOG.md"
24 | - "**/LICENSE"
25 | - "**/README.md"
26 | workflow_dispatch:
27 |
28 | concurrency:
29 | group: >
30 | ${{ github.workflow }}
31 | ${{ github.event.pull_request.number || github.ref }}
32 | cancel-in-progress: true
33 |
34 | jobs:
35 | build:
36 | name: ${{ matrix.runner }}
37 | runs-on: ${{ matrix.runner }}-latest
38 | timeout-minutes: 30
39 | strategy:
40 | fail-fast: false # Important
41 | matrix:
42 | runner: [ubuntu, windows, macos]
43 | include:
44 | - runner: ubuntu
45 | target: linux
46 | - runner: windows
47 | target: windows
48 | - runner: macos
49 | target: macos
50 |
51 | steps:
52 | - name: Checkout repository
53 | uses: actions/checkout@v3
54 | with:
55 | fetch-depth: 1
56 | submodules: true
57 |
58 | - name: Setup Flutter SDK
59 | uses: subosito/flutter-action@v2
60 | with:
61 | channel: "stable"
62 | cache: true
63 |
64 | - name: Setup Ninja and GTK3 toolchain (Only Linux)
65 | if: matrix.runner == 'ubuntu'
66 | run: |
67 | sudo apt-get update -y
68 | sudo apt-get install -y ninja-build libgtk-3-dev
69 |
70 | - name: Fetch dependencies
71 | working-directory: bitsdojo_window/example
72 | run: flutter pub get
73 |
74 | - name: Run flutter build ${{ matrix.target }}
75 | working-directory: bitsdojo_window/example
76 | run: flutter build ${{ matrix.target }} --release -v
77 |
78 | - name: Archive artifacts (Linux)
79 | if: matrix.runner == 'ubuntu'
80 | uses: actions/upload-artifact@v3
81 | with:
82 | name: bitsdojo_window_example_${{ matrix.runner }}
83 | path: bitsdojo_window/example/build/linux/x64/release/bundle/
84 |
85 | - name: Archive artifacts (Windows)
86 | if: matrix.runner == 'windows'
87 | uses: actions/upload-artifact@v3
88 | with:
89 | name: bitsdojo_window_example_${{ matrix.runner }}
90 | path: bitsdojo_window/example/build/windows/runner/Release/bitsdojo_window_example.exe
91 |
92 | - name: Archive artifacts (macOS)
93 | if: matrix.runner == 'macos'
94 | uses: actions/upload-artifact@v3
95 | with:
96 | name: bitsdojo_window_example_${{ matrix.runner }}
97 | path: bitsdojo_window/example/build/macos/Build/Products/Release/bitsdojo_window_example.app
98 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/lib/window_common.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/painting.dart';
2 |
3 | Rect getRectOnScreen(Size sizeOnScreen, Alignment _alignment, Rect screenRect) {
4 | if (_alignment == Alignment.topLeft) {
5 | final topLeft = screenRect.topLeft;
6 | final otherOffset = Offset(
7 | topLeft.dx + sizeOnScreen.width, topLeft.dy + sizeOnScreen.height);
8 | return Rect.fromPoints(topLeft, otherOffset);
9 | }
10 | if (_alignment == Alignment.topCenter) {
11 | final topLeft = Offset(screenRect.topCenter.dx - sizeOnScreen.width / 2,
12 | screenRect.topCenter.dy);
13 | final otherOffset = Offset(
14 | topLeft.dx + sizeOnScreen.width, topLeft.dy + sizeOnScreen.height);
15 | return Rect.fromPoints(topLeft, otherOffset);
16 | }
17 | if (_alignment == Alignment.topRight) {
18 | final topRight = screenRect.topRight;
19 | final otherOffset = Offset(
20 | topRight.dx - sizeOnScreen.width, topRight.dy + sizeOnScreen.height);
21 | return Rect.fromPoints(otherOffset, topRight);
22 | }
23 | if (_alignment == Alignment.bottomLeft) {
24 | final bottomRight = screenRect.bottomLeft;
25 | final topLeft = Offset(bottomRight.dx - sizeOnScreen.width,
26 | bottomRight.dy - sizeOnScreen.height);
27 |
28 | return Rect.fromPoints(topLeft, bottomRight);
29 | }
30 | if (_alignment == Alignment.bottomCenter) {
31 | final topLeft = Offset(screenRect.bottomCenter.dx - sizeOnScreen.width / 2,
32 | screenRect.bottomCenter.dy - sizeOnScreen.height);
33 | final bottomRight = Offset(
34 | topLeft.dx + sizeOnScreen.width, topLeft.dy + sizeOnScreen.height);
35 | return Rect.fromPoints(topLeft, bottomRight);
36 | }
37 | if (_alignment == Alignment.bottomRight) {
38 | final bottomRight = screenRect.bottomRight;
39 | final otherOffset = Offset(bottomRight.dx - sizeOnScreen.width,
40 | bottomRight.dy - sizeOnScreen.height);
41 | return Rect.fromPoints(bottomRight, otherOffset);
42 | }
43 | if (_alignment == Alignment.centerLeft) {
44 | final centerLeftTop = Offset(screenRect.centerLeft.dx,
45 | screenRect.centerLeft.dy - sizeOnScreen.height / 2);
46 | final otherOffset = Offset(centerLeftTop.dx + sizeOnScreen.width,
47 | centerLeftTop.dy + sizeOnScreen.height);
48 | return Rect.fromPoints(centerLeftTop, otherOffset);
49 | }
50 | if (_alignment == Alignment.center) {
51 | return Rect.fromCenter(
52 | center: screenRect.center,
53 | width: sizeOnScreen.width,
54 | height: sizeOnScreen.height);
55 | }
56 | if (_alignment == Alignment.centerRight) {
57 | final centerRightTop = Offset(
58 | screenRect.centerRight.dx - sizeOnScreen.width,
59 | screenRect.centerRight.dy - sizeOnScreen.height / 2);
60 | final otherOffset = Offset(centerRightTop.dx + sizeOnScreen.width,
61 | centerRightTop.dy + sizeOnScreen.height);
62 | return Rect.fromPoints(centerRightTop, otherOffset);
63 | }
64 | // Should not end up here
65 | assert(false, 'Alignment $_alignment not implemented');
66 | return Rect.zero;
67 | }
68 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 |
11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
12 | # which isn't available in 3.10.
13 | function(list_prepend LIST_NAME PREFIX)
14 | set(NEW_LIST "")
15 | foreach(element ${${LIST_NAME}})
16 | list(APPEND NEW_LIST "${PREFIX}${element}")
17 | endforeach(element)
18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
19 | endfunction()
20 |
21 | # === Flutter Library ===
22 | # System-level dependencies.
23 | find_package(PkgConfig REQUIRED)
24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
27 |
28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
29 |
30 | # Published to parent scope for install step.
31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
35 |
36 | list(APPEND FLUTTER_LIBRARY_HEADERS
37 | "fl_basic_message_channel.h"
38 | "fl_binary_codec.h"
39 | "fl_binary_messenger.h"
40 | "fl_dart_project.h"
41 | "fl_engine.h"
42 | "fl_json_message_codec.h"
43 | "fl_json_method_codec.h"
44 | "fl_message_codec.h"
45 | "fl_method_call.h"
46 | "fl_method_channel.h"
47 | "fl_method_codec.h"
48 | "fl_method_response.h"
49 | "fl_plugin_registrar.h"
50 | "fl_plugin_registry.h"
51 | "fl_standard_message_codec.h"
52 | "fl_standard_method_codec.h"
53 | "fl_string_codec.h"
54 | "fl_value.h"
55 | "fl_view.h"
56 | "flutter_linux.h"
57 | )
58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
59 | add_library(flutter INTERFACE)
60 | target_include_directories(flutter INTERFACE
61 | "${EPHEMERAL_DIR}"
62 | )
63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
64 | target_link_libraries(flutter INTERFACE
65 | PkgConfig::GTK
66 | PkgConfig::GLIB
67 | PkgConfig::GIO
68 | )
69 | add_dependencies(flutter flutter_assemble)
70 |
71 | # === Flutter tool backend ===
72 | # _phony_ is a non-existent file to force this command to run every time,
73 | # since currently there's no way to get a full input/output list from the
74 | # flutter tool.
75 | add_custom_command(
76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
78 | COMMAND ${CMAKE_COMMAND} -E env
79 | ${FLUTTER_TOOL_ENVIRONMENT}
80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
82 | VERBATIM
83 | )
84 | add_custom_target(flutter_assemble DEPENDS
85 | "${FLUTTER_LIBRARY}"
86 | ${FLUTTER_LIBRARY_HEADERS}
87 | )
88 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: bitsdojo_window_example
2 | description: Demonstrates how to use the bitsdojo_window plugin.
3 |
4 | # The following line prevents the package from being accidentally published to
5 | # pub.dev using `pub publish`. This is preferred for private packages.
6 | publish_to: "none" # Remove this line if you wish to publish to pub.dev
7 |
8 | platforms:
9 | linux:
10 | macos:
11 | windows:
12 |
13 | environment:
14 | sdk: ">=2.17.0 <4.0.0"
15 |
16 | dependencies:
17 | flutter:
18 | sdk: flutter
19 |
20 | bitsdojo_window:
21 | # When depending on this package from a real application you should use:
22 | # bitsdojo_window: ^x.y.z
23 | # See https://dart.dev/tools/pub/dependencies#version-constraints
24 | # The example app is bundled with the plugin so we use a path dependency on
25 | # the parent directory to use the current plugin's version.
26 | path: ../
27 |
28 | # The following adds the Cupertino Icons font to your application.
29 | # Use with the CupertinoIcons class for iOS style icons.
30 | cupertino_icons: ^1.0.1
31 |
32 | dev_dependencies:
33 | flutter_test:
34 | sdk: flutter
35 | integration_test:
36 | sdk: flutter
37 | # The "flutter_lints" package below contains a set of recommended lints to
38 | # encourage good coding practices. The lint set provided by the package is
39 | # activated in the `analysis_options.yaml` file located at the root of your
40 | # package. See that file for information about deactivating specific lint
41 | # rules and activating additional ones.
42 | flutter_lints: ^3.0.1
43 |
44 | # For information on the generic Dart part of this file, see the
45 | # following page: https://dart.dev/tools/pub/pubspec
46 |
47 | # The following section is specific to Flutter.
48 | flutter:
49 | # The following line ensures that the Material Icons font is
50 | # included with your application, so that you can use the icons in
51 | # the material Icons class.
52 | uses-material-design: true
53 |
54 | # To add assets to your application, add an assets section, like this:
55 | # assets:
56 | # - images/a_dot_burr.jpeg
57 | # - images/a_dot_ham.jpeg
58 |
59 | # An image asset can refer to one or more resolution-specific "variants", see
60 | # https://flutter.dev/assets-and-images/#resolution-aware.
61 |
62 | # For details regarding adding assets from package dependencies, see
63 | # https://flutter.dev/assets-and-images/#from-packages
64 |
65 | # To add custom fonts to your application, add a fonts section here,
66 | # in this "flutter" section. Each entry in this list should have a
67 | # "family" key with the font family name, and a "fonts" key with a
68 | # list giving the asset and other descriptors for the font. For
69 | # example:
70 | # fonts:
71 | # - family: Schyler
72 | # fonts:
73 | # - asset: fonts/Schyler-Regular.ttf
74 | # - asset: fonts/Schyler-Italic.ttf
75 | # style: italic
76 | # - family: Trajan Pro
77 | # fonts:
78 | # - asset: fonts/TrajanPro.ttf
79 | # - asset: fonts/TrajanPro_Bold.ttf
80 | # weight: 700
81 | #
82 | # For details regarding fonts from package dependencies,
83 | # see https://flutter.dev/custom-fonts/#from-packages
84 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #ifdef FLUTTER_BUILD_NUMBER
64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0
67 | #endif
68 |
69 | #ifdef FLUTTER_BUILD_NAME
70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "A new Flutter project." "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "bitsdojo_window_example" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "bitsdojo_window_example.exe" "\0"
98 | VALUE "ProductName", "bitsdojo_window_example" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/lib/src/gtk.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'package:ffi/ffi.dart';
3 |
4 | final _libgtk = DynamicLibrary.open('libgtk-3.so.0');
5 |
6 | final gtkWidgetGetParentWindow = _libgtk.lookupFunction<
7 | IntPtr Function(IntPtr widget),
8 | int Function(int widget)>('gtk_widget_get_parent_window');
9 |
10 | final gtkWidgetShow = _libgtk.lookupFunction('gtk_widget_show');
12 |
13 | final gtkWidgetHide = _libgtk.lookupFunction('gtk_widget_hide');
15 |
16 | final gtkWindowGetScreen = _libgtk.lookupFunction<
17 | IntPtr Function(IntPtr window),
18 | int Function(int window)>('gtk_window_get_screen');
19 |
20 | final gdkScreenGetDisplay = _libgtk.lookupFunction<
21 | IntPtr Function(IntPtr screen),
22 | int Function(int screen)>('gdk_screen_get_display');
23 |
24 | final gdkDisplayGetPrimaryMonitor = _libgtk.lookupFunction<
25 | IntPtr Function(IntPtr display),
26 | int Function(int display)>('gdk_display_get_primary_monitor');
27 |
28 | final gdkDisplayGetMonitorAtWindow = _libgtk.lookupFunction<
29 | IntPtr Function(IntPtr display, IntPtr window),
30 | int Function(int display, int window)>('gdk_display_get_monitor_at_window');
31 |
32 | final gdkMonitorGetScaleFactor = _libgtk.lookupFunction<
33 | Int32 Function(IntPtr monitor),
34 | int Function(int monitor)>('gdk_monitor_get_scale_factor');
35 |
36 | final gdkMonitorGetGeometry = _libgtk.lookupFunction<
37 | Int32 Function(IntPtr monitor, Pointer rect),
38 | int Function(int monitor, Pointer rect)>('gdk_monitor_get_geometry');
39 |
40 | final gtkWindowGetPosition = _libgtk.lookupFunction<
41 | Void Function(IntPtr window, Pointer x, Pointer y),
42 | void Function(int window, Pointer x,
43 | Pointer y)>('gtk_window_get_position');
44 |
45 | final gtkWindowGetSize = _libgtk.lookupFunction<
46 | Void Function(IntPtr window, Pointer x, Pointer y),
47 | void Function(
48 | int window, Pointer x, Pointer y)>('gtk_window_get_size');
49 |
50 | final gtkWindowMove = _libgtk.lookupFunction<
51 | Void Function(IntPtr window, Int32 x, Int32 y),
52 | void Function(int window, int x, int y)>('gtk_window_move');
53 |
54 | final gtkWindowResize = _libgtk.lookupFunction<
55 | Void Function(IntPtr window, Int32 width, Int32 height),
56 | void Function(int window, int width, int height)>('gtk_window_resize');
57 |
58 | final gtkWindowClose = _libgtk.lookupFunction('gtk_window_close');
60 |
61 | final gtkWindowIsMaximized = _libgtk.lookupFunction<
62 | Int32 Function(IntPtr window),
63 | int Function(int window)>('gtk_window_is_maximized');
64 |
65 | final gtkWindowMaximize = _libgtk.lookupFunction('gtk_window_maximize');
67 |
68 | final gtkWindowUnmaximize = _libgtk.lookupFunction('gtk_window_unmaximize');
70 |
71 | final gtkWindowIconify = _libgtk.lookupFunction('gtk_window_iconify');
73 |
74 | final gtkWindowDeiconify = _libgtk.lookupFunction('gtk_window_deiconify');
76 |
77 | final gtkWindowSetTitle = _libgtk.lookupFunction<
78 | Void Function(IntPtr window, Pointer title),
79 | void Function(int window, Pointer title)>('gtk_window_set_title');
80 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/bitsdojo_window_platform_interface/lib/window_not_implemented.dart:
--------------------------------------------------------------------------------
1 | import './window.dart';
2 | import 'package:flutter/rendering.dart';
3 |
4 | class NotImplementedWindow extends DesktopWindow {
5 | int get handle {
6 | throw UnimplementedError('handle getter has not been implemented');
7 | }
8 |
9 | set size(Size newSize) {
10 | throw UnimplementedError('size setter has not been implemented');
11 | }
12 |
13 | Size get size {
14 | throw UnimplementedError('size getter has not been implemented.');
15 | }
16 |
17 | Rect get rect {
18 | throw UnimplementedError('rect getter has not been implemented.');
19 | }
20 |
21 | set rect(Rect newRect) {
22 | throw UnimplementedError('rect setter has not been implemented.');
23 | }
24 |
25 | Offset get position {
26 | throw UnimplementedError('position getter has not been implemented.');
27 | }
28 |
29 | set position(Offset newPosition) {
30 | throw UnimplementedError('position setter has not been implemented.');
31 | }
32 |
33 | set minSize(Size? newSize) {
34 | throw UnimplementedError('minSize setter has not been implemented.');
35 | }
36 |
37 | set maxSize(Size? newSize) {
38 | throw UnimplementedError('maxSize setter has not been implemented.');
39 | }
40 |
41 | Alignment get alignment {
42 | throw UnimplementedError('alignment getter has not been implemented.');
43 | }
44 |
45 | set alignment(Alignment? newAlignment) {
46 | throw UnimplementedError('alignment setter has not been implemented.');
47 | }
48 |
49 | set title(String newTitle) {
50 | throw UnimplementedError('title setter has not been implemented.');
51 | }
52 |
53 | void show() {
54 | throw UnimplementedError('show() has not been implemented.');
55 | }
56 |
57 | void hide() {
58 | throw UnimplementedError('hide() has not been implemented.');
59 | }
60 |
61 | @Deprecated("use isVisible instead")
62 | bool get visible {
63 | return isVisible;
64 | }
65 |
66 | bool get isVisible {
67 | throw UnimplementedError('isVisible has not been implemented.');
68 | }
69 |
70 | @Deprecated("use show()/hide() instead")
71 | set visible(bool isVisible) {
72 | throw UnimplementedError('visible setter has not been implemented.');
73 | }
74 |
75 | Size get titleBarButtonSize {
76 | throw UnimplementedError(
77 | 'titleBarButtonSize getter has not been implemented.');
78 | }
79 |
80 | double get titleBarHeight {
81 | throw UnimplementedError('titleBarHeight getter has not been implemented.');
82 | }
83 |
84 | double get borderSize {
85 | throw UnimplementedError('borderSize getter has not been implemented.');
86 | }
87 |
88 | void close() {
89 | throw UnimplementedError('close() has not been implemented.');
90 | }
91 |
92 | void minimize() {
93 | throw UnimplementedError('minimize() has not been implemented.');
94 | }
95 |
96 | void maximize() {
97 | throw UnimplementedError('maximize() has not been implemented.');
98 | }
99 |
100 | void maximizeOrRestore() {
101 | throw UnimplementedError('maximizeOrRestore has not been implemented.');
102 | }
103 |
104 | void restore() {
105 | throw UnimplementedError('restore has not been implemented.');
106 | }
107 |
108 | void startDragging() {
109 | throw UnimplementedError('startDragging has not been implemented.');
110 | }
111 |
112 | bool get isMaximized {
113 | throw UnimplementedError('isMaximized getter has not been implemented.');
114 | }
115 |
116 | double get scaleFactor {
117 | throw UnimplementedError('scaleFactor setter has not been implemented');
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/bitsdojo_window_linux/linux/debug_helper.cpp:
--------------------------------------------------------------------------------
1 | #include "./debug_helper.h"
2 |
3 | #include
4 |
5 | namespace bitsdojo_window {
6 |
7 | #define CHECK_FLAG(x) \
8 | if (state & x) \
9 | g_string_append_printf(result, "%s%s", (result->len > 0) ? " | " : "", \
10 | #x);
11 |
12 | #define CHECK_EQUAL(x) \
13 | if (state == x) \
14 | g_string_append_printf(result, "%s%s", (result->len > 0) ? " | " : "", \
15 | #x);
16 |
17 | void printWindowStateMask(const char *description, GdkWindowState state) {
18 | auto result = g_string_new(nullptr);
19 | CHECK_FLAG(GDK_WINDOW_STATE_WITHDRAWN)
20 | CHECK_FLAG(GDK_WINDOW_STATE_ICONIFIED)
21 | CHECK_FLAG(GDK_WINDOW_STATE_MAXIMIZED)
22 | CHECK_FLAG(GDK_WINDOW_STATE_STICKY)
23 | CHECK_FLAG(GDK_WINDOW_STATE_FULLSCREEN)
24 | CHECK_FLAG(GDK_WINDOW_STATE_ABOVE)
25 | CHECK_FLAG(GDK_WINDOW_STATE_BELOW)
26 | CHECK_FLAG(GDK_WINDOW_STATE_FOCUSED)
27 | CHECK_FLAG(GDK_WINDOW_STATE_TILED)
28 | CHECK_FLAG(GDK_WINDOW_STATE_TOP_TILED)
29 | CHECK_FLAG(GDK_WINDOW_STATE_TOP_RESIZABLE)
30 | CHECK_FLAG(GDK_WINDOW_STATE_RIGHT_TILED)
31 | CHECK_FLAG(GDK_WINDOW_STATE_RIGHT_RESIZABLE)
32 | CHECK_FLAG(GDK_WINDOW_STATE_BOTTOM_TILED)
33 | CHECK_FLAG(GDK_WINDOW_STATE_BOTTOM_RESIZABLE)
34 | CHECK_FLAG(GDK_WINDOW_STATE_LEFT_TILED)
35 | CHECK_FLAG(GDK_WINDOW_STATE_LEFT_RESIZABLE)
36 | printf("%s: %s\n", description, result->str);
37 | g_string_free(result, TRUE);
38 | }
39 |
40 | void printGdkEvent(const char *description, GdkEventType state) {
41 | auto result = g_string_new(nullptr);
42 | CHECK_EQUAL(GDK_DELETE)
43 | CHECK_EQUAL(GDK_DESTROY)
44 | CHECK_EQUAL(GDK_EXPOSE)
45 | CHECK_EQUAL(GDK_MOTION_NOTIFY)
46 | CHECK_EQUAL(GDK_BUTTON_PRESS)
47 | CHECK_EQUAL(GDK_2BUTTON_PRESS)
48 | CHECK_EQUAL(GDK_3BUTTON_PRESS)
49 | CHECK_EQUAL(GDK_BUTTON_RELEASE)
50 | CHECK_EQUAL(GDK_KEY_PRESS)
51 | CHECK_EQUAL(GDK_KEY_RELEASE)
52 | CHECK_EQUAL(GDK_ENTER_NOTIFY)
53 | CHECK_EQUAL(GDK_LEAVE_NOTIFY)
54 | CHECK_EQUAL(GDK_FOCUS_CHANGE)
55 | CHECK_EQUAL(GDK_CONFIGURE)
56 | CHECK_EQUAL(GDK_MAP)
57 | CHECK_EQUAL(GDK_UNMAP)
58 | CHECK_EQUAL(GDK_PROPERTY_NOTIFY)
59 | CHECK_EQUAL(GDK_SELECTION_CLEAR)
60 | CHECK_EQUAL(GDK_SELECTION_REQUEST)
61 | CHECK_EQUAL(GDK_SELECTION_NOTIFY)
62 | CHECK_EQUAL(GDK_PROXIMITY_IN)
63 | CHECK_EQUAL(GDK_PROXIMITY_OUT)
64 | CHECK_EQUAL(GDK_DRAG_ENTER)
65 | CHECK_EQUAL(GDK_DRAG_LEAVE)
66 | CHECK_EQUAL(GDK_DRAG_MOTION)
67 | CHECK_EQUAL(GDK_DRAG_STATUS)
68 | CHECK_EQUAL(GDK_DROP_START)
69 | CHECK_EQUAL(GDK_DROP_FINISHED)
70 | CHECK_EQUAL(GDK_CLIENT_EVENT)
71 | CHECK_EQUAL(GDK_VISIBILITY_NOTIFY)
72 | CHECK_EQUAL(GDK_SCROLL)
73 | CHECK_EQUAL(GDK_WINDOW_STATE)
74 | CHECK_EQUAL(GDK_SETTING)
75 | CHECK_EQUAL(GDK_OWNER_CHANGE)
76 | CHECK_EQUAL(GDK_GRAB_BROKEN)
77 | CHECK_EQUAL(GDK_DAMAGE)
78 | CHECK_EQUAL(GDK_TOUCH_BEGIN)
79 | CHECK_EQUAL(GDK_TOUCH_UPDATE)
80 | CHECK_EQUAL(GDK_TOUCH_END)
81 | CHECK_EQUAL(GDK_TOUCH_CANCEL)
82 | CHECK_EQUAL(GDK_TOUCHPAD_SWIPE)
83 | CHECK_EQUAL(GDK_TOUCHPAD_PINCH)
84 | CHECK_EQUAL(GDK_PAD_BUTTON_PRESS)
85 | CHECK_EQUAL(GDK_PAD_BUTTON_RELEASE)
86 | CHECK_EQUAL(GDK_PAD_RING)
87 | CHECK_EQUAL(GDK_PAD_STRIP)
88 | CHECK_EQUAL(GDK_PAD_GROUP_MODE)
89 | printf("%s: %s\n", description, result->str);
90 | g_string_free(result, TRUE);
91 | }
92 |
93 | } // namespace bitsdojo_window
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------
/bitsdojo_window/example/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(bitsdojo_window_example LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "bitsdojo_window_example")
5 |
6 | cmake_policy(SET CMP0063 NEW)
7 |
8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
9 |
10 | # Configure build options.
11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
12 | if(IS_MULTICONFIG)
13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
14 | CACHE STRING "" FORCE)
15 | else()
16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17 | set(CMAKE_BUILD_TYPE "Debug" CACHE
18 | STRING "Flutter build mode" FORCE)
19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
20 | "Debug" "Profile" "Release")
21 | endif()
22 | endif()
23 |
24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
28 |
29 | # Use Unicode for all projects.
30 | add_definitions(-DUNICODE -D_UNICODE)
31 |
32 | # Compilation settings that should be applied to most targets.
33 | function(APPLY_STANDARD_SETTINGS TARGET)
34 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
36 | target_compile_options(${TARGET} PRIVATE /EHsc)
37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
39 | endfunction()
40 |
41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
42 |
43 | # Flutter library and tool build rules.
44 | add_subdirectory(${FLUTTER_MANAGED_DIR})
45 |
46 | # Application build
47 | add_subdirectory("runner")
48 |
49 | # Generated plugin build rules, which manage building the plugins and adding
50 | # them to the application.
51 | include(flutter/generated_plugins.cmake)
52 |
53 |
54 | # === Installation ===
55 | # Support files are copied into place next to the executable, so that it can
56 | # run in place. This is done instead of making a separate bundle (as on Linux)
57 | # so that building and running from within Visual Studio will work.
58 | set(BUILD_BUNDLE_DIR "$")
59 | # Make the "install" step default, as it's required to run.
60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
63 | endif()
64 |
65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
67 |
68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
69 | COMPONENT Runtime)
70 |
71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
72 | COMPONENT Runtime)
73 |
74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
75 | COMPONENT Runtime)
76 |
77 | if(PLUGIN_BUNDLED_LIBRARIES)
78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
80 | COMPONENT Runtime)
81 | endif()
82 |
83 | # Fully re-copy the assets directory on each build to avoid having stale files
84 | # from a previous install.
85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
86 | install(CODE "
87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
88 | " COMPONENT Runtime)
89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
91 |
92 | # Install the AOT library on non-Debug builds only.
93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
94 | CONFIGURATIONS Profile;Release
95 | COMPONENT Runtime)
96 |
--------------------------------------------------------------------------------
/bitsdojo_window_windows/windows/bitsdojo_window_plugin.cpp:
--------------------------------------------------------------------------------
1 | #include "include/bitsdojo_window_windows/bitsdojo_window_plugin.h"
2 |
3 | // This must be included before many other Windows headers.
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #include