aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail
diff options
context:
space:
mode:
Diffstat (limited to 'pugl/detail')
-rw-r--r--pugl/detail/win.c35
-rw-r--r--pugl/detail/win.h27
-rw-r--r--pugl/detail/win_stub.c80
-rw-r--r--pugl/detail/x11.c17
-rw-r--r--pugl/detail/x11.h18
-rw-r--r--pugl/detail/x11_stub.c54
6 files changed, 141 insertions, 90 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;
+}