diff options
-rw-r--r-- | pugl/detail/win.c | 35 | ||||
-rw-r--r-- | pugl/detail/win.h | 27 | ||||
-rw-r--r-- | pugl/detail/win_stub.c | 80 | ||||
-rw-r--r-- | pugl/detail/x11.c | 17 | ||||
-rw-r--r-- | pugl/detail/x11.h | 18 | ||||
-rw-r--r-- | pugl/detail/x11_stub.c | 54 | ||||
-rw-r--r-- | wscript | 11 |
7 files changed, 151 insertions, 91 deletions
diff --git a/pugl/detail/win.c b/pugl/detail/win.c index b3ba00d..078b0a0 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -1117,28 +1117,6 @@ puglSetClipboard(PuglView* const view, return PUGL_SUCCESS; } -static PuglStatus -puglWinStubEnter(PuglView* view, const PuglEventExpose* expose) -{ - if (expose) { - PAINTSTRUCT ps; - BeginPaint(view->impl->hwnd, &ps); - } - - return PUGL_SUCCESS; -} - -static PuglStatus -puglWinStubLeave(PuglView* view, const PuglEventExpose* expose) -{ - if (expose) { - PAINTSTRUCT ps; - EndPaint(view->impl->hwnd, &ps); - } - - return PUGL_SUCCESS; -} - static const char* const cursor_ids[] = { IDC_ARROW, // ARROW IDC_IBEAM, // CARET @@ -1172,16 +1150,3 @@ puglSetCursor(PuglView* view, PuglCursor cursor) return PUGL_SUCCESS; } - -const PuglBackend* -puglStubBackend(void) -{ - static const PuglBackend backend = {puglWinStubConfigure, - puglStubCreate, - puglStubDestroy, - puglWinStubEnter, - puglWinStubLeave, - puglStubGetContext}; - - return &backend; -} diff --git a/pugl/detail/win.h b/pugl/detail/win.h index 547bd02..b0d92e0 100644 --- a/pugl/detail/win.h +++ b/pugl/detail/win.h @@ -137,26 +137,11 @@ puglWinCreateWindow(PuglView* const view, return PUGL_SUCCESS; } -static inline PuglStatus -puglWinStubConfigure(PuglView* view) -{ - PuglInternals* const impl = view->impl; - PuglStatus st = PUGL_SUCCESS; - - if ((st = puglWinCreateWindow(view, "Pugl", &impl->hwnd, &impl->hdc))) { - return st; - } +PuglStatus +puglWinStubConfigure(PuglView* view); - impl->pfd = puglWinGetPixelFormatDescriptor(view->hints); - impl->pfId = ChoosePixelFormat(impl->hdc, &impl->pfd); +PuglStatus +puglWinStubEnter(PuglView* view, const PuglEventExpose* expose); - if (!SetPixelFormat(impl->hdc, impl->pfId, &impl->pfd)) { - ReleaseDC(impl->hwnd, impl->hdc); - DestroyWindow(impl->hwnd); - impl->hwnd = NULL; - impl->hdc = NULL; - return PUGL_SET_FORMAT_FAILED; - } - - return PUGL_SUCCESS; -} +PuglStatus +puglWinStubLeave(PuglView* view, const PuglEventExpose* expose); diff --git a/pugl/detail/win_stub.c b/pugl/detail/win_stub.c new file mode 100644 index 0000000..ab9e6aa --- /dev/null +++ b/pugl/detail/win_stub.c @@ -0,0 +1,80 @@ +/* + Copyright 2012-2020 David Robillard <d@drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "pugl/pugl_stub.h" + +#include "pugl/detail/stub.h" +#include "pugl/detail/types.h" +#include "pugl/detail/win.h" + +PuglStatus +puglWinStubConfigure(PuglView* view) +{ + PuglInternals* const impl = view->impl; + PuglStatus st = PUGL_SUCCESS; + + if ((st = puglWinCreateWindow(view, "Pugl", &impl->hwnd, &impl->hdc))) { + return st; + } + + impl->pfd = puglWinGetPixelFormatDescriptor(view->hints); + impl->pfId = ChoosePixelFormat(impl->hdc, &impl->pfd); + + if (!SetPixelFormat(impl->hdc, impl->pfId, &impl->pfd)) { + ReleaseDC(impl->hwnd, impl->hdc); + DestroyWindow(impl->hwnd); + impl->hwnd = NULL; + impl->hdc = NULL; + return PUGL_SET_FORMAT_FAILED; + } + + return PUGL_SUCCESS; +} + +PuglStatus +puglWinStubEnter(PuglView* view, const PuglEventExpose* expose) +{ + if (expose) { + PAINTSTRUCT ps; + BeginPaint(view->impl->hwnd, &ps); + } + + return PUGL_SUCCESS; +} + +PuglStatus +puglWinStubLeave(PuglView* view, const PuglEventExpose* expose) +{ + if (expose) { + PAINTSTRUCT ps; + EndPaint(view->impl->hwnd, &ps); + } + + return PUGL_SUCCESS; +} + +const PuglBackend* +puglStubBackend(void) +{ + static const PuglBackend backend = {puglWinStubConfigure, + puglStubCreate, + puglStubDestroy, + puglWinStubEnter, + puglWinStubLeave, + puglStubGetContext}; + + return &backend; +} diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index e6444c8..a41de3e 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -26,10 +26,8 @@ #include "pugl/detail/x11.h" #include "pugl/detail/implementation.h" -#include "pugl/detail/stub.h" #include "pugl/detail/types.h" #include "pugl/pugl.h" -#include "pugl/pugl_stub.h" #include <X11/X.h> #include <X11/Xatom.h> @@ -1343,18 +1341,3 @@ puglSetCursor(PuglView* view, PuglCursor cursor) return PUGL_FAILURE; #endif } - -const PuglBackend* -puglStubBackend(void) -{ - static const PuglBackend backend = { - puglX11StubConfigure, - puglStubCreate, - puglStubDestroy, - puglStubEnter, - puglStubLeave, - puglStubGetContext, - }; - - return &backend; -} diff --git a/pugl/detail/x11.h b/pugl/detail/x11.h index 4b0109d..b5ca75c 100644 --- a/pugl/detail/x11.h +++ b/pugl/detail/x11.h @@ -73,20 +73,4 @@ struct PuglInternalsImpl { #endif }; -static inline PuglStatus -puglX11StubConfigure(PuglView* view) -{ - PuglInternals* const impl = view->impl; - XVisualInfo pat = {0}; - int n = 0; - - pat.screen = impl->screen; - impl->vi = XGetVisualInfo(impl->display, VisualScreenMask, &pat, &n); - - view->hints[PUGL_RED_BITS] = impl->vi->bits_per_rgb; - view->hints[PUGL_GREEN_BITS] = impl->vi->bits_per_rgb; - view->hints[PUGL_BLUE_BITS] = impl->vi->bits_per_rgb; - view->hints[PUGL_ALPHA_BITS] = 0; - - return PUGL_SUCCESS; -} +PuglStatus puglX11StubConfigure(PuglView* view); diff --git a/pugl/detail/x11_stub.c b/pugl/detail/x11_stub.c new file mode 100644 index 0000000..8efd68f --- /dev/null +++ b/pugl/detail/x11_stub.c @@ -0,0 +1,54 @@ +/* + Copyright 2012-2020 David Robillard <d@drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "pugl/pugl_stub.h" + +#include "pugl/detail/stub.h" +#include "pugl/detail/types.h" +#include "pugl/detail/x11.h" + +PuglStatus +puglX11StubConfigure(PuglView* view) +{ + PuglInternals* const impl = view->impl; + XVisualInfo pat = {0}; + int n = 0; + + pat.screen = impl->screen; + impl->vi = XGetVisualInfo(impl->display, VisualScreenMask, &pat, &n); + + view->hints[PUGL_RED_BITS] = impl->vi->bits_per_rgb; + view->hints[PUGL_GREEN_BITS] = impl->vi->bits_per_rgb; + view->hints[PUGL_BLUE_BITS] = impl->vi->bits_per_rgb; + view->hints[PUGL_ALPHA_BITS] = 0; + + return PUGL_SUCCESS; +} + +const PuglBackend* +puglStubBackend(void) +{ + static const PuglBackend backend = { + puglX11StubConfigure, + puglStubCreate, + puglStubDestroy, + puglStubEnter, + puglStubLeave, + puglStubGetContext, + }; + + return &backend; +} @@ -350,6 +350,10 @@ def build(bld): uselib=['GDI32', 'USER32'], source=lib_source + ['pugl/detail/win.c']) + build_backend('win', 'stub', + uselib=['GDI32', 'USER32'], + source=['pugl/detail/win_stub.c']) + if bld.env.HAVE_GL: build_backend('win', 'gl', uselib=['GDI32', 'USER32', 'GL'], @@ -386,6 +390,10 @@ def build(bld): uselib=['M', 'X11', 'XSYNC', 'XCURSOR', 'XRANDR'], source=lib_source + ['pugl/detail/x11.c']) + build_backend('x11', 'stub', + uselib=['X11'], + source=['pugl/detail/x11_stub.c']) + if bld.env.HAVE_GL: glx_lib = 'GLX' if bld.env.LIB_GLX else 'GL' build_backend('x11', 'gl', @@ -395,7 +403,8 @@ def build(bld): if bld.env.HAVE_CAIRO: build_backend('x11', 'cairo', uselib=['CAIRO', 'X11'], - source=['pugl/detail/x11_cairo.c']) + source=['pugl/detail/x11_cairo.c', + 'pugl/detail/x11_stub.c']) def build_example(prog, source, platform, backend, **kwargs): lang = 'cxx' if source[0].endswith('.cpp') else 'c' |