aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Westerfeld <stefan@space.twc.de>2019-06-23 16:21:15 +0200
committerDavid Robillard <d@drobilla.net>2019-07-24 01:02:52 +0200
commit9d127e389aa182f5d75395a59b3ba7241575f525 (patch)
tree6edec70b0538845a8179c00a269fc1c2af2477d9
parentb0ddcbba56b8fc6f1576553c805b5dc7185773e4 (diff)
Represent event time as double in seconds on all platforms
-rw-r--r--pugl/pugl.h10
-rw-r--r--pugl/pugl_win.c10
-rw-r--r--pugl/pugl_x11.c10
3 files changed, 15 insertions, 15 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index d744477..0953238 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -218,7 +218,7 @@ typedef struct {
PuglEventType type; /**< PUGL_BUTTON_PRESS or PUGL_BUTTON_RELEASE. */
PuglView* view; /**< View that received this event. */
uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */
- uint32_t time; /**< Time in milliseconds. */
+ double time; /**< Time in seconds. */
double x; /**< View-relative X coordinate. */
double y; /**< View-relative Y coordinate. */
double x_root; /**< Root-relative X coordinate. */
@@ -288,7 +288,7 @@ typedef struct {
PuglEventType type; /**< PUGL_KEY_PRESS or PUGL_KEY_RELEASE. */
PuglView* view; /**< View that received this event. */
uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */
- uint32_t time; /**< Time in milliseconds. */
+ double time; /**< Time in seconds. */
double x; /**< View-relative X coordinate. */
double y; /**< View-relative Y coordinate. */
double x_root; /**< Root-relative X coordinate. */
@@ -308,7 +308,7 @@ typedef struct {
PuglEventType type; /**< PUGL_ENTER_NOTIFY or PUGL_LEAVE_NOTIFY. */
PuglView* view; /**< View that received this event. */
uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */
- uint32_t time; /**< Time in milliseconds. */
+ double time; /**< Time in seconds. */
double x; /**< View-relative X coordinate. */
double y; /**< View-relative Y coordinate. */
double x_root; /**< Root-relative X coordinate. */
@@ -324,7 +324,7 @@ typedef struct {
PuglEventType type; /**< PUGL_MOTION_NOTIFY. */
PuglView* view; /**< View that received this event. */
uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */
- uint32_t time; /**< Time in milliseconds. */
+ double time; /**< Time in seconds. */
double x; /**< View-relative X coordinate. */
double y; /**< View-relative Y coordinate. */
double x_root; /**< Root-relative X coordinate. */
@@ -347,7 +347,7 @@ typedef struct {
PuglEventType type; /**< PUGL_SCROLL. */
PuglView* view; /**< View that received this event. */
uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */
- uint32_t time; /**< Time in milliseconds. */
+ double time; /**< Time in seconds. */
double x; /**< View-relative X coordinate. */
double y; /**< View-relative Y coordinate. */
double x_root; /**< Root-relative X coordinate. */
diff --git a/pugl/pugl_win.c b/pugl/pugl_win.c
index af32210..e9fecac 100644
--- a/pugl/pugl_win.c
+++ b/pugl/pugl_win.c
@@ -457,7 +457,7 @@ initMouseEvent(PuglEvent* event,
ReleaseCapture();
}
- event->button.time = (uint32_t)GetMessageTime();
+ event->button.time = GetMessageTime() / 1e3;
event->button.type = press ? PUGL_BUTTON_PRESS : PUGL_BUTTON_RELEASE;
event->button.x = GET_X_LPARAM(lParam);
event->button.y = GET_Y_LPARAM(lParam);
@@ -473,7 +473,7 @@ initScrollEvent(PuglEvent* event, PuglView* view, LPARAM lParam)
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
ScreenToClient(view->impl->hwnd, &pt);
- event->scroll.time = (uint32_t)GetMessageTime();
+ event->scroll.time = GetMessageTime() / 1e3;
event->scroll.type = PUGL_SCROLL;
event->scroll.x = pt.x;
event->scroll.y = pt.y;
@@ -518,7 +518,7 @@ initKeyEvent(PuglEvent* event, PuglView* view, bool press, LPARAM lParam)
ScreenToClient(view->impl->hwnd, &rpos);
event->key.type = press ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE;
- event->key.time = (uint32_t)GetMessageTime();
+ event->key.time = GetMessageTime() / 1e3;
event->key.state = getModifiers();
event->key.x_root = rpos.x;
event->key.y_root = rpos.y;
@@ -638,7 +638,7 @@ handleCrossing(PuglView* view, const PuglEventType type, POINT pos)
type,
view,
0,
- (uint32_t)GetMessageTime(),
+ GetMessageTime() / 1e3,
(double)pos.x,
(double)pos.y,
(double)root_pos.x,
@@ -740,7 +740,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
ClientToScreen(view->impl->hwnd, &pt);
event.motion.type = PUGL_MOTION_NOTIFY;
- event.motion.time = (uint32_t)GetMessageTime();
+ event.motion.time = GetMessageTime() / 1e3;
event.motion.x = GET_X_LPARAM(lParam);
event.motion.y = GET_Y_LPARAM(lParam);
event.motion.x_root = pt.x;
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index bd9de42..3bd94df 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -336,7 +336,7 @@ translateEvent(PuglView* view, XEvent xevent)
break;
case MotionNotify:
event.type = PUGL_MOTION_NOTIFY;
- event.motion.time = xevent.xmotion.time;
+ event.motion.time = xevent.xmotion.time / 1e3;
event.motion.x = xevent.xmotion.x;
event.motion.y = xevent.xmotion.y;
event.motion.x_root = xevent.xmotion.x_root;
@@ -347,7 +347,7 @@ translateEvent(PuglView* view, XEvent xevent)
case ButtonPress:
if (xevent.xbutton.button >= 4 && xevent.xbutton.button <= 7) {
event.type = PUGL_SCROLL;
- event.scroll.time = xevent.xbutton.time;
+ event.scroll.time = xevent.xbutton.time / 1e3;
event.scroll.x = xevent.xbutton.x;
event.scroll.y = xevent.xbutton.y;
event.scroll.x_root = xevent.xbutton.x_root;
@@ -369,7 +369,7 @@ translateEvent(PuglView* view, XEvent xevent)
event.button.type = ((xevent.type == ButtonPress)
? PUGL_BUTTON_PRESS
: PUGL_BUTTON_RELEASE);
- event.button.time = xevent.xbutton.time;
+ event.button.time = xevent.xbutton.time / 1e3;
event.button.x = xevent.xbutton.x;
event.button.y = xevent.xbutton.y;
event.button.x_root = xevent.xbutton.x_root;
@@ -383,7 +383,7 @@ translateEvent(PuglView* view, XEvent xevent)
event.type = ((xevent.type == KeyPress)
? PUGL_KEY_PRESS
: PUGL_KEY_RELEASE);
- event.key.time = xevent.xkey.time;
+ event.key.time = xevent.xkey.time / 1e3;
event.key.x = xevent.xkey.x;
event.key.y = xevent.xkey.y;
event.key.x_root = xevent.xkey.x_root;
@@ -396,7 +396,7 @@ translateEvent(PuglView* view, XEvent xevent)
event.type = ((xevent.type == EnterNotify)
? PUGL_ENTER_NOTIFY
: PUGL_LEAVE_NOTIFY);
- event.crossing.time = xevent.xcrossing.time;
+ event.crossing.time = xevent.xcrossing.time / 1e3;
event.crossing.x = xevent.xcrossing.x;
event.crossing.y = xevent.xcrossing.y;
event.crossing.x_root = xevent.xcrossing.x_root;