Permalink
Browse files

fixed an issue where an app was able to enter fullscreen only once

  • Loading branch information...
1 parent 32c5b79 commit 55e645fee6fefc4650c34ca10ef3940214487b7e @rsms committed May 20, 2010
Showing with 14 additions and 5 deletions.
  1. +1 −0 resources/index.html
  2. +11 −5 src/CUApp.m
  3. +2 −0 src/CUWin.m
View
@@ -119,6 +119,7 @@
</p>
<p>
<button onclick="demo_animation()">Run animated demo</button>
+ <button onclick="Win.fullscreen=(Win.fullscreen ? false : true)">Toggle fullscreen</button>
</p>
<hr>
<p>
View
@@ -267,27 +267,33 @@ -(void)setFullscreen:(BOOL)b {
-(BOOL)enterFullscreen:(CGDirectDisplayID)screenID {
if (fullscreen == -1) {
- fullscreen = screenID;
- if (CGDisplayCapture(fullscreen) == kCGErrorSuccess)
+ if (CGDisplayCapture(screenID) == kCGErrorSuccess) {
+ fullscreen = screenID;
return YES;
- fullscreen = -1;
+ }
+ NSLog(@"Failed to capture screen (enter fullscreen)");
CUJS_THROW(@"Failed to capture screen (enter fullscreen)");
+ } else {
+ NSLog(@"Avoided entering fullscreen (already in fullscreen mode)");
}
return NO;
}
-(CGDirectDisplayID)exitFullscreen {
+ CGDirectDisplayID sid = fullscreen;
if (fullscreen != -1 && [self exitFullscreen:fullscreen]) {
- CGDirectDisplayID sid = fullscreen;
fullscreen = -1;
return sid;
}
return -1;
}
-(BOOL)exitFullscreen:(CGDirectDisplayID)screenID {
- if (CGDisplayRelease(screenID) == kCGErrorSuccess)
+ if (CGDisplayRelease(screenID) == kCGErrorSuccess) {
+ if (screenID == fullscreen)
+ fullscreen = -1;
return YES;
+ }
NSLog(@"Failed to release screen %d (exit fullscreen) -- terminating application", fullscreen);
CUJS_THROW(@"Failed to release screen %d (exit fullscreen) -- terminating application", fullscreen);
[NSApp terminate:self];
View
@@ -65,6 +65,7 @@ -(BOOL)fullscreen {
-(void)setFullscreen:(BOOL)b {
if (b && fullscreen == -1) {
+ NSLog(@"entering fullscreen");
fullscreen = CGMainDisplayID();
if ([win.app enterFullscreen:fullscreen]) {
CUJS_DISPATCH_EVENT(windowDidEnterFullscreen, [[win.webView mainFrame] DOMDocument]);
@@ -78,6 +79,7 @@ -(void)setFullscreen:(BOOL)b {
}
}
else if (fullscreen != -1 && [win.app exitFullscreen:fullscreen]) {
+ NSLog(@"exiting fullscreen");
CUJS_DISPATCH_EVENT(windowDidExitFullscreen, [[win.webView mainFrame] DOMDocument]);
fullscreen = -1;
[win setLevel:_levelBeforeFullscreen];

0 comments on commit 55e645f

Please sign in to comment.