]> git.sesse.net Git - vlc/blob - modules/gui/macosx/embeddedwindow.m
macosx: added an entry to Video->Aspect-ratio to disable our AR-lock for one session.
[vlc] / modules / gui / macosx / embeddedwindow.m
1 /*****************************************************************************
2  * embeddedwindow.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2005-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Benjamin Pracht <bigben at videolan dot org>
8  *          Felix Paul Kühne <fkuehne at videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28
29 #import "intf.h"
30 #import "controls.h"
31 #import "vout.h"
32 #import "embeddedwindow.h"
33 #import "fspanel.h"
34
35 /* SetSystemUIMode, ... */
36 #import <Carbon/Carbon.h>
37
38 /*****************************************************************************
39  * VLCEmbeddedWindow Implementation
40  *****************************************************************************/
41
42 @implementation VLCEmbeddedWindow
43
44 - (id)initWithContentRect:(NSRect)contentRect styleMask: (NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
45 {
46     BOOL b_useTextured = YES;
47     if( [[NSWindow class] instancesRespondToSelector:@selector(setContentBorderThickness:forEdge:)] )
48     {
49         b_useTextured = NO;
50         windowStyle ^= NSTexturedBackgroundWindowMask;
51     }
52     self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
53     if(! b_useTextured )
54     {
55         [self setContentBorderThickness:28.0 forEdge:NSMinYEdge];
56     }
57     return self;
58 }
59
60 - (void)awakeFromNib
61 {
62     [self setDelegate: self];
63
64     [o_btn_backward setToolTip: _NS("Rewind")];
65     [o_btn_forward setToolTip: _NS("Fast Forward")];
66     [o_btn_fullscreen setToolTip: _NS("Fullscreen")];
67     [o_btn_play setToolTip: _NS("Play")];
68     [o_slider setToolTip: _NS("Position")];
69
70     o_img_play = [NSImage imageNamed: @"play_embedded"];
71     o_img_pause = [NSImage imageNamed: @"pause_embedded"];
72     [self controlTintChanged];
73     [[NSNotificationCenter defaultCenter] addObserver: self
74                                              selector: @selector( controlTintChanged )
75                                                  name: NSControlTintDidChangeNotification
76                                                object: nil];
77
78     /* Useful to save o_view frame in fullscreen mode */
79     o_temp_view = [[NSView alloc] init];
80     [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
81
82     o_fullscreen_window = nil;
83     o_fullscreen_anim1 = o_fullscreen_anim2 = nil;
84
85     /* Not fullscreen when we wake up */
86     [o_btn_fullscreen setState: NO];
87     b_fullscreen = NO;
88
89     [self setMovableByWindowBackground:YES];
90
91     [self setDelegate:self];
92
93     /* Make sure setVisible: returns NO */
94     [self orderOut:self];
95     b_window_is_invisible = YES;
96     videoRatio = NSMakeSize( 0., 0. );
97 }
98
99 - (void)controlTintChanged
100 {
101     BOOL b_playing = NO;
102     if( [o_btn_play alternateImage] == o_img_play_pressed )
103         b_playing = YES;
104     
105     if( [NSColor currentControlTint] == NSGraphiteControlTint )
106     {
107         o_img_play_pressed = [NSImage imageNamed: @"play_embedded_graphite"];
108         o_img_pause_pressed = [NSImage imageNamed: @"pause_embedded_graphite"];
109         [o_btn_backward setAlternateImage: [NSImage imageNamed: @"skip_previous_embedded_graphite"]];
110         [o_btn_forward setAlternateImage: [NSImage imageNamed: @"skip_forward_embedded_graphite"]];
111         [o_btn_fullscreen setAlternateImage: [NSImage imageNamed: @"fullscreen_graphite"]];
112     }
113     else
114     {
115         o_img_play_pressed = [NSImage imageNamed: @"play_embedded_blue"];
116         o_img_pause_pressed = [NSImage imageNamed: @"pause_embedded_blue"];
117         [o_btn_backward setAlternateImage: [NSImage imageNamed: @"skip_previous_embedded_blue"]];
118         [o_btn_forward setAlternateImage: [NSImage imageNamed: @"skip_forward_embedded_blue"]];
119         [o_btn_fullscreen setAlternateImage: [NSImage imageNamed: @"fullscreen_blue"]];
120     }
121     
122     if( b_playing )
123         [o_btn_play setAlternateImage: o_img_play_pressed];
124     else
125         [o_btn_play setAlternateImage: o_img_pause_pressed];
126 }
127
128 - (void)dealloc
129 {
130     [[NSNotificationCenter defaultCenter] removeObserver: self];
131     [o_img_play release];
132     [o_img_play_pressed release];
133     [o_img_pause release];
134     [o_img_pause_pressed release];
135     
136     [super dealloc];
137 }
138
139 - (void)setTime:(NSString *)o_arg_time position:(float)f_position
140 {
141     [o_time setStringValue: o_arg_time];
142     [o_slider setFloatValue: f_position];
143 }
144
145 - (void)playStatusUpdated:(int)i_status
146 {
147     if( i_status == PLAYING_S )
148     {
149         [o_btn_play setImage: o_img_pause];
150         [o_btn_play setAlternateImage: o_img_pause_pressed];
151         [o_btn_play setToolTip: _NS("Pause")];
152     }
153     else
154     {
155         [o_btn_play setImage: o_img_play];
156         [o_btn_play setAlternateImage: o_img_play_pressed];
157         [o_btn_play setToolTip: _NS("Play")];
158     }
159 }
160
161 - (void)setSeekable:(BOOL)b_seekable
162 {
163     [o_btn_forward setEnabled: b_seekable];
164     [o_btn_backward setEnabled: b_seekable];
165     [o_slider setEnabled: b_seekable];
166 }
167
168 - (BOOL)windowShouldZoom:(NSWindow *)sender toFrame:(NSRect)newFrame
169 {
170     [self setFrame: newFrame display: YES animate: YES];
171     return NO;
172 }
173
174 - (BOOL)windowShouldClose:(id)sender
175 {
176     playlist_t * p_playlist = pl_Hold( VLCIntf );
177
178     playlist_Stop( p_playlist );
179     pl_Release( VLCIntf );
180     return YES;
181 }
182
183 - (NSView *)mainView
184 {
185     if (o_fullscreen_window)
186         return o_temp_view;
187     else
188         return o_view;
189 }
190
191 - (void)setVideoRatio:(NSSize)ratio
192 {
193     videoRatio = ratio;
194 }
195
196 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
197 {
198     if( videoRatio.height == 0. || videoRatio.width == 0. )
199         return proposedFrameSize;
200
201     if( [[[VLCMain sharedInstance] controls] aspectRatioIsLocked] )
202     {
203         NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
204         NSRect contentRect = [self contentRectForFrameRect:[self frame]];
205         float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
206         float marginx = contentRect.size.width - viewRect.size.width;
207         proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
208     }
209
210     return proposedFrameSize;
211 }
212
213 /*****************************************************************************
214  * Fullscreen support
215  */
216
217 - (BOOL)isFullscreen
218 {
219     return b_fullscreen;
220 }
221
222 - (void)lockFullscreenAnimation
223 {
224     [o_animation_lock lock];
225 }
226
227 - (void)unlockFullscreenAnimation
228 {
229     [o_animation_lock unlock];
230 }
231
232 - (void)enterFullscreen
233 {
234     NSMutableDictionary *dict1, *dict2;
235     NSScreen *screen;
236     NSRect screen_rect;
237     NSRect rect;
238     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
239     BOOL blackout_other_displays = config_GetInt( VLCIntf, "macosx-black" );
240
241     screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_GetInteger( p_vout, "video-device" )]; 
242  
243     [self lockFullscreenAnimation];
244
245     if (!screen)
246     {
247         msg_Dbg( p_vout, "chosen screen isn't present, using current screen for fullscreen mode" );
248         screen = [self screen];
249     }
250     if (!screen)
251     {
252         msg_Dbg( p_vout, "Using deepest screen" );
253         screen = [NSScreen deepestScreen];
254     }
255
256     vlc_object_release( p_vout );
257
258     screen_rect = [screen frame];
259
260     [o_btn_fullscreen setState: YES];
261
262     [NSCursor setHiddenUntilMouseMoves: YES];
263  
264     if( blackout_other_displays )        
265         [screen blackoutOtherScreens];
266
267     /* Make sure we don't see the window flashes in float-on-top mode */
268     originalLevel = [self level];
269     [self setLevel:NSNormalWindowLevel];
270
271     /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
272     if (!o_fullscreen_window)
273     {
274         /* We can't change the styleMask of an already created NSWindow, so we create an other window, and do eye catching stuff */
275
276         rect = [[o_view superview] convertRect: [o_view frame] toView: nil]; /* Convert to Window base coord */
277         rect.origin.x += [self frame].origin.x;
278         rect.origin.y += [self frame].origin.y;
279         o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
280         [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
281         [o_fullscreen_window setCanBecomeKeyWindow: YES];
282
283         if (![self isVisible] || [self alphaValue] == 0.0)
284         {
285             /* We don't animate if we are not visible, instead we
286              * simply fade the display */
287             CGDisplayFadeReservationToken token;
288  
289             CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
290             CGDisplayFade( token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
291  
292             if ([screen isMainScreen])
293                 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
294  
295             [[self contentView] replaceSubview:o_view with:o_temp_view];
296             [o_temp_view setFrame:[o_view frame]];
297             [o_fullscreen_window setContentView:o_view];
298
299             [o_fullscreen_window makeKeyAndOrderFront:self];
300             [o_fullscreen_window orderFront:self animate:YES];
301
302             [o_fullscreen_window setFrame:screen_rect display:YES];
303
304             CGDisplayFade( token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
305             CGReleaseDisplayFadeReservation( token);
306
307             /* Will release the lock */
308             [self hasBecomeFullscreen];
309
310             return;
311         }
312  
313         /* Make sure we don't see the o_view disappearing of the screen during this operation */
314         NSDisableScreenUpdates();
315                 [[self contentView] replaceSubview:o_view with:o_temp_view];
316         [o_temp_view setFrame:[o_view frame]];
317         [o_fullscreen_window setContentView:o_view];
318         [o_fullscreen_window makeKeyAndOrderFront:self];
319         NSEnableScreenUpdates();
320     }
321
322     /* We are in fullscreen (and no animation is running) */
323     if (b_fullscreen)
324     {
325         /* Make sure we are hidden */
326         [super orderOut: self];
327         [self unlockFullscreenAnimation];
328         return;
329     }
330
331     if (o_fullscreen_anim1)
332     {
333         [o_fullscreen_anim1 stopAnimation];
334         [o_fullscreen_anim1 release];
335     }
336     if (o_fullscreen_anim2)
337     {
338         [o_fullscreen_anim2 stopAnimation];
339         [o_fullscreen_anim2 release];
340     }
341  
342     if ([screen isMainScreen])
343         SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
344
345     dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
346     dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
347
348     [dict1 setObject:self forKey:NSViewAnimationTargetKey];
349     [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
350
351     [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
352     [dict2 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
353     [dict2 setObject:[NSValue valueWithRect:screen_rect] forKey:NSViewAnimationEndFrameKey];
354
355     /* Strategy with NSAnimation allocation:
356         - Keep at most 2 animation at a time
357         - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
358     */
359     o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
360     o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
361
362     [dict1 release];
363     [dict2 release];
364
365     [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
366     [o_fullscreen_anim1 setDuration: 0.3];
367     [o_fullscreen_anim1 setFrameRate: 30];
368     [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
369     [o_fullscreen_anim2 setDuration: 0.2];
370     [o_fullscreen_anim2 setFrameRate: 30];
371
372     [o_fullscreen_anim2 setDelegate: self];
373     [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
374
375     [o_fullscreen_anim1 startAnimation];
376     /* fullscreenAnimation will be unlocked when animation ends */
377 }
378
379 - (void)hasBecomeFullscreen
380 {
381     [o_fullscreen_window makeFirstResponder: [[[VLCMain sharedInstance] controls] voutView]];
382
383     [o_fullscreen_window makeKeyWindow];
384     [o_fullscreen_window setAcceptsMouseMovedEvents: TRUE];
385
386     /* tell the fspanel to move itself to front next time it's triggered */
387     [[[[VLCMain sharedInstance] controls] fspanel] setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
388
389     if([self isVisible])
390         [super orderOut: self];
391
392     [[[[VLCMain sharedInstance] controls] fspanel] setActive: nil];
393
394     b_fullscreen = YES;
395     [self unlockFullscreenAnimation];
396 }
397
398 - (void)leaveFullscreen
399 {
400     [self leaveFullscreenAndFadeOut: NO];
401 }
402
403 - (void)leaveFullscreenAndFadeOut: (BOOL)fadeout
404 {
405     NSMutableDictionary *dict1, *dict2;
406     NSRect frame;
407
408     [self lockFullscreenAnimation];
409
410     b_fullscreen = NO;
411     [o_btn_fullscreen setState: NO];
412
413     /* We always try to do so */
414     [NSScreen unblackoutScreens];
415
416     /* Don't do anything if o_fullscreen_window is already closed */
417     if (!o_fullscreen_window)
418     {
419         [self unlockFullscreenAnimation];
420         return;
421     }
422
423     if (fadeout)
424     {
425         /* We don't animate if we are not visible, instead we
426         * simply fade the display */
427         CGDisplayFadeReservationToken token;
428
429         CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
430         CGDisplayFade( token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
431
432         [[[[VLCMain sharedInstance] controls] fspanel] setNonActive: nil];
433         SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
434
435         /* Will release the lock */
436         [self hasEndedFullscreen];
437
438         /* Our window is hidden, and might be faded. We need to workaround that, so note it
439          * here */
440         b_window_is_invisible = YES;
441
442         CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
443         CGReleaseDisplayFadeReservation( token);
444         return;
445     }
446
447     [self setAlphaValue: 0.0];
448     [self orderFront: self];
449
450     [[[[VLCMain sharedInstance] controls] fspanel] setNonActive: nil];
451     SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
452
453     if (o_fullscreen_anim1)
454     {
455         [o_fullscreen_anim1 stopAnimation];
456         [o_fullscreen_anim1 release];
457     }
458     if (o_fullscreen_anim2)
459     {
460         [o_fullscreen_anim2 stopAnimation];
461         [o_fullscreen_anim2 release];
462     }
463
464     frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
465     frame.origin.x += [self frame].origin.x;
466     frame.origin.y += [self frame].origin.y;
467
468     dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
469     [dict2 setObject:self forKey:NSViewAnimationTargetKey];
470     [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
471
472     o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
473     [dict2 release];
474
475     [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
476     [o_fullscreen_anim2 setDuration: 0.3];
477     [o_fullscreen_anim2 setFrameRate: 30];
478
479     [o_fullscreen_anim2 setDelegate: self];
480
481     dict1 = [[NSMutableDictionary alloc] initWithCapacity:3];
482
483     [dict1 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
484     [dict1 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
485     [dict1 setObject:[NSValue valueWithRect:frame] forKey:NSViewAnimationEndFrameKey];
486
487     o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
488     [dict1 release];
489
490     [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
491     [o_fullscreen_anim1 setDuration: 0.2];
492     [o_fullscreen_anim1 setFrameRate: 30];
493     [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
494
495     /* Make sure o_fullscreen_window is the frontmost window */
496     [o_fullscreen_window orderFront: self];
497
498     [o_fullscreen_anim1 startAnimation];
499     /* fullscreenAnimation will be unlocked when animation ends */
500 }
501
502 - (void)hasEndedFullscreen
503 {
504     /* This function is private and should be only triggered at the end of the fullscreen change animation */
505     /* Make sure we don't see the o_view disappearing of the screen during this operation */
506     NSDisableScreenUpdates();
507     [o_view retain];
508     [o_view removeFromSuperviewWithoutNeedingDisplay];
509     [[self contentView] replaceSubview:o_temp_view with:o_view];
510     [o_view release];
511     [o_view setFrame:[o_temp_view frame]];
512     [self makeFirstResponder: o_view];
513     if ([self isVisible])
514         [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
515     [o_fullscreen_window orderOut: self];
516     NSEnableScreenUpdates();
517
518     [o_fullscreen_window release];
519     o_fullscreen_window = nil;
520     [self setLevel:originalLevel];
521
522     [self unlockFullscreenAnimation];
523 }
524
525 - (void)animationDidEnd:(NSAnimation*)animation
526 {
527     NSArray *viewAnimations;
528
529     if ([animation currentValue] < 1.0)
530         return;
531
532     /* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
533     viewAnimations = [o_fullscreen_anim2 viewAnimations];
534     if ([viewAnimations count] >=1 &&
535         [[[viewAnimations objectAtIndex: 0] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect])
536     {
537         /* Fullscreen ended */
538         [self hasEndedFullscreen];
539     }
540     else
541     {
542         /* Fullscreen started */
543         [self hasBecomeFullscreen];
544     }
545 }
546
547 - (void)orderOut: (id)sender
548 {
549     [super orderOut: sender];
550
551     /* Make sure we leave fullscreen */
552     [self leaveFullscreenAndFadeOut: YES];
553 }
554
555 - (void)makeKeyAndOrderFront: (id)sender
556 {
557     /* Hack
558      * when we exit fullscreen and fade out, we may endup in
559      * having a window that is faded. We can't have it fade in unless we
560      * animate again. */
561
562     if(!b_window_is_invisible)
563     {
564         /* Make sure we don't do it too much */
565         [super makeKeyAndOrderFront: sender];
566         return;
567     }
568
569     [super setAlphaValue:0.0f];
570     [super makeKeyAndOrderFront: sender];
571
572     NSMutableDictionary * dict = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease];
573     [dict setObject:self forKey:NSViewAnimationTargetKey];
574     [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
575
576     NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
577
578     [anim setAnimationBlockingMode: NSAnimationNonblocking];
579     [anim setDuration: 0.1];
580     [anim setFrameRate: 30];
581
582     [anim startAnimation];
583     b_window_is_invisible = NO;
584
585     /* fullscreenAnimation will be unlocked when animation ends */
586 }
587
588
589
590 /* Make sure setFrame gets executed on main thread especially if we are animating.
591  * (Thus we won't block the video output thread) */
592 - (void)setFrame:(NSRect)frame display:(BOOL)display animate:(BOOL)animate
593 {
594     struct { NSRect frame; BOOL display; BOOL animate;} args;
595     NSData *packedargs;
596
597     args.frame = frame;
598     args.display = display;
599     args.animate = animate;
600
601     packedargs = [NSData dataWithBytes:&args length:sizeof(args)];
602
603     [self performSelectorOnMainThread:@selector(setFrameOnMainThread:)
604                     withObject: packedargs waitUntilDone: YES];
605 }
606
607 - (void)setFrameOnMainThread:(NSData*)packedargs
608 {
609     struct args { NSRect frame; BOOL display; BOOL animate; } * args = (struct args*)[packedargs bytes];
610
611     if( args->animate )
612     {
613         /* Make sure we don't block too long and set up a non blocking animation */
614         NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
615             self, NSViewAnimationTargetKey,
616             [NSValue valueWithRect:[self frame]], NSViewAnimationStartFrameKey,
617             [NSValue valueWithRect:args->frame], NSViewAnimationEndFrameKey, nil];
618
619         NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
620
621         [anim setAnimationBlockingMode: NSAnimationNonblocking];
622         [anim setDuration: 0.4];
623         [anim setFrameRate: 30];
624         [anim startAnimation];
625     }
626     else {
627         [super setFrame:args->frame display:args->display animate:args->animate];
628     }
629
630 }
631 @end