WebVideoFullscreenHUDWindowController.mm 19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * Copyright (C) 2009 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
13 14 15 16 17 18 19 20 21 22
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 24 25 26 27 28 29
 */

#if ENABLE(VIDEO)

#import "WebVideoFullscreenHUDWindowController.h"

#import "WebKitSystemInterface.h"
30
#import "WebTypesInternal.h"
31 32 33
#import <JavaScriptCore/RetainPtr.h>
#import <JavaScriptCore/UnusedParam.h>
#import <WebCore/HTMLMediaElement.h>
34

35
using namespace WebCore;
36
using namespace std;
37

38 39 40 41 42 43 44
static inline CGFloat webkit_CGFloor(CGFloat value)
{
    if (sizeof(value) == sizeof(float))
        return floorf(value);
    return floor(value);
}

45 46 47 48 49 50 51 52 53 54 55
#define HAVE_MEDIA_CONTROL (!defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD))

@interface WebVideoFullscreenHUDWindowController (Private) <NSWindowDelegate>

- (void)updateTime;
- (void)timelinePositionChanged:(id)sender;
- (float)currentTime;
- (void)setCurrentTime:(float)currentTime;
- (double)duration;

- (void)volumeChanged:(id)sender;
56
- (double)maxVolume;
57 58
- (double)volume;
- (void)setVolume:(double)volume;
59 60
- (void)decrementVolume;
- (void)incrementVolume;
61

62
- (void)togglePlaying:(id)sender;
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
- (BOOL)playing;
- (void)setPlaying:(BOOL)playing;

- (void)rewind:(id)sender;
- (void)fastForward:(id)sender;

- (NSString *)remainingTimeText;
- (NSString *)elapsedTimeText;

- (void)exitFullscreen:(id)sender;
@end

@interface WebVideoFullscreenHUDWindow : NSWindow
@end

@implementation WebVideoFullscreenHUDWindow

80
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
{
    UNUSED_PARAM(aStyle);
    self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];
    if (!self)
        return nil;

    [self setOpaque:NO];
    [self setBackgroundColor:[NSColor clearColor]];
    [self setLevel:NSPopUpMenuWindowLevel];
    [self setAcceptsMouseMovedEvents:YES];
    [self setIgnoresMouseEvents:NO];
    [self setMovableByWindowBackground:YES];
    [self setHidesOnDeactivate:YES];

    return self;
}

- (BOOL)canBecomeKeyWindow
{
    return YES;
}

- (void)cancelOperation:(id)sender
{
    [[self windowController] exitFullscreen:self];
}

- (void)center
{
    NSRect hudFrame = [self frame];
    NSRect screenFrame = [[NSScreen mainScreen] frame];
    [self setFrameTopLeftPoint:NSMakePoint(screenFrame.origin.x + (screenFrame.size.width - hudFrame.size.width) / 2,
                                           screenFrame.origin.y + (screenFrame.size.height - hudFrame.size.height) / 6)];
}

- (void)keyDown:(NSEvent *)event
{
    [super keyDown:event];
    [[self windowController] fadeWindowIn];
}

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
- (BOOL)resignFirstResponder
{
    return NO;
}

- (BOOL)performKeyEquivalent:(NSEvent *)event
{
    // Block all command key events while the fullscreen window is up.
    if ([event type] != NSKeyDown)
        return NO;
    
    if (!([event modifierFlags] & NSCommandKeyMask))
        return NO;
    
    return YES;
}

139 140 141 142 143 144 145 146 147 148 149
@end

static const CGFloat windowHeight = 59;
static const CGFloat windowWidth = 438;

static const NSTimeInterval HUDWindowFadeOutDelay = 3;

@implementation WebVideoFullscreenHUDWindowController

- (id)init
{
150
    NSWindow *window = [[WebVideoFullscreenHUDWindow alloc] initWithContentRect:NSMakeRect(0, 0, windowWidth, windowHeight)
151 152 153 154 155 156 157 158 159 160 161 162 163
                            styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
    self = [super initWithWindow:window];
    [window setDelegate:self];
    [window release];
    if (!self)
        return nil;
    [self windowDidLoad];
    return self;
}

- (void)dealloc
{
    ASSERT(!_timelineUpdateTimer);
164
#if !defined(BUILDING_ON_TIGER)
165
    ASSERT(!_area);
166
#endif
167 168 169 170 171 172 173 174
    [_timeline release];
    [_remainingTimeText release];
    [_elapsedTimeText release];
    [_volumeSlider release];
    [_playButton release];
    [super dealloc];
}

175
#if !defined(BUILDING_ON_TIGER)
176 177 178 179 180 181 182
- (void)setArea:(NSTrackingArea *)area
{
    if (area == _area)
        return;
    [_area release];
    _area = [area retain];
}
183
#endif
184

185 186
- (void)keyDown:(NSEvent *)event
{
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
    NSString *charactersIgnoringModifiers = [event charactersIgnoringModifiers];
    if ([charactersIgnoringModifiers length] == 1) {
        switch ([charactersIgnoringModifiers characterAtIndex:0]) {
            case ' ':
                [self togglePlaying:nil];
                return;
            case NSUpArrowFunctionKey:
                if ([event modifierFlags] & NSAlternateKeyMask)
                    [self setVolume:[self maxVolume]];
                else
                    [self incrementVolume];
                return;
            case NSDownArrowFunctionKey:
                if ([event modifierFlags] & NSAlternateKeyMask)
                    [self setVolume:0];
                else
                    [self decrementVolume];
                return;
            default:
                break;
        }
208
    }
209 210

    [super keyDown:event];
211 212
}

213 214 215 216
- (id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate
{
    return _delegate;
}
217

218 219 220 221 222 223 224 225 226 227 228
- (void)setDelegate:(id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate
{
    _delegate = delegate;
}

- (void)scheduleTimeUpdate
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(unscheduleTimeUpdate) object:self];

    // First, update right away, then schedule future update
    [self updateTime];
229
    [self updateRate];
230 231 232 233 234 235

    [_timelineUpdateTimer invalidate];
    [_timelineUpdateTimer release];

    // Note that this creates a retain cycle between the window and us.
    _timelineUpdateTimer = [[NSTimer timerWithTimeInterval:0.25 target:self selector:@selector(updateTime) userInfo:nil repeats:YES] retain];
236
#if defined(BUILDING_ON_TIGER)
237
    [[NSRunLoop currentRunLoop] addTimer:_timelineUpdateTimer forMode:(NSString *)kCFRunLoopCommonModes];
238
#else
239
    [[NSRunLoop currentRunLoop] addTimer:_timelineUpdateTimer forMode:NSRunLoopCommonModes];
240
#endif
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
}

- (void)unscheduleTimeUpdate
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(unscheduleTimeUpdate) object:nil];

    [_timelineUpdateTimer invalidate];
    [_timelineUpdateTimer release];
    _timelineUpdateTimer = nil;
}

- (void)fadeWindowIn
{
    NSWindow *window = [self window];
    if (![window isVisible])
        [window setAlphaValue:0];

    [window makeKeyAndOrderFront:self];
259 260 261
#if defined(BUILDING_ON_TIGER)
    [window setAlphaValue:1];
#else
262
    [[window animator] setAlphaValue:1];
263
#endif
264 265 266 267 268 269 270 271 272 273
    [self scheduleTimeUpdate];

    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];
    if (!_mouseIsInHUD && [self playing])   // Don't fade out when paused.
        [self performSelector:@selector(fadeWindowOut) withObject:nil afterDelay:HUDWindowFadeOutDelay];
}

- (void)fadeWindowOut
{
    [NSCursor setHiddenUntilMouseMoves:YES];
274 275 276
#if defined(BUILDING_ON_TIGER)
    [[self window] setAlphaValue:0];
#else
277
    [[[self window] animator] setAlphaValue:0];
278
#endif
279 280 281 282 283 284 285 286
    [self performSelector:@selector(unscheduleTimeUpdate) withObject:nil afterDelay:1];
}

- (void)closeWindow
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];
    [self unscheduleTimeUpdate];
    NSWindow *window = [self window];
287
#if !defined(BUILDING_ON_TIGER)
288 289
    [[window contentView] removeTrackingArea:_area];
    [self setArea:nil];
290
#endif
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
    [window close];
    [window setDelegate:nil];
    [self setWindow:nil];
}

