Putting up a full screen window

  • Hi,

    I've found a tutorial for creating a full screen window after
    capturing the screen, but I cannot get it to work... can anyone find
    the problem with my code? I'm really frustrated with it now! :-)
    I don't think that it is setting the window up correctly...

    - (void)applicationDidFinishLaunching:(NSNotification *)notification
    {
        int windowLevel;
        NSRect screenRect;

    // Capture the main display
        if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
            NSLog( @"Couldn't capture the main display!" );
            // Note: you'll probably want to display a proper error
    dialog here
        }

    // Get the shielding window level
        windowLevel = CGShieldingWindowLevel();

    // Get the screen rect of our main display
        screenRect = [[NSScreen mainScreen] frame];

    // Put up a new window
        mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                                styleMask:NSBorderlessWindowMask
                                                 backing:NSBackingStoreBuffered
                                                    defer:NO screen:[NSScreen mainScreen]];
    [mainWindow setBackgroundColor:[NSColor blackColor]];

    // Load our content view
        [slideShowPanel setFrame:screenRect display:YES];
        [mainWindow setContentView:[slideShowPanel contentView]];
    [mainWindow setLevel:windowLevel];

    // Show the window.
    [mainWindow makeKeyAndOrderFront:self];

    }
  • On Thursday, October 05, 2006, at 02:23PM, Adam Radestock <raddish...> wrote:

    > I've found a tutorial for creating a full screen window after
    > capturing the screen, but I cannot get it to work... can anyone find
    > the problem with my code? I'm really frustrated with it now! :-)
    > I don't think that it is setting the window up correctly...

    First question to ask is whether or not your full screen window plans to contain standard controls (i.e. buttons, etc.) or even controls of your own creation (subclass of NSControl, etc.)

    If the answer to that is 'yes', then completely avoid that sample code.  In fact, I wish that sample would finally be updated with notes on why it can be potentially dangerous.

    For an answer as to the why, search this list archives.  I know I've commented on it in the past.  For the original Apple supplied reason why it's bad, search the quartz-dev archives.

    Now then, if you need to go full screen and work with standard controls and events...

    * Use the SetSystemUIMode API to hide Dock and/or menu bar.
    * Use NSScreen APIs to put up 'blanking' windows (if needed) on all screens
    * Create a borderless window for your 'content' window and place it as needed on the desired screen.

    Note that if you go the blanking window route, you can set the content window as a child window of the blanking window to prevent illegal window ordering.

    --
    Rick Sharp
    Instant Interactive(tm)
  • Maybe some background is in order... I am new to Cocoa programming,
    most of my coding experience being with REALBasic... I'm trying to
    write an application to run Quartz Compositions on two projection
    screens in a night club. I need the main display (in this particular
    case, the MacBook Pro's internal screen) to be as normal, as I am
    going to have the controls for the visuals on this screen, but the
    second display, which runs to the projectors, I need to capture and
    use exclusively for my app (even to the extent of layering my window
    above the NSScreenSaverLevel).
    I have thought about using a QCPatchController and QCView to display
    the various compositions, simply because that route offers Cocoa
    Binding relatively easily, which means less glue code for me and a
    faster development time.
    Is this possible? I have had no end of grief trying to get this to
    work full screen - I just can't seem to get the full screen window to
    work...
    Can you suggest some leads that I can follow up?

    Thank you for all your help,

    Adam Radestock
    Glass Monkey Design Co.

    On 5 Oct 2006, at 9:16 pm, Ricky Sharp wrote:

    >
    > On Thursday, October 05, 2006, at 02:23PM, Adam Radestock
    > <raddish...> wrote:
    >
    >> I've found a tutorial for creating a full screen window after
    >> capturing the screen, but I cannot get it to work... can anyone find
    >> the problem with my code? I'm really frustrated with it now! :-)
    >> I don't think that it is setting the window up correctly...
    >
    > First question to ask is whether or not your full screen window
    > plans to contain standard controls (i.e. buttons, etc.) or even
    > controls of your own creation (subclass of NSControl, etc.)
    >
    > If the answer to that is 'yes', then completely avoid that sample
    > code.  In fact, I wish that sample would finally be updated with
    > notes on why it can be potentially dangerous.
    >
    > For an answer as to the why, search this list archives.  I know
    > I've commented on it in the past.  For the original Apple supplied
    > reason why it's bad, search the quartz-dev archives.
    >
    > Now then, if you need to go full screen and work with standard
    > controls and events...
    >
    > * Use the SetSystemUIMode API to hide Dock and/or menu bar.
    > * Use NSScreen APIs to put up 'blanking' windows (if needed) on all
    > screens
    > * Create a borderless window for your 'content' window and place it
    > as needed on the desired screen.
    >
    > Note that if you go the blanking window route, you can set the
    > content window as a child window of the blanking window to prevent
    > illegal window ordering.
    >
    > --
    > Rick Sharp
    > Instant Interactive(tm)
    >
    >
    >
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today