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

Fix subdialogs of the ISO props dialog... sort of #2509

Merged
merged 1 commit into from Jun 8, 2015

Conversation

comex
Copy link
Contributor

@comex comex commented Jun 3, 2015

On OS X, if you close a subdialog of the ISO Properties dialog, such as
the one to add a new AR code, the main Dolphin window would magically
get raised above ISO Properties. This is confusing, to say the least;
when I encountered this the other day, I thought the dialog was actually
getting closed.

I think the diagnosis looks like this:
Cocoa expects NSPanel (not to be confused with wxPanel) to be for things
like find dialogs, font dialogs with the little title bars, sheets, etc.
See:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/WinPanel/Concepts/ChangingMainKeyWindow.html
Therefore, NSPanels return NO for canBecomeMainWindow, which is
documented; and when [NSWindow orderOut:] is called to hide a window,
Cocoa seems to want to make the window it focuses in its place a main
window, which, as far as I can tell, is not. So if the next highest
window is a panel, it gets skipped over. (I tested this by overriding
wxNSPanel's canBecomeMainWindow to return YES, in which case the right
window gets focused, but this isn't a correct fix.)

The ISO Properties dialog does have grounds to be a dialog/panel - the
close button, whose positioning is provided by the wxDialog class. This
is arguably simply a roundabout discovery that our UI sucks for an OS X
app and that to be consistent with other nonmodal preferences dialogs,
it shouldn't have such a button on OS X (though ESC to close is still
kosher). However, I'm not willing to make that change right now, so...

Hack around the problem by calling Raise (on this) after each call to
ShowModal in CISOProperties. The resulting behavior is slightly
glitchy, and I'd like to revisit it, but for now it fixes the issue.

On OS X, if you close a subdialog of the ISO Properties dialog, such as
the one to add a new AR code, the main Dolphin window would magically
get raised above ISO Properties.  This is confusing, to say the least;
when I encountered this the other day, I thought the dialog was actually
getting closed.

I *think* the diagnosis looks like this:
Cocoa expects NSPanel (not to be confused with wxPanel) to be for things
like find dialogs, font dialogs with the little title bars, sheets, etc.
See:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/WinPanel/Concepts/ChangingMainKeyWindow.html
Therefore, NSPanels return NO for canBecomeMainWindow, which is
documented; and when [NSWindow orderOut:] is called to hide a window,
Cocoa seems to want to make the window it focuses in its place a main
window, which, as far as I can tell, is not.  So if the next highest
window is a panel, it gets skipped over.  (I tested this by overriding
wxNSPanel's canBecomeMainWindow to return YES, in which case the right
window gets focused, but this isn't a correct fix.)

The ISO Properties dialog does have grounds to be a dialog/panel - the
close button, whose positioning is provided by the wxDialog class.  This
is arguably simply a roundabout discovery that our UI sucks for an OS X
app and that to be consistent with other nonmodal preferences dialogs,
it shouldn't have such a button on OS X (though ESC to close is still
kosher).  However, I'm not willing to make that change right now, so...

Hack around the problem by calling Raise (on this) after each call to
ShowModal in CISOProperties.  The resulting behavior is slightly
glitchy, and I'd like to revisit it, but for now it fixes the issue.
@BhaaLseN
Copy link
Member

BhaaLseN commented Jun 3, 2015

If both solutions are rather hacky, why not choose the shorter canBecomeMainWindow one? Or does that come with other issues that Raise wont have?

@comex
Copy link
Contributor Author

comex commented Jun 4, 2015

The obvious way to do it would require modifying wx. Can be done in a more hacky way from elsewhere, but I'd rather wait until I can make it stop being a dialog altogether - in the meantime, the symptoms of this issue are pretty bad for the 3 users on OS X, so...

@comex
Copy link
Contributor Author

comex commented Jun 6, 2015

The bomb is now set with a fuse of 3 days. If it reaches 0, I merge regardless of review. Therefore, please review!

@endrift
Copy link
Contributor

endrift commented Jun 8, 2015

Given that I didn't realize this PR existed (it wasn't mentioned in https://code.google.com/p/dolphin-emu/issues/detail?id=8572, which @JMC47 prodded me to fix), I wrote #2556 which is basically exactly the same patch, give or take some minutiae, and had a very similar analysis of the bug. This gets my +1, although a wxMac bug report should probably be filed regardless. (Also while I was in the code I fixed a few minor issues, but those shouldn't present an issue if they don't get merged.)

Sonicadvance1 added a commit that referenced this pull request Jun 8, 2015
Fix subdialogs of the ISO props dialog... sort of
@Sonicadvance1 Sonicadvance1 merged commit 881f6db into dolphin-emu:master Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants