aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-17 21:56:37 +0000
committerDavid Robillard <d@drobilla.net>2014-01-17 21:56:37 +0000
commit12898ecf40723adb674bad95c10d1e8092794297 (patch)
tree131ca9eebaa3c488b7124db4831392872f25caf1 /pugl
parentcea41bcb9be36fdfe9d273133996e1622586f27b (diff)
downloadpugl-12898ecf40723adb674bad95c10d1e8092794297.tar.gz
pugl-12898ecf40723adb674bad95c10d1e8092794297.tar.bz2
pugl-12898ecf40723adb674bad95c10d1e8092794297.zip
Add mouse position to PuglScrollFunc (apply #896).
Fix compilation of pugl_test.
Diffstat (limited to 'pugl')
-rw-r--r--pugl/pugl.h6
-rw-r--r--pugl/pugl_osx.m5
-rw-r--r--pugl/pugl_win.cpp6
-rw-r--r--pugl/pugl_x11.c4
4 files changed, 16 insertions, 5 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 7f68351..8d82016 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -199,7 +199,11 @@ typedef void (*PuglReshapeFunc)(PuglView* view, int width, int height);
@param dx The scroll x distance.
@param dx The scroll y distance.
*/
-typedef void (*PuglScrollFunc)(PuglView* view, float dx, float dy);
+typedef void (*PuglScrollFunc)(PuglView* view,
+ int x,
+ int y,
+ float dx,
+ float dy);
/**
A function called when a special key is pressed or released.
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index a9bbd24..c318d91 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -273,8 +273,11 @@ getModifiers(PuglView* view, NSEvent* ev)
- (void) scrollWheel:(NSEvent*)event
{
if (puglview->scrollFunc) {
+ NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
- puglview->scrollFunc(puglview, [event deltaX], [event deltaY]);
+ puglview->scrollFunc(puglview,
+ loc.x, puglview->height - loc.y,
+ [event deltaX], [event deltaY]);
}
[self updateTrackingAreas];
}
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 780752b..c95a2d2 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -286,13 +286,15 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
if (view->scrollFunc) {
view->scrollFunc(
- view, 0, (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA);
+ view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
+ (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA);
}
break;
case WM_MOUSEHWHEEL:
if (view->scrollFunc) {
view->scrollFunc(
- view, (int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0);
+ view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
+ (int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0);
}
break;
case WM_KEYDOWN:
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index d9fccf2..bd29074 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -296,7 +296,9 @@ puglProcessEvents(PuglView* view)
case 6: dx = -1.0f; break;
case 7: dx = 1.0f; break;
}
- view->scrollFunc(view, dx, dy);
+ view->scrollFunc(view,
+ event.xbutton.x, event.xbutton.y,
+ dx, dy);
}
break;
}