diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 6459163f..6fa5f3a6 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -264,7 +264,11 @@ bool Window::setClipboard(const char* const mimeType, const void* const data, co const void* Window::getClipboard(const char*& mimeType, size_t& dataSize) { - return puglGetClipboard(pData->view, &mimeType, &dataSize); + DISTRHO_SAFE_ASSERT_RETURN(!pData->ignoreEvents, nullptr); + pData->ignoreEvents = true; + const void* const clipboard = puglGetClipboard(pData->view, &mimeType, &dataSize); + pData->ignoreEvents = false; + return clipboard; } bool Window::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs) diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp index 097299b2..6c4ee299 100644 --- a/dgl/src/WindowPrivateData.cpp +++ b/dgl/src/WindowPrivateData.cpp @@ -83,6 +83,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s) minHeight(0), keepAspectRatio(false), ignoreIdleCallbacks(false), + ignoreEvents(false), filenameToRenderInto(nullptr), #ifndef DGL_FILE_BROWSER_DISABLED fileBrowserHandle(nullptr), @@ -109,6 +110,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, PrivateData* c minHeight(0), keepAspectRatio(false), ignoreIdleCallbacks(false), + ignoreEvents(false), filenameToRenderInto(nullptr), #ifndef DGL_FILE_BROWSER_DISABLED fileBrowserHandle(nullptr), @@ -139,6 +141,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, minHeight(0), keepAspectRatio(false), ignoreIdleCallbacks(false), + ignoreEvents(false), filenameToRenderInto(nullptr), #ifndef DGL_FILE_BROWSER_DISABLED fileBrowserHandle(nullptr), @@ -171,6 +174,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, minHeight(0), keepAspectRatio(false), ignoreIdleCallbacks(false), + ignoreEvents(false), filenameToRenderInto(nullptr), #ifndef DGL_FILE_BROWSER_DISABLED fileBrowserHandle(nullptr), @@ -785,6 +789,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< View must be drawn, a #PuglEventExpose case PUGL_EXPOSE: + if (pData->ignoreEvents) + break; // unused x, y, width, height (double) pData->onPuglExpose(); break; @@ -798,6 +804,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu case PUGL_FOCUS_IN: ///< Keyboard focus left view, a #PuglEventFocus case PUGL_FOCUS_OUT: + if (pData->ignoreEvents) + break; pData->onPuglFocus(event->type == PUGL_FOCUS_IN, static_cast(event->focus.mode)); break; @@ -807,6 +815,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< Key released, a #PuglEventKey case PUGL_KEY_RELEASE: { + if (pData->ignoreEvents) + break; // unused x, y, xRoot, yRoot (double) Widget::KeyboardEvent ev; ev.mod = event->key.state; @@ -830,6 +840,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< Character entered, a #PuglEventText case PUGL_TEXT: { + if (pData->ignoreEvents) + break; // unused x, y, xRoot, yRoot (double) Widget::CharacterInputEvent ev; ev.mod = event->text.state; @@ -854,6 +866,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< Mouse button released, a #PuglEventButton case PUGL_BUTTON_RELEASE: { + if (pData->ignoreEvents) + break; Widget::MouseEvent ev; ev.mod = event->button.state; ev.flags = event->button.flags; @@ -869,6 +883,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< Pointer moved, a #PuglEventMotion case PUGL_MOTION: { + if (pData->ignoreEvents) + break; Widget::MotionEvent ev; ev.mod = event->motion.state; ev.flags = event->motion.flags; @@ -882,6 +898,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< Scrolled, a #PuglEventScroll case PUGL_SCROLL: { + if (pData->ignoreEvents) + break; Widget::ScrollEvent ev; ev.mod = event->scroll.state; ev.flags = event->scroll.flags; @@ -900,6 +918,8 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< Timer triggered, a #PuglEventTimer case PUGL_TIMER: + if (pData->ignoreEvents) + break; if (IdleCallback* const idleCallback = reinterpret_cast(event->timer.id)) idleCallback->idleCallback(); break; diff --git a/dgl/src/WindowPrivateData.hpp b/dgl/src/WindowPrivateData.hpp index 68b2e375..ffb2237a 100644 --- a/dgl/src/WindowPrivateData.hpp +++ b/dgl/src/WindowPrivateData.hpp @@ -77,6 +77,9 @@ struct Window::PrivateData : IdleCallback { /** Whether to ignore idle callback requests, useful for temporary windows. */ bool ignoreIdleCallbacks; + /** Whether to ignore pugl events (except create and destroy), used for puglGetClipboard. */ + bool ignoreEvents; + /** Render to a picture file when non-null, automatically free+unset after saving. */ char* filenameToRenderInto; diff --git a/dgl/src/pugl-upstream b/dgl/src/pugl-upstream index 7418e9d1..f69d953d 160000 --- a/dgl/src/pugl-upstream +++ b/dgl/src/pugl-upstream @@ -1 +1 @@ -Subproject commit 7418e9d1f0045d192c86e7dea25272264ca92f22 +Subproject commit f69d953d95dae70e32d37e522076fd41cec31a22