Browse Source
Merge pull request #8257 from AvaloniaUI/fixes/osx-toolbar-hint
Fixes/osx toolbar hint
pull/8258/head
Dan Walmsley
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
12 additions and
9 deletions
-
native/Avalonia.Native/src/OSX/AvnWindow.mm
-
native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
-
native/Avalonia.Native/src/OSX/WindowImpl.mm
-
samples/ControlCatalog/MainWindow.xaml.cs
|
|
@ -33,6 +33,7 @@ |
|
|
bool _isEnabled; |
|
|
bool _isEnabled; |
|
|
bool _canBecomeKeyWindow; |
|
|
bool _canBecomeKeyWindow; |
|
|
bool _isExtended; |
|
|
bool _isExtended; |
|
|
|
|
|
bool _isTransitioningToFullScreen; |
|
|
AvnMenu* _menu; |
|
|
AvnMenu* _menu; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -175,6 +176,7 @@ |
|
|
[self setBackgroundColor: [NSColor clearColor]]; |
|
|
[self setBackgroundColor: [NSColor clearColor]]; |
|
|
|
|
|
|
|
|
_isExtended = false; |
|
|
_isExtended = false; |
|
|
|
|
|
_isTransitioningToFullScreen = false; |
|
|
|
|
|
|
|
|
if(self.isDialog) |
|
|
if(self.isDialog) |
|
|
{ |
|
|
{ |
|
|
@ -349,6 +351,7 @@ |
|
|
|
|
|
|
|
|
- (void)windowWillEnterFullScreen:(NSNotification *_Nonnull)notification |
|
|
- (void)windowWillEnterFullScreen:(NSNotification *_Nonnull)notification |
|
|
{ |
|
|
{ |
|
|
|
|
|
_isTransitioningToFullScreen = true; |
|
|
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); |
|
|
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); |
|
|
|
|
|
|
|
|
if(parent != nullptr) |
|
|
if(parent != nullptr) |
|
|
@ -359,6 +362,7 @@ |
|
|
|
|
|
|
|
|
- (void)windowDidEnterFullScreen:(NSNotification *_Nonnull)notification |
|
|
- (void)windowDidEnterFullScreen:(NSNotification *_Nonnull)notification |
|
|
{ |
|
|
{ |
|
|
|
|
|
_isTransitioningToFullScreen = false; |
|
|
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); |
|
|
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); |
|
|
|
|
|
|
|
|
if(parent != nullptr) |
|
|
if(parent != nullptr) |
|
|
@ -441,7 +445,10 @@ |
|
|
_parent->BaseEvents->RawMouseEvent(NonClientLeftButtonDown, static_cast<uint32>([event timestamp] * 1000), AvnInputModifiersNone, point, delta); |
|
|
_parent->BaseEvents->RawMouseEvent(NonClientLeftButtonDown, static_cast<uint32>([event timestamp] * 1000), AvnInputModifiersNone, point, delta); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_parent->BringToFront(); |
|
|
if(!_isTransitioningToFullScreen) |
|
|
|
|
|
{ |
|
|
|
|
|
_parent->BringToFront(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
@ -90,8 +90,6 @@ HRESULT WindowBaseImpl::Show(bool activate, bool isDialog) { |
|
|
START_COM_CALL; |
|
|
START_COM_CALL; |
|
|
|
|
|
|
|
|
@autoreleasepool { |
|
|
@autoreleasepool { |
|
|
InitialiseNSWindow(); |
|
|
|
|
|
|
|
|
|
|
|
if(hasPosition) |
|
|
if(hasPosition) |
|
|
{ |
|
|
{ |
|
|
SetPosition(lastPositionSet); |
|
|
SetPosition(lastPositionSet); |
|
|
|
|
|
@ -32,11 +32,11 @@ void WindowImpl::HideOrShowTrafficLights() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome); |
|
|
bool wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome); |
|
|
bool hasTrafficLights = _isClientAreaExtended ? wantsChrome : _decorations != SystemDecorationsFull; |
|
|
bool hasTrafficLights = _isClientAreaExtended ? wantsChrome : _decorations == SystemDecorationsFull; |
|
|
|
|
|
|
|
|
[[Window standardWindowButton:NSWindowCloseButton] setHidden:hasTrafficLights]; |
|
|
[[Window standardWindowButton:NSWindowCloseButton] setHidden:!hasTrafficLights]; |
|
|
[[Window standardWindowButton:NSWindowMiniaturizeButton] setHidden:hasTrafficLights]; |
|
|
[[Window standardWindowButton:NSWindowMiniaturizeButton] setHidden:!hasTrafficLights]; |
|
|
[[Window standardWindowButton:NSWindowZoomButton] setHidden:hasTrafficLights]; |
|
|
[[Window standardWindowButton:NSWindowZoomButton] setHidden:!hasTrafficLights]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void WindowImpl::OnInitialiseNSWindow(){ |
|
|
void WindowImpl::OnInitialiseNSWindow(){ |
|
|
|
|
|
@ -29,8 +29,6 @@ namespace ControlCatalog |
|
|
|
|
|
|
|
|
DataContext = new MainWindowViewModel(_notificationArea); |
|
|
DataContext = new MainWindowViewModel(_notificationArea); |
|
|
_recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu; |
|
|
_recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu; |
|
|
|
|
|
|
|
|
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.OSXThickTitleBar; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static string MenuQuitHeader => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "Quit Avalonia" : "E_xit"; |
|
|
public static string MenuQuitHeader => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "Quit Avalonia" : "E_xit"; |
|
|
|