#ifndef HAVE_MEDIA_CONTROL
enum {
    WKMediaUIControlPlayPauseButton,
    WKMediaUIControlRewindButton,
    WKMediaUIControlFastForwardButton,
    WKMediaUIControlExitFullscreenButton,
    WKMediaUIControlVolumeDownButton,
    WKMediaUIControlSlider,
    WKMediaUIControlVolumeUpButton,
    WKMediaUIControlTimeline
};
#endif

static NSControl *createControlWithMediaUIControlType(int controlType, NSRect frame)
{
#ifdef HAVE_MEDIA_CONTROL
    NSControl *control = WKCreateMediaUIControl(controlType);
    [control setFrame:frame];
    return control;
#else
    if (controlType == WKMediaUIControlSlider)
        return [[NSSlider alloc] initWithFrame:frame];
    return [[NSControl alloc] initWithFrame:frame];
#endif
}

static NSTextField *createTimeTextField(NSRect frame)
{
    NSTextField *textField = [[NSTextField alloc] initWithFrame:frame];
    [textField setTextColor:[NSColor whiteColor]];
    [textField setBordered:NO];
327
    [textField setFont:[NSFont boldSystemFontOfSize:10]];
328 329 330 331 332 333 334 335 336
    [textField setDrawsBackground:NO];
    [textField setBezeled:NO];
    [textField setEditable:NO];
    [textField setSelectable:NO];
    return textField;
}

- (void)windowDidLoad
{
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
    static const CGFloat horizontalMargin = 10;
    static const CGFloat playButtonWidth = 41;
    static const CGFloat playButtonHeight = 35;
    static const CGFloat playButtonTopMargin = 4;
    static const CGFloat volumeSliderWidth = 50;
    static const CGFloat volumeSliderHeight = 13;
    static const CGFloat volumeButtonWidth = 18;
    static const CGFloat volumeButtonHeight = 16;
    static const CGFloat volumeUpButtonLeftMargin = 4;
    static const CGFloat volumeControlsTopMargin = 13;
    static const CGFloat exitFullScreenButtonWidth = 25;
    static const CGFloat exitFullScreenButtonHeight = 21;
    static const CGFloat exitFullScreenButtonTopMargin = 11;
    static const CGFloat timelineWidth = 315;
    static const CGFloat timelineHeight = 14;
    static const CGFloat timelineBottomMargin = 7;
    static const CGFloat timeTextFieldWidth = 54;
    static const CGFloat timeTextFieldHeight = 13;
    static const CGFloat timeTextFieldHorizontalMargin = 7;
356 357 358 359 360 361 362 363 364 365

    NSWindow *window = [self window];
    ASSERT(window);

#ifdef HAVE_MEDIA_CONTROL
    NSView *background = WKCreateMediaUIBackgroundView();
#else
    NSView *background = [[NSView alloc] init];
#endif
    [window setContentView:background];
366
#if !defined(BUILDING_ON_TIGER)
367
    _area = [[NSTrackingArea alloc] initWithRect:[background bounds] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil];
368
    [background addTrackingArea:_area];
369
#endif
370 371
    [background release];    

372
    NSView *contentView = [window contentView];
373

374 375
    CGFloat center = webkit_CGFloor((windowWidth - playButtonWidth) / 2);
    _playButton = (NSButton *)createControlWithMediaUIControlType(WKMediaUIControlPlayPauseButton, NSMakeRect(center, windowHeight - playButtonTopMargin - playButtonHeight, playButtonWidth, playButtonHeight));
376
    ASSERT([_playButton isKindOfClass:[NSButton class]]);
377
    [_playButton setTarget:self];
378
    [_playButton setAction:@selector(togglePlaying:)];
379 380
    [contentView addSubview:_playButton];

381 382
    CGFloat closeToRight = windowWidth - horizontalMargin - exitFullScreenButtonWidth;
    NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, windowHeight - exitFullScreenButtonTopMargin - exitFullScreenButtonHeight, exitFullScreenButtonWidth, exitFullScreenButtonHeight));
383 384 385 386 387
    [exitFullscreenButton setAction:@selector(exitFullscreen:)];
    [exitFullscreenButton setTarget:self];
    [contentView addSubview:exitFullscreenButton];
    [exitFullscreenButton release];
    
