Skip to content

Commit d1b2366

Browse files
committed
fix: maximization for non decoration window
1 parent 2ad9126 commit d1b2366

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tao": patch
3+
---
4+
5+
Fixed maximization for non decoration window.

src/platform_impl/macos/util/async.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
use cocoa::{
1010
appkit::{CGFloat, NSScreen, NSWindow, NSWindowStyleMask},
1111
base::{id, nil},
12-
foundation::{NSPoint, NSSize, NSString},
12+
foundation::{NSPoint, NSRect, NSSize, NSString},
1313
};
1414
use dispatch::Queue;
1515
use objc::{
@@ -179,8 +179,20 @@ pub unsafe fn set_maximized_async(
179179
} else {
180180
// if it's not resizable, we set the frame directly
181181
let new_rect = if maximized {
182+
let max_size = ns_window.maxSize();
182183
let screen = NSScreen::mainScreen(nil);
183-
NSScreen::visibleFrame(screen)
184+
let screen_rect = NSScreen::visibleFrame(screen);
185+
let width = if max_size.width < screen_rect.size.width {
186+
max_size.width
187+
} else {
188+
screen_rect.size.width
189+
};
190+
let height = if max_size.height < screen_rect.size.height {
191+
max_size.height
192+
} else {
193+
screen_rect.size.height
194+
};
195+
NSRect::new(screen_rect.origin, NSSize::new(width, height))
184196
} else {
185197
shared_state_lock.saved_standard_frame()
186198
};

0 commit comments

Comments
 (0)