Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos: Fix child window key handling #9716

Merged
merged 5 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion native/Avalonia.Native/src/OSX/AvnWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ -(void) setIsExtended:(bool)value;

-(bool) isDialog
{
return _parent->IsDialog();
return _parent->IsModal();
}

-(double) getExtendedTitleBarHeight
Expand Down Expand Up @@ -281,6 +281,9 @@ -(void)becomeKeyWindow

- (void)windowDidBecomeKey:(NSNotification *_Nonnull)notification
{
if (_parent == nullptr)
return;

_parent->BringToFront();

dispatch_async(dispatch_get_main_queue(), ^{
Expand Down
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/WindowBaseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ BEGIN_INTERFACE_MAP()
IAvnClipboard *clipboard, IAvnDndResultCallback *cb,
void *sourceHandle) override;

virtual bool IsDialog();
virtual bool IsModal();

id<AvnWindowProtocol> GetWindowProtocol ();

Expand Down
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@
return S_OK;
}

bool WindowBaseImpl::IsDialog() {
bool WindowBaseImpl::IsModal() {
return false;
}

Expand Down
6 changes: 4 additions & 2 deletions native/Avalonia.Native/src/OSX/WindowImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WindowImpl : public virtual WindowBaseImpl, public virtual IAvnWindow, pub
NSRect _preZoomSize;
bool _transitioningWindowState;
bool _isClientAreaExtended;
bool _isDialog;
bool _isModal;
WindowImpl* _parent;
std::list<WindowImpl*> _children;
AvnExtendClientAreaChromeHints _extendClientHints;
Expand Down Expand Up @@ -91,7 +91,9 @@ BEGIN_INTERFACE_MAP()

virtual HRESULT SetWindowState (AvnWindowState state) override;

virtual bool IsDialog() override;
virtual bool IsModal() override;

bool IsOwned();

virtual void BringToFront () override;

Expand Down
18 changes: 11 additions & 7 deletions native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
START_COM_CALL;

@autoreleasepool {
_isDialog = isDialog || _parent != nullptr;
_isModal = isDialog;

WindowBaseImpl::Show(activate, isDialog);

Expand Down Expand Up @@ -97,7 +97,7 @@

_parent = cparent;

_isDialog = _parent != nullptr;
_isModal = _parent != nullptr;

if(_parent != nullptr && Window != nullptr){
// If one tries to show a child window with a minimized parent window, then the parent window will be
Expand All @@ -123,7 +123,7 @@
{
if ([Window isVisible] && ![Window isMiniaturized])
{
if(IsDialog())
if(IsModal())
{
Activate();
}
Expand All @@ -150,7 +150,7 @@
{
for(auto iterator = _children.begin(); iterator != _children.end(); iterator++)
{
if((*iterator)->IsDialog())
if((*iterator)->IsModal())
{
return false;
}
Expand Down Expand Up @@ -569,8 +569,12 @@
}
}

bool WindowImpl::IsDialog() {
return _isDialog;
bool WindowImpl::IsModal() {
return _isModal;
}

bool WindowImpl::IsOwned() {
return _parent != nullptr;
}

NSWindowStyleMask WindowImpl::GetStyle() {
Expand Down Expand Up @@ -599,7 +603,7 @@
break;
}

if (!IsDialog()) {
if (!IsOwned()) {
s |= NSWindowStyleMaskMiniaturizable;
}

Expand Down