388 389 390
    CGFloat volumeControlsBottom = windowHeight - volumeControlsTopMargin - volumeButtonHeight;
    CGFloat left = horizontalMargin;
    NSControl *volumeDownButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeDownButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight));
391
    [contentView addSubview:volumeDownButton];
392
    [volumeDownButton setTarget:self];
393
    [volumeDownButton setAction:@selector(setVolumeToZero:)];
394 395
    [volumeDownButton release];

396
    left += volumeButtonWidth;
397
    _volumeSlider = createControlWithMediaUIControlType(WKMediaUIControlSlider, NSMakeRect(left, volumeControlsBottom + webkit_CGFloor((volumeButtonHeight - volumeSliderHeight) / 2), volumeSliderWidth, volumeSliderHeight));
398 399 400 401 402
    [_volumeSlider setValue:[NSNumber numberWithDouble:[self maxVolume]] forKey:@"maxValue"];
    [_volumeSlider setTarget:self];
    [_volumeSlider setAction:@selector(volumeChanged:)];
    [contentView addSubview:_volumeSlider];

403 404
    left += volumeSliderWidth + volumeUpButtonLeftMargin;
    NSControl *volumeUpButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeUpButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight));
405
    [volumeUpButton setTarget:self];
406
    [volumeUpButton setAction:@selector(setVolumeToMaximum:)];
407 408
    [contentView addSubview:volumeUpButton];
    [volumeUpButton release];
409 410

#ifdef HAVE_MEDIA_CONTROL
411
    _timeline = WKCreateMediaUIControl(WKMediaUIControlTimeline);
412 413 414 415 416
#else
    _timeline = [[NSSlider alloc] init];
#endif
    [_timeline setTarget:self];
    [_timeline setAction:@selector(timelinePositionChanged:)];
417
    [_timeline setFrame:NSMakeRect(webkit_CGFloor((windowWidth - timelineWidth) / 2), timelineBottomMargin, timelineWidth, timelineHeight)];
418 419
    [contentView addSubview:_timeline];

420 421
    _elapsedTimeText = createTimeTextField(NSMakeRect(timeTextFieldHorizontalMargin, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight));
    [_elapsedTimeText setAlignment:NSLeftTextAlignment];
422 423
    [contentView addSubview:_elapsedTimeText];

424 425
    _remainingTimeText = createTimeTextField(NSMakeRect(windowWidth - timeTextFieldHorizontalMargin - timeTextFieldWidth, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight));
    [_remainingTimeText setAlignment:NSRightTextAlignment];
426
    [contentView addSubview:_remainingTimeText];
427

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
    [window recalculateKeyViewLoop];
    [window setInitialFirstResponder:_playButton];
    [window center];
}

- (void)updateVolume
{
    [_volumeSlider setDoubleValue:[self volume]];
}

- (void)updateTime
{
    [self updateVolume];

    [_timeline setFloatValue:[self currentTime]];
443
    [_timeline setValue:[NSNumber numberWithDouble:[self duration]] forKey:@"maxValue"];
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464

    [_remainingTimeText setStringValue:[self remainingTimeText]];
    [_elapsedTimeText setStringValue:[self elapsedTimeText]];
}

- (void)timelinePositionChanged:(id)sender
{
    [self setCurrentTime:[_timeline floatValue]];
}

- (float)currentTime
{
    return [_delegate mediaElement] ? [_delegate mediaElement]->currentTime() : 0;
}

- (void)setCurrentTime:(float)currentTime
{
    if (![_delegate mediaElement])
        return;
    WebCore::ExceptionCode e;
    [_delegate mediaElement]->setCurrentTime(currentTime, e);
465
    [self updateTime];
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
}

- (double)duration
{
    return [_delegate mediaElement] ? [_delegate mediaElement]->duration() : 0;
}

- (double)maxVolume
{
    // Set the volume slider resolution
    return 100;
}

- (void)volumeChanged:(id)sender
{
    [self setVolume:[_volumeSlider doubleValue]];
}

484 485 486 487 488 489 490 491 492 493 494
- (void)setVolumeToZero:(id)sender
{
    [self setVolume:0];
}

