Skip to content

Commit bd6d665

Browse files
committed
Merge pull request AvaloniaUI#8257 from AvaloniaUI/fixes/osx-toolbar-hint
Fixes/osx toolbar hint
1 parent 4d99ad1 commit bd6d665

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

native/Avalonia.Native/src/OSX/AvnWindow.mm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ @implementation CLASS_NAME
3232
bool _isEnabled;
3333
bool _canBecomeKeyWindow;
3434
bool _isExtended;
35+
bool _isTransitioningToFullScreen;
3536
AvnMenu* _menu;
3637
}
3738

@@ -174,6 +175,7 @@ -(CLASS_NAME*_Nonnull) initWithParent: (WindowBaseImpl*_Nonnull) parent content
174175
[self setBackgroundColor: [NSColor clearColor]];
175176

176177
_isExtended = false;
178+
_isTransitioningToFullScreen = false;
177179

178180
if(self.isDialog)
179181
{
@@ -348,6 +350,7 @@ - (void)windowDidExitFullScreen:(NSNotification *_Nonnull)notification
348350

349351
- (void)windowWillEnterFullScreen:(NSNotification *_Nonnull)notification
350352
{
353+
_isTransitioningToFullScreen = true;
351354
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
352355

353356
if(parent != nullptr)
@@ -358,6 +361,7 @@ - (void)windowWillEnterFullScreen:(NSNotification *_Nonnull)notification
358361

359362
- (void)windowDidEnterFullScreen:(NSNotification *_Nonnull)notification
360363
{
364+
_isTransitioningToFullScreen = false;
361365
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
362366

363367
if(parent != nullptr)
@@ -440,7 +444,10 @@ - (void)sendEvent:(NSEvent *_Nonnull)event
440444
_parent->BaseEvents->RawMouseEvent(NonClientLeftButtonDown, static_cast<uint32>([event timestamp] * 1000), AvnInputModifiersNone, point, delta);
441445
}
442446

443-
_parent->BringToFront();
447+
if(!_isTransitioningToFullScreen)
448+
{
449+
_parent->BringToFront();
450+
}
444451
}
445452
break;
446453

native/Avalonia.Native/src/OSX/WindowBaseImpl.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@
8989
START_COM_CALL;
9090

9191
@autoreleasepool {
92-
InitialiseNSWindow();
93-
9492
if(hasPosition)
9593
{
9694
SetPosition(lastPositionSet);

native/Avalonia.Native/src/OSX/WindowImpl.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
}
3232

3333
bool wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome);
34-
bool hasTrafficLights = _isClientAreaExtended ? wantsChrome : _decorations != SystemDecorationsFull;
34+
bool hasTrafficLights = _isClientAreaExtended ? wantsChrome : _decorations == SystemDecorationsFull;
3535

36-
[[Window standardWindowButton:NSWindowCloseButton] setHidden:hasTrafficLights];
37-
[[Window standardWindowButton:NSWindowMiniaturizeButton] setHidden:hasTrafficLights];
38-
[[Window standardWindowButton:NSWindowZoomButton] setHidden:hasTrafficLights];
36+
[[Window standardWindowButton:NSWindowCloseButton] setHidden:!hasTrafficLights];
37+
[[Window standardWindowButton:NSWindowMiniaturizeButton] setHidden:!hasTrafficLights];
38+
[[Window standardWindowButton:NSWindowZoomButton] setHidden:!hasTrafficLights];
3939
}
4040

4141
void WindowImpl::OnInitialiseNSWindow(){

samples/ControlCatalog/MainWindow.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public MainWindow()
3232

3333
DataContext = new MainWindowViewModel(_notificationArea);
3434
_recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu;
35-
36-
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.OSXThickTitleBar;
3735
}
3836

3937
public static string MenuQuitHeader => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "Quit Avalonia" : "E_xit";

0 commit comments

Comments
 (0)