]> git.sesse.net Git - vlc/commitdiff
* ./modules/gui/macosx/vout.m: mouse coordinates support.
authorJon Lech Johansen <jlj@videolan.org>
Wed, 4 Dec 2002 20:51:23 +0000 (20:51 +0000)
committerJon Lech Johansen <jlj@videolan.org>
Wed, 4 Dec 2002 20:51:23 +0000 (20:51 +0000)
modules/gui/macosx/intf.m
modules/gui/macosx/vout.m

index 20e9ccf8b9156d98d73cb3b7f382161d4df11280..d30c33907b885187294224b353df5191507eb5ac 100644 (file)
@@ -2,7 +2,7 @@
  * intf.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: intf.m,v 1.5 2002/11/28 17:35:01 sam Exp $
+ * $Id: intf.m,v 1.6 2002/12/04 20:51:23 jlj Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -902,7 +902,6 @@ static void Run( intf_thread_t *p_intf )
 
         [p_req->p_vout->p_sys->o_window setTitle: [NSString 
             stringWithCString: VOUT_TITLE " (QuickTime)"]];
-        [p_req->p_vout->p_sys->o_window setAcceptsMouseMovedEvents: YES];
         [p_req->p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
 
         p_req->i_result = 1;
index 559f13c4068ab4ce774a203bdeecd69f1e49db5c..3b4662456dfaffa2d72b5ae3dbc5392f4f2a737b 100644 (file)
@@ -2,7 +2,7 @@
  * vout.m: MacOS X video output plugin
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: vout.m,v 1.4 2002/11/18 23:00:41 massiot Exp $
+ * $Id: vout.m,v 1.5 2002/12/04 20:51:23 jlj Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Florian G. Pflug <fgp@phlo.org>
@@ -816,4 +816,75 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
     p_vout->i_changes |= VOUT_SIZE_CHANGE;
 }
 
+- (BOOL)acceptsFirstResponder
+{
+    return( YES );
+}
+
+- (BOOL)becomeFirstResponder
+{
+    [[self window] setAcceptsMouseMovedEvents: YES];
+    return( YES );
+}
+
+- (BOOL)resignFirstResponder
+{
+    [[self window] setAcceptsMouseMovedEvents: NO];
+    return( YES );
+}
+
+- (void)mouseUp:(NSEvent *)o_event
+{
+    switch( [o_event type] )
+    {
+        case NSLeftMouseUp:
+        {
+            vlc_value_t val;
+            val.b_bool = VLC_TRUE;
+            var_Set( p_vout, "mouse-clicked", val );        
+        }
+        break;
+
+        default:
+            [super mouseUp: o_event];
+        break;
+    }
+}
+
+- (void)mouseMoved:(NSEvent *)o_event
+{
+    NSPoint ml;
+    NSRect s_rect;
+    BOOL b_inside;
+
+    s_rect = [self bounds];
+    ml = [self convertPoint: [o_event locationInWindow] fromView: nil];
+    b_inside = [self mouse: ml inRect: s_rect];
+
+    if( b_inside )
+    {
+        vlc_value_t val;
+        int i_width, i_height, i_x, i_y;
+
+        vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width,
+                                   (unsigned int)s_rect.size.height,
+                                   &i_x, &i_y, &i_width, &i_height );
+
+        val.i_int = ( ((int)ml.x) - i_x ) * 
+                    p_vout->render.i_width / i_width;
+        var_Set( p_vout, "mouse-x", val );
+
+        val.i_int = ( ((int)ml.y) - i_y ) * 
+                    p_vout->render.i_height / i_height;
+        var_Set( p_vout, "mouse-y", val );
+
+        val.b_bool = VLC_TRUE;
+        var_Set( p_vout, "mouse-moved", val );
+    }
+    else
+    {
+        [super mouseMoved: o_event];
+    }
+}
+
 @end