#ifndef RUNNER_FLUTTER_WINDOW_H_ #define RUNNER_FLUTTER_WINDOW_H_ #include #include #include #include #include #include "win32_window.h" #include "tray_icon.h" // A window that does nothing but host a Flutter view. class FlutterWindow : public Win32Window { public: // Creates a new FlutterWindow hosting a Flutter view running |project|. explicit FlutterWindow(const flutter::DartProject& project); virtual ~FlutterWindow(); public: void SetMinimumSize(SIZE size); // App Events handler void onHideWindow(); void onShowWindow(); void onToggleWindow(); void onActiveWindow(); // Tray Events handler void onTrayIconLButtonDown(); void onTrayIconLButtonUp(); void onTrayIconRButtonDown(); void onTrayIconRButtonUp(); protected: // Win32Window: bool OnCreate() override; void OnDestroy() override; LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override; private: void createMenu(HMENU menu, flutter::EncodableMap args); std::optional handleMessage(HWND window, UINT const message, WPARAM const wparam, LPARAM const lparam); void registerMethodChannel(flutter::FlutterEngine* engine); void handleAppMethodCall( const flutter::MethodCall& method_call, std::unique_ptr> result); void handleTrayMethodCall( const flutter::MethodCall& method_call, std::unique_ptr> result); void setSystemTray( const flutter::MethodCall& method_call, std::unique_ptr> result); void resetSystemTray( const flutter::MethodCall& method_call, std::unique_ptr> result); void setContextMenu( const flutter::MethodCall& method_call, std::unique_ptr> result); void popUpContextMenu( const flutter::MethodCall& method_call, std::unique_ptr> result); void extractFileIcon( const flutter::MethodCall& method_call, std::unique_ptr> result); void getFileDescription( const flutter::MethodCall& method_call, std::unique_ptr> result); private: SIZE min_window_size_ = {0, 0}; // The project to run. flutter::DartProject project_; // The Flutter instance hosted by this window. std::unique_ptr flutter_controller_; // The system tray TrayIcon m_tray; HMENU m_menuHandle; }; #endif // RUNNER_FLUTTER_WINDOW_H_