diff --git a/dgl/Window.hpp b/dgl/Window.hpp index 5e80b1a9..bc9df247 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -306,7 +306,10 @@ public: This gets the system clipboard contents, which may have been set with setClipboard() or copied from another application. - returns the clipboard contents, or null. + Returns the clipboard contents, or null. + + @note By default only "text/plain" mimetype is supported and returned. + Override onClipboardDataOffer for supporting other types. */ const void* getClipboard(size_t& dataSize); @@ -465,7 +468,7 @@ protected: Reimplement and return a non-zero id to accept the clipboard data offer for a particular type. Applications must ignore any type they do not recognize. - The default implementation does nothing. + The default implementation accepts the "text/plain" mimetype. */ virtual uint32_t onClipboardDataOffer(); diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index e44ffd18..b65261ff 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -485,6 +485,15 @@ std::vector Window::getClipboardDataOfferTypes() uint32_t Window::onClipboardDataOffer() { + std::vector offers(getClipboardDataOfferTypes()); + + for (std::vector::iterator it=offers.begin(), end=offers.end(); it != end;++it) + { + const ClipboardDataOffer offer = *it; + if (std::strcmp(offer.type, "text/plain") == 0) + return offer.id; + } + return 0; } diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 3b0bd007..7b0dafda 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -309,7 +309,7 @@ protected: Reimplement and return a non-zero id to accept the clipboard data offer for a particular type. UIs must ignore any type they do not recognize. - The default implementation does nothing. + The default implementation accepts the "text/plain" mimetype. */ virtual uint32_t uiClipboardDataOffer(); diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 2fe43a1b..9a5ef855 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -345,6 +345,15 @@ std::vector UI::getClipboardDataOfferTypes() uint32_t UI::uiClipboardDataOffer() { + std::vector offers(uiData->window->getClipboardDataOfferTypes()); + + for (std::vector::iterator it=offers.begin(), end=offers.end(); it != end;++it) + { + const ClipboardDataOffer offer = *it; + if (std::strcmp(offer.type, "text/plain") == 0) + return offer.id; + } + return 0; } diff --git a/pugl-updates-notes.txt b/pugl-updates-notes.txt index 8e22c015..e33b6a0e 100644 --- a/pugl-updates-notes.txt +++ b/pugl-updates-notes.txt @@ -4,7 +4,3 @@ puglSetWindowSize was used on first show, still needed? transientParentView needed? remove from WindowPrivateData update distrhoui.cpp get scale factor to match new parent request setup and pugl - -clipboard todo - -pugl namespace details finalized