├── .github └── workflows │ └── pull-request.yml ├── .gitignore ├── LICENSE ├── README.md ├── desktop_context_menu ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example │ ├── .gitignore │ ├── README.md │ ├── analysis_options.yaml │ ├── lib │ │ └── main.dart │ ├── macos │ │ ├── .gitignore │ │ ├── Flutter │ │ │ ├── Flutter-Debug.xcconfig │ │ │ ├── Flutter-Release.xcconfig │ │ │ └── GeneratedPluginRegistrant.swift │ │ ├── Podfile │ │ ├── Podfile.lock │ │ ├── Runner.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ ├── Runner.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── Runner │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── 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 │ │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ │ ├── DebugProfile.entitlements │ │ │ ├── Info.plist │ │ │ ├── MainFlutterWindow.swift │ │ │ └── Release.entitlements │ ├── pubspec.lock │ ├── pubspec.yaml │ └── windows │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ │ └── runner │ │ ├── CMakeLists.txt │ │ ├── Runner.rc │ │ ├── flutter_window.cpp │ │ ├── flutter_window.h │ │ ├── main.cpp │ │ ├── resource.h │ │ ├── resources │ │ └── app_icon.ico │ │ ├── runner.exe.manifest │ │ ├── utils.cpp │ │ ├── utils.h │ │ ├── win32_window.cpp │ │ └── win32_window.h ├── lib │ └── desktop_context_menu.dart └── pubspec.yaml ├── desktop_context_menu_macos ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib │ └── desktop_context_menu_macos.dart ├── macos │ ├── Classes │ │ └── DesktopContextMenuMacosPlugin.swift │ └── desktop_context_menu_macos.podspec ├── pubspec.yaml └── test │ └── desktop_context_menu_macos_test.dart ├── desktop_context_menu_platform_interface ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib │ ├── desktop_context_menu_platform_interface.dart │ └── src │ │ ├── method_channel │ │ └── method_channel_desktop_context_menu.dart │ │ ├── platform_interface │ │ └── desktop_context_menu_platform.dart │ │ └── types │ │ ├── context_menu_item.dart │ │ ├── context_menu_item_base.dart │ │ ├── context_menu_item_separator.dart │ │ ├── context_menu_item_type.dart │ │ └── types.dart └── pubspec.yaml ├── desktop_context_menu_windows ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib │ └── desktop_context_menu_windows.dart ├── pubspec.yaml ├── test │ └── desktop_context_menu_windows_test.dart └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── desktop_context_menu_windows_plugin.cpp │ └── include │ └── desktop_context_menu_windows │ ├── desktop_context_menu_windows_plugin.h │ └── encoding.h └── melos.yaml /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: pull-request 2 | 3 | on: 4 | pull_request: 5 | types: [opened, reopened, synchronize] 6 | 7 | concurrency: 8 | group: ${{ github.head_ref }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | ci: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | 18 | - name: Install flutter 19 | uses: subosito/flutter-action@master 20 | with: 21 | channel: 'stable' 22 | 23 | - name: Activate melos 24 | uses: bluefireteam/melos-action@v1 25 | 26 | - name: Check format 27 | run: melos run check_format 28 | 29 | - name: Run analyzer 30 | run: melos run analyze 31 | 32 | - name: Run unit tests 33 | run: melos run test --no-select -------------------------------------------------------------------------------- /.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 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Rows GmbH (rows.com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |
4 | Rows 5 |
6 | 7 |
8 |

9 | 10 |

11 | The spreadsheet with superpowers ✨! 12 |
13 |
14 |

15 | 16 |

17 | 18 | 19 | 20 |

21 | 22 | --- 23 | 24 | # Desktop Context Menu 25 | 26 | A context menu plugin for Flutter Desktop. Supports MacOS and Windows. 27 | -------------------------------------------------------------------------------- /desktop_context_menu/.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 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /desktop_context_menu/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.1 2 | 3 | * Expose `ContextMenuItemBase`. 4 | 5 | ## 0.1.0 6 | 7 | * Initial release. 8 | -------------------------------------------------------------------------------- /desktop_context_menu/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Rows GmbH (rows.com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /desktop_context_menu/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |
4 | Rows 5 |
6 | Spreadsheet with superpowers! 7 |
8 |
9 |
10 |

11 | 12 |

13 | 14 | 15 |

16 | 17 | # Desktop Context Menu 18 | 19 | A package that spawns a context menu at the mouse coordinates. 20 | 21 | Available for MacOS and Windows. 22 | 23 | | MacOS | Windows | 24 | | ------------------- | ------------------- | 25 | | image | ![image](https://user-images.githubusercontent.com/36768712/165944913-b40af592-5150-4a18-b65d-fbad854cab8f.png) | 26 | 27 | ## Features 28 | 29 | - Native context menu 30 | - Separators between menu items 31 | - Specify shortcuts for menu items 32 | 33 | ## Usage 34 | 35 | To invoke the context menu you can do the following: 36 | 37 | ```dart 38 | final selectedItem = await showContextMenu(menuItems: [...]); 39 | ``` 40 | 41 | In case an item is selected in the context menu, that item is returned. If no item is selected, `null` is returned. 42 | 43 | A context menu item can be of type `ContextMenuItem` or `ContextMenuSeparator`. 44 | 45 | To define a menu item of type `ContextMenuItem`, you can do the following: 46 | 47 | ```dart 48 | ... 49 | ContextMenuItem( 50 | title: 'Menu item title', 51 | onTap: () { 52 | // do something... 53 | }, 54 | ), 55 | ... 56 | ``` 57 | 58 | If you do not set the `onTap` callback, the menu item will be disabled. 59 | 60 | To add a separator between menu items, you need to add a `ContextMenuSeparator` between `ContextMenuItem`s: 61 | 62 | ```dart 63 | ... 64 | menuItems: [ 65 | ContextMenuItem( 66 | title: 'Menu item title', 67 | onTap: () { 68 | // do something... 69 | }, 70 | ), 71 | ContextMenuSeparator(), 72 | ContextMenuItem( 73 | title: 'Disabled menu item', 74 | ), 75 | ], 76 | ... 77 | ``` 78 | 79 | To define a shortcut for a menu item, just specify the shortcut property of `ContextMenuItem` that takes a `SingleActivator`: 80 | 81 | ```dart 82 | ... 83 | ContextMenuItem( 84 | title: 'Copy', 85 | onTap: () { 86 | // do something... 87 | }, 88 | shortcut: SingleActivator( 89 | LogicalKeyboardKey.keyC, 90 | meta: Platform.isMacOS, 91 | control: Platform.isWindows, 92 | ), 93 | ), 94 | ... 95 | ``` 96 | -------------------------------------------------------------------------------- /desktop_context_menu/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:rows_lint/analysis_options.yaml -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | Demonstrates how to use the `desktop_context_menu` plugin. 4 | -------------------------------------------------------------------------------- /desktop_context_menu/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:rows_lint/analysis_options.yaml -------------------------------------------------------------------------------- /desktop_context_menu/example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:desktop_context_menu/desktop_context_menu.dart'; 4 | import 'package:flutter/gestures.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/services.dart'; 7 | 8 | void main() { 9 | runApp(const MyApp()); 10 | } 11 | 12 | class MyApp extends StatelessWidget { 13 | const MyApp({Key? key}) : super(key: key); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return MaterialApp( 18 | theme: ThemeData( 19 | primarySwatch: Colors.blue, 20 | ), 21 | home: const MyHomePage(title: 'Desktop Context Menu Example'), 22 | ); 23 | } 24 | } 25 | 26 | class MyHomePage extends StatefulWidget { 27 | const MyHomePage({Key? key, required this.title}) : super(key: key); 28 | 29 | final String title; 30 | 31 | @override 32 | State createState() => _MyHomePageState(); 33 | } 34 | 35 | class _MyHomePageState extends State { 36 | bool _openContextMenu = false; 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return Listener( 41 | /// Listener.onPointerUp cannot check if the clicked mouse button is 42 | /// the secondary one. 43 | onPointerDown: (event) { 44 | _openContextMenu = event.kind == PointerDeviceKind.mouse && 45 | event.buttons == kSecondaryMouseButton; 46 | }, 47 | onPointerUp: (event) { 48 | if (!_openContextMenu) { 49 | return; 50 | } 51 | 52 | _openContextMenu = false; 53 | 54 | _showContextMenu(); 55 | }, 56 | child: Scaffold( 57 | appBar: AppBar( 58 | title: Text(widget.title), 59 | ), 60 | body: const Center( 61 | child: Text('right click anywhere to open context menu'), 62 | ), 63 | ), 64 | ); 65 | } 66 | 67 | void _showContextMenu() async { 68 | final selectedItem = await showContextMenu( 69 | menuItems: [ 70 | ContextMenuItem( 71 | title: 'Copy', 72 | onTap: () {}, 73 | shortcut: SingleActivator( 74 | LogicalKeyboardKey.keyC, 75 | meta: Platform.isMacOS, 76 | control: Platform.isWindows, 77 | ), 78 | ), 79 | ContextMenuItem( 80 | title: 'Paste', 81 | onTap: () {}, 82 | shortcut: SingleActivator( 83 | LogicalKeyboardKey.keyV, 84 | meta: Platform.isMacOS, 85 | control: Platform.isWindows, 86 | ), 87 | ), 88 | ContextMenuItem( 89 | title: 'Paste as values', 90 | onTap: () {}, 91 | shortcut: SingleActivator( 92 | LogicalKeyboardKey.keyV, 93 | meta: Platform.isMacOS, 94 | control: Platform.isWindows, 95 | shift: true, 96 | ), 97 | ), 98 | const ContextMenuSeparator(), 99 | ContextMenuItem( 100 | title: 'Item number two', 101 | onTap: () {}, 102 | ), 103 | const ContextMenuItem(title: 'Disabled item'), 104 | const ContextMenuItem( 105 | title: 'Disabled item with shortcut', 106 | shortcut: SingleActivator( 107 | LogicalKeyboardKey.keyV, 108 | meta: true, 109 | shift: true, 110 | ), 111 | ), 112 | const ContextMenuSeparator(), 113 | ContextMenuItem( 114 | title: 'Zoom in', 115 | shortcut: const SingleActivator( 116 | LogicalKeyboardKey.add, 117 | alt: true, 118 | ), 119 | onTap: () {}, 120 | ), 121 | ContextMenuItem( 122 | title: 'Zoom out', 123 | shortcut: const SingleActivator( 124 | LogicalKeyboardKey.minus, 125 | alt: true, 126 | ), 127 | onTap: () {}, 128 | ), 129 | const ContextMenuSeparator(), 130 | ContextMenuItem( 131 | title: 'Control shortcut', 132 | shortcut: const SingleActivator( 133 | LogicalKeyboardKey.keyJ, 134 | control: true, 135 | ), 136 | onTap: () {}, 137 | ), 138 | ], 139 | ); 140 | 141 | if (selectedItem == null) { 142 | return null; 143 | } 144 | 145 | print(selectedItem.title); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import desktop_context_menu_macos 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | DesktopContextMenuMacosPlugin.register(with: registry.registrar(forPlugin: "DesktopContextMenuMacosPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - desktop_context_menu_macos (0.1.0): 3 | - FlutterMacOS 4 | - FlutterMacOS (1.0.0) 5 | 6 | DEPENDENCIES: 7 | - desktop_context_menu_macos (from `Flutter/ephemeral/.symlinks/plugins/desktop_context_menu_macos/macos`) 8 | - FlutterMacOS (from `Flutter/ephemeral`) 9 | 10 | EXTERNAL SOURCES: 11 | desktop_context_menu_macos: 12 | :path: Flutter/ephemeral/.symlinks/plugins/desktop_context_menu_macos/macos 13 | FlutterMacOS: 14 | :path: Flutter/ephemeral 15 | 16 | SPEC CHECKSUMS: 17 | desktop_context_menu_macos: 75dc0a4697165c567eeb0e4cae511d1ecd5131fc 18 | FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 19 | 20 | PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 21 | 22 | COCOAPODS: 1.11.3 23 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; 13 | buildPhases = ( 14 | 33CC111E2044C6BF0003C045 /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | ); 18 | name = "Flutter Assemble"; 19 | productName = FLX; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 25 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 26 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 27 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 28 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 29 | 5839F004743F1835D49C6890 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AE9F436C1A6A52CF0B87BD /* Pods_Runner.framework */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXContainerItemProxy section */ 33 | 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 33CC111A2044C6BA0003C045; 38 | remoteInfo = FLX; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXCopyFilesBuildPhase section */ 43 | 33CC110E2044A8840003C045 /* Bundle Framework */ = { 44 | isa = PBXCopyFilesBuildPhase; 45 | buildActionMask = 2147483647; 46 | dstPath = ""; 47 | dstSubfolderSpec = 10; 48 | files = ( 49 | ); 50 | name = "Bundle Framework"; 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXCopyFilesBuildPhase section */ 54 | 55 | /* Begin PBXFileReference section */ 56 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 57 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 58 | 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 60 | 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 61 | 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 62 | 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; 63 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; 64 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 65 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 66 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; 67 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 68 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 69 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 70 | 5F9FC74E30F2F5922325F5C7 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 71 | 65AE9F436C1A6A52CF0B87BD /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 73 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 74 | AF7BFD8F4F49DDE0DA508ABF /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 75 | B995835D39775F71EBBBDB69 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | 33CC10EA2044A3C60003C045 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | 5839F004743F1835D49C6890 /* Pods_Runner.framework in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | 33BA886A226E78AF003329D5 /* Configs */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */, 94 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 95 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 96 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, 97 | ); 98 | path = Configs; 99 | sourceTree = ""; 100 | }; 101 | 33CC10E42044A3C60003C045 = { 102 | isa = PBXGroup; 103 | children = ( 104 | 33FAB671232836740065AC1E /* Runner */, 105 | 33CEB47122A05771004F2AC0 /* Flutter */, 106 | 33CC10EE2044A3C60003C045 /* Products */, 107 | D73912EC22F37F3D000D13A0 /* Frameworks */, 108 | CBEE27E6B38564CDFB20CAFC /* Pods */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 33CC10EE2044A3C60003C045 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 33CC10ED2044A3C60003C045 /* example.app */, 116 | ); 117 | name = Products; 118 | sourceTree = ""; 119 | }; 120 | 33CC11242044D66E0003C045 /* Resources */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 33CC10F22044A3C60003C045 /* Assets.xcassets */, 124 | 33CC10F42044A3C60003C045 /* MainMenu.xib */, 125 | 33CC10F72044A3C60003C045 /* Info.plist */, 126 | ); 127 | name = Resources; 128 | path = ..; 129 | sourceTree = ""; 130 | }; 131 | 33CEB47122A05771004F2AC0 /* Flutter */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, 135 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 136 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 137 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, 138 | ); 139 | path = Flutter; 140 | sourceTree = ""; 141 | }; 142 | 33FAB671232836740065AC1E /* Runner */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */, 146 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, 147 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */, 148 | 33E51914231749380026EE4D /* Release.entitlements */, 149 | 33CC11242044D66E0003C045 /* Resources */, 150 | 33BA886A226E78AF003329D5 /* Configs */, 151 | ); 152 | path = Runner; 153 | sourceTree = ""; 154 | }; 155 | CBEE27E6B38564CDFB20CAFC /* Pods */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | AF7BFD8F4F49DDE0DA508ABF /* Pods-Runner.debug.xcconfig */, 159 | 5F9FC74E30F2F5922325F5C7 /* Pods-Runner.release.xcconfig */, 160 | B995835D39775F71EBBBDB69 /* Pods-Runner.profile.xcconfig */, 161 | ); 162 | name = Pods; 163 | path = Pods; 164 | sourceTree = ""; 165 | }; 166 | D73912EC22F37F3D000D13A0 /* Frameworks */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 65AE9F436C1A6A52CF0B87BD /* Pods_Runner.framework */, 170 | ); 171 | name = Frameworks; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXGroup section */ 175 | 176 | /* Begin PBXNativeTarget section */ 177 | 33CC10EC2044A3C60003C045 /* Runner */ = { 178 | isa = PBXNativeTarget; 179 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; 180 | buildPhases = ( 181 | B114240EC48D9D6260E8C9AA /* [CP] Check Pods Manifest.lock */, 182 | 33CC10E92044A3C60003C045 /* Sources */, 183 | 33CC10EA2044A3C60003C045 /* Frameworks */, 184 | 33CC10EB2044A3C60003C045 /* Resources */, 185 | 33CC110E2044A8840003C045 /* Bundle Framework */, 186 | 3399D490228B24CF009A79C7 /* ShellScript */, 187 | B22448A8505A500350EC6798 /* [CP] Embed Pods Frameworks */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | 33CC11202044C79F0003C045 /* PBXTargetDependency */, 193 | ); 194 | name = Runner; 195 | productName = Runner; 196 | productReference = 33CC10ED2044A3C60003C045 /* example.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | /* End PBXNativeTarget section */ 200 | 201 | /* Begin PBXProject section */ 202 | 33CC10E52044A3C60003C045 /* Project object */ = { 203 | isa = PBXProject; 204 | attributes = { 205 | LastSwiftUpdateCheck = 0920; 206 | LastUpgradeCheck = 1300; 207 | ORGANIZATIONNAME = ""; 208 | TargetAttributes = { 209 | 33CC10EC2044A3C60003C045 = { 210 | CreatedOnToolsVersion = 9.2; 211 | LastSwiftMigration = 1100; 212 | ProvisioningStyle = Automatic; 213 | SystemCapabilities = { 214 | com.apple.Sandbox = { 215 | enabled = 1; 216 | }; 217 | }; 218 | }; 219 | 33CC111A2044C6BA0003C045 = { 220 | CreatedOnToolsVersion = 9.2; 221 | ProvisioningStyle = Manual; 222 | }; 223 | }; 224 | }; 225 | buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; 226 | compatibilityVersion = "Xcode 9.3"; 227 | developmentRegion = en; 228 | hasScannedForEncodings = 0; 229 | knownRegions = ( 230 | en, 231 | Base, 232 | ); 233 | mainGroup = 33CC10E42044A3C60003C045; 234 | productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; 235 | projectDirPath = ""; 236 | projectRoot = ""; 237 | targets = ( 238 | 33CC10EC2044A3C60003C045 /* Runner */, 239 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */, 240 | ); 241 | }; 242 | /* End PBXProject section */ 243 | 244 | /* Begin PBXResourcesBuildPhase section */ 245 | 33CC10EB2044A3C60003C045 /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 250 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | /* End PBXResourcesBuildPhase section */ 255 | 256 | /* Begin PBXShellScriptBuildPhase section */ 257 | 3399D490228B24CF009A79C7 /* ShellScript */ = { 258 | isa = PBXShellScriptBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | inputFileListPaths = ( 263 | ); 264 | inputPaths = ( 265 | ); 266 | outputFileListPaths = ( 267 | ); 268 | outputPaths = ( 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | shellPath = /bin/sh; 272 | shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; 273 | }; 274 | 33CC111E2044C6BF0003C045 /* ShellScript */ = { 275 | isa = PBXShellScriptBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | ); 279 | inputFileListPaths = ( 280 | Flutter/ephemeral/FlutterInputs.xcfilelist, 281 | ); 282 | inputPaths = ( 283 | Flutter/ephemeral/tripwire, 284 | ); 285 | outputFileListPaths = ( 286 | Flutter/ephemeral/FlutterOutputs.xcfilelist, 287 | ); 288 | outputPaths = ( 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | shellPath = /bin/sh; 292 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; 293 | }; 294 | B114240EC48D9D6260E8C9AA /* [CP] Check Pods Manifest.lock */ = { 295 | isa = PBXShellScriptBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | ); 299 | inputFileListPaths = ( 300 | ); 301 | inputPaths = ( 302 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 303 | "${PODS_ROOT}/Manifest.lock", 304 | ); 305 | name = "[CP] Check Pods Manifest.lock"; 306 | outputFileListPaths = ( 307 | ); 308 | outputPaths = ( 309 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | shellPath = /bin/sh; 313 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 314 | showEnvVarsInLog = 0; 315 | }; 316 | B22448A8505A500350EC6798 /* [CP] Embed Pods Frameworks */ = { 317 | isa = PBXShellScriptBuildPhase; 318 | buildActionMask = 2147483647; 319 | files = ( 320 | ); 321 | inputFileListPaths = ( 322 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 323 | ); 324 | name = "[CP] Embed Pods Frameworks"; 325 | outputFileListPaths = ( 326 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 327 | ); 328 | runOnlyForDeploymentPostprocessing = 0; 329 | shellPath = /bin/sh; 330 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 331 | showEnvVarsInLog = 0; 332 | }; 333 | /* End PBXShellScriptBuildPhase section */ 334 | 335 | /* Begin PBXSourcesBuildPhase section */ 336 | 33CC10E92044A3C60003C045 /* Sources */ = { 337 | isa = PBXSourcesBuildPhase; 338 | buildActionMask = 2147483647; 339 | files = ( 340 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, 341 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, 342 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | /* End PBXSourcesBuildPhase section */ 347 | 348 | /* Begin PBXTargetDependency section */ 349 | 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { 350 | isa = PBXTargetDependency; 351 | target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; 352 | targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; 353 | }; 354 | /* End PBXTargetDependency section */ 355 | 356 | /* Begin PBXVariantGroup section */ 357 | 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { 358 | isa = PBXVariantGroup; 359 | children = ( 360 | 33CC10F52044A3C60003C045 /* Base */, 361 | ); 362 | name = MainMenu.xib; 363 | path = Runner; 364 | sourceTree = ""; 365 | }; 366 | /* End PBXVariantGroup section */ 367 | 368 | /* Begin XCBuildConfiguration section */ 369 | 338D0CE9231458BD00FA5F75 /* Profile */ = { 370 | isa = XCBuildConfiguration; 371 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | CLANG_ANALYZER_NONNULL = YES; 375 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 376 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 377 | CLANG_CXX_LIBRARY = "libc++"; 378 | CLANG_ENABLE_MODULES = YES; 379 | CLANG_ENABLE_OBJC_ARC = YES; 380 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 385 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 386 | CLANG_WARN_EMPTY_BODY = YES; 387 | CLANG_WARN_ENUM_CONVERSION = YES; 388 | CLANG_WARN_INFINITE_RECURSION = YES; 389 | CLANG_WARN_INT_CONVERSION = YES; 390 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 391 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 393 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 394 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 395 | CODE_SIGN_IDENTITY = "-"; 396 | COPY_PHASE_STRIP = NO; 397 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 398 | ENABLE_NS_ASSERTIONS = NO; 399 | ENABLE_STRICT_OBJC_MSGSEND = YES; 400 | GCC_C_LANGUAGE_STANDARD = gnu11; 401 | GCC_NO_COMMON_BLOCKS = YES; 402 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 403 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 404 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 405 | GCC_WARN_UNUSED_FUNCTION = YES; 406 | GCC_WARN_UNUSED_VARIABLE = YES; 407 | MACOSX_DEPLOYMENT_TARGET = 10.11; 408 | MTL_ENABLE_DEBUG_INFO = NO; 409 | SDKROOT = macosx; 410 | SWIFT_COMPILATION_MODE = wholemodule; 411 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 412 | }; 413 | name = Profile; 414 | }; 415 | 338D0CEA231458BD00FA5F75 /* Profile */ = { 416 | isa = XCBuildConfiguration; 417 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 418 | buildSettings = { 419 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 420 | CLANG_ENABLE_MODULES = YES; 421 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 422 | CODE_SIGN_STYLE = Automatic; 423 | COMBINE_HIDPI_IMAGES = YES; 424 | INFOPLIST_FILE = Runner/Info.plist; 425 | LD_RUNPATH_SEARCH_PATHS = ( 426 | "$(inherited)", 427 | "@executable_path/../Frameworks", 428 | ); 429 | PROVISIONING_PROFILE_SPECIFIER = ""; 430 | SWIFT_VERSION = 5.0; 431 | }; 432 | name = Profile; 433 | }; 434 | 338D0CEB231458BD00FA5F75 /* Profile */ = { 435 | isa = XCBuildConfiguration; 436 | buildSettings = { 437 | CODE_SIGN_STYLE = Manual; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | }; 440 | name = Profile; 441 | }; 442 | 33CC10F92044A3C60003C045 /* Debug */ = { 443 | isa = XCBuildConfiguration; 444 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 445 | buildSettings = { 446 | ALWAYS_SEARCH_USER_PATHS = NO; 447 | CLANG_ANALYZER_NONNULL = YES; 448 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 449 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 450 | CLANG_CXX_LIBRARY = "libc++"; 451 | CLANG_ENABLE_MODULES = YES; 452 | CLANG_ENABLE_OBJC_ARC = YES; 453 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 454 | CLANG_WARN_BOOL_CONVERSION = YES; 455 | CLANG_WARN_CONSTANT_CONVERSION = YES; 456 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 457 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 458 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 459 | CLANG_WARN_EMPTY_BODY = YES; 460 | CLANG_WARN_ENUM_CONVERSION = YES; 461 | CLANG_WARN_INFINITE_RECURSION = YES; 462 | CLANG_WARN_INT_CONVERSION = YES; 463 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 464 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 465 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 466 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 467 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 468 | CODE_SIGN_IDENTITY = "-"; 469 | COPY_PHASE_STRIP = NO; 470 | DEBUG_INFORMATION_FORMAT = dwarf; 471 | ENABLE_STRICT_OBJC_MSGSEND = YES; 472 | ENABLE_TESTABILITY = YES; 473 | GCC_C_LANGUAGE_STANDARD = gnu11; 474 | GCC_DYNAMIC_NO_PIC = NO; 475 | GCC_NO_COMMON_BLOCKS = YES; 476 | GCC_OPTIMIZATION_LEVEL = 0; 477 | GCC_PREPROCESSOR_DEFINITIONS = ( 478 | "DEBUG=1", 479 | "$(inherited)", 480 | ); 481 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 482 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 483 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 484 | GCC_WARN_UNUSED_FUNCTION = YES; 485 | GCC_WARN_UNUSED_VARIABLE = YES; 486 | MACOSX_DEPLOYMENT_TARGET = 10.11; 487 | MTL_ENABLE_DEBUG_INFO = YES; 488 | ONLY_ACTIVE_ARCH = YES; 489 | SDKROOT = macosx; 490 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 491 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 492 | }; 493 | name = Debug; 494 | }; 495 | 33CC10FA2044A3C60003C045 /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 498 | buildSettings = { 499 | ALWAYS_SEARCH_USER_PATHS = NO; 500 | CLANG_ANALYZER_NONNULL = YES; 501 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 502 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 503 | CLANG_CXX_LIBRARY = "libc++"; 504 | CLANG_ENABLE_MODULES = YES; 505 | CLANG_ENABLE_OBJC_ARC = YES; 506 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 507 | CLANG_WARN_BOOL_CONVERSION = YES; 508 | CLANG_WARN_CONSTANT_CONVERSION = YES; 509 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 510 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 511 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 512 | CLANG_WARN_EMPTY_BODY = YES; 513 | CLANG_WARN_ENUM_CONVERSION = YES; 514 | CLANG_WARN_INFINITE_RECURSION = YES; 515 | CLANG_WARN_INT_CONVERSION = YES; 516 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 517 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 518 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 519 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 520 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 521 | CODE_SIGN_IDENTITY = "-"; 522 | COPY_PHASE_STRIP = NO; 523 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 524 | ENABLE_NS_ASSERTIONS = NO; 525 | ENABLE_STRICT_OBJC_MSGSEND = YES; 526 | GCC_C_LANGUAGE_STANDARD = gnu11; 527 | GCC_NO_COMMON_BLOCKS = YES; 528 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 529 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 530 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 531 | GCC_WARN_UNUSED_FUNCTION = YES; 532 | GCC_WARN_UNUSED_VARIABLE = YES; 533 | MACOSX_DEPLOYMENT_TARGET = 10.11; 534 | MTL_ENABLE_DEBUG_INFO = NO; 535 | SDKROOT = macosx; 536 | SWIFT_COMPILATION_MODE = wholemodule; 537 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 538 | }; 539 | name = Release; 540 | }; 541 | 33CC10FC2044A3C60003C045 /* Debug */ = { 542 | isa = XCBuildConfiguration; 543 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 544 | buildSettings = { 545 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 546 | CLANG_ENABLE_MODULES = YES; 547 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 548 | CODE_SIGN_STYLE = Automatic; 549 | COMBINE_HIDPI_IMAGES = YES; 550 | INFOPLIST_FILE = Runner/Info.plist; 551 | LD_RUNPATH_SEARCH_PATHS = ( 552 | "$(inherited)", 553 | "@executable_path/../Frameworks", 554 | ); 555 | PROVISIONING_PROFILE_SPECIFIER = ""; 556 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 557 | SWIFT_VERSION = 5.0; 558 | }; 559 | name = Debug; 560 | }; 561 | 33CC10FD2044A3C60003C045 /* Release */ = { 562 | isa = XCBuildConfiguration; 563 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 564 | buildSettings = { 565 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 566 | CLANG_ENABLE_MODULES = YES; 567 | CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; 568 | CODE_SIGN_STYLE = Automatic; 569 | COMBINE_HIDPI_IMAGES = YES; 570 | INFOPLIST_FILE = Runner/Info.plist; 571 | LD_RUNPATH_SEARCH_PATHS = ( 572 | "$(inherited)", 573 | "@executable_path/../Frameworks", 574 | ); 575 | PROVISIONING_PROFILE_SPECIFIER = ""; 576 | SWIFT_VERSION = 5.0; 577 | }; 578 | name = Release; 579 | }; 580 | 33CC111C2044C6BA0003C045 /* Debug */ = { 581 | isa = XCBuildConfiguration; 582 | buildSettings = { 583 | CODE_SIGN_STYLE = Manual; 584 | PRODUCT_NAME = "$(TARGET_NAME)"; 585 | }; 586 | name = Debug; 587 | }; 588 | 33CC111D2044C6BA0003C045 /* Release */ = { 589 | isa = XCBuildConfiguration; 590 | buildSettings = { 591 | CODE_SIGN_STYLE = Automatic; 592 | PRODUCT_NAME = "$(TARGET_NAME)"; 593 | }; 594 | name = Release; 595 | }; 596 | /* End XCBuildConfiguration section */ 597 | 598 | /* Begin XCConfigurationList section */ 599 | 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { 600 | isa = XCConfigurationList; 601 | buildConfigurations = ( 602 | 33CC10F92044A3C60003C045 /* Debug */, 603 | 33CC10FA2044A3C60003C045 /* Release */, 604 | 338D0CE9231458BD00FA5F75 /* Profile */, 605 | ); 606 | defaultConfigurationIsVisible = 0; 607 | defaultConfigurationName = Release; 608 | }; 609 | 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { 610 | isa = XCConfigurationList; 611 | buildConfigurations = ( 612 | 33CC10FC2044A3C60003C045 /* Debug */, 613 | 33CC10FD2044A3C60003C045 /* Release */, 614 | 338D0CEA231458BD00FA5F75 /* Profile */, 615 | ); 616 | defaultConfigurationIsVisible = 0; 617 | defaultConfigurationName = Release; 618 | }; 619 | 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { 620 | isa = XCConfigurationList; 621 | buildConfigurations = ( 622 | 33CC111C2044C6BA0003C045 /* Debug */, 623 | 33CC111D2044C6BA0003C045 /* Release */, 624 | 338D0CEB231458BD00FA5F75 /* Profile */, 625 | ); 626 | defaultConfigurationIsVisible = 0; 627 | defaultConfigurationName = Release; 628 | }; 629 | /* End XCConfigurationList section */ 630 | }; 631 | rootObject = 33CC10E52044A3C60003C045 /* Project object */; 632 | } 633 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | -------------------------------------------------------------------------------- /desktop_context_menu/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 = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /desktop_context_menu/example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /desktop_context_menu/example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.0.4" 53 | desktop_context_menu: 54 | dependency: "direct main" 55 | description: 56 | path: ".." 57 | relative: true 58 | source: path 59 | version: "0.1.1" 60 | desktop_context_menu_macos: 61 | dependency: "direct overridden" 62 | description: 63 | path: "../../desktop_context_menu_macos" 64 | relative: true 65 | source: path 66 | version: "0.1.1" 67 | desktop_context_menu_platform_interface: 68 | dependency: "direct overridden" 69 | description: 70 | path: "../../desktop_context_menu_platform_interface" 71 | relative: true 72 | source: path 73 | version: "0.1.1" 74 | desktop_context_menu_windows: 75 | dependency: "direct overridden" 76 | description: 77 | path: "../../desktop_context_menu_windows" 78 | relative: true 79 | source: path 80 | version: "0.1.1" 81 | effective_dart: 82 | dependency: transitive 83 | description: 84 | name: effective_dart 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "1.3.2" 88 | fake_async: 89 | dependency: transitive 90 | description: 91 | name: fake_async 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "1.2.0" 95 | flutter: 96 | dependency: "direct main" 97 | description: flutter 98 | source: sdk 99 | version: "0.0.0" 100 | flutter_test: 101 | dependency: "direct dev" 102 | description: flutter 103 | source: sdk 104 | version: "0.0.0" 105 | matcher: 106 | dependency: transitive 107 | description: 108 | name: matcher 109 | url: "https://pub.dartlang.org" 110 | source: hosted 111 | version: "0.12.11" 112 | material_color_utilities: 113 | dependency: transitive 114 | description: 115 | name: material_color_utilities 116 | url: "https://pub.dartlang.org" 117 | source: hosted 118 | version: "0.1.3" 119 | meta: 120 | dependency: transitive 121 | description: 122 | name: meta 123 | url: "https://pub.dartlang.org" 124 | source: hosted 125 | version: "1.7.0" 126 | path: 127 | dependency: transitive 128 | description: 129 | name: path 130 | url: "https://pub.dartlang.org" 131 | source: hosted 132 | version: "1.8.0" 133 | plugin_platform_interface: 134 | dependency: transitive 135 | description: 136 | name: plugin_platform_interface 137 | url: "https://pub.dartlang.org" 138 | source: hosted 139 | version: "2.1.2" 140 | rows_lint: 141 | dependency: "direct dev" 142 | description: 143 | name: rows_lint 144 | url: "https://pub.dartlang.org" 145 | source: hosted 146 | version: "0.1.1" 147 | sky_engine: 148 | dependency: transitive 149 | description: flutter 150 | source: sdk 151 | version: "0.0.99" 152 | source_span: 153 | dependency: transitive 154 | description: 155 | name: source_span 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "1.8.1" 159 | stack_trace: 160 | dependency: transitive 161 | description: 162 | name: stack_trace 163 | url: "https://pub.dartlang.org" 164 | source: hosted 165 | version: "1.10.0" 166 | stream_channel: 167 | dependency: transitive 168 | description: 169 | name: stream_channel 170 | url: "https://pub.dartlang.org" 171 | source: hosted 172 | version: "2.1.0" 173 | string_scanner: 174 | dependency: transitive 175 | description: 176 | name: string_scanner 177 | url: "https://pub.dartlang.org" 178 | source: hosted 179 | version: "1.1.0" 180 | term_glyph: 181 | dependency: transitive 182 | description: 183 | name: term_glyph 184 | url: "https://pub.dartlang.org" 185 | source: hosted 186 | version: "1.2.0" 187 | test_api: 188 | dependency: transitive 189 | description: 190 | name: test_api 191 | url: "https://pub.dartlang.org" 192 | source: hosted 193 | version: "0.4.8" 194 | typed_data: 195 | dependency: transitive 196 | description: 197 | name: typed_data 198 | url: "https://pub.dartlang.org" 199 | source: hosted 200 | version: "1.3.0" 201 | vector_math: 202 | dependency: transitive 203 | description: 204 | name: vector_math 205 | url: "https://pub.dartlang.org" 206 | source: hosted 207 | version: "2.1.1" 208 | sdks: 209 | dart: ">=2.14.0 <3.0.0" 210 | -------------------------------------------------------------------------------- /desktop_context_menu/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: desktop_context_menu_example 2 | description: Demonstrates how to use the desktop_context_menu plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.12.0 <3.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | desktop_context_menu: 12 | path: ../ 13 | 14 | cupertino_icons: ^1.0.2 15 | 16 | dev_dependencies: 17 | rows_lint: 0.1.1 18 | flutter_test: 19 | sdk: flutter 20 | 21 | flutter: 22 | uses-material-design: true -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(example LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 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 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | DesktopContextMenuWindowsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("DesktopContextMenuWindowsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | desktop_context_menu_windows 7 | ) 8 | 9 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows 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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /desktop_context_menu/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", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "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 | -------------------------------------------------------------------------------- /desktop_context_menu/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(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /desktop_context_menu/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 "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rows/desktop_context_menu/bdea4a35a54a9f7ea953d91ae3f7a160934f219d/desktop_context_menu/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /desktop_context_menu/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 | -------------------------------------------------------------------------------- /desktop_context_menu/lib/desktop_context_menu.dart: -------------------------------------------------------------------------------- 1 | import 'package:desktop_context_menu_platform_interface/desktop_context_menu_platform_interface.dart'; 2 | 3 | export 'package:desktop_context_menu_platform_interface/desktop_context_menu_platform_interface.dart' 4 | show ContextMenuItem, ContextMenuSeparator, ContextMenuItemBase; 5 | 6 | /// Exposes a simple API to show a context menu at the mouse coordinates. 7 | Future showContextMenu({ 8 | required Iterable menuItems, 9 | }) { 10 | final platform = DesktopContextMenuPlatform.instance; 11 | 12 | return platform.showContextMenu(menuItems: menuItems); 13 | } 14 | -------------------------------------------------------------------------------- /desktop_context_menu/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: desktop_context_menu 2 | description: A plugin that opens a context menu on the cursor position. 3 | version: 0.1.1 4 | repository: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu 5 | homepage: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu 6 | issue_tracker: https://github.com/rows/desktop_context_menu/issues 7 | 8 | environment: 9 | sdk: ">=2.12.0 <3.0.0" 10 | flutter: ">=2.5.0" 11 | 12 | dependencies: 13 | desktop_context_menu_platform_interface: ^0.1.1 14 | desktop_context_menu_windows: ^0.1.1 15 | desktop_context_menu_macos: ^0.1.1 16 | flutter: 17 | sdk: flutter 18 | 19 | dev_dependencies: 20 | rows_lint: 0.1.1 21 | flutter_test: 22 | sdk: flutter 23 | 24 | flutter: 25 | plugin: 26 | platforms: 27 | windows: 28 | default_package: desktop_context_menu_windows 29 | macos: 30 | default_package: desktop_context_menu_macos 31 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/.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 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.1 2 | 3 | * Update `desktop_context_menu` dependency. 4 | 5 | ## 0.1.0 6 | 7 | * Initial release. 8 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Rows GmbH (rows.com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |
4 | Rows 5 |
6 | Spreadsheet with superpowers! 7 |
8 |
9 |
10 |

11 | 12 |

13 | 14 | 15 |

16 | 17 | # desktop_context_menu_macos 18 | 19 | The MacOS implementation of [`desktop_context_menu`][1]. 20 | 21 | ## Usage 22 | 23 | This package is [endorsed][2], which means you can simply use `desktop_context_menu` 24 | normally. This package will be automatically included in your app when you do. 25 | 26 | [1]: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu 27 | [2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin 28 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:rows_lint/analysis_options.yaml 2 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/lib/desktop_context_menu_macos.dart: -------------------------------------------------------------------------------- 1 | import 'package:desktop_context_menu_platform_interface/desktop_context_menu_platform_interface.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/services.dart'; 4 | 5 | const MethodChannel _channel = MethodChannel('desktop_context_menu_macos'); 6 | 7 | class DesktopContextMenuMacos extends DesktopContextMenuPlatform { 8 | @visibleForTesting 9 | MethodChannel get channel => _channel; 10 | 11 | /// Registers this class as the default instance 12 | /// of [DesktopContextMenuPlatform]. 13 | static void registerWith() { 14 | DesktopContextMenuPlatform.instance = DesktopContextMenuMacos(); 15 | } 16 | 17 | @override 18 | Future showContextMenu({ 19 | required Iterable menuItems, 20 | }) async { 21 | final selectedItemId = await _channel.invokeMethod( 22 | 'showContextMenu', 23 | menuItems.map((menuItem) => menuItem.toJson()).toList(), 24 | ); 25 | 26 | if (selectedItemId == null) { 27 | return null; 28 | } 29 | 30 | return menuItems.elementAt(selectedItemId) as ContextMenuItem; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/macos/Classes/DesktopContextMenuMacosPlugin.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | public class DesktopContextMenuMacosPlugin: NSObject, FlutterPlugin { 5 | /// Used to save the flutter app window. 6 | let registrar: FlutterPluginRegistrar 7 | 8 | init(_ registrar: FlutterPluginRegistrar) { 9 | self.registrar = registrar 10 | } 11 | 12 | /// Gets the flutter app window. 13 | lazy var currentWindow:NSWindow? = { 14 | return registrar.view?.window ?? NSApplication.shared.keyWindow ?? NSApplication.shared.mainWindow; 15 | }() 16 | 17 | /// Used to communicate back the context menu selected item id. 18 | var result: FlutterResult? 19 | 20 | /// Sends back through the method channel the selected item id. 21 | @objc func emitSelectedItemId(_ sender: NSMenuItem) { 22 | guard let result = self.result else { 23 | return; 24 | } 25 | 26 | result(sender.tag) 27 | } 28 | 29 | /// Defines the available menu items types. 30 | enum menuItemType: String { 31 | case standard = "standard" 32 | case separator = "separator" 33 | } 34 | 35 | /// Defines the possible modifiers of a shortcut. 36 | enum shortcutModifier: String, CaseIterable { 37 | case command = "command" 38 | case shift = "shift" 39 | case alt = "alt" 40 | case control = "control" 41 | } 42 | 43 | /// Maps a `shortcutModifier` to a `NSEvent.ModifierFlags` struct. 44 | /// 45 | /// Used to define the `keyEquivalentModifierMask` property of a `NSMenuItem`. 46 | let shortcutModifiersFlags: [shortcutModifier: NSEvent.ModifierFlags] = [ 47 | shortcutModifier.command: NSEvent.ModifierFlags.command, 48 | shortcutModifier.shift: NSEvent.ModifierFlags.shift, 49 | shortcutModifier.alt: NSEvent.ModifierFlags.option, 50 | shortcutModifier.control: NSEvent.ModifierFlags.control 51 | ] 52 | 53 | public static func register(with registrar: FlutterPluginRegistrar) { 54 | let channel = FlutterMethodChannel(name: "desktop_context_menu_macos", binaryMessenger: registrar.messenger) 55 | let instance = DesktopContextMenuMacosPlugin(registrar) 56 | registrar.addMethodCallDelegate(instance, channel: channel) 57 | } 58 | 59 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 60 | switch call.method { 61 | case "showContextMenu": 62 | self.result = result 63 | 64 | guard let activeWindow = currentWindow else { 65 | return; 66 | } 67 | 68 | // Get the mouse coordinates to define where to show the context menu. 69 | let mouseLocation = activeWindow.mouseLocationOutsideOfEventStream 70 | 71 | // Get the menu items passed through the method channel. 72 | let arguments = call.arguments as! NSArray 73 | 74 | // Creates the context menu with the given arguments. 75 | let menu = createContextMenu(arguments) 76 | 77 | // Shows the context menu at the mouse coordinates in the flutter app window. 78 | let popUpMenuResult = menu.popUp( 79 | positioning: nil, 80 | at: NSPoint(x: mouseLocation.x, y: mouseLocation.y), 81 | in: activeWindow.contentView 82 | ) 83 | 84 | // The `popUp` function returns `true` if an item was selected and `false` if the menu was dismissed. 85 | // 86 | // The follow condition alerts the method channel that the menu was dismissed. 87 | if !popUpMenuResult { 88 | result(nil) 89 | } 90 | default: 91 | result(FlutterMethodNotImplemented) 92 | } 93 | } 94 | 95 | /// Creates the context menu for the given items. 96 | func createContextMenu(_ items: NSArray) -> NSMenu { 97 | let menu = NSMenu() 98 | 99 | var menuItem: NSMenuItem 100 | 101 | for index in 0...items.count - 1 { 102 | let item = items[index] as! NSDictionary 103 | let type = item["type"] as! String 104 | 105 | // If the menu is separator, it does not have a title or an action. 106 | if type == menuItemType.separator.rawValue { 107 | menuItem = .separator() 108 | } else { 109 | let shortcut = item["shortcut"] as? NSDictionary 110 | let key = shortcut?["key"] as? String 111 | 112 | menuItem = NSMenuItem( 113 | title: item["title"] as! String, 114 | action: #selector(emitSelectedItemId(_:)), 115 | // `keyEquivalent` takes a character that corresponds to the key triggered in the keyboard. 116 | // In case this property is defined with an upper case letter, it will automatically 117 | // add a `SHIFT` modifier to the shortcut. To prevent that, we convert 118 | // the `key` to lower case and decide to use `SHIFT` or not with the 119 | // value of `shortcut[shortcutModifier.shift.rawValue]`. 120 | keyEquivalent: key?.lowercased() ?? "" 121 | ) 122 | 123 | let modifiers = getShortcutModifiers(shortcut) 124 | 125 | // Sets the current menu item modifiers if they are not null. 126 | if modifiers != nil { 127 | menuItem.keyEquivalentModifierMask = modifiers! 128 | } 129 | 130 | menuItem.isEnabled = item["enabled"] as! Bool == true 131 | } 132 | 133 | menuItem.target = self 134 | 135 | // Sets the id of the current menu item. 136 | menuItem.tag = index 137 | 138 | menu.addItem(menuItem) 139 | } 140 | 141 | // Let the dev decide if a menu item should be enabled or not. 142 | menu.autoenablesItems = false 143 | 144 | return menu 145 | } 146 | 147 | /// Gets the current shortcut modifiers. 148 | /// 149 | /// See: 150 | /// - `shortcutModifier` enum and `shortcutModifiersFlags` map. 151 | func getShortcutModifiers(_ shortcut: NSDictionary?) -> NSEvent.ModifierFlags? { 152 | guard let currentShortcut = shortcut else { 153 | return nil 154 | } 155 | 156 | var modifiers: NSEvent.ModifierFlags = [] 157 | 158 | for modifier in shortcutModifier.allCases { 159 | let isEnabled = currentShortcut[modifier.rawValue] as? Bool == true 160 | 161 | if isEnabled { 162 | modifiers.insert(shortcutModifiersFlags[modifier]!) 163 | } 164 | } 165 | 166 | return modifiers 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/macos/desktop_context_menu_macos.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint desktop_context_menu_macos.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'desktop_context_menu_macos' 7 | s.version = '0.1.0' 8 | s.summary = 'Flutter MacOS implementation of context menu.' 9 | s.description = <<-DESC 10 | A MacOS implementation of the desktop_context_menu plugin. 11 | DESC 12 | s.homepage = 'https://github.com/rows/desktop_context_menu' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Rows' => 'opensource@rows.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 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 | end 23 | -------------------------------------------------------------------------------- /desktop_context_menu_macos/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: desktop_context_menu_macos 2 | description: The implementation of the context menu plugin for MacOS. 3 | version: 0.1.1 4 | homepage: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu_macos 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | flutter: ">=2.5.0" 9 | 10 | dependencies: 11 | desktop_context_menu_platform_interface: ^0.1.1 12 | flutter: 13 | sdk: flutter 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | rows_lint: 0.1.1 19 | 20 | flutter: 21 | plugin: 22 | implements: desktop_context_menu 23 | platforms: 24 | macos: 25 | dartPluginClass: DesktopContextMenuMacos 26 | pluginClass: DesktopContextMenuMacosPlugin -------------------------------------------------------------------------------- /desktop_context_menu_macos/test/desktop_context_menu_macos_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:desktop_context_menu_macos/desktop_context_menu_macos.dart'; 2 | import 'package:desktop_context_menu_platform_interface/desktop_context_menu_platform_interface.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | import 'package:flutter_test/flutter_test.dart'; 6 | 7 | void main() { 8 | TestWidgetsFlutterBinding.ensureInitialized(); 9 | 10 | late _DesktopContextMenuMacosTester contextMenuMacosTester; 11 | 12 | final menuItems = [ 13 | ContextMenuItem(title: 'Item 1', onTap: () {}), 14 | const ContextMenuSeparator(), 15 | const ContextMenuItem(title: 'Disabled item'), 16 | ContextMenuItem( 17 | title: 'Copy', 18 | shortcut: const SingleActivator( 19 | LogicalKeyboardKey.keyC, 20 | meta: true, 21 | ), 22 | onTap: () {}, 23 | ), 24 | ]; 25 | 26 | setUpAll(() { 27 | contextMenuMacosTester = const _DesktopContextMenuMacosTester(); 28 | }); 29 | 30 | group('showContextMenu', () { 31 | test('standard', () async { 32 | final selectedItem = await contextMenuMacosTester.mockSelectedItem( 33 | selectedItemId: 0, 34 | menuItems: menuItems, 35 | ); 36 | 37 | final contextMenuItem = selectedItem! as ContextMenuItem; 38 | 39 | expect(contextMenuItem.title, 'Item 1'); 40 | expect(contextMenuItem.onTap, isNotNull); 41 | expect(contextMenuItem.toJson(), { 42 | 'title': 'Item 1', 43 | 'enabled': true, 44 | 'shortcut': null, 45 | 'type': 'standard', 46 | }); 47 | }); 48 | 49 | test('separator', () { 50 | expect(menuItems.elementAt(1).toJson(), {'type': 'separator'}); 51 | }); 52 | 53 | test('disabled', () async { 54 | final selectedItem = await contextMenuMacosTester.mockSelectedItem( 55 | selectedItemId: 2, 56 | menuItems: menuItems, 57 | ); 58 | 59 | final contextMenuItem = selectedItem! as ContextMenuItem; 60 | 61 | expect(contextMenuItem.title, 'Disabled item'); 62 | expect(contextMenuItem.onTap, isNull); 63 | expect(contextMenuItem.toJson(), { 64 | 'title': 'Disabled item', 65 | 'enabled': false, 66 | 'shortcut': null, 67 | 'type': 'standard', 68 | }); 69 | }); 70 | 71 | test('shortcut', () async { 72 | final selectedItem = await contextMenuMacosTester.mockSelectedItem( 73 | selectedItemId: 3, 74 | menuItems: menuItems, 75 | ); 76 | 77 | final contextMenuItem = selectedItem! as ContextMenuItem; 78 | 79 | expect(contextMenuItem.title, 'Copy'); 80 | expect(contextMenuItem.onTap, isNotNull); 81 | expect(contextMenuItem.toJson(), { 82 | 'title': 'Copy', 83 | 'enabled': true, 84 | 'shortcut': { 85 | 'alt': false, 86 | 'control': false, 87 | 'command': true, 88 | 'shift': false, 89 | 'key': 'C', 90 | }, 91 | 'type': 'standard', 92 | }); 93 | }); 94 | }); 95 | } 96 | 97 | class _DesktopContextMenuMacosTester { 98 | const _DesktopContextMenuMacosTester(); 99 | 100 | Future mockSelectedItem({ 101 | required int selectedItemId, 102 | required List menuItems, 103 | }) async { 104 | final contextMenuMacos = DesktopContextMenuMacos(); 105 | 106 | contextMenuMacos.channel.setMockMethodCallHandler((methodCall) async { 107 | return selectedItemId; 108 | }); 109 | 110 | return contextMenuMacos.showContextMenu(menuItems: menuItems); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/.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 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.1 2 | 3 | * Update `desktop_context_menu` dependency. 4 | 5 | ## 0.1.0 6 | 7 | * Initial release. 8 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Rows GmbH (rows.com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |
4 | Rows 5 |
6 | Spreadsheet with superpowers! 7 |
8 |
9 |
10 |

11 | 12 |

13 | 14 | 15 | 16 |

17 | 18 | # desktop_context_menu_platform_interface 19 | 20 | A common platform interface for the [`desktop_context_menu`][1] plugin. 21 | 22 | ## Usage 23 | 24 | To implement a new platform-specific implementation of `desktop_context_menu`, extend 25 | [`DesktopContextMenuPlatform`][2] with an implementation that performs the 26 | platform-specific behavior, and when you register your plugin, set the default 27 | `DesktopContextMenuPlatform` by calling 28 | `DesktopContextMenuPlatform.instance = MyPlatformContextMenu()`. 29 | 30 | [1]: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu 31 | [2]: lib/src/platform_interface/desktop_context_menu_platform.dart 32 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:rows_lint/analysis_options.yaml -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/desktop_context_menu_platform_interface.dart: -------------------------------------------------------------------------------- 1 | export 'src/platform_interface/desktop_context_menu_platform.dart'; 2 | export 'src/types/types.dart'; 3 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/method_channel/method_channel_desktop_context_menu.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/services.dart'; 5 | 6 | import '../platform_interface/desktop_context_menu_platform.dart'; 7 | import '../types/types.dart'; 8 | 9 | const MethodChannel _channel = MethodChannel('desktop_context_menu'); 10 | 11 | /// An implementation of [DesktopContextMenuPlatform] that uses method channels. 12 | class MethodChannelDesktopContextMenu extends DesktopContextMenuPlatform { 13 | @visibleForTesting 14 | MethodChannel get channel => _channel; 15 | 16 | @override 17 | Future showContextMenu({ 18 | required Iterable menuItems, 19 | }) async { 20 | throw UnimplementedError( 21 | 'Context menu plugin not implemented in this platform.', 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/platform_interface/desktop_context_menu_platform.dart: -------------------------------------------------------------------------------- 1 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 2 | 3 | import '../method_channel/method_channel_desktop_context_menu.dart'; 4 | import '../types/types.dart'; 5 | 6 | /// The interface that implementations of `desktop_context_menu` must implement. 7 | abstract class DesktopContextMenuPlatform extends PlatformInterface { 8 | DesktopContextMenuPlatform() : super(token: _token); 9 | 10 | static final Object _token = Object(); 11 | 12 | static DesktopContextMenuPlatform _instance = 13 | MethodChannelDesktopContextMenu(); 14 | 15 | /// The default instance of [DesktopContextMenuPlatform] to use. 16 | /// 17 | /// Defaults to [MethodChannelDesktopContextMenu]. 18 | static DesktopContextMenuPlatform get instance => _instance; 19 | 20 | /// Platform-specific plugins should set this with their own platform-specific 21 | /// class that extends [DesktopContextMenuPlatform] when they register 22 | /// themselves. 23 | static set instance(DesktopContextMenuPlatform instance) { 24 | PlatformInterface.verify(instance, _token); 25 | _instance = instance; 26 | } 27 | 28 | /// Shows the context menu with the given [menuItems] at the mouse 29 | /// coordinates. 30 | Future showContextMenu({ 31 | required Iterable menuItems, 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/types/context_menu_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | import 'context_menu_item_base.dart'; 4 | import 'context_menu_item_type.dart'; 5 | 6 | /// A class that represents each standard menu item of the context menu. 7 | class ContextMenuItem extends ContextMenuItemBase { 8 | /// The title of the context menu item. 9 | final String? title; 10 | 11 | /// Callback invoked when a menu item is tapped. 12 | final VoidCallback? onTap; 13 | 14 | /// The shortcut that appears on the right of a menu item. 15 | final SingleActivator? shortcut; 16 | 17 | const ContextMenuItem({ 18 | required this.title, 19 | this.onTap, 20 | this.shortcut, 21 | }); 22 | 23 | @override 24 | Map toJson() { 25 | return { 26 | 'title': title, 27 | 'enabled': onTap != null, 28 | 'shortcut': shortcut?.toJson(), 29 | 'type': ContextMenuItemType.standard.name, 30 | }; 31 | } 32 | } 33 | 34 | extension on SingleActivator { 35 | /// Map the [SingleActivator] info to json to pass it through 36 | /// the platform communication channel. 37 | Map toJson() { 38 | return { 39 | 'alt': alt, 40 | 'control': control, 41 | 'command': meta, 42 | 'shift': shift, 43 | 'key': trigger.keyLabel, 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/types/context_menu_item_base.dart: -------------------------------------------------------------------------------- 1 | /// A class that represents each item of the context menu. 2 | abstract class ContextMenuItemBase { 3 | const ContextMenuItemBase(); 4 | 5 | Map toJson(); 6 | } 7 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/types/context_menu_item_separator.dart: -------------------------------------------------------------------------------- 1 | import 'context_menu_item_base.dart'; 2 | import 'context_menu_item_type.dart'; 3 | 4 | /// A class that represents a separator between menu items in the context menu. 5 | class ContextMenuSeparator extends ContextMenuItemBase { 6 | const ContextMenuSeparator(); 7 | 8 | @override 9 | Map toJson() { 10 | return { 11 | 'type': ContextMenuItemType.separator.name, 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/types/context_menu_item_type.dart: -------------------------------------------------------------------------------- 1 | /// The type of the context menu item. 2 | /// 3 | /// It can be a standard menu item that has text and an action or a divider 4 | /// between menu items. 5 | enum ContextMenuItemType { 6 | standard, 7 | separator, 8 | } 9 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/lib/src/types/types.dart: -------------------------------------------------------------------------------- 1 | export 'context_menu_item.dart'; 2 | export 'context_menu_item_base.dart'; 3 | export 'context_menu_item_separator.dart'; 4 | -------------------------------------------------------------------------------- /desktop_context_menu_platform_interface/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: desktop_context_menu_platform_interface 2 | description: A common platform interface for desktop_context_menu. 3 | version: 0.1.1 4 | homepage: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu_platform_interface 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | plugin_platform_interface: ^2.1.2 14 | 15 | dev_dependencies: 16 | rows_lint: 0.1.1 17 | flutter_test: 18 | sdk: flutter -------------------------------------------------------------------------------- /desktop_context_menu_windows/.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 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.1 2 | 3 | * Update `desktop_context_menu` dependency. 4 | 5 | ## 0.1.0 6 | 7 | * Initial release. 8 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Rows GmbH (rows.com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |
4 | Rows 5 |
6 | Spreadsheet with superpowers! 7 |
8 |
9 |
10 |

11 | 12 |

13 | 14 | 15 |

16 | 17 | # desktop_context_menu_windows 18 | 19 | The Windows implementation of [`desktop_context_menu`][1]. 20 | 21 | ## Usage 22 | 23 | This package is [endorsed][2], which means you can simply use `desktop_context_menu` 24 | normally. This package will be automatically included in your app when you do. 25 | 26 | [1]: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu 27 | [2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin 28 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:rows_lint/analysis_options.yaml 2 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/lib/desktop_context_menu_windows.dart: -------------------------------------------------------------------------------- 1 | import 'package:desktop_context_menu_platform_interface/desktop_context_menu_platform_interface.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/services.dart'; 4 | 5 | const MethodChannel _channel = MethodChannel('desktop_context_menu_windows'); 6 | 7 | class DesktopContextMenuWindows extends DesktopContextMenuPlatform { 8 | @visibleForTesting 9 | MethodChannel get channel => _channel; 10 | 11 | /// Registers this class as the default instance 12 | /// of [DesktopContextMenuPlatform]. 13 | static void registerWith() { 14 | DesktopContextMenuPlatform.instance = DesktopContextMenuWindows(); 15 | } 16 | 17 | @override 18 | Future showContextMenu({ 19 | required Iterable menuItems, 20 | }) async { 21 | final selectedItemId = await _channel.invokeMethod( 22 | 'showContextMenu', 23 | menuItems.map((menuItem) => menuItem.toJson()).toList(), 24 | ); 25 | 26 | if (selectedItemId == null) { 27 | return null; 28 | } 29 | 30 | return menuItems.elementAt(selectedItemId) as ContextMenuItem; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: desktop_context_menu_windows 2 | description: The implementation of the context menu plugin for Windows. 3 | version: 0.1.1 4 | homepage: https://github.com/rows/desktop_context_menu/tree/main/desktop_context_menu_windows 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | flutter: ">=2.5.0" 9 | 10 | dependencies: 11 | desktop_context_menu_platform_interface: ^0.1.1 12 | flutter: 13 | sdk: flutter 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | rows_lint: 0.1.1 19 | 20 | flutter: 21 | plugin: 22 | implements: desktop_context_menu 23 | platforms: 24 | windows: 25 | dartPluginClass: DesktopContextMenuWindows 26 | pluginClass: DesktopContextMenuWindowsPlugin -------------------------------------------------------------------------------- /desktop_context_menu_windows/test/desktop_context_menu_windows_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:desktop_context_menu_platform_interface/desktop_context_menu_platform_interface.dart'; 2 | import 'package:desktop_context_menu_windows/desktop_context_menu_windows.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | import 'package:flutter_test/flutter_test.dart'; 6 | 7 | void main() { 8 | TestWidgetsFlutterBinding.ensureInitialized(); 9 | 10 | late _DesktopContextMenuWindowsTester contextMenuWindowsTester; 11 | 12 | final menuItems = [ 13 | ContextMenuItem(title: 'Item 1', onTap: () {}), 14 | const ContextMenuSeparator(), 15 | const ContextMenuItem(title: 'Disabled item'), 16 | ContextMenuItem( 17 | title: 'Copy', 18 | shortcut: const SingleActivator( 19 | LogicalKeyboardKey.keyC, 20 | meta: true, 21 | ), 22 | onTap: () {}, 23 | ), 24 | ]; 25 | 26 | setUpAll(() { 27 | contextMenuWindowsTester = const _DesktopContextMenuWindowsTester(); 28 | }); 29 | 30 | group('showContextMenu', () { 31 | test('standard', () async { 32 | final selectedItem = await contextMenuWindowsTester.mockSelectedItem( 33 | selectedItemId: 0, 34 | menuItems: menuItems, 35 | ); 36 | 37 | final contextMenuItem = selectedItem! as ContextMenuItem; 38 | 39 | expect(contextMenuItem.title, 'Item 1'); 40 | expect(contextMenuItem.onTap, isNotNull); 41 | expect(contextMenuItem.toJson(), { 42 | 'title': 'Item 1', 43 | 'enabled': true, 44 | 'shortcut': null, 45 | 'type': 'standard', 46 | }); 47 | }); 48 | 49 | test('separator', () { 50 | expect(menuItems.elementAt(1).toJson(), {'type': 'separator'}); 51 | }); 52 | 53 | test('disabled', () async { 54 | final selectedItem = await contextMenuWindowsTester.mockSelectedItem( 55 | selectedItemId: 2, 56 | menuItems: menuItems, 57 | ); 58 | 59 | final contextMenuItem = selectedItem! as ContextMenuItem; 60 | 61 | expect(contextMenuItem.title, 'Disabled item'); 62 | expect(contextMenuItem.onTap, isNull); 63 | expect(contextMenuItem.toJson(), { 64 | 'title': 'Disabled item', 65 | 'enabled': false, 66 | 'shortcut': null, 67 | 'type': 'standard', 68 | }); 69 | }); 70 | 71 | test('shortcut', () async { 72 | final selectedItem = await contextMenuWindowsTester.mockSelectedItem( 73 | selectedItemId: 3, 74 | menuItems: menuItems, 75 | ); 76 | 77 | final contextMenuItem = selectedItem! as ContextMenuItem; 78 | 79 | expect(contextMenuItem.title, 'Copy'); 80 | expect(contextMenuItem.onTap, isNotNull); 81 | expect(contextMenuItem.toJson(), { 82 | 'title': 'Copy', 83 | 'enabled': true, 84 | 'shortcut': { 85 | 'alt': false, 86 | 'control': false, 87 | 'command': true, 88 | 'shift': false, 89 | 'key': 'C', 90 | }, 91 | 'type': 'standard', 92 | }); 93 | }); 94 | }); 95 | } 96 | 97 | class _DesktopContextMenuWindowsTester { 98 | const _DesktopContextMenuWindowsTester(); 99 | 100 | Future mockSelectedItem({ 101 | required int selectedItemId, 102 | required List menuItems, 103 | }) async { 104 | final contextMenuWindows = DesktopContextMenuWindows(); 105 | 106 | contextMenuWindows.channel.setMockMethodCallHandler((methodCall) async { 107 | return selectedItemId; 108 | }); 109 | 110 | return contextMenuWindows.showContextMenu(menuItems: menuItems); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /desktop_context_menu_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 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | set(PROJECT_NAME "desktop_context_menu_windows") 3 | project(${PROJECT_NAME} LANGUAGES CXX) 4 | 5 | # This value is used when generating builds using this plugin, so it must 6 | # not be changed 7 | set(PLUGIN_NAME "desktop_context_menu_windows_plugin") 8 | 9 | add_library(${PLUGIN_NAME} SHARED 10 | "desktop_context_menu_windows_plugin.cpp" 11 | ) 12 | apply_standard_settings(${PLUGIN_NAME}) 13 | set_target_properties(${PLUGIN_NAME} PROPERTIES 14 | CXX_VISIBILITY_PRESET hidden) 15 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 16 | target_include_directories(${PLUGIN_NAME} INTERFACE 17 | "${CMAKE_CURRENT_SOURCE_DIR}/include") 18 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) 19 | 20 | # List of absolute paths to libraries that should be bundled with the plugin 21 | set(desktop_context_menu_windows_bundled_libraries 22 | "" 23 | PARENT_SCOPE 24 | ) 25 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/windows/desktop_context_menu_windows_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "include/desktop_context_menu_windows/desktop_context_menu_windows_plugin.h" 2 | #include "include/desktop_context_menu_windows/encoding.h" 3 | 4 | // This must be included before many other Windows headers. 5 | #include 6 | 7 | // For getPlatformVersion; remove unless needed for your plugin implementation. 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace { 19 | 20 | /// Defines all the modifiers of a shortcut. 21 | std::map modifiers = { 22 | {"control", "Ctrl"}, 23 | {"shift", "Shift"}, 24 | {"alt", "Alt"} 25 | }; 26 | 27 | /// Gets the menu item title with the shortcut on the right. 28 | std::string GetTitleWithShortcut(flutter::EncodableMap shortcut, std::string title) { 29 | std::string result = ""; 30 | 31 | // Iterates through all modifiers, check if they exist and if they do, append them to 32 | // the `result` string. 33 | for (flutter::EncodableMap::iterator it = shortcut.begin(); it != shortcut.end(); ++it) { 34 | // `shortcut` map includes also the `key` that was pressed on the keyboard apart from the modifiers. 35 | // 36 | // It is necessary to skip it to get only the modifiers. 37 | auto key = std::get(flutter::EncodableValue(it->first)); 38 | 39 | if (key == "key") { 40 | continue; 41 | } 42 | 43 | auto enabled = std::get(flutter::EncodableValue(it->second)); 44 | 45 | // If the current modifier is enabled, add the corresponding modifier label to `result`. 46 | if (enabled) { 47 | result += modifiers[key] + "+"; 48 | } 49 | } 50 | 51 | if (shortcut.count(flutter::EncodableValue("key"))) { 52 | // Gets the shortcut key label. 53 | auto trigger = std::get(shortcut[flutter::EncodableValue("key")]); 54 | 55 | // To define a shortcut for a menu item in Win32 API, please read the paragraph 56 | // of the following link to better understand what's going on in the return: 57 | // - https://docs.microsoft.com/en-us/windows/win32/menurc/about-menus#menu-shortcut-keys 58 | return "&" + title + "\t" + result + trigger; 59 | } 60 | 61 | return result; 62 | } 63 | 64 | class DesktopContextMenuWindowsPlugin : public flutter::Plugin { 65 | public: 66 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); 67 | 68 | DesktopContextMenuWindowsPlugin(); 69 | 70 | virtual ~DesktopContextMenuWindowsPlugin(); 71 | 72 | private: 73 | // Called when a method is called on this plugin's channel from Dart. 74 | void HandleMethodCall( 75 | const flutter::MethodCall &method_call, 76 | std::unique_ptr> result); 77 | }; 78 | 79 | // static 80 | void DesktopContextMenuWindowsPlugin::RegisterWithRegistrar( 81 | flutter::PluginRegistrarWindows *registrar) { 82 | auto channel = 83 | std::make_unique>( 84 | registrar->messenger(), "desktop_context_menu_windows", 85 | &flutter::StandardMethodCodec::GetInstance()); 86 | 87 | auto plugin = std::make_unique(); 88 | 89 | channel->SetMethodCallHandler( 90 | [plugin_pointer = plugin.get()](const auto &call, auto result) { 91 | plugin_pointer->HandleMethodCall(call, std::move(result)); 92 | }); 93 | 94 | registrar->AddPlugin(std::move(plugin)); 95 | } 96 | 97 | DesktopContextMenuWindowsPlugin::DesktopContextMenuWindowsPlugin() {} 98 | 99 | DesktopContextMenuWindowsPlugin::~DesktopContextMenuWindowsPlugin() {} 100 | 101 | void DesktopContextMenuWindowsPlugin::HandleMethodCall( 102 | const flutter::MethodCall &method_call, 103 | std::unique_ptr> result) { 104 | if (method_call.method_name().compare("showContextMenu") == 0) { 105 | // Gets the flutter app window. 106 | const auto activeWindow = GetActiveWindow(); 107 | 108 | POINT cursorPosition; 109 | 110 | // Gets the cursor position offset and assigns it to `cursorPosition`. 111 | ::GetCursorPos(&cursorPosition); 112 | 113 | // Creates the context menu. 114 | const auto contextMenu = CreatePopupMenu(); 115 | 116 | // Gets the menu items of the context menu that have been passed through the arguments parameter. 117 | const auto* items = std::get_if(method_call.arguments()); 118 | 119 | if (!items) { 120 | result->Error("Missing required type parameter", "Expected list of items"); 121 | return; 122 | } 123 | 124 | // Unfortunately, `TrackPopupMenu` returns `0` instead of `-1` when no item is selected. Because of that, 125 | // the id of the first element of `items` starts at `1` instead of `0`. 126 | // 127 | // See: 128 | // - https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-trackpopupmenu#return-value 129 | for (int i = 1; i <= items->size(); i++) { 130 | auto item = std::get(items->at(i - 1)); 131 | 132 | const auto* type = std::get_if(&item[flutter::EncodableValue("type")]); 133 | 134 | if (!type) { 135 | result->Error("Missing required type parameter", "Expected type"); 136 | return; 137 | } 138 | 139 | // No need to get and set the title of the menu item if it's a separator. 140 | if (type->compare("separator") == 0) { 141 | AppendMenuW(contextMenu, MF_SEPARATOR, i, NULL); 142 | } else { 143 | const auto* title = std::get_if(&item[flutter::EncodableValue("title")]); 144 | 145 | if (!title) { 146 | result->Error("Missing required type parameter", "Expected title"); 147 | return; 148 | } 149 | 150 | const auto* enabled = std::get_if(&item[flutter::EncodableValue("enabled")]); 151 | 152 | if (!enabled) { 153 | result->Error("Missing required type parameter", "Expected enabled"); 154 | return; 155 | } 156 | 157 | std::string menuItemTitle = ""; 158 | 159 | const auto* shortcut = std::get_if(&item[flutter::EncodableValue("shortcut")]); 160 | 161 | // If there's no shortcut, use the default title of the menu item, otherwise, show 162 | // the default title with the shortcut on the right. 163 | if (!shortcut) { 164 | menuItemTitle = *title; 165 | } else { 166 | menuItemTitle = GetTitleWithShortcut(*shortcut, *title); 167 | } 168 | 169 | // Since AppendMenuW takes a wchar_t[], after converting utf8 to wstring, a conversion to wchar_t[] is done. 170 | std::wstring widestr = Encoding::Utf8ToWide(menuItemTitle); 171 | const wchar_t* widecstr = widestr.c_str(); 172 | 173 | AppendMenuW(contextMenu, *enabled ? MF_STRING : MF_GRAYED, i, widecstr); 174 | } 175 | } 176 | 177 | SetForegroundWindow(activeWindow); 178 | 179 | int selectedItemId = TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, cursorPosition.x, cursorPosition.y, 0, activeWindow, nullptr); 180 | 181 | // If no item is selected don't pass any value. 182 | if (0 == selectedItemId) { 183 | result->Success(); 184 | } else { 185 | result->Success(flutter::EncodableValue(selectedItemId - 1)); 186 | } 187 | } else { 188 | result->NotImplemented(); 189 | } 190 | } 191 | 192 | } // namespace 193 | 194 | void DesktopContextMenuWindowsPluginRegisterWithRegistrar( 195 | FlutterDesktopPluginRegistrarRef registrar) { 196 | DesktopContextMenuWindowsPlugin::RegisterWithRegistrar( 197 | flutter::PluginRegistrarManager::GetInstance() 198 | ->GetRegistrar(registrar)); 199 | } 200 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/windows/include/desktop_context_menu_windows/desktop_context_menu_windows_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_DESKTOP_CONTEXT_MENU_WINDOWS_PLUGIN_H_ 2 | #define FLUTTER_PLUGIN_DESKTOP_CONTEXT_MENU_WINDOWS_PLUGIN_H_ 3 | 4 | #include 5 | 6 | #ifdef FLUTTER_PLUGIN_IMPL 7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) 8 | #else 9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) 10 | #endif 11 | 12 | #if defined(__cplusplus) 13 | extern "C" { 14 | #endif 15 | 16 | FLUTTER_PLUGIN_EXPORT void DesktopContextMenuWindowsPluginRegisterWithRegistrar( 17 | FlutterDesktopPluginRegistrarRef registrar); 18 | 19 | #if defined(__cplusplus) 20 | } // extern "C" 21 | #endif 22 | 23 | #endif // FLUTTER_PLUGIN_DESKTOP_CONTEXT_MENU_WINDOWS_PLUGIN_H_ 24 | -------------------------------------------------------------------------------- /desktop_context_menu_windows/windows/include/desktop_context_menu_windows/encoding.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace Encoding { 5 | /** 6 | * @brief Converts an UTF-8 string to a wide string. 7 | * 8 | * @param str 9 | * @return std::wstring 10 | */ 11 | std::wstring Utf8ToWide(const std::string& str) 12 | { 13 | int count = MultiByteToWideChar( 14 | CP_UTF8, 15 | 0, 16 | str.c_str(), 17 | static_cast(str.length()), 18 | nullptr, 19 | 0); 20 | std::wstring wstr(count, 0); 21 | MultiByteToWideChar( 22 | CP_UTF8, 23 | 0, 24 | str.c_str(), 25 | static_cast(str.length()), 26 | &wstr[0], 27 | count); 28 | return wstr; 29 | } 30 | } -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: desktop_context_menu 2 | 3 | packages: 4 | - "**" 5 | 6 | scripts: 7 | check_format: melos exec -- "flutter format --set-exit-if-changed ." 8 | analyze: melos exec -- "flutter analyze ." 9 | test: 10 | name: Run flutter tests 11 | run: melos exec flutter test 12 | select-package: 13 | dir-exists: test --------------------------------------------------------------------------------