diff options
author | David Robillard <d@drobilla.net> | 2022-05-22 17:48:16 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-11-11 09:49:51 -0500 |
commit | c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6 (patch) | |
tree | ca5e6f85207f3f51bd3015a67c23d9dd0c917846 /src/win.c | |
parent | 32733abab8546b708cab59a4df09f92eb3214f73 (diff) | |
download | pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.tar.gz pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.tar.bz2 pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.zip |
Add API support for multiple clipboards
Adds a PuglClipboard enum, and uses it everywhere necessary to "structurally"
support multiple clipboards. Towards re-using this API to support DnD.
Diffstat (limited to 'src/win.c')
-rw-r--r-- | src/win.c | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -1348,16 +1348,22 @@ puglSetTransientParent(PuglView* view, PuglNativeView parent) } uint32_t -puglGetNumClipboardTypes(const PuglView* const PUGL_UNUSED(view)) +puglGetNumClipboardTypes(const PuglView* const PUGL_UNUSED(view), + const PuglClipboard clipboard) { - return IsClipboardFormatAvailable(CF_UNICODETEXT) ? 1U : 0U; + return (clipboard == PUGL_CLIPBOARD_GENERAL && + IsClipboardFormatAvailable(CF_UNICODETEXT)) + ? 1U + : 0U; } const char* puglGetClipboardType(const PuglView* const PUGL_UNUSED(view), - const uint32_t typeIndex) + const PuglClipboard clipboard, + const uint32_t PUGL_UNUSED(typeIndex)) { - return (typeIndex == 0 && IsClipboardFormatAvailable(CF_UNICODETEXT)) + return (clipboard == PUGL_CLIPBOARD_GENERAL && typeIndex == 0 && + IsClipboardFormatAvailable(CF_UNICODETEXT)) ? "text/plain" : NULL; } @@ -1388,12 +1394,17 @@ puglAcceptOffer(PuglView* const view, } const void* -puglGetClipboard(PuglView* const view, - const uint32_t typeIndex, - size_t* const len) +puglGetClipboard(PuglView* const view, + const PuglClipboard clipboard, + const uint32_t typeIndex, + size_t* const len) { PuglInternals* const impl = view->impl; + if (clipboard != PUGL_CLIPBOARD_GENERAL) { + return NULL; + } + if (typeIndex > 0U || !IsClipboardFormatAvailable(CF_UNICODETEXT) || !OpenClipboard(impl->hwnd)) { return NULL; @@ -1418,13 +1429,18 @@ puglGetClipboard(PuglView* const view, } PuglStatus -puglSetClipboard(PuglView* const view, - const char* const type, - const void* const data, - const size_t len) +puglSetClipboard(PuglView* const view, + const PuglClipboard clipboard, + const char* const type, + const void* const data, + const size_t len) { PuglInternals* const impl = view->impl; + if (clipboard != PUGL_CLIPBOARD_GENERAL) { + return PUGL_FAILURE; + } + PuglStatus st = puglSetBlob(&view->impl->clipboard, data, len); if (st) { return st; |