Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#10575 from AvaloniaUI/fixes/macos-no-re…
Browse files Browse the repository at this point in the history
…size-zoom

macOS: Don't allow window zoom when CanResize=false.
  • Loading branch information
Dan Walmsley authored and grokys committed Mar 23, 2023
1 parent a674362 commit 9bebc76
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/AvnWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ - (void)windowDidEnterFullScreen:(NSNotification *_Nonnull)notification

- (BOOL)windowShouldZoom:(NSWindow *_Nonnull)window toFrame:(NSRect)newFrame
{
return true;
return _parent->CanZoom();
}

-(void)windowDidResignKey:(NSNotification *)notification
Expand Down
2 changes: 2 additions & 0 deletions native/Avalonia.Native/src/OSX/WindowBaseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ BEGIN_INTERFACE_MAP()

virtual void BringToFront ();

virtual bool CanZoom() { return false; }

protected:
virtual NSWindowStyleMask CalculateStyleMask() = 0;
virtual void UpdateStyle();
Expand Down
2 changes: 2 additions & 0 deletions native/Avalonia.Native/src/OSX/WindowImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ BEGIN_INTERFACE_MAP()

bool CanBecomeKeyWindow ();

bool CanZoom() override { return _isEnabled && _canResize; }

protected:
virtual NSWindowStyleMask CalculateStyleMask() override;
void UpdateStyle () override;
Expand Down
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -616,5 +616,5 @@
[miniaturizeButton setHidden:!hasTrafficLights];
[miniaturizeButton setEnabled:_isEnabled];
[zoomButton setHidden:!hasTrafficLights];
[zoomButton setEnabled:_isEnabled && _canResize];
[zoomButton setEnabled:CanZoom()];
}

0 comments on commit 9bebc76

Please sign in to comment.