]> git.sesse.net Git - vlc/commitdiff
Mac OS X gui: Use the proper vlc infrastructure to send mouse wheel event.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 22 Apr 2007 16:45:08 +0000 (16:45 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 22 Apr 2007 16:45:08 +0000 (16:45 +0000)
modules/gui/macosx/controls.h
modules/gui/macosx/controls.m
modules/gui/macosx/vout.m

index cc7111597bbb0f5fb3bdcf8ac632e8e5326ae549..6462e8776d742d641af05b4332dd837a35231437 100644 (file)
@@ -83,6 +83,7 @@
 - (BOOL) isFullscreen;
 - (IBAction)windowAction:(id)sender;
 - (BOOL)keyEvent:(NSEvent *)o_event;
+- (void)scrollWheel:(NSEvent *)theEvent;
 
 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
                     target:(vlc_object_t *)p_object
index 92afaf8feaf9bac82255e8dccc4611ac2d7c9613..862e54bb3e82392365c283c12d08d420613025a6 100644 (file)
@@ -38,6 +38,7 @@
 #import "controls.h"
 #import "playlist.h"
 #include <vlc_osd.h>
+#include <vlc_keys.h>
 
 /*****************************************************************************
  * VLCControls implementation 
 
 }
 
+- (void)scrollWheel:(NSEvent *)theEvent
+{
+    intf_thread_t * p_intf = VLCIntf;
+    float f_absvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
+    int i, i_vlckey;
+
+    f_absvalue = f_absvalue/2.0f + 1.0f;
+
+    if ([theEvent deltaY] < 0.0f)
+        i_vlckey = KEY_MOUSEWHEELDOWN;
+    else
+        i_vlckey = KEY_MOUSEWHEELUP;
+
+    /* Send multiple key event, depending on the intensity of the event */
+    for (i = 0; i < (int)f_absvalue; i++)
+        var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
+}
+
 - (BOOL)keyEvent:(NSEvent *)o_event
 {
     BOOL eventHandled = NO;
index 279cfdcfe25fb786f7650a7021a39f1ce9ba8c4f..bb487d0d79a0458f610e50300a2eeedfb3720215 100644 (file)
@@ -442,22 +442,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 - (void)scrollWheel:(NSEvent *)theEvent
 {
     VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls];
-    float f_absvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
-    int i;
-    f_absvalue /= 2.0f;
-    f_absvalue += 1.0f;
-
-    /* Set the volume */
-    if (f_absvalue > 1.1f)
-    {
-        for (i = 0; i < (int)f_absvalue; i++)
-        {
-            if ([theEvent deltaY] < 0.0f)
-                [o_controls volumeDown: self];
-            else
-                [o_controls volumeUp: self];
-        }
-    }
+    [o_controls scrollWheel: theEvent];
 }
 
 - (void)keyDown:(NSEvent *)o_event
@@ -960,6 +945,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
         [self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
 
+        [o_window setAspectRatio:NSMakeSize([o_window frame].size.width, [o_window frame].size.height)];
+
         /* Make sure our window is visible, if we are not in fullscreen */
         if (![o_window isFullscreen])
             [o_window makeKeyAndOrderFront: self];