diff options
author | David Robillard <d@drobilla.net> | 2023-01-02 17:04:12 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-01-02 17:04:12 -0500 |
commit | 23a1b165950d2f7b738ed42144e1569f0c82793c (patch) | |
tree | d16102362bd941a086b688d5ca15a669d7591917 | |
parent | 1b9c26d0e28bf5eeab864099bc422444bc439fd3 (diff) | |
download | pugl-23a1b165950d2f7b738ed42144e1569f0c82793c.tar.gz pugl-23a1b165950d2f7b738ed42144e1569f0c82793c.tar.bz2 pugl-23a1b165950d2f7b738ed42144e1569f0c82793c.zip |
X11: Factor out getCurrentConfiguration
-rw-r--r-- | src/x11.c | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -754,6 +754,23 @@ translateClientMessage(PuglView* const view, XClientMessageEvent message) } static PuglEvent +getCurrentConfiguration(PuglView* const view) +{ + // Get initial window position and size + XWindowAttributes attrs; + XGetWindowAttributes(view->world->impl->display, view->impl->win, &attrs); + + // Build a configure event with the current position and size + PuglEvent configureEvent = {{PUGL_CONFIGURE, 0}}; + configureEvent.configure.x = (PuglCoord)attrs.x; + configureEvent.configure.y = (PuglCoord)attrs.y; + configureEvent.configure.width = (PuglSpan)attrs.width; + configureEvent.configure.height = (PuglSpan)attrs.height; + + return configureEvent; +} + +static PuglEvent translatePropertyNotify(PuglView* const view, XPropertyEvent message) { const PuglX11Atoms* const atoms = &view->world->impl->atoms; @@ -1362,17 +1379,7 @@ handleTimerEvent(PuglWorld* const world, const XEvent xevent) static PuglStatus dispatchCurrentConfiguration(PuglView* const view) { - // Get initial window position and size - XWindowAttributes attrs; - XGetWindowAttributes(view->world->impl->display, view->impl->win, &attrs); - - // Build an initial configure event in case the WM doesn't send one - PuglEvent configureEvent = {{PUGL_CONFIGURE, 0}}; - configureEvent.configure.x = (PuglCoord)attrs.x; - configureEvent.configure.y = (PuglCoord)attrs.y; - configureEvent.configure.width = (PuglSpan)attrs.width; - configureEvent.configure.height = (PuglSpan)attrs.height; - + const PuglEvent configureEvent = getCurrentConfiguration(view); return puglDispatchEvent(view, &configureEvent); } |