diff options
Diffstat (limited to 'vncviewer/cocoa.mm')
-rw-r--r-- | vncviewer/cocoa.mm | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm index 6300d3c0..6872b230 100644 --- a/vncviewer/cocoa.mm +++ b/vncviewer/cocoa.mm @@ -24,15 +24,36 @@ static bool captured = false; -int cocoa_capture_display(Fl_Window *win) +int cocoa_capture_display(Fl_Window *win, bool all_displays) { NSWindow *nsw; nsw = (NSWindow*)fl_xid(win); if (!captured) { - if (CGDisplayCapture(kCGDirectMainDisplay) != kCGErrorSuccess) - return 1; + if (all_displays) { + if (CGCaptureAllDisplays() != kCGErrorSuccess) + return 1; + } else { + CGDirectDisplayID displays[16]; + CGDisplayCount count; + int index; + + if (CGGetActiveDisplayList(16, displays, &count) != kCGErrorSuccess) + return 1; + + if (count != Fl::screen_count()) + return 1; + +#ifdef HAVE_FLTK_FULLSCREEN_SCREENS + index = Fl::screen_num(win->x(), win->y(), win->w(), win->h()); +#else + index = 0; +#endif + + if (CGDisplayCapture(displays[index]) != kCGErrorSuccess) + return 1; + } captured = true; } @@ -51,7 +72,7 @@ void cocoa_release_display(Fl_Window *win) int newlevel; if (captured) - CGDisplayRelease(kCGDirectMainDisplay); + CGReleaseAllDisplays(); captured = false; |