在Cocoa应用程序中,有没有办法判断另一个应用程序当前是否处于全屏模式?
我的应用程序配置为显示在所有空间上并侦听mouseEntered事件以将自己命令到前端.
问题是当另一个应用程序处于全屏模式并且用户碰巧将鼠标移动到我的应用程序窗口所在的黑色区域时,它将被带到前面(多个监视器发生).
我只看到了上面[self setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces];启用的行为.
这是我的应用程序的其他相关代码.
- (void) mouseEntered:(NSEvent *)theEvent
{
// Don't do this when another app is in full screen mode:
[[self window] orderFront:self];
}
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中创建了主窗口以进行这些设置:
[self setLevel:kCGDesktopWindowLevel + 1];
[self setCollectionBehavior:
(NSWindowCollectionBehaviorCanJoinAllSpaces |
NSWindowCollectionBehaviorStationary |
NSWindowCollectionBehaviorIgnoresCycle)];
Run Code Online (Sandbox Code Playgroud)
这是一个非常自定义的窗口,可以在桌面上方浮动.
另外,它是一个菜单栏应用程序(LSUIElement).
好吧,所以如果出现问题,我需要显示警报.我是这样做的:
NSAlert *alert = [NSAlert alertWithMessageText:@""
defaultButton:@""
alternateButton:@""
otherButton:@""
informativeTextWithFormat:@""];
[alert runModal];
Run Code Online (Sandbox Code Playgroud)
我当然填写了按钮和其他文字.
这是我的问题:当我的应用程序当前不是关键应用程序,并且弹出此警报时,它不是关键窗口.像这样:

看看窗口是如何选择的?有没有办法改变我的整个应用程序窗口级别?谢谢!