1 /*****************************************************************************
2 * vout.m: MacOS X video output plugin
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: vout.m,v 1.6 2002/12/07 23:50:30 massiot Exp $
7 * Authors: Colin Delacroix <colin@zoy.org>
8 * Florian G. Pflug <fgp@phlo.org>
9 * Jon Lech Johansen <jon-vl@nanocrew.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include <errno.h> /* ENOMEM */
30 #include <stdlib.h> /* free() */
31 #include <string.h> /* strerror() */
38 #include <Cocoa/Cocoa.h>
39 #include <QuickTime/QuickTime.h>
44 #define QT_MAX_DIRECTBUFFERS 10
51 /* When using I420 output */
52 PlanarPixmapInfoYUV420 pixmap_i420;
55 /*****************************************************************************
57 *****************************************************************************/
58 static int vout_Init ( vout_thread_t * );
59 static void vout_End ( vout_thread_t * );
60 static int vout_Manage ( vout_thread_t * );
61 static void vout_Display ( vout_thread_t *, picture_t * );
63 static int CoSendRequest ( vout_thread_t *, long );
64 static int CoCreateWindow ( vout_thread_t * );
65 static int CoDestroyWindow ( vout_thread_t * );
66 static int CoToggleFullscreen ( vout_thread_t * );
68 static void QTScaleMatrix ( vout_thread_t * );
69 static int QTCreateSequence ( vout_thread_t * );
70 static void QTDestroySequence ( vout_thread_t * );
71 static int QTNewPicture ( vout_thread_t *, picture_t * );
72 static void QTFreePicture ( vout_thread_t *, picture_t * );
74 /*****************************************************************************
75 * OpenVideo: allocates MacOS X video thread output method
76 *****************************************************************************
77 * This function allocates and initializes a MacOS X vout method.
78 *****************************************************************************/
79 int E_(OpenVideo) ( vlc_object_t *p_this )
81 vout_thread_t * p_vout = (vout_thread_t *)p_this;
85 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
86 if( p_vout->p_sys == NULL )
88 msg_Err( p_vout, "out of memory" );
92 memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
94 /* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
95 for( i_timeout = 20 ; i_timeout-- ; )
97 vlc_list_t * p_list = vlc_list_find( p_vout, VLC_OBJECT_INTF,
99 intf_thread_t ** pp_intf = (intf_thread_t **)p_list->pp_objects;
101 /* Parse the list of interfaces to see if one suits us */
102 for( ; *pp_intf ; pp_intf++ )
104 if( (*pp_intf)->p_module &&
105 !strcmp( (*pp_intf)->p_module->psz_object_name, MODULE_STRING ) )
107 vlc_object_yield( *pp_intf );
108 p_vout->p_sys->p_intf = *pp_intf;
112 vlc_list_release( p_list );
114 if( p_vout->p_sys->p_intf == NULL )
116 msleep( INTF_IDLE_SLEEP );
120 if( p_vout->p_sys->p_intf == NULL )
122 msg_Err( p_vout, "no MacOS X interface present" );
123 free( p_vout->p_sys );
127 p_vout->p_sys->h_img_descr =
128 (ImageDescriptionHandle)NewHandleClear( sizeof(ImageDescription) );
129 p_vout->p_sys->p_matrix = (MatrixRecordPtr)malloc( sizeof(MatrixRecord) );
131 p_vout->p_sys->b_mouse_pointer_visible = 1;
133 /* set window size */
134 p_vout->p_sys->s_rect.size.width = p_vout->i_window_width;
135 p_vout->p_sys->s_rect.size.height = p_vout->i_window_height;
137 if( ( err = EnterMovies() ) != noErr )
139 msg_Err( p_vout, "EnterMovies failed: %d", err );
140 free( p_vout->p_sys->p_matrix );
141 DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
142 vlc_object_release( p_vout->p_sys->p_intf );
143 free( p_vout->p_sys );
147 if( vout_ChromaCmp( p_vout->render.i_chroma, VLC_FOURCC('I','4','2','0') ) )
149 err = FindCodec( kYUV420CodecType, bestSpeedCodec,
150 nil, &p_vout->p_sys->img_dc );
151 if( err == noErr && p_vout->p_sys->img_dc != 0 )
153 p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
154 p_vout->p_sys->i_codec = kYUV420CodecType;
158 msg_Err( p_vout, "failed to find an appropriate codec" );
163 msg_Err( p_vout, "chroma 0x%08x not supported",
164 p_vout->render.i_chroma );
167 if( p_vout->p_sys->img_dc == 0 )
169 free( p_vout->p_sys->p_matrix );
170 DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
171 vlc_object_release( p_vout->p_sys->p_intf );
172 free( p_vout->p_sys );
176 NSArray * p_screens = [NSScreen screens];
177 if ( [p_screens count] > 0 )
180 var_Destroy( p_vout, "video-device" );
181 var_Create( p_vout, "video-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
182 NSEnumerator * p_enumerator = [p_screens objectEnumerator];
185 while ( (p_screen = [p_enumerator nextObject]) != NULL )
187 NSRect p_rect = [p_screen frame];
189 snprintf(psz_temp, sizeof(psz_temp), "%s %d (%dx%d)",
190 _("Screen"), i, (int)p_rect.size.width,
191 (int)p_rect.size.height);
192 val.psz_string = psz_temp;
193 var_Change( p_vout, "video-device", VLC_VAR_ADDCHOICE, &val );
196 var_AddCallback( p_vout, "video-device", vout_VarCallback,
199 val.b_bool = VLC_TRUE;
200 var_Set( p_vout, "intf-change", val );
203 if( CoCreateWindow( p_vout ) )
205 msg_Err( p_vout, "unable to create window" );
206 free( p_vout->p_sys->p_matrix );
207 DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
208 vlc_object_release( p_vout->p_sys->p_intf );
209 free( p_vout->p_sys );
213 p_vout->pf_init = vout_Init;
214 p_vout->pf_end = vout_End;
215 p_vout->pf_manage = vout_Manage;
216 p_vout->pf_render = NULL;
217 p_vout->pf_display = vout_Display;
222 /*****************************************************************************
223 * vout_Init: initialize video thread output method
224 *****************************************************************************/
225 static int vout_Init( vout_thread_t *p_vout )
230 I_OUTPUTPICTURES = 0;
232 /* Initialize the output structure; we already found a codec,
233 * and the corresponding chroma we will be using. Since we can
234 * arbitrary scale, stick to the coordinates and aspect. */
235 p_vout->output.i_width = p_vout->render.i_width;
236 p_vout->output.i_height = p_vout->render.i_height;
237 p_vout->output.i_aspect = p_vout->render.i_aspect;
239 SetPort( p_vout->p_sys->p_qdport );
240 QTScaleMatrix( p_vout );
242 if( QTCreateSequence( p_vout ) )
244 msg_Err( p_vout, "unable to create sequence" );
248 /* Try to initialize up to QT_MAX_DIRECTBUFFERS direct buffers */
249 while( I_OUTPUTPICTURES < QT_MAX_DIRECTBUFFERS )
253 /* Find an empty picture slot */
254 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
256 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
258 p_pic = p_vout->p_picture + i_index;
263 /* Allocate the picture */
264 if( p_pic == NULL || QTNewPicture( p_vout, p_pic ) )
269 p_pic->i_status = DESTROYED_PICTURE;
270 p_pic->i_type = DIRECT_PICTURE;
272 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
280 /*****************************************************************************
281 * vout_End: terminate video thread output method
282 *****************************************************************************/
283 static void vout_End( vout_thread_t *p_vout )
287 QTDestroySequence( p_vout );
289 /* Free the direct buffers we allocated */
290 for( i_index = I_OUTPUTPICTURES; i_index; )
293 QTFreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] );
297 /*****************************************************************************
298 * CloseVideo: destroy video thread output method
299 *****************************************************************************/
300 void E_(CloseVideo) ( vlc_object_t *p_this )
302 vout_thread_t * p_vout = (vout_thread_t *)p_this;
304 if( CoDestroyWindow( p_vout ) )
306 msg_Err( p_vout, "unable to destroy window" );
311 free( p_vout->p_sys->p_matrix );
312 DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
314 vlc_object_release( p_vout->p_sys->p_intf );
316 free( p_vout->p_sys );
319 /*****************************************************************************
320 * vout_Manage: handle events
321 *****************************************************************************
322 * This function should be called regularly by video output thread. It manages
323 * console events. It returns a non null value on error.
324 *****************************************************************************/
325 static int vout_Manage( vout_thread_t *p_vout )
327 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
329 if( CoToggleFullscreen( p_vout ) )
334 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
337 if( p_vout->i_changes & VOUT_SIZE_CHANGE )
339 QTScaleMatrix( p_vout );
340 SetDSequenceMatrix( p_vout->p_sys->i_seq,
341 p_vout->p_sys->p_matrix );
343 p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
346 /* hide/show mouse cursor */
347 if( p_vout->p_sys->b_mouse_moved ||
348 p_vout->p_sys->i_time_mouse_last_moved )
350 vlc_bool_t b_change = 0;
352 if( !p_vout->p_sys->b_mouse_pointer_visible )
354 CGDisplayShowCursor( kCGDirectMainDisplay );
358 else if( !p_vout->p_sys->b_mouse_moved &&
359 mdate() - p_vout->p_sys->i_time_mouse_last_moved > 2000000 &&
360 p_vout->p_sys->b_mouse_pointer_visible )
362 CGDisplayHideCursor( kCGDirectMainDisplay );
369 p_vout->p_sys->i_time_mouse_last_moved = 0;
370 p_vout->p_sys->b_mouse_moved = 0;
371 p_vout->p_sys->b_mouse_pointer_visible =
372 !p_vout->p_sys->b_mouse_pointer_visible;
379 /*****************************************************************************
380 * vout_Display: displays previously rendered output
381 *****************************************************************************
382 * This function sends the currently rendered image to the display.
383 *****************************************************************************/
384 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
389 if( ( err = DecompressSequenceFrameS(
390 p_vout->p_sys->i_seq,
391 p_pic->p_sys->p_info,
392 p_pic->p_sys->i_size,
393 codecFlagUseImageBuffer, &flags, nil ) != noErr ) )
395 msg_Err( p_vout, "DecompressSequenceFrameS failed: %d", err );
399 QDFlushPortBuffer( p_vout->p_sys->p_qdport, nil );
403 /*****************************************************************************
404 * CoSendRequest: send request to interface thread
405 *****************************************************************************
406 * Returns 0 on success, 1 otherwise
407 *****************************************************************************/
408 static int CoSendRequest( vout_thread_t *p_vout, long i_request )
411 NSPortMessage *o_msg;
412 struct vout_req_t req;
413 struct vout_req_t *p_req = &req;
414 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
415 NSPort *recvPort = [[NSPort port] retain];
417 memset( &req, 0, sizeof(req) );
418 req.i_type = i_request;
421 req.o_lock = [[NSConditionLock alloc] initWithCondition: 0];
423 o_array = [NSArray arrayWithObject:
424 [NSData dataWithBytes: &p_req length: sizeof(void *)]];
425 o_msg = [[NSPortMessage alloc]
426 initWithSendPort: p_vout->p_sys->p_intf->p_sys->o_sendport
427 receivePort: recvPort components: o_array];
429 [o_msg sendBeforeDate: [NSDate distantPast]];
431 [req.o_lock lockWhenCondition: 1];
435 [req.o_lock release];
440 return( !req.i_result );
443 /*****************************************************************************
444 * CoCreateWindow: create new window
445 *****************************************************************************
446 * Returns 0 on success, 1 otherwise
447 *****************************************************************************/
448 static int CoCreateWindow( vout_thread_t *p_vout )
450 if( CoSendRequest( p_vout, VOUT_REQ_CREATE_WINDOW ) )
452 msg_Err( p_vout, "CoSendRequest (CREATE_WINDOW) failed" );
459 /*****************************************************************************
460 * CoDestroyWindow: destroy window
461 *****************************************************************************
462 * Returns 0 on success, 1 otherwise
463 *****************************************************************************/
464 static int CoDestroyWindow( vout_thread_t *p_vout )
466 if( !p_vout->p_sys->b_mouse_pointer_visible )
468 CGDisplayShowCursor( kCGDirectMainDisplay );
469 p_vout->p_sys->b_mouse_pointer_visible = 1;
472 if( CoSendRequest( p_vout, VOUT_REQ_DESTROY_WINDOW ) )
474 msg_Err( p_vout, "CoSendRequest (DESTROY_WINDOW) failed" );
481 /*****************************************************************************
482 * CoToggleFullscreen: toggle fullscreen
483 *****************************************************************************
484 * Returns 0 on success, 1 otherwise
485 *****************************************************************************/
486 static int CoToggleFullscreen( vout_thread_t *p_vout )
488 QTDestroySequence( p_vout );
490 if( CoDestroyWindow( p_vout ) )
492 msg_Err( p_vout, "unable to destroy window" );
496 p_vout->b_fullscreen = !p_vout->b_fullscreen;
498 if( p_vout->b_fullscreen )
507 if( CoCreateWindow( p_vout ) )
509 msg_Err( p_vout, "unable to create window" );
513 SetPort( p_vout->p_sys->p_qdport );
514 QTScaleMatrix( p_vout );
516 if( QTCreateSequence( p_vout ) )
518 msg_Err( p_vout, "unable to create sequence" );
525 /*****************************************************************************
526 * QTScaleMatrix: scale matrix
527 *****************************************************************************/
528 static void QTScaleMatrix( vout_thread_t *p_vout )
531 int i_width, i_height;
532 Fixed factor_x, factor_y;
536 GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
538 i_width = s_rect.right - s_rect.left;
539 i_height = s_rect.bottom - s_rect.top;
541 if( i_height * p_vout->output.i_aspect < i_width * VOUT_ASPECT_FACTOR )
543 int i_adj_width = i_height * p_vout->output.i_aspect /
546 factor_x = FixDiv( Long2Fix( i_adj_width ),
547 Long2Fix( p_vout->output.i_width ) );
548 factor_y = FixDiv( Long2Fix( i_height ),
549 Long2Fix( p_vout->output.i_height ) );
551 i_offset_x = (i_width - i_adj_width) / 2;
555 int i_adj_height = i_width * VOUT_ASPECT_FACTOR /
556 p_vout->output.i_aspect;
558 factor_x = FixDiv( Long2Fix( i_width ),
559 Long2Fix( p_vout->output.i_width ) );
560 factor_y = FixDiv( Long2Fix( i_adj_height ),
561 Long2Fix( p_vout->output.i_height ) );
563 i_offset_y = (i_height - i_adj_height) / 2;
566 SetIdentityMatrix( p_vout->p_sys->p_matrix );
568 ScaleMatrix( p_vout->p_sys->p_matrix,
570 Long2Fix(0), Long2Fix(0) );
572 TranslateMatrix( p_vout->p_sys->p_matrix,
573 Long2Fix(i_offset_x),
574 Long2Fix(i_offset_y) );
577 /*****************************************************************************
578 * QTCreateSequence: create a new sequence
579 *****************************************************************************
580 * Returns 0 on success, 1 otherwise
581 *****************************************************************************/
582 static int QTCreateSequence( vout_thread_t *p_vout )
585 ImageDescriptionPtr p_descr;
587 HLock( (Handle)p_vout->p_sys->h_img_descr );
588 p_descr = *p_vout->p_sys->h_img_descr;
590 p_descr->idSize = sizeof(ImageDescription);
591 p_descr->cType = p_vout->p_sys->i_codec;
592 p_descr->version = 1;
593 p_descr->revisionLevel = 0;
594 p_descr->vendor = 'appl';
595 p_descr->width = p_vout->output.i_width;
596 p_descr->height = p_vout->output.i_height;
597 p_descr->hRes = Long2Fix(72);
598 p_descr->vRes = Long2Fix(72);
599 p_descr->spatialQuality = codecLosslessQuality;
600 p_descr->frameCount = 1;
601 p_descr->clutID = -1;
602 p_descr->dataSize = 0;
605 HUnlock( (Handle)p_vout->p_sys->h_img_descr );
607 if( ( err = DecompressSequenceBeginS(
608 &p_vout->p_sys->i_seq,
609 p_vout->p_sys->h_img_descr,
611 p_vout->p_sys->p_qdport,
613 p_vout->p_sys->p_matrix,
615 codecFlagUseImageBuffer,
616 codecLosslessQuality,
617 p_vout->p_sys->img_dc ) ) )
619 msg_Err( p_vout, "DecompressSequenceBeginS failed: %d", err );
626 /*****************************************************************************
627 * QTDestroySequence: destroy sequence
628 *****************************************************************************/
629 static void QTDestroySequence( vout_thread_t *p_vout )
631 CDSequenceEnd( p_vout->p_sys->i_seq );
634 /*****************************************************************************
635 * QTNewPicture: allocate a picture
636 *****************************************************************************
637 * Returns 0 on success, 1 otherwise
638 *****************************************************************************/
639 static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
641 int i_width = p_vout->output.i_width;
642 int i_height = p_vout->output.i_height;
644 /* We know the chroma, allocate a buffer which will be used
645 * directly by the decoder */
646 p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
648 if( p_pic->p_sys == NULL )
653 switch( p_vout->output.i_chroma )
655 case VLC_FOURCC('I','4','2','0'):
657 p_pic->p_sys->p_info = (void *)&p_pic->p_sys->pixmap_i420;
658 p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420);
660 /* Allocate the memory buffer */
661 p_pic->p_data = vlc_memalign( &p_pic->p_data_orig,
662 16, i_width * i_height * 3 / 2 );
665 p_pic->Y_PIXELS = p_pic->p_data;
666 p_pic->p[Y_PLANE].i_lines = i_height;
667 p_pic->p[Y_PLANE].i_pitch = i_width;
668 p_pic->p[Y_PLANE].i_pixel_pitch = 1;
669 p_pic->p[Y_PLANE].i_visible_pitch = i_width;
672 p_pic->U_PIXELS = p_pic->Y_PIXELS + i_height * i_width;
673 p_pic->p[U_PLANE].i_lines = i_height / 2;
674 p_pic->p[U_PLANE].i_pitch = i_width / 2;
675 p_pic->p[U_PLANE].i_pixel_pitch = 1;
676 p_pic->p[U_PLANE].i_visible_pitch = i_width / 2;
679 p_pic->V_PIXELS = p_pic->U_PIXELS + i_height * i_width / 4;
680 p_pic->p[V_PLANE].i_lines = i_height / 2;
681 p_pic->p[V_PLANE].i_pitch = i_width / 2;
682 p_pic->p[V_PLANE].i_pixel_pitch = 1;
683 p_pic->p[V_PLANE].i_visible_pitch = i_width / 2;
685 /* We allocated 3 planes */
688 #define P p_pic->p_sys->pixmap_i420
689 P.componentInfoY.offset = (void *)p_pic->Y_PIXELS
690 - p_pic->p_sys->p_info;
691 P.componentInfoCb.offset = (void *)p_pic->U_PIXELS
692 - p_pic->p_sys->p_info;
693 P.componentInfoCr.offset = (void *)p_pic->V_PIXELS
694 - p_pic->p_sys->p_info;
696 P.componentInfoY.rowBytes = i_width;
697 P.componentInfoCb.rowBytes = i_width / 2;
698 P.componentInfoCr.rowBytes = i_width / 2;
704 /* Unknown chroma, tell the guy to get lost */
705 free( p_pic->p_sys );
706 msg_Err( p_vout, "never heard of chroma 0x%.8x (%4.4s)",
707 p_vout->output.i_chroma, (char*)&p_vout->output.i_chroma );
715 /*****************************************************************************
716 * QTFreePicture: destroy a picture allocated with QTNewPicture
717 *****************************************************************************/
718 static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
720 switch( p_vout->output.i_chroma )
722 case VLC_FOURCC('I','4','2','0'):
723 free( p_pic->p_data_orig );
727 free( p_pic->p_sys );
730 /*****************************************************************************
731 * VLCWindow implementation
732 *****************************************************************************/
733 @implementation VLCWindow
735 - (void)setVout:(vout_thread_t *)_p_vout
740 - (void)toggleFullscreen
742 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
747 return( p_vout->b_fullscreen );
750 - (BOOL)canBecomeKeyWindow
755 - (void)keyDown:(NSEvent *)o_event
759 if( [[o_event characters] length] )
761 key = [[o_event characters] characterAtIndex: 0];
766 case (unichar)0xf700: /* up-arrow */
768 aout_instance_t * p_aout = vlc_object_find( p_vout, VLC_OBJECT_AOUT,
770 if ( p_aout != NULL )
772 aout_VolumeUp( p_aout, 1, NULL );
773 vlc_object_release( (vlc_object_t *)p_aout );
778 case (unichar)0xf701: /* down-arrow */
780 aout_instance_t * p_aout = vlc_object_find( p_vout, VLC_OBJECT_AOUT,
782 if ( p_aout != NULL )
784 aout_VolumeDown( p_aout, 1, NULL );
785 vlc_object_release( (vlc_object_t *)p_aout );
791 [self toggleFullscreen];
794 case (unichar)0x1b: /* escape */
795 if( [self isFullscreen] )
797 [self toggleFullscreen];
802 p_vout->p_vlc->b_die = VLC_TRUE;
806 input_SetStatus( p_vout, INPUT_STATUS_PAUSE );
810 [super keyDown: o_event];
817 /*****************************************************************************
818 * VLCView implementation
819 *****************************************************************************/
820 @implementation VLCView
822 - (void)setVout:(vout_thread_t *)_p_vout
827 - (void)drawRect:(NSRect)rect
829 [[NSColor blackColor] set];
831 [super drawRect: rect];
833 p_vout->i_changes |= VOUT_SIZE_CHANGE;
836 - (BOOL)acceptsFirstResponder
841 - (BOOL)becomeFirstResponder
843 [[self window] setAcceptsMouseMovedEvents: YES];
847 - (BOOL)resignFirstResponder
849 [[self window] setAcceptsMouseMovedEvents: NO];
853 - (void)mouseUp:(NSEvent *)o_event
855 switch( [o_event type] )
860 val.b_bool = VLC_TRUE;
861 var_Set( p_vout, "mouse-clicked", val );
866 [super mouseUp: o_event];
871 - (void)mouseMoved:(NSEvent *)o_event
877 s_rect = [self bounds];
878 ml = [self convertPoint: [o_event locationInWindow] fromView: nil];
879 b_inside = [self mouse: ml inRect: s_rect];
884 int i_width, i_height, i_x, i_y;
886 vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width,
887 (unsigned int)s_rect.size.height,
888 &i_x, &i_y, &i_width, &i_height );
890 val.i_int = ( ((int)ml.x) - i_x ) *
891 p_vout->render.i_width / i_width;
892 var_Set( p_vout, "mouse-x", val );
894 val.i_int = ( ((int)ml.y) - i_y ) *
895 p_vout->render.i_height / i_height;
896 var_Set( p_vout, "mouse-y", val );
898 val.b_bool = VLC_TRUE;
899 var_Set( p_vout, "mouse-moved", val );
903 [super mouseMoved: o_event];