Commit 2a2b4783 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Mac OS X gui: Use the proper vlc infrastructure to send mouse wheel event.

parent 3af039a0
......@@ -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
......
......@@ -38,6 +38,7 @@
#import "controls.h"
#import "playlist.h"
#include <vlc_osd.h>
#include <vlc_keys.h>
/*****************************************************************************
* VLCControls implementation
......@@ -464,6 +465,24 @@
}
- (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;
......
......@@ -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];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment