|
@@ -6,8 +6,6 @@
|
|
|
#include <OpenGL/gl.h>
|
|
#include <OpenGL/gl.h>
|
|
|
#include "rendertarget.h"
|
|
#include "rendertarget.h"
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
class WindowBaseImpl : public virtual ComSingleObject<IAvnWindowBase, &IID_IAvnWindowBase>, public INSWindowHolder
|
|
class WindowBaseImpl : public virtual ComSingleObject<IAvnWindowBase, &IID_IAvnWindowBase>, public INSWindowHolder
|
|
|
{
|
|
{
|
|
|
private:
|
|
private:
|
|
@@ -20,7 +18,7 @@ public:
|
|
|
View = NULL;
|
|
View = NULL;
|
|
|
Window = NULL;
|
|
Window = NULL;
|
|
|
}
|
|
}
|
|
|
- NSVisualEffectView* VisualEffect;
|
|
|
|
|
|
|
+ AutoFitContentView* StandardContainer;
|
|
|
AvnView* View;
|
|
AvnView* View;
|
|
|
AvnWindow* Window;
|
|
AvnWindow* Window;
|
|
|
ComPtr<IAvnWindowBaseEvents> BaseEvents;
|
|
ComPtr<IAvnWindowBaseEvents> BaseEvents;
|
|
@@ -39,6 +37,7 @@ public:
|
|
|
_glContext = gl;
|
|
_glContext = gl;
|
|
|
renderTarget = [[IOSurfaceRenderTarget alloc] initWithOpenGlContext: gl];
|
|
renderTarget = [[IOSurfaceRenderTarget alloc] initWithOpenGlContext: gl];
|
|
|
View = [[AvnView alloc] initWithParent:this];
|
|
View = [[AvnView alloc] initWithParent:this];
|
|
|
|
|
+ StandardContainer = [[AutoFitContentView new] initWithContent:View];
|
|
|
|
|
|
|
|
Window = [[AvnWindow alloc] initWithParent:this];
|
|
Window = [[AvnWindow alloc] initWithParent:this];
|
|
|
|
|
|
|
@@ -49,12 +48,8 @@ public:
|
|
|
[Window setStyleMask:NSWindowStyleMaskBorderless];
|
|
[Window setStyleMask:NSWindowStyleMaskBorderless];
|
|
|
[Window setBackingType:NSBackingStoreBuffered];
|
|
[Window setBackingType:NSBackingStoreBuffered];
|
|
|
|
|
|
|
|
- VisualEffect = [AutoFitContentVisualEffectView new];
|
|
|
|
|
- [VisualEffect setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
|
|
|
|
- [VisualEffect setMaterial:NSVisualEffectMaterialLight];
|
|
|
|
|
- [VisualEffect setAutoresizesSubviews:true];
|
|
|
|
|
-
|
|
|
|
|
- [Window setContentView: View];
|
|
|
|
|
|
|
+ [Window setOpaque:false];
|
|
|
|
|
+ [Window setContentView: StandardContainer];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
virtual HRESULT ObtainNSWindowHandle(void** ret) override
|
|
virtual HRESULT ObtainNSWindowHandle(void** ret) override
|
|
@@ -116,10 +111,15 @@ public:
|
|
|
{
|
|
{
|
|
|
SetPosition(lastPositionSet);
|
|
SetPosition(lastPositionSet);
|
|
|
UpdateStyle();
|
|
UpdateStyle();
|
|
|
-
|
|
|
|
|
- [Window makeKeyAndOrderFront:Window];
|
|
|
|
|
- [NSApp activateIgnoringOtherApps:YES];
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(ShouldTakeFocusOnShow())
|
|
|
|
|
+ {
|
|
|
|
|
+ [Window makeKeyAndOrderFront:Window];
|
|
|
|
|
+ [NSApp activateIgnoringOtherApps:YES];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [Window orderFront: Window];
|
|
|
|
|
+ }
|
|
|
[Window setTitle:_lastTitle];
|
|
[Window setTitle:_lastTitle];
|
|
|
|
|
|
|
|
_shown = true;
|
|
_shown = true;
|
|
@@ -128,6 +128,11 @@ public:
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ virtual bool ShouldTakeFocusOnShow()
|
|
|
|
|
+ {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
virtual HRESULT Hide () override
|
|
virtual HRESULT Hide () override
|
|
|
{
|
|
{
|
|
|
@autoreleasepool
|
|
@autoreleasepool
|
|
@@ -390,14 +395,17 @@ public:
|
|
|
return *ppv == nil ? E_FAIL : S_OK;
|
|
return *ppv == nil ? E_FAIL : S_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ virtual HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut) override
|
|
|
|
|
+ {
|
|
|
|
|
+ if(View == NULL)
|
|
|
|
|
+ return E_FAIL;
|
|
|
|
|
+ *retOut = ::CreateNativeControlHost(View);
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
virtual HRESULT SetBlurEnabled (bool enable) override
|
|
virtual HRESULT SetBlurEnabled (bool enable) override
|
|
|
{
|
|
{
|
|
|
- [Window setContentView: enable ? VisualEffect : View];
|
|
|
|
|
-
|
|
|
|
|
- if(enable)
|
|
|
|
|
- {
|
|
|
|
|
- [VisualEffect addSubview:View];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ [StandardContainer ShowBlur:enable];
|
|
|
|
|
|
|
|
return S_OK;
|
|
return S_OK;
|
|
|
}
|
|
}
|
|
@@ -474,6 +482,8 @@ private:
|
|
|
bool _inSetWindowState;
|
|
bool _inSetWindowState;
|
|
|
NSRect _preZoomSize;
|
|
NSRect _preZoomSize;
|
|
|
bool _transitioningWindowState;
|
|
bool _transitioningWindowState;
|
|
|
|
|
+ bool _isClientAreaExtended;
|
|
|
|
|
+ AvnExtendClientAreaChromeHints _extendClientHints;
|
|
|
|
|
|
|
|
FORWARD_IUNKNOWN()
|
|
FORWARD_IUNKNOWN()
|
|
|
BEGIN_INTERFACE_MAP()
|
|
BEGIN_INTERFACE_MAP()
|
|
@@ -487,6 +497,8 @@ private:
|
|
|
ComPtr<IAvnWindowEvents> WindowEvents;
|
|
ComPtr<IAvnWindowEvents> WindowEvents;
|
|
|
WindowImpl(IAvnWindowEvents* events, IAvnGlContext* gl) : WindowBaseImpl(events, gl)
|
|
WindowImpl(IAvnWindowEvents* events, IAvnGlContext* gl) : WindowBaseImpl(events, gl)
|
|
|
{
|
|
{
|
|
|
|
|
+ _isClientAreaExtended = false;
|
|
|
|
|
+ _extendClientHints = AvnDefaultChrome;
|
|
|
_fullScreenActive = false;
|
|
_fullScreenActive = false;
|
|
|
_canResize = true;
|
|
_canResize = true;
|
|
|
_decorations = SystemDecorationsFull;
|
|
_decorations = SystemDecorationsFull;
|
|
@@ -505,8 +517,20 @@ private:
|
|
|
if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")]) {
|
|
if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")]) {
|
|
|
NSView *titlebarView = [subview subviews][0];
|
|
NSView *titlebarView = [subview subviews][0];
|
|
|
for (id button in titlebarView.subviews) {
|
|
for (id button in titlebarView.subviews) {
|
|
|
- if ([button isKindOfClass:[NSButton class]]) {
|
|
|
|
|
- [button setHidden: (_decorations != SystemDecorationsFull)];
|
|
|
|
|
|
|
+ if ([button isKindOfClass:[NSButton class]])
|
|
|
|
|
+ {
|
|
|
|
|
+ if(_isClientAreaExtended)
|
|
|
|
|
+ {
|
|
|
|
|
+ auto wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome);
|
|
|
|
|
+
|
|
|
|
|
+ [button setHidden: !wantsChrome];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [button setHidden: (_decorations != SystemDecorationsFull)];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [button setWantsLayer:true];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -582,6 +606,35 @@ private:
|
|
|
|
|
|
|
|
if(_lastWindowState != state)
|
|
if(_lastWindowState != state)
|
|
|
{
|
|
{
|
|
|
|
|
+ if(_isClientAreaExtended)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(_lastWindowState == FullScreen)
|
|
|
|
|
+ {
|
|
|
|
|
+ // we exited fs.
|
|
|
|
|
+ if(_extendClientHints & AvnOSXThickTitleBar)
|
|
|
|
|
+ {
|
|
|
|
|
+ Window.toolbar = [NSToolbar new];
|
|
|
|
|
+ Window.toolbar.showsBaselineSeparator = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [Window setTitlebarAppearsTransparent:true];
|
|
|
|
|
+
|
|
|
|
|
+ [StandardContainer setFrameSize: StandardContainer.frame.size];
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(state == FullScreen)
|
|
|
|
|
+ {
|
|
|
|
|
+ // we entered fs.
|
|
|
|
|
+ if(_extendClientHints & AvnOSXThickTitleBar)
|
|
|
|
|
+ {
|
|
|
|
|
+ Window.toolbar = nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [Window setTitlebarAppearsTransparent:false];
|
|
|
|
|
+
|
|
|
|
|
+ [StandardContainer setFrameSize: StandardContainer.frame.size];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
_lastWindowState = state;
|
|
_lastWindowState = state;
|
|
|
WindowEvents->WindowStateChanged(state);
|
|
WindowEvents->WindowStateChanged(state);
|
|
|
}
|
|
}
|
|
@@ -638,8 +691,6 @@ private:
|
|
|
return S_OK;
|
|
return S_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- auto currentFrame = [Window frame];
|
|
|
|
|
-
|
|
|
|
|
UpdateStyle();
|
|
UpdateStyle();
|
|
|
|
|
|
|
|
HideOrShowTrafficLights();
|
|
HideOrShowTrafficLights();
|
|
@@ -766,6 +817,90 @@ private:
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ virtual HRESULT TakeFocusFromChildren () override
|
|
|
|
|
+ {
|
|
|
|
|
+ if(Window == nil)
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ if([Window isKeyWindow])
|
|
|
|
|
+ [Window makeFirstResponder: View];
|
|
|
|
|
+
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ virtual HRESULT SetExtendClientArea (bool enable) override
|
|
|
|
|
+ {
|
|
|
|
|
+ _isClientAreaExtended = enable;
|
|
|
|
|
+
|
|
|
|
|
+ if(enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ Window.titleVisibility = NSWindowTitleHidden;
|
|
|
|
|
+
|
|
|
|
|
+ [Window setTitlebarAppearsTransparent:true];
|
|
|
|
|
+
|
|
|
|
|
+ auto wantsTitleBar = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome);
|
|
|
|
|
+
|
|
|
|
|
+ if (wantsTitleBar)
|
|
|
|
|
+ {
|
|
|
|
|
+ [StandardContainer ShowTitleBar:true];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [StandardContainer ShowTitleBar:false];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(_extendClientHints & AvnOSXThickTitleBar)
|
|
|
|
|
+ {
|
|
|
|
|
+ Window.toolbar = [NSToolbar new];
|
|
|
|
|
+ Window.toolbar.showsBaselineSeparator = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Window.toolbar = nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Window.titleVisibility = NSWindowTitleVisible;
|
|
|
|
|
+ Window.toolbar = nullptr;
|
|
|
|
|
+ [Window setTitlebarAppearsTransparent:false];
|
|
|
|
|
+ View.layer.zPosition = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [Window setIsExtended:enable];
|
|
|
|
|
+
|
|
|
|
|
+ HideOrShowTrafficLights();
|
|
|
|
|
+
|
|
|
|
|
+ UpdateStyle();
|
|
|
|
|
+
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ virtual HRESULT SetExtendClientAreaHints (AvnExtendClientAreaChromeHints hints) override
|
|
|
|
|
+ {
|
|
|
|
|
+ _extendClientHints = hints;
|
|
|
|
|
+
|
|
|
|
|
+ SetExtendClientArea(_isClientAreaExtended);
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ virtual HRESULT GetExtendTitleBarHeight (double*ret) override
|
|
|
|
|
+ {
|
|
|
|
|
+ if(ret == nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ return E_POINTER;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ *ret = [Window getExtendedTitleBarHeight];
|
|
|
|
|
+
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ virtual HRESULT SetExtendTitleBarHeight (double value) override
|
|
|
|
|
+ {
|
|
|
|
|
+ [StandardContainer SetTitleBarHeightHint:value];
|
|
|
|
|
+ return S_OK;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void EnterFullScreenMode ()
|
|
void EnterFullScreenMode ()
|
|
|
{
|
|
{
|
|
|
_fullScreenActive = true;
|
|
_fullScreenActive = true;
|
|
@@ -775,8 +910,9 @@ private:
|
|
|
[Window setTitlebarAppearsTransparent:NO];
|
|
[Window setTitlebarAppearsTransparent:NO];
|
|
|
[Window setTitle:_lastTitle];
|
|
[Window setTitle:_lastTitle];
|
|
|
|
|
|
|
|
- [Window setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskResizable];
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Window.styleMask = Window.styleMask | NSWindowStyleMaskTitled | NSWindowStyleMaskResizable;
|
|
|
|
|
+ Window.styleMask = Window.styleMask & ~NSWindowStyleMaskFullSizeContentView;
|
|
|
|
|
+
|
|
|
[Window toggleFullScreen:nullptr];
|
|
[Window toggleFullScreen:nullptr];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -924,19 +1060,120 @@ protected:
|
|
|
{
|
|
{
|
|
|
s |= NSWindowStyleMaskMiniaturizable;
|
|
s |= NSWindowStyleMaskMiniaturizable;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if(_isClientAreaExtended)
|
|
|
|
|
+ {
|
|
|
|
|
+ s |= NSWindowStyleMaskFullSizeContentView | NSWindowStyleMaskTexturedBackground;
|
|
|
|
|
+ }
|
|
|
return s;
|
|
return s;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, NSRunLoopCommonModes, NSConnectionReplyMode, nil];
|
|
NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, NSRunLoopCommonModes, NSConnectionReplyMode, nil];
|
|
|
|
|
|
|
|
-@implementation AutoFitContentVisualEffectView
|
|
|
|
|
|
|
+@implementation AutoFitContentView
|
|
|
|
|
+{
|
|
|
|
|
+ NSVisualEffectView* _titleBarMaterial;
|
|
|
|
|
+ NSBox* _titleBarUnderline;
|
|
|
|
|
+ NSView* _content;
|
|
|
|
|
+ NSVisualEffectView* _blurBehind;
|
|
|
|
|
+ double _titleBarHeightHint;
|
|
|
|
|
+ bool _settingSize;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(AutoFitContentView* _Nonnull) initWithContent:(NSView *)content
|
|
|
|
|
+{
|
|
|
|
|
+ _titleBarHeightHint = -1;
|
|
|
|
|
+ _content = content;
|
|
|
|
|
+ _settingSize = false;
|
|
|
|
|
+
|
|
|
|
|
+ [self setAutoresizesSubviews:true];
|
|
|
|
|
+ [self setWantsLayer:true];
|
|
|
|
|
+
|
|
|
|
|
+ _titleBarMaterial = [NSVisualEffectView new];
|
|
|
|
|
+ [_titleBarMaterial setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
|
|
|
|
|
+ [_titleBarMaterial setMaterial:NSVisualEffectMaterialTitlebar];
|
|
|
|
|
+ [_titleBarMaterial setWantsLayer:true];
|
|
|
|
|
+ _titleBarMaterial.hidden = true;
|
|
|
|
|
+
|
|
|
|
|
+ _titleBarUnderline = [NSBox new];
|
|
|
|
|
+ _titleBarUnderline.boxType = NSBoxSeparator;
|
|
|
|
|
+ _titleBarUnderline.fillColor = [NSColor underPageBackgroundColor];
|
|
|
|
|
+ _titleBarUnderline.hidden = true;
|
|
|
|
|
+
|
|
|
|
|
+ [self addSubview:_titleBarMaterial];
|
|
|
|
|
+ [self addSubview:_titleBarUnderline];
|
|
|
|
|
+
|
|
|
|
|
+ _blurBehind = [NSVisualEffectView new];
|
|
|
|
|
+ [_blurBehind setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
|
|
|
|
+ [_blurBehind setMaterial:NSVisualEffectMaterialLight];
|
|
|
|
|
+ [_blurBehind setWantsLayer:true];
|
|
|
|
|
+ _blurBehind.hidden = true;
|
|
|
|
|
+
|
|
|
|
|
+ [self addSubview:_blurBehind];
|
|
|
|
|
+ [self addSubview:_content];
|
|
|
|
|
+
|
|
|
|
|
+ [self setWantsLayer:true];
|
|
|
|
|
+ return self;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(void) ShowBlur:(bool)show
|
|
|
|
|
+{
|
|
|
|
|
+ _blurBehind.hidden = !show;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(void) ShowTitleBar: (bool) show
|
|
|
|
|
+{
|
|
|
|
|
+ _titleBarMaterial.hidden = !show;
|
|
|
|
|
+ _titleBarUnderline.hidden = !show;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(void) SetTitleBarHeightHint: (double) height
|
|
|
|
|
+{
|
|
|
|
|
+ _titleBarHeightHint = height;
|
|
|
|
|
+
|
|
|
|
|
+ [self setFrameSize:self.frame.size];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
-(void)setFrameSize:(NSSize)newSize
|
|
-(void)setFrameSize:(NSSize)newSize
|
|
|
{
|
|
{
|
|
|
- [super setFrameSize:newSize];
|
|
|
|
|
- if([[self subviews] count] == 0)
|
|
|
|
|
|
|
+ if(_settingSize)
|
|
|
|
|
+ {
|
|
|
return;
|
|
return;
|
|
|
- [[self subviews][0] setFrameSize: newSize];
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _settingSize = true;
|
|
|
|
|
+ [super setFrameSize:newSize];
|
|
|
|
|
+
|
|
|
|
|
+ [_blurBehind setFrameSize:newSize];
|
|
|
|
|
+ [_content setFrameSize:newSize];
|
|
|
|
|
+
|
|
|
|
|
+ auto window = objc_cast<AvnWindow>([self window]);
|
|
|
|
|
+
|
|
|
|
|
+ // TODO get actual titlebar size
|
|
|
|
|
+
|
|
|
|
|
+ double height = _titleBarHeightHint == -1 ? [window getExtendedTitleBarHeight] : _titleBarHeightHint;
|
|
|
|
|
+
|
|
|
|
|
+ NSRect tbar;
|
|
|
|
|
+ tbar.origin.x = 0;
|
|
|
|
|
+ tbar.origin.y = newSize.height - height;
|
|
|
|
|
+ tbar.size.width = newSize.width;
|
|
|
|
|
+ tbar.size.height = height;
|
|
|
|
|
+
|
|
|
|
|
+ [_titleBarMaterial setFrame:tbar];
|
|
|
|
|
+ tbar.size.height = height < 1 ? 0 : 1;
|
|
|
|
|
+ [_titleBarUnderline setFrame:tbar];
|
|
|
|
|
+ _settingSize = false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(void) SetContent: (NSView* _Nonnull) content
|
|
|
|
|
+{
|
|
|
|
|
+ if(content != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ [content removeFromSuperview];
|
|
|
|
|
+ [self addSubview:content];
|
|
|
|
|
+ _content = content;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
@@ -1060,9 +1297,9 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
_parent->BaseEvents->Resized(AvnSize{newSize.width, newSize.height});
|
|
_parent->BaseEvents->Resized(AvnSize{newSize.width, newSize.height});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- (void)updateLayer
|
|
- (void)updateLayer
|
|
|
{
|
|
{
|
|
|
|
|
+ AvnInsidePotentialDeadlock deadlock;
|
|
|
if (_parent == nullptr)
|
|
if (_parent == nullptr)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
@@ -1107,7 +1344,11 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
_lastPixelSize.Width = (int)fsize.width;
|
|
_lastPixelSize.Width = (int)fsize.width;
|
|
|
_lastPixelSize.Height = (int)fsize.height;
|
|
_lastPixelSize.Height = (int)fsize.height;
|
|
|
[self updateRenderTarget];
|
|
[self updateRenderTarget];
|
|
|
- _parent->BaseEvents->ScalingChanged([_parent->Window backingScaleFactor]);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(_parent != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ _parent->BaseEvents->ScalingChanged([_parent->Window backingScaleFactor]);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
[super viewDidChangeBackingProperties];
|
|
[super viewDidChangeBackingProperties];
|
|
|
}
|
|
}
|
|
@@ -1138,7 +1379,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [self becomeFirstResponder];
|
|
|
|
|
auto localPoint = [self convertPoint:[event locationInWindow] toView:self];
|
|
auto localPoint = [self convertPoint:[event locationInWindow] toView:self];
|
|
|
auto avnPoint = [self toAvnPoint:localPoint];
|
|
auto avnPoint = [self toAvnPoint:localPoint];
|
|
|
auto point = [self translateLocalPoint:avnPoint];
|
|
auto point = [self translateLocalPoint:avnPoint];
|
|
@@ -1165,11 +1405,31 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
auto timestamp = [event timestamp] * 1000;
|
|
auto timestamp = [event timestamp] * 1000;
|
|
|
auto modifiers = [self getModifiers:[event modifierFlags]];
|
|
auto modifiers = [self getModifiers:[event modifierFlags]];
|
|
|
|
|
|
|
|
- [self becomeFirstResponder];
|
|
|
|
|
- _parent->BaseEvents->RawMouseEvent(type, timestamp, modifiers, point, delta);
|
|
|
|
|
|
|
+ if(type != AvnRawMouseEventType::Move ||
|
|
|
|
|
+ (
|
|
|
|
|
+ [self window] != nil &&
|
|
|
|
|
+ (
|
|
|
|
|
+ [[self window] firstResponder] == nil
|
|
|
|
|
+ || ![[[self window] firstResponder] isKindOfClass: [NSView class]]
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ [self becomeFirstResponder];
|
|
|
|
|
+
|
|
|
|
|
+ if(_parent != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ _parent->BaseEvents->RawMouseEvent(type, timestamp, modifiers, point, delta);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
[super mouseMoved:event];
|
|
[super mouseMoved:event];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (BOOL) resignFirstResponder
|
|
|
|
|
+{
|
|
|
|
|
+ _parent->BaseEvents->LostFocus();
|
|
|
|
|
+ return YES;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
- (void)mouseMoved:(NSEvent *)event
|
|
- (void)mouseMoved:(NSEvent *)event
|
|
|
{
|
|
{
|
|
|
[self mouseEvent:event withType:Move];
|
|
[self mouseEvent:event withType:Move];
|
|
@@ -1290,7 +1550,10 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
auto timestamp = [event timestamp] * 1000;
|
|
auto timestamp = [event timestamp] * 1000;
|
|
|
auto modifiers = [self getModifiers:[event modifierFlags]];
|
|
auto modifiers = [self getModifiers:[event modifierFlags]];
|
|
|
|
|
|
|
|
- _lastKeyHandled = _parent->BaseEvents->RawKeyEvent(type, timestamp, modifiers, key);
|
|
|
|
|
|
|
+ if(_parent != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ _lastKeyHandled = _parent->BaseEvents->RawKeyEvent(type, timestamp, modifiers, key);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)performKeyEquivalent:(NSEvent *)event
|
|
- (BOOL)performKeyEquivalent:(NSEvent *)event
|
|
@@ -1381,7 +1644,10 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
{
|
|
{
|
|
|
if(!_lastKeyHandled)
|
|
if(!_lastKeyHandled)
|
|
|
{
|
|
{
|
|
|
- _lastKeyHandled = _parent->BaseEvents->RawTextInputEvent(0, [string UTF8String]);
|
|
|
|
|
|
|
+ if(_parent != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ _lastKeyHandled = _parent->BaseEvents->RawTextInputEvent(0, [string UTF8String]);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1467,15 +1733,43 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
bool _canBecomeKeyAndMain;
|
|
bool _canBecomeKeyAndMain;
|
|
|
bool _closed;
|
|
bool _closed;
|
|
|
bool _isEnabled;
|
|
bool _isEnabled;
|
|
|
|
|
+ bool _isExtended;
|
|
|
AvnMenu* _menu;
|
|
AvnMenu* _menu;
|
|
|
double _lastScaling;
|
|
double _lastScaling;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+-(void) setIsExtended:(bool)value;
|
|
|
|
|
+{
|
|
|
|
|
+ _isExtended = value;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
-(double) getScaling
|
|
-(double) getScaling
|
|
|
{
|
|
{
|
|
|
return _lastScaling;
|
|
return _lastScaling;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+-(double) getExtendedTitleBarHeight
|
|
|
|
|
+{
|
|
|
|
|
+ if(_isExtended)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (id subview in self.contentView.superview.subviews)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")])
|
|
|
|
|
+ {
|
|
|
|
|
+ NSView *titlebarView = [subview subviews][0];
|
|
|
|
|
+
|
|
|
|
|
+ return (double)titlebarView.frame.size.height;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+(void)closeAll
|
|
+(void)closeAll
|
|
|
{
|
|
{
|
|
|
NSArray<NSWindow*>* windows = [NSArray arrayWithArray:[NSApp windows]];
|
|
NSArray<NSWindow*>* windows = [NSArray arrayWithArray:[NSApp windows]];
|
|
@@ -1594,6 +1888,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
[self setOpaque:NO];
|
|
[self setOpaque:NO];
|
|
|
[self setBackgroundColor: [NSColor clearColor]];
|
|
[self setBackgroundColor: [NSColor clearColor]];
|
|
|
[self invalidateShadow];
|
|
[self invalidateShadow];
|
|
|
|
|
+ _isExtended = false;
|
|
|
return self;
|
|
return self;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1677,7 +1972,11 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
{
|
|
{
|
|
|
[self showWindowMenuWithAppMenu];
|
|
[self showWindowMenuWithAppMenu];
|
|
|
|
|
|
|
|
- _parent->BaseEvents->Activated();
|
|
|
|
|
|
|
+ if(_parent != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ _parent->BaseEvents->Activated();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
[super becomeKeyWindow];
|
|
[super becomeKeyWindow];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1794,8 +2093,12 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
|
|
|
- (void)windowDidMove:(NSNotification *)notification
|
|
- (void)windowDidMove:(NSNotification *)notification
|
|
|
{
|
|
{
|
|
|
AvnPoint position;
|
|
AvnPoint position;
|
|
|
- _parent->GetPosition(&position);
|
|
|
|
|
- _parent->BaseEvents->PositionChanged(position);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(_parent != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ _parent->GetPosition(&position);
|
|
|
|
|
+ _parent->BaseEvents->PositionChanged(position);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
@@ -1813,7 +2116,6 @@ private:
|
|
|
WindowEvents = events;
|
|
WindowEvents = events;
|
|
|
[Window setLevel:NSPopUpMenuWindowLevel];
|
|
[Window setLevel:NSPopUpMenuWindowLevel];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
protected:
|
|
protected:
|
|
|
virtual NSWindowStyleMask GetStyle() override
|
|
virtual NSWindowStyleMask GetStyle() override
|
|
|
{
|
|
{
|
|
@@ -1831,6 +2133,11 @@ protected:
|
|
|
return S_OK;
|
|
return S_OK;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+public:
|
|
|
|
|
+ virtual bool ShouldTakeFocusOnShow() override
|
|
|
|
|
+ {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
extern IAvnPopup* CreateAvnPopup(IAvnWindowEvents*events, IAvnGlContext* gl)
|
|
extern IAvnPopup* CreateAvnPopup(IAvnWindowEvents*events, IAvnGlContext* gl)
|