From d7f0b78c32bc8da9461b8abed8722d15ddb0360a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 1 Mar 2020 11:18:37 +0100 Subject: Put PuglEventAny member of PuglEvent first for easy initialization --- pugl/detail/mac.m | 9 +++------ pugl/detail/x11.c | 2 +- pugl/pugl.h | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'pugl') diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index ca2cb7c..36499c0 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -643,8 +643,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) { (void)sender; - PuglEvent ev = { 0 }; - ev.type = PUGL_CLOSE; + const PuglEvent ev = {{PUGL_CLOSE, 0}}; puglDispatchEvent(window->puglview, &ev); return YES; } @@ -666,8 +665,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) wrapperView->urgentTimer = NULL; } - PuglEvent ev = { 0 }; - ev.type = PUGL_FOCUS_IN; + PuglEvent ev = {{PUGL_FOCUS_IN, 0}}; ev.focus.grab = false; puglDispatchEvent(window->puglview, &ev); } @@ -676,8 +674,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) { (void)notification; - PuglEvent ev = { 0 }; - ev.type = PUGL_FOCUS_OUT; + PuglEvent ev = {{PUGL_FOCUS_OUT, 0}}; ev.focus.grab = false; puglDispatchEvent(window->puglview, &ev); } diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index 38f10d0..9156c57 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -409,7 +409,7 @@ translateEvent(PuglView* view, XEvent xevent) { const PuglX11Atoms* atoms = &view->world->impl->atoms; - PuglEvent event = {0}; + PuglEvent event = {{PUGL_NOTHING, 0}}; event.any.flags = xevent.xany.send_event ? PUGL_IS_SEND_EVENT : 0; switch (xevent.type) { diff --git a/pugl/pugl.h b/pugl/pugl.h index 0bd8b47..b5b6d25 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -411,8 +411,8 @@ typedef struct { either be cast to the appropriate type, or the union members used. */ typedef union { - PuglEventType type; ///< Event type PuglEventAny any; ///< Valid for all event types + PuglEventType type; ///< Event type PuglEventButton button; ///< PUGL_BUTTON_PRESS, PUGL_BUTTON_RELEASE PuglEventConfigure configure; ///< PUGL_CONFIGURE PuglEventExpose expose; ///< PUGL_EXPOSE -- cgit v1.2.1