Re: How to check for full-screen apps, robustly?
Thanks a million! (and sorry for the late response) For the record (i.e., Google's databases), in case somebody else googles for this: this seems to recognize full-screen windows even on Mac's with a notch: if ( win_rect.size.width >= mainScreen.visibleFrame.size.width && win_rect.size.height >= mainScreen.visibleFrame.size.height ) Best regards, Gabriel > On 19. Aug 2023, at 20:02, Angela Brett wrote: > >> >> >> Now, this does not work any more on Mac's with "the notch". >> At least, the Quicktime full-screen window, and a youtube video playing in >> Safari in full-screen, is smaller than the mainScreen.frame.size . > > Have you tried using mainScreen.visibleFrame, or adjusting mainScreen.frame > with mainScreen.safeAreaInsets? I haven’t tried it but I would hope those > would give the right ‘fullscreen’ sizes for any current or future screen > shape. > > > Angela Brett (she/her) > http://angelastic.com > ang...@angelastic.com > > > > > smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to check for full-screen apps, robustly?
> > > Now, this does not work any more on Mac's with "the notch". > At least, the Quicktime full-screen window, and a youtube video playing in > Safari in full-screen, is smaller than the mainScreen.frame.size . Have you tried using mainScreen.visibleFrame, or adjusting mainScreen.frame with mainScreen.safeAreaInsets? I haven’t tried it but I would hope those would give the right ‘fullscreen’ sizes for any current or future screen shape. Angela Brett (she/her) http://angelastic.com ang...@angelastic.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to check for full-screen apps, robustly?
Thanks a lot for the quick response. I was thinking of the styleMask, too, but IIUC, the documentation of CGWindowListCopyWindowInfo says that I get only Required Window List Keys and Optional Window List Keys, and the styleMask is not part of those. Best regards, Gabriel smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to check for full-screen apps, robustly?
How can I robustly check in my app whether or not there is any other window running in full-screen? I would like to prevent my app from going full-screen if another app is currently running in full-screen. (For instance, when the user is watching a video in Quicktime Player or Safari in full-screen, or is having a video call, then they probably don't want my app to interfere.) So far, I did that with the following lines of code (omitting some minor details): guard let winArray = CGWindowListCopyWindowInfo(options, kCGNullWindowID) as? [[ String : Any]] else { .. } for winInfo in winArray { guard let boundsDict = winInfo[kCGWindowBounds as String] as! CFDictionary? else { .. } guard let win_rect = CGRect.init( dictionaryRepresentation: boundsDict ) if ( __CGSizeEqualToSize( win_rect.size, mainScreen.frame.size) ) .. found full-screen window .. } Now, this does not work any more on Mac's with "the notch". At least, the Quicktime full-screen window, and a youtube video playing in Safari in full-screen, is smaller than the mainScreen.frame.size . I guess I could detect whether or not it's a Mac with the notch, and use a smaller mainScreen.frame.size accordingly; but I am pretty sure this would break with the next Mac models again. So, I am looking for something more future-proof. Best regards, Gabriel smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com