I don't quit understand what you are suggesting here. And the original
code here is not to clear by itself.
I think we may have four cases that this code needs to handle: The
application may be active or not and it may be hidden or not.
In all these four cases there may be a suitable window to make key or
not.
In the end we expect that the application is activated unhidden and a
suitable window made key.
We already have a call to unhide: here, this will activate the
application if it isn't active already.
case active + unhidden
unhide: gets called, but nothing happens
case active + hidden
windows get reorder, unhide: gets called, hidden windows get displayed
case inactive + unhidden
unhide gets called, this calls activateIgnoringOtherApps:
case inactive + hidden
windows get reorder, unhide: gets called, hidden windows get displayed,
activateIgnoringOtherApps: gets called
As far as I can see this is OK. It may not be the best way to structure
the code. I think it would be better to put the windows reordering into
unhideWithoutActivation. But which part of this is causing you
problems.
Or is it only the issue, when there is no suitable key window? This
really is a problem, but moving or changing code in mouseEvent: wont
solve it.