Working on full screen mac app. I am using webView to show some weather related information. Not able to show the same webView content to all connected monitor screens like it appears on the main screen.(not by using Airplay-mirroring
).
Currently i am able to set the wallpaper of other displays only. by using ([NSScreen screens])
Could someone please advise me something? Thanks.
It was so simple. I searched about many related things like "CGDisplayCapture" and "CGShieldingWindowLevel()" but there was no need of that in my case.
1.. Below line will give you all connected screens
for (NSScreen *screen in [NSScreen screens]) { }
2.. Now find screen size, because connected displays may have different screen size then the current screen. And alloc a new window with current screen and current screen size as parameter--
// Draw a new window to fill the screen
NSRect screenRect = CGRectMake(0, 0, screen.frame.size.width , screen.frame.size.height);
secondaryMonitorWindow = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:screen];
3.. In my case desktop icons should be visible over the window so i set the window level as kCGDesktopWindowLevel. And made this window "makeKeyAndOrderFront".
4.. We can not add any view as subview to multiple windows. And new window needs same view as my mainscreen window has. So i created copy of the same view with this --
id copyOfView = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:self.webView]];
5.. Assign same screensize frame to this view and added this to the new window.
[copyOfView setFrame:screenRect];
[secondaryMonitorWindow.contentView addSubview:(WebView*)copyOfView];
And its done. Now to same change to both displays, one has to make change for both window objects.