DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 576ffb6afc43dd9c76ffeedeef5260996c850ec5
parent f618b3377286940702d86f637781ac657ee1db7f
Author: falkTX <falktx@falktx.com>
Date:   Wed,  8 Sep 2021 20:10:00 +0100

Add and use puglX11SetWindowTypeAndPID as old code used to do

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdgl/src/WindowPrivateData.cpp | 4++--
Mdgl/src/pugl.cpp | 27+++++++++++++++++++++++++--
Mdgl/src/pugl.hpp | 6+++++-
3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp @@ -902,9 +902,9 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ///< View created, a #PuglEventCreate case PUGL_CREATE: -#ifdef DGL_PUGL_USING_X11 +#ifdef HAVE_X11 if (! pData->isEmbed) - puglExtraSetWindowTypeAndPID(view); + puglX11SetWindowTypeAndPID(view); #endif break; diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp @@ -601,9 +601,9 @@ void puglWin32SetWindowResizable(PuglView* const view, const bool resizable) // -------------------------------------------------------------------------------------------------------------------- // X11 specific, safer way to grab focus -PuglStatus puglX11GrabFocus(PuglView* const view) +PuglStatus puglX11GrabFocus(const PuglView* const view) { - PuglInternals* const impl = view->impl; + const PuglInternals* const impl = view->impl; XWindowAttributes wa; std::memset(&wa, 0, sizeof(wa)); @@ -621,6 +621,29 @@ PuglStatus puglX11GrabFocus(PuglView* const view) } // -------------------------------------------------------------------------------------------------------------------- +// X11 specific, set dialog window type and pid hints + +void puglX11SetWindowTypeAndPID(const PuglView* const view) +{ + const PuglInternals* const impl = view->impl; + + const pid_t pid = getpid(); + const Atom _nwp = XInternAtom(impl->display, "_NET_WM_PID", False); + XChangeProperty(impl->display, impl->win, _nwp, XA_CARDINAL, 32, PropModeReplace, (const uchar*)&pid, 1); + + const Atom _wt = XInternAtom(impl->display, "_NET_WM_WINDOW_TYPE", False); + + // Setting the window to both dialog and normal will produce a decorated floating dialog + // Order is important: DIALOG needs to come before NORMAL + const Atom _wts[2] = { + XInternAtom(impl->display, "_NET_WM_WINDOW_TYPE_DIALOG", False), + XInternAtom(impl->display, "_NET_WM_WINDOW_TYPE_NORMAL", False) + }; + + XChangeProperty(impl->display, impl->win, _wt, XA_ATOM, 32, PropModeReplace, (const uchar*)&_wts, 2); +} + +// -------------------------------------------------------------------------------------------------------------------- // X11 specific stuff for sofd static Display* sofd_display; diff --git a/dgl/src/pugl.hpp b/dgl/src/pugl.hpp @@ -130,7 +130,11 @@ puglWin32SetWindowResizable(PuglView* view, bool resizable); #ifdef HAVE_X11 // X11 specific, safer way to grab focus PUGL_API PuglStatus -puglX11GrabFocus(PuglView* view); +puglX11GrabFocus(const PuglView* view); + +// X11 specific, set dialog window type and pid hints +PUGL_API void +puglX11SetWindowTypeAndPID(const PuglView* view); // X11 specific, show file dialog via sofd PUGL_API bool