Revision: 4977 http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4977&view=rev Author: ossman_ Date: 2012-08-27 14:40:51 +0000 (Mon, 27 Aug 2012) Log Message: ----------- The OS X keyboard grabbing code needs to be multi-head aware to function properly.
Modified Paths: -------------- trunk/vncviewer/DesktopWindow.cxx trunk/vncviewer/cocoa.h trunk/vncviewer/cocoa.mm Modified: trunk/vncviewer/DesktopWindow.cxx =================================================================== --- trunk/vncviewer/DesktopWindow.cxx 2012-08-27 13:02:47 UTC (rev 4976) +++ trunk/vncviewer/DesktopWindow.cxx 2012-08-27 14:40:51 UTC (rev 4977) @@ -439,7 +439,13 @@ #elif defined(__APPLE__) int ret; - ret = cocoa_capture_display(this); + ret = cocoa_capture_display(this, +#ifdef HAVE_FLTK_FULLSCREEN_SCREENS + fullScreenAllMonitors +#else + false +#endif + ); if (ret != 0) vlog.error(_("Failure grabbing keyboard")); #else Modified: trunk/vncviewer/cocoa.h =================================================================== --- trunk/vncviewer/cocoa.h 2012-08-27 13:02:47 UTC (rev 4976) +++ trunk/vncviewer/cocoa.h 2012-08-27 14:40:51 UTC (rev 4977) @@ -19,7 +19,7 @@ #ifndef __VNCVIEWER_COCOA_H__ #define __VNCVIEWER_COCOA_H__ -int cocoa_capture_display(Fl_Window *win); +int cocoa_capture_display(Fl_Window *win, bool all_displays); void cocoa_release_display(Fl_Window *win); #endif Modified: trunk/vncviewer/cocoa.mm =================================================================== --- trunk/vncviewer/cocoa.mm 2012-08-27 13:02:47 UTC (rev 4976) +++ trunk/vncviewer/cocoa.mm 2012-08-27 14:40:51 UTC (rev 4977) @@ -24,16 +24,37 @@ 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 @@ int newlevel; if (captured) - CGDisplayRelease(kCGDirectMainDisplay); + CGReleaseAllDisplays(); captured = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Tigervnc-commits mailing list Tigervnc-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-commits