Browse Source

Workaround puglGetClipboard behaviour on X11

pull/351/head
falkTX 3 years ago
parent
commit
84745e90c9
4 changed files with 29 additions and 2 deletions
  1. +5
    -1
      dgl/src/Window.cpp
  2. +20
    -0
      dgl/src/WindowPrivateData.cpp
  3. +3
    -0
      dgl/src/WindowPrivateData.hpp
  4. +1
    -1
      dgl/src/pugl-upstream

+ 5
- 1
dgl/src/Window.cpp View File

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


+ 20
- 0
dgl/src/WindowPrivateData.cpp View File

@@ -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<CrossingMode>(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<IdleCallback*>(event->timer.id))
idleCallback->idleCallback();
break;


+ 3
- 0
dgl/src/WindowPrivateData.hpp View File

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



+ 1
- 1
dgl/src/pugl-upstream

@@ -1 +1 @@
Subproject commit 7418e9d1f0045d192c86e7dea25272264ca92f22
Subproject commit f69d953d95dae70e32d37e522076fd41cec31a22

Loading…
Cancel
Save