Skip to content

Commit

Permalink
merged latest fixes, renamed files and classes for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo committed Oct 8, 2024
1 parent 2d5ba21 commit 72f7406
Show file tree
Hide file tree
Showing 8 changed files with 991 additions and 977 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Change the file `windows/runner/main.cpp` as follows:
#include "flutter_window.h"
#include "utils.h"

+ #include "window_manager/window_manager_plugin.h"
+ #include "window_manager_plus/window_manager_plus_plugin.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance,
_In_opt_ HINSTANCE prev,
Expand Down Expand Up @@ -229,7 +229,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance,
- window.SetQuitOnClose(true);
+ window.SetQuitOnClose(false);
+
+ WindowManagerPluginSetWindowCreatedCallback(
+ WindowManagerPlusPluginSetWindowCreatedCallback(
+ [](std::vector<std::string> command_line_arguments) {
+ flutter::DartProject project(L"data");
+
Expand Down Expand Up @@ -260,7 +260,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance,
`window->SetQuitOnClose(false);` is necessary to prevent the application from closing when the window is closed.

If you want to close the App only when the main window is closed, you can set `window->SetQuitOnClose(true);` in the main window.
The others called inside the `WindowManagerPluginSetWindowCreatedCallback` should be set to `false`.
The others called inside the `WindowManagerPlusPluginSetWindowCreatedCallback` should be set to `false`.

### Usage

Expand Down
4 changes: 2 additions & 2 deletions example/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "flutter_window.h"
#include "utils.h"

#include "window_manager/window_manager_plugin.h"
#include "window_manager_plus/window_manager_plus_plugin.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance,
_In_opt_ HINSTANCE prev,
Expand Down Expand Up @@ -37,7 +37,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance,
}
window.SetQuitOnClose(false);

WindowManagerPluginSetWindowCreatedCallback(
WindowManagerPlusPluginSetWindowCreatedCallback(
[](std::vector<std::string> command_line_arguments) {
flutter::DartProject project(L"data");

Expand Down
10 changes: 5 additions & 5 deletions windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
cmake_minimum_required(VERSION 3.15)
set(PROJECT_NAME "window_manager")
set(PROJECT_NAME "window_manager_plus")
project(${PROJECT_NAME} LANGUAGES CXX)

# This value is used when generating builds using this plugin, so it must
# not be changed
set(PLUGIN_NAME "window_manager_plugin")
set(PLUGIN_NAME "window_manager_plus_plugin")

add_library(${PLUGIN_NAME} SHARED
"window_manager.cpp"
"window_manager.h"
"window_manager_plugin.cpp"
"window_manager_plus.cpp"
"window_manager_plus.h"
"window_manager_plus_plugin.cpp"
)
apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
#ifndef FLUTTER_PLUGIN_WINDOW_MANAGER_PLUGIN_H_
#define FLUTTER_PLUGIN_WINDOW_MANAGER_PLUGIN_H_

#include <any>
#include <map>
#include <string>
#include <vector>
#include <windows.h>

#include <flutter_plugin_registrar.h>

#include <memory>

#ifdef FLUTTER_PLUGIN_IMPL
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
#else
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
#endif

#if defined(__cplusplus)
extern "C" {
#endif

FLUTTER_PLUGIN_EXPORT void WindowManagerPluginRegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar);

#ifndef RUNNER_FLUTTER_WINDOW_H_
#define RUNNER_FLUTTER_WINDOW_H_
class FlutterWindow {
public:
virtual void Destroy() = 0;
};

#endif // RUNNER_FLUTTER_WINDOW_H_

typedef std::shared_ptr<FlutterWindow> (*WindowCreatedCallback)(
std::vector<std::string> command_line_arguments);
FLUTTER_PLUGIN_EXPORT void WindowManagerPluginSetWindowCreatedCallback(
WindowCreatedCallback callback);

#if defined(__cplusplus)
} // extern "C"
#endif

#endif // FLUTTER_PLUGIN_WINDOW_MANAGER_PLUGIN_H_
#ifndef FLUTTER_PLUGIN_WINDOW_MANAGER_PLUS_PLUGIN_H_
#define FLUTTER_PLUGIN_WINDOW_MANAGER_PLUS_PLUGIN_H_

#include <any>
#include <map>
#include <string>
#include <vector>
#include <windows.h>

#include <flutter_plugin_registrar.h>

#include <memory>

#ifdef FLUTTER_PLUGIN_IMPL
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
#else
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
#endif

#if defined(__cplusplus)
extern "C" {
#endif

FLUTTER_PLUGIN_EXPORT void WindowManagerPlusPluginRegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar);

#ifndef RUNNER_FLUTTER_WINDOW_H_
#define RUNNER_FLUTTER_WINDOW_H_
class FlutterWindow {
public:
virtual void Destroy() = 0;
};

#endif // RUNNER_FLUTTER_WINDOW_H_

typedef std::shared_ptr<FlutterWindow> (
*WindowManagerPlusPluginWindowCreatedCallback)(
std::vector<std::string> command_line_arguments);
FLUTTER_PLUGIN_EXPORT void WindowManagerPlusPluginSetWindowCreatedCallback(
WindowManagerPlusPluginWindowCreatedCallback callback);

#if defined(__cplusplus)
} // extern "C"
#endif

#endif // FLUTTER_PLUGIN_WINDOW_MANAGER_PLUS_PLUGIN_H_
153 changes: 0 additions & 153 deletions windows/window_manager.h

This file was deleted.

Loading

0 comments on commit 72f7406

Please sign in to comment.