diff options
author | David Robillard <d@drobilla.net> | 2016-08-31 18:11:48 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-08-31 18:11:48 -0400 |
commit | 156d9f03f26b4dd85dc75f652fb370b07bc2dab7 (patch) | |
tree | 3b27501b42cd0ba4d16bbf508acbebe2c963bffa /pugl | |
parent | 80510efead3512766d798d29fbfb66ea5646a249 (diff) | |
download | pugl-156d9f03f26b4dd85dc75f652fb370b07bc2dab7.tar.gz pugl-156d9f03f26b4dd85dc75f652fb370b07bc2dab7.tar.bz2 pugl-156d9f03f26b4dd85dc75f652fb370b07bc2dab7.zip |
Replace send_event with extensible flags
This is currently functionally equivalent, but taking up space in the
event struct for a single bool which could be used for 32 flags for any
number of things that might show up in the future seems like a very bad
idea.
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/event.h | 40 | ||||
-rw-r--r-- | pugl/pugl_osx.m | 14 | ||||
-rw-r--r-- | pugl/pugl_win.cpp | 8 | ||||
-rw-r--r-- | pugl/pugl_x11.c | 7 |
4 files changed, 38 insertions, 31 deletions
diff --git a/pugl/event.h b/pugl/event.h index 731e045..2c48369 100644 --- a/pugl/event.h +++ b/pugl/event.h @@ -49,6 +49,10 @@ typedef enum { PUGL_FOCUS_OUT } PuglEventType; +typedef enum { + PUGL_IS_SEND_EVENT = 1 +} PuglEventFlag; + /** Reason for a PuglEventCrossing. */ @@ -64,7 +68,7 @@ typedef enum { typedef struct { PuglEventType type; /**< Event type. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ } PuglEventAny; /** @@ -75,7 +79,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_BUTTON_PRESS or PUGL_BUTTON_RELEASE. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ uint32_t time; /**< Time in milliseconds. */ double x; /**< View-relative X coordinate. */ double y; /**< View-relative Y coordinate. */ @@ -91,7 +95,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_CONFIGURE. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ double x; /**< New parent-relative X coordinate. */ double y; /**< New parent-relative Y coordinate. */ double width; /**< New width. */ @@ -104,7 +108,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_EXPOSE. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ double x; /**< View-relative X coordinate. */ double y; /**< View-relative Y coordinate. */ double width; /**< Width of exposed region. */ @@ -136,7 +140,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_KEY_PRESS or PUGL_KEY_RELEASE. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ uint32_t time; /**< Time in milliseconds. */ double x; /**< View-relative X coordinate. */ double y; /**< View-relative Y coordinate. */ @@ -154,16 +158,16 @@ typedef struct { Pointer crossing event (enter and leave). */ typedef struct { - PuglEventType type; /**< PUGL_ENTER_NOTIFY or PUGL_LEAVE_NOTIFY. */ - PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ - uint32_t time; /**< Time in milliseconds. */ - double x; /**< View-relative X coordinate. */ - double y; /**< View-relative Y coordinate. */ - double x_root; /**< Root-relative X coordinate. */ - double y_root; /**< Root-relative Y coordinate. */ - unsigned state; /**< Bitwise OR of PuglMod flags. */ - PuglCrossingMode mode; /**< Reason for crossing. */ + 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 x; /**< View-relative X coordinate. */ + double y; /**< View-relative Y coordinate. */ + double x_root; /**< Root-relative X coordinate. */ + double y_root; /**< Root-relative Y coordinate. */ + unsigned state; /**< Bitwise OR of PuglMod flags. */ + PuglCrossingMode mode; /**< Reason for crossing. */ } PuglEventCrossing; /** @@ -172,7 +176,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_MOTION_NOTIFY. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ uint32_t time; /**< Time in milliseconds. */ double x; /**< View-relative X coordinate. */ double y; /**< View-relative Y coordinate. */ @@ -195,7 +199,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_SCROLL. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ uint32_t time; /**< Time in milliseconds. */ double x; /**< View-relative X coordinate. */ double y; /**< View-relative Y coordinate. */ @@ -212,7 +216,7 @@ typedef struct { typedef struct { PuglEventType type; /**< PUGL_FOCUS_IN or PUGL_FOCUS_OUT. */ PuglView* view; /**< View that received this event. */ - bool send_event; /**< True iff event was sent explicitly. */ + uint32_t flags; /**< Bitwise OR of PuglEventFlag values. */ bool grab; /**< True iff this is a grab/ungrab event. */ } PuglEventFocus; diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 1d9e408..7888c6c 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -182,7 +182,7 @@ puglDisplay(PuglView* view) const PuglEventConfigure ev = { PUGL_CONFIGURE, puglview, - false, + 0, bounds.origin.x, bounds.origin.y, bounds.size.width, @@ -276,7 +276,7 @@ getModifiers(PuglView* view, NSEvent* ev) const PuglEventMotion ev = { PUGL_MOTION_NOTIFY, puglview, - false, + 0, [event timestamp], wloc.x, puglview->height - wloc.y, @@ -306,7 +306,7 @@ getModifiers(PuglView* view, NSEvent* ev) const PuglEventButton ev = { PUGL_BUTTON_PRESS, puglview, - false, + 0, [event timestamp], wloc.x, puglview->height - wloc.y, @@ -325,7 +325,7 @@ getModifiers(PuglView* view, NSEvent* ev) const PuglEventButton ev = { PUGL_BUTTON_RELEASE, puglview, - false, + 0, [event timestamp], wloc.x, puglview->height - wloc.y, @@ -357,7 +357,7 @@ getModifiers(PuglView* view, NSEvent* ev) const PuglEventScroll ev = { PUGL_SCROLL, puglview, - false, + 0, [event timestamp], wloc.x, puglview->height - wloc.y, @@ -384,7 +384,7 @@ getModifiers(PuglView* view, NSEvent* ev) PuglEventKey ev = { PUGL_KEY_PRESS, puglview, - false, + 0, [event timestamp], wloc.x, puglview->height - wloc.y, @@ -410,7 +410,7 @@ getModifiers(PuglView* view, NSEvent* ev) const PuglEventKey ev = { PUGL_KEY_RELEASE, puglview, - false, + 0, [event timestamp], wloc.x, puglview->height - wloc.y, diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp index 1b303db..b834143 100644 --- a/pugl/pugl_win.cpp +++ b/pugl/pugl_win.cpp @@ -469,9 +469,11 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) memset(&event, 0, sizeof(event)); - event.any.type = PUGL_NOTHING; - event.any.view = view; - event.any.send_event = InSendMessageEx(dummy_ptr); + event.any.type = PUGL_NOTHING; + event.any.view = view; + if (InSendMessageEx(dummy_ptr)) { + event.any.flags |= PUGL_IS_SEND_EVENT; + } setModifiers(view); switch (message) { diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index e6d240c..5cd4373 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -453,8 +453,10 @@ translateEvent(PuglView* view, XEvent xevent) PuglEvent event; memset(&event, 0, sizeof(event)); - event.any.view = view; - event.any.send_event = xevent.xany.send_event; + event.any.view = view; + if (xevent.xany.send_event) { + event.any.flags |= PUGL_IS_SEND_EVENT; + } switch (xevent.type) { case ConfigureNotify: @@ -676,7 +678,6 @@ puglProcessEvents(PuglView* view) if (view->redisplay) { expose_event.expose.type = PUGL_EXPOSE; expose_event.expose.view = view; - expose_event.expose.send_event = true; expose_event.expose.x = 0; expose_event.expose.y = 0; expose_event.expose.width = view->width; |