Browse Source

Make the default onClipboardDataOffer more friendly

Signed-off-by: falkTX <falktx@falktx.com>
pull/321/head
falkTX 2 years ago
parent
commit
fdbc69f0ba
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 24 additions and 7 deletions
  1. +5
    -2
      dgl/Window.hpp
  2. +9
    -0
      dgl/src/Window.cpp
  3. +1
    -1
      distrho/DistrhoUI.hpp
  4. +9
    -0
      distrho/src/DistrhoUI.cpp
  5. +0
    -4
      pugl-updates-notes.txt

+ 5
- 2
dgl/Window.hpp View File

@@ -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();



+ 9
- 0
dgl/src/Window.cpp View File

@@ -485,6 +485,15 @@ std::vector<ClipboardDataOffer> Window::getClipboardDataOfferTypes()

uint32_t Window::onClipboardDataOffer()
{
std::vector<ClipboardDataOffer> offers(getClipboardDataOfferTypes());

for (std::vector<ClipboardDataOffer>::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;
}



+ 1
- 1
distrho/DistrhoUI.hpp View File

@@ -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();



+ 9
- 0
distrho/src/DistrhoUI.cpp View File

@@ -345,6 +345,15 @@ std::vector<DGL_NAMESPACE::ClipboardDataOffer> UI::getClipboardDataOfferTypes()

uint32_t UI::uiClipboardDataOffer()
{
std::vector<ClipboardDataOffer> offers(uiData->window->getClipboardDataOfferTypes());

for (std::vector<ClipboardDataOffer>::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;
}



+ 0
- 4
pugl-updates-notes.txt View File

@@ -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

Loading…
Cancel
Save