سؤال

I have a full screen application that opens an NSWindow that will cover all available displays.

NSRect screenArea = {{0,0},{0,0}};
for(int i=0; i<[[NSScreen screens] count]; i++) {
    screenArea = NSUnionRect(screenArea, [[[NSScreen screens] objectAtIndex:i] frame]);
}

self.fullScreenView = [[MDScreenShotImageView alloc] initWithFrame:screenArea];
[self.fullScreenView setDelegate:self];

self.fullScreenWindow = [[MDWindow alloc] initWithContentRect:screenArea styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
[self.fullScreenWindow setDelegate:self];
[self.fullScreenWindow setReleasedWhenClosed:NO];
[self.fullScreenWindow setMovableByWindowBackground:NO];
[self.fullScreenWindow setBackgroundColor:[NSColor whiteColor]];
[self.fullScreenWindow setLevel:NSScreenSaverWindowLevel];
[self.fullScreenWindow setOpaque:YES];
[self.fullScreenWindow setHasShadow:NO];
[self.fullScreenWindow setBackgroundColor:[NSColor blackColor]];
[self.fullScreenWindow setContentView:self.fullScreenView];

In Mountain Lion this worked great! I had a full screen window covering both my displays (which are set side by side in the Displays System Preference pane). In Mavericks this does not work any more. OSX will automatically cut my NSWindow so that only the part on the largest screen will be visible. The part on the other screen is cut off and nothing is visible on this screen. I have drawer crossing lines on the NSWindow to illustrate below: enter image description here

I know that this is a thing that changed in Mavericks. I can get back the old behavior by going into System Preferences, Mission Control and unpicking "Displays Have separate Spaces". enter image description here

But I don't want to force my users to do this since it would cause a very bad user experience. I really need a full screen window spanning all displays, but I don't want to force the users to enable the option. Is there a workaround for this? enter image description here

UPDATE 1: Thanks Will Shipley for the suggestion to have two windows. I have tried this as following:

NSRect rect1 = [[[NSScreen screens] objectAtIndex:0] frame];
NSRect rect2 = [[[NSScreen screens] objectAtIndex:1] frame];

MDScreenShotImageView *screenShotImageView = [[MDScreenShotImageView alloc] initWithFrame:rect1];
self.fullScreenView = screenShotImageView;
[self.fullScreenView setDelegate:self];

MDWindow *window = [[MDWindow alloc] initWithContentRect:rect1 styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
self.fullScreenWindow = window;

[self.fullScreenWindow setDelegate:self];
[self.fullScreenWindow setReleasedWhenClosed:NO];
[self.fullScreenWindow setMovableByWindowBackground:NO];
[self.fullScreenWindow setBackgroundColor:[NSColor whiteColor]];
[self.fullScreenWindow setLevel:NSScreenSaverWindowLevel];
[self.fullScreenWindow setOpaque:YES];
[self.fullScreenWindow setHasShadow:NO];
[self.fullScreenWindow setBackgroundColor:[NSColor blackColor]];
[self.fullScreenWindow setContentView:self.fullScreenView];


MDScreenShotImageView *screenShotImageView2 = [[MDScreenShotImageView alloc] initWithFrame:rect2];
self.fullScreenView2 = screenShotImageView2;
[self.fullScreenView2 setDelegate:self];

MDWindow *window2 = [[MDWindow alloc] initWithContentRect:rect2 styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
self.fullScreenWindow2 = window2;

[self.fullScreenWindow2 setDelegate:self];
[self.fullScreenWindow2 setReleasedWhenClosed:NO];
[self.fullScreenWindow2 setMovableByWindowBackground:NO];
[self.fullScreenWindow2 setBackgroundColor:[NSColor whiteColor]];
[self.fullScreenWindow2 setLevel:NSScreenSaverWindowLevel];
[self.fullScreenWindow2 setOpaque:YES];
[self.fullScreenWindow2 setHasShadow:NO];
[self.fullScreenWindow2 setBackgroundColor:[NSColor blackColor]];
[self.fullScreenWindow2 setContentView:self.fullScreenView2];

[self.fullScreenWindow display];
[self.fullScreenWindow2 display];

Unfortunately I cannot get this to work, maybe I am doing something incorrectly but the window is only displayed on one screen.

هل كانت مفيدة؟

المحلول 2

Why can’t you just create two windows?

نصائح أخرى

Short answer: No

Like most things to do with Spaces Apple have decided the choice between the two modes is up to the user and not applications, so there is no API to change it or allow windows to span screens when the user has set the screens to be independent. What you can do is determine the mode, advise the user, and select the largest screen available if your users choose to run in independent screen mode.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top