Commit e666b3b2 authored by Jjgod Jiang's avatar Jjgod Jiang

Fix mouse wheel events in fullscreen mode for OS X

With proposed patch by vernier.
parent 5c9e54ea
...@@ -201,6 +201,7 @@ Cocoa_PumpEvents(_THIS) ...@@ -201,6 +201,7 @@ Cocoa_PumpEvents(_THIS)
case NSLeftMouseDragged: case NSLeftMouseDragged:
case NSRightMouseDragged: case NSRightMouseDragged:
case NSOtherMouseDragged: /* usually middle mouse dragged */ case NSOtherMouseDragged: /* usually middle mouse dragged */
case NSScrollWheel:
case NSMouseMoved: case NSMouseMoved:
Cocoa_HandleMouseEvent(_this, event); Cocoa_HandleMouseEvent(_this, event);
/* Pass through to NSApp to make sure everything stays in sync */ /* Pass through to NSApp to make sure everything stays in sync */
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
extern void Cocoa_InitMouse(_THIS); extern void Cocoa_InitMouse(_THIS);
extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event); extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event);
extern void Cocoa_QuitMouse(_THIS); extern void Cocoa_QuitMouse(_THIS);
extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event);
#endif /* _SDL_cocoamouse_h */ #endif /* _SDL_cocoamouse_h */
......
...@@ -93,6 +93,9 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) ...@@ -93,6 +93,9 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
case NSRightMouseUp: case NSRightMouseUp:
SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber])); SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
break; break;
case NSScrollWheel:
Cocoa_HandleMouseWheel(window, event);
break;
case NSLeftMouseDragged: case NSLeftMouseDragged:
case NSRightMouseDragged: case NSRightMouseDragged:
case NSOtherMouseDragged: /* usually middle mouse dragged */ case NSOtherMouseDragged: /* usually middle mouse dragged */
...@@ -109,4 +112,23 @@ Cocoa_QuitMouse(_THIS) ...@@ -109,4 +112,23 @@ Cocoa_QuitMouse(_THIS)
{ {
} }
void
Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
{
float x = [event deltaX];
float y = [event deltaY];
if (x > 0) {
x += 0.9f;
} else if (x < 0) {
x -= 0.9f;
}
if (y > 0) {
y += 0.9f;
} else if (y < 0) {
y -= 0.9f;
}
SDL_SendMouseWheel(window, (int)x, (int)y);
}
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "../../events/SDL_windowevents_c.h" #include "../../events/SDL_windowevents_c.h"
#include "SDL_cocoavideo.h" #include "SDL_cocoavideo.h"
#include "SDL_cocoashape.h" #include "SDL_cocoashape.h"
#include "SDL_cocoamouse.h"
static __inline__ void ConvertNSRect(NSRect *r) static __inline__ void ConvertNSRect(NSRect *r)
{ {
...@@ -260,20 +261,7 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -260,20 +261,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)scrollWheel:(NSEvent *)theEvent - (void)scrollWheel:(NSEvent *)theEvent
{ {
float x = [theEvent deltaX]; Cocoa_HandleMouseWheel(_data->window, theEvent);
float y = [theEvent deltaY];
if (x > 0) {
x += 0.9f;
} else if (x < 0) {
x -= 0.9f;
}
if (y > 0) {
y += 0.9f;
} else if (y < 0) {
y -= 0.9f;
}
SDL_SendMouseWheel(_data->window, (int)x, (int)y);
} }
- (void)touchesBeganWithEvent:(NSEvent *) theEvent - (void)touchesBeganWithEvent:(NSEvent *) theEvent
......
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