aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-05-08 13:42:17 -0400
committerDavid Robillard <d@drobilla.net>2021-05-08 13:42:17 -0400
commit44ac442eb14a0cef9c51f2654b87f56afc17ff2a (patch)
tree7c1fa265b389424cbac81c71c72749960bb2b5cb
parent0380b427cdf712e46befccaffe85d30f09e851dc (diff)
downloadpugl-44ac442eb14a0cef9c51f2654b87f56afc17ff2a.tar.gz
pugl-44ac442eb14a0cef9c51f2654b87f56afc17ff2a.tar.bz2
pugl-44ac442eb14a0cef9c51f2654b87f56afc17ff2a.zip
X11: Factor out translateClientMessage()
-rw-r--r--src/x11.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/x11.c b/src/x11.c
index cdbb252..4c4bb42 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -551,25 +551,34 @@ translateModifiers(const unsigned xstate)
}
static PuglEvent
-translateEvent(PuglView* const view, XEvent xevent)
+translateClientMessage(PuglView* const view, const XClientMessageEvent message)
{
- const PuglX11Atoms* atoms = &view->world->impl->atoms;
+ const PuglX11Atoms* const atoms = &view->world->impl->atoms;
+ PuglEvent event = {{PUGL_NOTHING, 0}};
+ if (message.message_type == atoms->WM_PROTOCOLS) {
+ const Atom protocol = (Atom)message.data.l[0];
+ if (protocol == atoms->WM_DELETE_WINDOW) {
+ event.type = PUGL_CLOSE;
+ }
+ } else if (message.message_type == atoms->PUGL_CLIENT_MSG) {
+ event.type = PUGL_CLIENT;
+ event.client.data1 = (uintptr_t)message.data.l[0];
+ event.client.data2 = (uintptr_t)message.data.l[1];
+ }
+
+ return event;
+}
+
+static PuglEvent
+translateEvent(PuglView* const view, XEvent xevent)
+{
PuglEvent event = {{PUGL_NOTHING, 0}};
event.any.flags = xevent.xany.send_event ? PUGL_IS_SEND_EVENT : 0;
switch (xevent.type) {
case ClientMessage:
- if (xevent.xclient.message_type == atoms->WM_PROTOCOLS) {
- const Atom protocol = (Atom)xevent.xclient.data.l[0];
- if (protocol == atoms->WM_DELETE_WINDOW) {
- event.type = PUGL_CLOSE;
- }
- } else if (xevent.xclient.message_type == atoms->PUGL_CLIENT_MSG) {
- event.type = PUGL_CLIENT;
- event.client.data1 = (uintptr_t)xevent.xclient.data.l[0];
- event.client.data2 = (uintptr_t)xevent.xclient.data.l[1];
- }
+ event = translateClientMessage(view, xevent.xclient);
break;
case VisibilityNotify:
view->visible = xevent.xvisibility.state != VisibilityFullyObscured;