diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp index 892b068b..3318c499 100644 --- 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 index 75d9c850..9e61ef0c 100644 --- 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)); @@ -620,6 +620,29 @@ PuglStatus puglX11GrabFocus(PuglView* const view) return PUGL_SUCCESS; } +// -------------------------------------------------------------------------------------------------------------------- +// 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 diff --git a/dgl/src/pugl.hpp b/dgl/src/pugl.hpp index 595c360b..897d6272 100644 --- 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