- (void)setVolumeToMaximum:(id)sender
{
    [self setVolume:[self maxVolume]];
}

- (void)decrementVolume
495 496 497 498 499 500 501 502
{
    if (![_delegate mediaElement])
        return;

    double volume = [self volume] - 10;
    [self setVolume:max(volume, 0.)];
}

503
- (void)incrementVolume
504 505 506 507 508 509 510 511
{
    if (![_delegate mediaElement])
        return;

    double volume = [self volume] + 10;
    [self setVolume:min(volume, [self maxVolume])];
}

512 513 514 515 516 517 518 519 520 521
- (double)volume
{
    return [_delegate mediaElement] ? [_delegate mediaElement]->volume() * [self maxVolume] : 0;
}

- (void)setVolume:(double)volume
{
    if (![_delegate mediaElement])
        return;
    WebCore::ExceptionCode e;
522 523
    if ([_delegate mediaElement]->muted())
        [_delegate mediaElement]->setMuted(false);
524
    [_delegate mediaElement]->setVolume(volume / [self maxVolume], e);
525
    [self updateVolume];
526 527
}

528 529 530 531 532
- (void)updateRate
{
    [_playButton setIntValue:[self playing]];
}

533
- (void)togglePlaying:(id)sender
534
{
535 536 537
    BOOL nowPlaying = [self playing];
    [self setPlaying:!nowPlaying];

538
    // Keep HUD visible when paused
539
    if (!nowPlaying)
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
        [self fadeWindowIn];
    else if (!_mouseIsInHUD) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];
        [self performSelector:@selector(fadeWindowOut) withObject:nil afterDelay:HUDWindowFadeOutDelay];
    }
}

- (BOOL)playing
{
    if (![_delegate mediaElement])
        return false;
    return ![_delegate mediaElement]->canPlay();
}

- (void)setPlaying:(BOOL)playing
{
    if (![_delegate mediaElement])
        return;

    if (playing)
        [_delegate mediaElement]->play();
    else
        [_delegate mediaElement]->pause();
}

static NSString *timeToString(double time)
{
567 568
    ASSERT_ARG(time, time >= 0);

569 570
    if (!isfinite(time))
        time = 0;
571

572
    int seconds = fabs(time); 
573 574 575
    int hours = seconds / (60 * 60);
    int minutes = (seconds / 60) % 60;
    seconds %= 60;
576 577 578 579 580

    if (hours)
        return [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds];

    return [NSString stringWithFormat:@"%02d:%02d", minutes, seconds];    
581 582 583 584
}

- (NSString *)remainingTimeText
{
585 586
    HTMLMediaElement* mediaElement = [_delegate mediaElement];
    if (!mediaElement)
587 588
        return @"";

589
    return [@"-" stringByAppendingString:timeToString(mediaElement->duration() - mediaElement->currentTime())];
590 591 592 593 594 595 596
}

- (NSString *)elapsedTimeText
{
    if (![_delegate mediaElement])
        return @"";

597
    return timeToString([_delegate mediaElement]->currentTime());
598 599
}

600
#pragma mark NSResponder
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629

- (void)mouseEntered:(NSEvent *)theEvent
{
    // Make sure the HUD won't be hidden from now
    _mouseIsInHUD = YES;
    [self fadeWindowIn];
}

- (void)mouseExited:(NSEvent *)theEvent
{
    _mouseIsInHUD = NO;
    [self fadeWindowIn];
}

- (void)rewind:(id)sender
{
    if (![_delegate mediaElement])
        return;
    [_delegate mediaElement]->rewind(30);
}

- (void)fastForward:(id)sender
{
    if (![_delegate mediaElement])
        return;
}

- (void)exitFullscreen:(id)sender
{
630 631 632
    if (_isEndingFullscreen)
        return;
    _isEndingFullscreen = YES;
633 634 635
    [_delegate requestExitFullscreen]; 
}

636
#pragma mark NSWindowDelegate
637 638 639 640 641 642 643 644 645 646 647 648 649 650

- (void)windowDidExpose:(NSNotification *)notification
{
    [self scheduleTimeUpdate];
}

- (void)windowDidClose:(NSNotification *)notification
{
    [self unscheduleTimeUpdate];
}

@end

#endif