From 1d80bc8b8c989dca2dece2acf4225dc3b8993a7a Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 22 Aug 2021 22:38:23 +0100 Subject: [PATCH] Add ExternalWindow::isEmbed() Signed-off-by: falkTX --- distrho/extra/ExternalWindow.hpp | 8 ++++++++ examples/EmbedExternalUI/EmbedExternalExampleUI.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/distrho/extra/ExternalWindow.hpp b/distrho/extra/ExternalWindow.hpp index 06f5937d..dd21ad1f 100644 --- a/distrho/extra/ExternalWindow.hpp +++ b/distrho/extra/ExternalWindow.hpp @@ -114,6 +114,14 @@ public: } #if DISTRHO_PLUGIN_HAS_EMBED_UI + /** + Whether this Window is embed into another (usually not DGL-controlled) Window. + */ + bool isEmbed() const noexcept + { + return pData.parentWindowHandle != 0; + } + /** Get the "native" window handle. This can be reimplemented in order to pass the child window to hosts that can use such informaton. diff --git a/examples/EmbedExternalUI/EmbedExternalExampleUI.cpp b/examples/EmbedExternalUI/EmbedExternalExampleUI.cpp index 7b7af0ae..1b5f1cf5 100644 --- a/examples/EmbedExternalUI/EmbedExternalExampleUI.cpp +++ b/examples/EmbedExternalUI/EmbedExternalExampleUI.cpp @@ -57,7 +57,7 @@ public: const int screen = DefaultScreen(fDisplay); const ::Window root = RootWindow(fDisplay, screen); - const ::Window parent = getParentWindowHandle() != 0 ? (::Window)getParentWindowHandle() : root; + const ::Window parent = isEmbed() ? (::Window)getParentWindowHandle() : root; XSetWindowAttributes attr = {}; attr.event_mask = KeyPressMask|KeyReleaseMask;