diff options
author | David Robillard <d@drobilla.net> | 2020-03-17 18:43:41 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-03-17 18:58:42 +0100 |
commit | 8ecb682579e5a8236cddf151ec200f5ea07d3292 (patch) | |
tree | 51d8bf5ba75384d4365071f42559b5ad626107c0 | |
parent | 163748d173af0ebeeec80b1e414169e72d23bb24 (diff) |
Use clearer names for pointer events
These old "notify" names are a smell from X11 which is a bit strange and
inconsistent here, since nearly everything is a "notification" of sorts. I
think the new names here are much more clear since they are consistent with the
keyboard focus events.
-rw-r--r-- | examples/pugl_cairo_demo.c | 4 | ||||
-rw-r--r-- | examples/pugl_embed_demo.c | 8 | ||||
-rw-r--r-- | examples/pugl_window_demo.c | 6 | ||||
-rw-r--r-- | pugl/detail/mac.m | 6 | ||||
-rw-r--r-- | pugl/detail/win.c | 6 | ||||
-rw-r--r-- | pugl/detail/x11.c | 6 | ||||
-rw-r--r-- | pugl/pugl.h | 41 | ||||
-rw-r--r-- | test/test_utils.h | 6 |
8 files changed, 46 insertions, 37 deletions
diff --git a/examples/pugl_cairo_demo.c b/examples/pugl_cairo_demo.c index a1423ae..6b43cb0 100644 --- a/examples/pugl_cairo_demo.c +++ b/examples/pugl_cairo_demo.c @@ -195,11 +195,11 @@ onEvent(PuglView* view, const PuglEvent* event) app->mouseDown = false; postButtonRedisplay(view); break; - case PUGL_ENTER_NOTIFY: + case PUGL_POINTER_IN: app->entered = true; puglPostRedisplay(view); break; - case PUGL_LEAVE_NOTIFY: + case PUGL_POINTER_OUT: app->entered = false; puglPostRedisplay(view); break; diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c index a540b67..313a92c 100644 --- a/examples/pugl_embed_demo.c +++ b/examples/pugl_embed_demo.c @@ -193,7 +193,7 @@ onParentEvent(PuglView* view, const PuglEvent* event) case PUGL_KEY_PRESS: onKeyPress(view, &event->key, "Parent: "); break; - case PUGL_MOTION_NOTIFY: + case PUGL_MOTION: break; case PUGL_CLOSE: app->quit = 1; @@ -230,7 +230,7 @@ onEvent(PuglView* view, const PuglEvent* event) case PUGL_KEY_PRESS: onKeyPress(view, &event->key, "Child: "); break; - case PUGL_MOTION_NOTIFY: + case PUGL_MOTION: app->xAngle -= event->motion.x - app->lastMouseX; app->yAngle += event->motion.y - app->lastMouseY; app->lastMouseX = event->motion.x; @@ -246,10 +246,10 @@ onEvent(PuglView* view, const PuglEvent* event) puglPostRedisplay(view); } break; - case PUGL_ENTER_NOTIFY: + case PUGL_POINTER_IN: app->mouseEntered = true; break; - case PUGL_LEAVE_NOTIFY: + case PUGL_POINTER_OUT: app->mouseEntered = false; break; case PUGL_TIMER: diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c index 175d782..7beb330 100644 --- a/examples/pugl_window_demo.c +++ b/examples/pugl_window_demo.c @@ -142,7 +142,7 @@ onEvent(PuglView* view, const PuglEvent* event) case PUGL_KEY_PRESS: onKeyPress(view, &event->key); break; - case PUGL_MOTION_NOTIFY: + case PUGL_MOTION: cube->xAngle -= event->motion.x - cube->lastMouseX; cube->yAngle += event->motion.y - cube->lastMouseY; cube->lastMouseX = event->motion.x; @@ -153,11 +153,11 @@ onEvent(PuglView* view, const PuglEvent* event) cube->dist = fmaxf(10.0f, cube->dist + (float)event->scroll.dy); redisplayView(app, view); break; - case PUGL_ENTER_NOTIFY: + case PUGL_POINTER_IN: cube->entered = true; redisplayView(app, view); break; - case PUGL_LEAVE_NOTIFY: + case PUGL_POINTER_OUT: cube->entered = false; redisplayView(app, view); break; diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index 8a0f0c2..bd1fdcf 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -271,12 +271,12 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) - (void) mouseEntered:(NSEvent*)event { - handleCrossing(self, event, PUGL_ENTER_NOTIFY); + handleCrossing(self, event, PUGL_POINTER_IN); } - (void) mouseExited:(NSEvent*)event { - handleCrossing(self, event, PUGL_LEAVE_NOTIFY); + handleCrossing(self, event, PUGL_POINTER_OUT); } - (void) mouseMoved:(NSEvent*)event @@ -284,7 +284,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) const NSPoint wloc = [self eventLocation:event]; const NSPoint rloc = [NSEvent mouseLocation]; const PuglEventMotion ev = { - PUGL_MOTION_NOTIFY, + PUGL_MOTION, 0, [event timestamp], wloc.x, diff --git a/pugl/detail/win.c b/pugl/detail/win.c index 7678607..4606d60 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -617,12 +617,12 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) tme.hwndTrack = view->impl->hwnd; TrackMouseEvent(&tme); - handleCrossing(view, PUGL_ENTER_NOTIFY, pt); + handleCrossing(view, PUGL_POINTER_IN, pt); view->impl->mouseTracked = true; } ClientToScreen(view->impl->hwnd, &pt); - event.motion.type = PUGL_MOTION_NOTIFY; + event.motion.type = PUGL_MOTION; event.motion.time = GetMessageTime() / 1e3; event.motion.x = GET_X_LPARAM(lParam); event.motion.y = GET_Y_LPARAM(lParam); @@ -634,7 +634,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) case WM_MOUSELEAVE: GetCursorPos(&pt); ScreenToClient(view->impl->hwnd, &pt); - handleCrossing(view, PUGL_LEAVE_NOTIFY, pt); + handleCrossing(view, PUGL_POINTER_OUT, pt); view->impl->mouseTracked = false; break; case WM_LBUTTONDOWN: diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index 9613dfb..1511b7b 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -493,7 +493,7 @@ translateEvent(PuglView* view, XEvent xevent) event.expose.count = xevent.xexpose.count; break; case MotionNotify: - event.type = PUGL_MOTION_NOTIFY; + event.type = PUGL_MOTION; event.motion.time = xevent.xmotion.time / 1e3; event.motion.x = xevent.xmotion.x; event.motion.y = xevent.xmotion.y; @@ -552,8 +552,8 @@ translateEvent(PuglView* view, XEvent xevent) case EnterNotify: case LeaveNotify: event.type = ((xevent.type == EnterNotify) - ? PUGL_ENTER_NOTIFY - : PUGL_LEAVE_NOTIFY); + ? PUGL_POINTER_IN + : PUGL_POINTER_OUT); event.crossing.time = xevent.xcrossing.time / 1e3; event.crossing.x = xevent.xcrossing.x; event.crossing.y = xevent.xcrossing.y; diff --git a/pugl/pugl.h b/pugl/pugl.h index 8e20f35..0d0f3b6 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -42,6 +42,16 @@ # define PUGL_API #endif +#ifndef PUGL_DISABLE_DEPRECATED +# if defined(__clang__) +# define PUGL_DEPRECATED_BY(rep) __attribute__((deprecated("", rep))) +# elif defined(__GNUC__) +# define PUGL_DEPRECATED_BY(rep) __attribute__((deprecated("Use " rep))) +# else +# define PUGL_DEPRECATED_BY(rep) +# endif +#endif + #ifdef __cplusplus # define PUGL_BEGIN_DECLS extern "C" { # define PUGL_END_DECLS } @@ -179,14 +189,21 @@ typedef enum { PUGL_KEY_PRESS, ///< Key pressed, a #PuglEventKey PUGL_KEY_RELEASE, ///< Key released, a #PuglEventKey PUGL_TEXT, ///< Character entered, a #PuglEventText - PUGL_ENTER_NOTIFY, ///< Pointer entered view, a #PuglEventCrossing - PUGL_LEAVE_NOTIFY, ///< Pointer left view, a #PuglEventCrossing - PUGL_MOTION_NOTIFY, ///< Pointer moved, a #PuglEventMotion + PUGL_POINTER_IN, ///< Pointer entered view, a #PuglEventCrossing + PUGL_POINTER_OUT, ///< Pointer left view, a #PuglEventCrossing + PUGL_MOTION, ///< Pointer moved, a #PuglEventMotion PUGL_SCROLL, ///< Scrolled, a #PuglEventScroll PUGL_FOCUS_IN, ///< Keyboard focus entered view, a #PuglEventFocus PUGL_FOCUS_OUT, ///< Keyboard focus left view, a #PuglEventFocus PUGL_CLIENT, ///< Custom client message, a #PuglEventClient - PUGL_TIMER ///< Timer triggered, a #PuglEventTimer + PUGL_TIMER, ///< Timer triggered, a #PuglEventTimer + +#ifndef PUGL_DISABLE_DEPRECATED + PUGL_ENTER_NOTIFY PUGL_DEPRECATED_BY("PUGL_POINTER_IN") = PUGL_POINTER_IN, + PUGL_LEAVE_NOTIFY PUGL_DEPRECATED_BY("PUGL_POINTER_OUT") = PUGL_POINTER_OUT, + PUGL_MOTION_NOTIFY PUGL_DEPRECATED_BY("PUGL_MOTION") = PUGL_MOTION, +#endif + } PuglEventType; /** @@ -330,7 +347,7 @@ typedef struct { window edge), as described by the #mode field. */ typedef struct { - PuglEventType type; ///< #PUGL_ENTER_NOTIFY or #PUGL_LEAVE_NOTIFY + PuglEventType type; ///< #PUGL_POINTER_IN or #PUGL_POINTER_OUT PuglEventFlags flags; ///< Bitwise OR of #PuglEventFlag values double time; ///< Time in seconds double x; ///< View-relative X coordinate @@ -345,7 +362,7 @@ typedef struct { Pointer motion event. */ typedef struct { - PuglEventType type; ///< #PUGL_MOTION_NOTIFY + PuglEventType type; ///< #PUGL_MOTION PuglEventFlags flags; ///< Bitwise OR of #PuglEventFlag values double time; ///< Time in seconds double x; ///< View-relative X coordinate @@ -440,8 +457,8 @@ typedef union { PuglEventExpose expose; ///< #PUGL_EXPOSE PuglEventKey key; ///< #PUGL_KEY_PRESS, #PUGL_KEY_RELEASE PuglEventText text; ///< #PUGL_TEXT - PuglEventCrossing crossing; ///< #PUGL_ENTER_NOTIFY, #PUGL_LEAVE_NOTIFY - PuglEventMotion motion; ///< #PUGL_MOTION_NOTIFY + PuglEventCrossing crossing; ///< #PUGL_POINTER_IN, #PUGL_POINTER_OUT + PuglEventMotion motion; ///< #PUGL_MOTION PuglEventScroll scroll; ///< #PUGL_SCROLL PuglEventFocus focus; ///< #PUGL_FOCUS_IN, #PUGL_FOCUS_OUT PuglEventClient client; ///< #PUGL_CLIENT @@ -1114,14 +1131,6 @@ puglSendEvent(PuglView* view, const PuglEvent* event); @{ */ -#if defined(__clang__) -# define PUGL_DEPRECATED_BY(name) __attribute__((deprecated("", name))) -#elif defined(__GNUC__) -# define PUGL_DEPRECATED_BY(name) __attribute__((deprecated("Use " name))) -#else -# define PUGL_DEPRECATED_BY(name) -#endif - /** Create a Pugl application and view. diff --git a/test/test_utils.h b/test/test_utils.h index cef94dd..34b66c0 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -103,12 +103,12 @@ printEvent(const PuglEvent* event, const char* prefix, const bool verbose) event->scroll.x, event->scroll.y) + printModifiers(event->scroll.state)); - case PUGL_ENTER_NOTIFY: + case PUGL_POINTER_IN: return PRINT("%sMouse enter at " PFMT "\n", prefix, event->crossing.x, event->crossing.y); - case PUGL_LEAVE_NOTIFY: + case PUGL_POINTER_OUT: return PRINT("%sMouse leave at " PFMT "\n", prefix, event->crossing.x, @@ -160,7 +160,7 @@ printEvent(const PuglEvent* event, const char* prefix, const bool verbose) event->expose.height); case PUGL_CLOSE: return PRINT("%sClose\n", prefix); - case PUGL_MOTION_NOTIFY: + case PUGL_MOTION: return PRINT("%sMouse motion at " PFMT "\n", prefix, event->motion.x, |