|
|
|
@ -9,6 +9,7 @@ |
|
|
|
#include "WindowProtocol.h" |
|
|
|
|
|
|
|
WindowImpl::WindowImpl(IAvnWindowEvents *events, IAvnGlContext *gl) : WindowBaseImpl(events, gl) { |
|
|
|
_isEnabled = true; |
|
|
|
_children = std::list<WindowImpl*>(); |
|
|
|
_isClientAreaExtended = false; |
|
|
|
_extendClientHints = AvnDefaultChrome; |
|
|
|
@ -22,6 +23,8 @@ WindowImpl::WindowImpl(IAvnWindowEvents *events, IAvnGlContext *gl) : WindowBase |
|
|
|
_lastTitle = @""; |
|
|
|
_parent = nullptr; |
|
|
|
WindowEvents = events; |
|
|
|
|
|
|
|
OnInitialiseNSWindow(); |
|
|
|
} |
|
|
|
|
|
|
|
void WindowImpl::HideOrShowTrafficLights() { |
|
|
|
@ -30,15 +33,16 @@ void WindowImpl::HideOrShowTrafficLights() { |
|
|
|
} |
|
|
|
|
|
|
|
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:NSWindowMiniaturizeButton] setHidden:hasTrafficLights]; |
|
|
|
[[Window standardWindowButton:NSWindowZoomButton] setHidden:hasTrafficLights]; |
|
|
|
[[Window standardWindowButton:NSWindowCloseButton] setHidden:!hasTrafficLights]; |
|
|
|
[[Window standardWindowButton:NSWindowMiniaturizeButton] setHidden:!hasTrafficLights]; |
|
|
|
[[Window standardWindowButton:NSWindowZoomButton] setHidden:!hasTrafficLights]; |
|
|
|
} |
|
|
|
|
|
|
|
void WindowImpl::OnInitialiseNSWindow(){ |
|
|
|
[GetWindowProtocol() setCanBecomeKeyWindow:true]; |
|
|
|
|
|
|
|
[Window disableCursorRects]; |
|
|
|
[Window setTabbingMode:NSWindowTabbingModeDisallowed]; |
|
|
|
[Window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; |
|
|
|
@ -75,7 +79,9 @@ HRESULT WindowImpl::SetEnabled(bool enable) { |
|
|
|
START_COM_CALL; |
|
|
|
|
|
|
|
@autoreleasepool { |
|
|
|
_isEnabled = enable; |
|
|
|
[GetWindowProtocol() setEnabled:enable]; |
|
|
|
UpdateStyle(); |
|
|
|
return S_OK; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -87,11 +93,8 @@ HRESULT WindowImpl::SetParent(IAvnWindow *parent) { |
|
|
|
if(_parent != nullptr) |
|
|
|
{ |
|
|
|
_parent->_children.remove(this); |
|
|
|
auto parent = _parent; |
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{ |
|
|
|
parent->BringToFront(); |
|
|
|
}); |
|
|
|
_parent->BringToFront(); |
|
|
|
} |
|
|
|
|
|
|
|
auto cparent = dynamic_cast<WindowImpl *>(parent); |
|
|
|
@ -118,20 +121,23 @@ HRESULT WindowImpl::SetParent(IAvnWindow *parent) { |
|
|
|
|
|
|
|
void WindowImpl::BringToFront() |
|
|
|
{ |
|
|
|
if(IsDialog()) |
|
|
|
if(Window != nullptr) |
|
|
|
{ |
|
|
|
Activate(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
[Window orderFront:nullptr]; |
|
|
|
} |
|
|
|
|
|
|
|
[Window invalidateShadow]; |
|
|
|
|
|
|
|
for(auto iterator = _children.begin(); iterator != _children.end(); iterator++) |
|
|
|
{ |
|
|
|
(*iterator)->BringToFront(); |
|
|
|
if(IsDialog()) |
|
|
|
{ |
|
|
|
Activate(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
[Window orderFront:nullptr]; |
|
|
|
} |
|
|
|
|
|
|
|
[Window invalidateShadow]; |
|
|
|
|
|
|
|
for(auto iterator = _children.begin(); iterator != _children.end(); iterator++) |
|
|
|
{ |
|
|
|
(*iterator)->BringToFront(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -560,6 +566,11 @@ bool WindowImpl::IsDialog() { |
|
|
|
|
|
|
|
NSWindowStyleMask WindowImpl::GetStyle() { |
|
|
|
unsigned long s = NSWindowStyleMaskBorderless; |
|
|
|
|
|
|
|
if(_actualWindowState == FullScreen) |
|
|
|
{ |
|
|
|
s |= NSWindowStyleMaskFullScreen; |
|
|
|
} |
|
|
|
|
|
|
|
switch (_decorations) { |
|
|
|
case SystemDecorationsNone: |
|
|
|
@ -573,7 +584,7 @@ NSWindowStyleMask WindowImpl::GetStyle() { |
|
|
|
case SystemDecorationsFull: |
|
|
|
s = s | NSWindowStyleMaskTitled | NSWindowStyleMaskClosable; |
|
|
|
|
|
|
|
if (_canResize) { |
|
|
|
if (_canResize && _isEnabled) { |
|
|
|
s = s | NSWindowStyleMaskResizable; |
|
|
|
} |
|
|
|
break; |
|
|
|
|