summaryrefslogtreecommitdiffstats
path: root/vncviewer/cocoa.mm
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-06-14 13:36:57 +0000
committerPierre Ossman <ossman@cendio.se>2011-06-14 13:36:57 +0000
commita4f0f181b3ed0a0906083c453632e39e19472135 (patch)
treebdb1d4c95eb72e7f6be26db3826b20c8c461f189 /vncviewer/cocoa.mm
parentdb7091c0f48c5b6a4adaf1701a3a9dcf4b32daa1 (diff)
downloadtigervnc-a4f0f181b3ed0a0906083c453632e39e19472135.tar.gz
tigervnc-a4f0f181b3ed0a0906083c453632e39e19472135.zip
Implement a more robust method to handle the keyboard grab/focus voodoo as
it didn't catch some cases on OS X. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4496 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/cocoa.mm')
-rw-r--r--vncviewer/cocoa.mm18
1 files changed, 13 insertions, 5 deletions
diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm
index 589da2d9..6300d3c0 100644
--- a/vncviewer/cocoa.mm
+++ b/vncviewer/cocoa.mm
@@ -22,19 +22,24 @@
#import <Cocoa/Cocoa.h>
+static bool captured = false;
+
int cocoa_capture_display(Fl_Window *win)
{
NSWindow *nsw;
nsw = (NSWindow*)fl_xid(win);
- // Already captured?
+ if (!captured) {
+ if (CGDisplayCapture(kCGDirectMainDisplay) != kCGErrorSuccess)
+ return 1;
+
+ captured = true;
+ }
+
if ([nsw level] == CGShieldingWindowLevel())
return 0;
- if (CGDisplayCapture(kCGDirectMainDisplay) != kCGErrorSuccess)
- return 1;
-
[nsw setLevel:CGShieldingWindowLevel()];
return 0;
@@ -45,7 +50,10 @@ void cocoa_release_display(Fl_Window *win)
NSWindow *nsw;
int newlevel;
- CGDisplayRelease(kCGDirectMainDisplay);
+ if (captured)
+ CGDisplayRelease(kCGDirectMainDisplay);
+
+ captured = false;
nsw = (NSWindow*)fl_xid(win);