Skip to content

Commit

Permalink
Expose WindowManagerPlusFlutterWindow macos class
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo committed Oct 8, 2024
1 parent f0b0c8d commit 8a046b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.2

- Expose WindowManagerPlusFlutterWindow macos class
- Updated README

## 1.0.1

- Updated README
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,18 @@ Change the file `macos/Runner/AppDelegate.swift` as follows:
```diff
import Cocoa
import FlutterMacOS
+ import window_manager_plus

@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
- return true
+ return NSApp.windows.count == 1 // or return false
+ return NSApp.windows.filter({$0 is MainFlutterWindow || $0 is WindowManagerPlusFlutterWindow}).count == 1 // or return false
}
}
```

Without returning at least `NSApp.windows.count == 1`, the application will close when the main flutter window is closed.
Without changing the return logic, the application will close when the main flutter window is closed.

#### Windows

Expand Down Expand Up @@ -427,7 +428,7 @@ class AppDelegate: FlutterAppDelegate {
}
```

#### Windows
##### Windows

Change the file `windows/runner/main.cpp` as follows:

Expand Down
8 changes: 4 additions & 4 deletions macos/Classes/WindowManagerPlus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ extension NSRect {
}

/// Add extra hooks for window
class FlutterWindowInner: NSPanel {
public class WindowManagerPlusFlutterWindow: NSPanel {
override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
super.order(place, relativeTo: otherWin)
hiddenWindowAtLaunch()
}

deinit {
debugPrint("FlutterWindowInner dealloc")
debugPrint("WindowManagerPlusFlutterWindow dealloc")
}
}

public class WindowManagerPlus: NSObject, NSWindowDelegate {
private static var autoincrementId: Int64 = 0;
private static var windows: [Int64:FlutterWindowInner?] = [:];
private static var windows: [Int64:WindowManagerPlusFlutterWindow?] = [:];
public static var windowManagers: [Int64:WindowManagerPlus?] = [:];

public var staticChannel: FlutterMethodChannel?
Expand All @@ -83,7 +83,7 @@ public class WindowManagerPlus: NSObject, NSWindowDelegate {
commandLineArguments.append(contentsOf: args)
project.dartEntrypointArguments = commandLineArguments

let window = FlutterWindowInner(
let window = WindowManagerPlusFlutterWindow(
contentRect: NSRect(x: 0, y: 0, width: 480, height: 270),
styleMask: [.miniaturizable, .closable, .resizable, .titled, .fullSizeContentView],
backing: .buffered, defer: false)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: window_manager_plus
description: This plugin allows Flutter desktop apps to create and manage multiple windows, such as resizing and repositioning, and communicate between them.
version: 1.0.1
version: 1.0.2
homepage: https://github.com/pichillilorenzo/window_manager_plus
repository: https://github.com/pichillilorenzo/window_manager_plus
issue_tracker: https://github.com/pichillilorenzo/window_manager_plus/issues
Expand Down

0 comments on commit 8a046b4

Please sign in to comment.