Swift OSX video app fullscreen with preference window in front - please help

Hi All,


I'm making a small video app for an artist for gallery use. All is going well but I have a small problem with the fullscreen mode in swift (Ive tested when not in fullscreen mode and all functions well as expected.


I use this code to enter fullscreen at startup:


    func fullscreen(){
        let presOptions: NSApplicationPresentationOptions = ([.autoHideMenuBar
            ,.autoHideDock])
      
        let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions :
            NSNumber(value: presOptions.rawValue)]
      
        self.view.enterFullScreenMode(NSScreen.main()!, withOptions:optionsDictionary)
        self.view.wantsLayer = true
    }


This works well but then there is a preferences window which the user can open and which appears in front of the fullscreen video (this also works but only if I set the NSApplicationPresentationOptions as above - not in default fullscreen). The problem comes when the user closes the preferences window as a small gray window appears above the fullscreen video. See photo:


Also, when the app is in fullscreen and you go into mission control mode on mac you can see multiple windows such as;



This is a more of an annoying problem as it requires more from the user when setting preferences than I would hope - the app will be used by gallerists and the collectors who by the work of the artist so it needs to be as user friendly as possible.


Thanks in advance for your help with this.


Sam

I think

let presOptions: NSApplicationPresentationOptions = ([.autoHideMenuBar  ,.autoHideDock])

is not correct, because of parenthesis

Could look at h ttps://github.com/WatershedArts/NSPresentationOptionsTest/blob/master/NSPresentationOptionsExample/ViewController.swift

for other details.


I wrote this, seems to work (at least bring full screen and hides menubar)

    override func viewDidAppear() {
        let presOptions: NSApplicationPresentationOptions = [.autoHideDock, .autoHideMenuBar]       
        let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions :
            NSNumber(value: presOptions.rawValue)]
      
        self.view.enterFullScreenMode(NSScreen.main()!, withOptions:optionsDictionary)
        self.view.wantsLayer = true
    }

Thanks Claude, but unfortunately I get the same results with this (seems youre right that those brackets are unecessary!).


To be clear, the fullscreen works fine, the problem appears when I close another window (preferences for the app) which was in front of the fullscreen video. In this case I get an empty window which appears and needs to be quit by the user to see the film.


Also, its apparently that when I use this code to set the app to fullscreen it seems to create a bunch of other windows which dont exist without the fullscreen (I can see them all and select them from the misson control.


Ive just realised that the images I tried to attach didnt work so I hope I have well explained. If not I can put them online somewhere else for you to see

You get an empty window which appears

What is this window ? Is it your app window or something else ?

and needs to be quit by the user to see the film

Does the film stop playing ? Or even closes ?


Also, its apparently that when I use this code to set the app to fullscreen it seems to create a bunch of other windows which dont exist without the fullscreen (I can see them all and select them from the misson control.


Can you identify what those windows are ? They are problem other apps' windows ?


Have you defined

func windowDidBecomeMain(notification: NSNotification) { }

That could be a place to activate video ?


and


func windowDidResignMain(notification: NSNotification) { }

Hi,


I think that the other windows are duplicates of the app windows. as they are the same size as the video window and the preferences window. They are definitely from this app and not others.


It doesnt effect the playing of the film - that works fine, its just as if a different window (which shouldnt exist in the first place) is brought to the forefront after closing the prefs window.


No i havent defined those functions you mention - could you explain how /when they should be used and what they do ?


As mentioned this app is really simple - it should just have one window playing the film in fullscreen and then one preferences window which you can call from the menu bar. This all works as expected when the app is not in fullscreen but actually it has to be automatically in fullscreen all the time due to the nature of the project.


Whilst Im here - did you by any chance see the other question I posted regarding the video controls on yosemite ? I have a problem where on yosemite the play/pause button is missing in fullscreen mode - it seems all of my problems are with this fullscreen so Im thinking that I havent coded this part correctly. ps this is my first app in Swift so thanks for being patient with my novice questions!


Sam

Hi,

Ive just been trying a few things and have found that if I replace the fullscreen code with just this:


view.window!.toggleFullScreen(self)


...it seems to work how I would like without this problem of duplicate windows. I will send it to the artist now for him to test on a yosemite OS to see if I still have this problem with the controls as mentioned above.

Yes, window-based fullscreen is much easier to deal with than the older view-based kind. Since it's a normal window it plays nicely with your other windows and the Mission Control Spaces. View-style came out in 10.5; I did investigate it briefly but it was far too limited for my needs. I think it was primarily meant for simple kiosk-style apps, like touch-screen entry systems in a store, where the user isn't meant to ever interact with anything else on the Mac.

Yes its way easier however Ive found that the window-based fullscreen doesnt work at all for me on Yosemite 😟


I will use this for all other OS but I will need to stick with view-based fullscreen for Yosemite so I continue to have all of the problems mentioned above. Does anyone have any other suggestions.


The problems are with the duplicates of views when in fullscreen and the fact that the video controls change in fullscreen making the play/pause button unaccessable.

... or is there a way to make the window-based fullscreen work on yosemite ??


as mentioned Im using this line of code for fullscreen

view.window!.toggleFullScreen(self)
Swift OSX video app fullscreen with preference window in front - please help
 
 
Q