diff --git a/dgl/Application.hpp b/dgl/Application.hpp index fac5fccc..935e5d50 100644 --- a/dgl/Application.hpp +++ b/dgl/Application.hpp @@ -87,6 +87,7 @@ public: Type of application to setup, either "classic" or "modern". What this means depends on the OS. + For now it's only relevant on X11 vs Wayland systems, where X11 is kTypeClassic and Wayland is kTypeModern. */ enum Type { kTypeAuto, diff --git a/dgl/src/ApplicationPrivateData.cpp b/dgl/src/ApplicationPrivateData.cpp index 3a145e9b..5a40ab80 100644 --- a/dgl/src/ApplicationPrivateData.cpp +++ b/dgl/src/ApplicationPrivateData.cpp @@ -44,6 +44,16 @@ static bool isThisTheMainThread(const d_ThreadHandle mainThreadHandle) noexcept #endif } +static constexpr inline uint32_t AppTypePuglWorldFlags(const Application::Type type) noexcept +{ + #ifdef DGL_USING_X11_OR_WAYLAND + return type == Application::kTypeClassic ? PUGL_WORLD_BACKEND_X11 : + type == Application::kTypeModern ? PUGL_WORLD_BACKEND_WAYLAND : 0; + #else + return 0 & type; + #endif +} + // -------------------------------------------------------------------------------------------------------------------- const char* Application::getClassName() const noexcept @@ -55,8 +65,12 @@ const char* Application::getClassName() const noexcept Application::PrivateData::PrivateData(const bool standalone, const Type type) : world(puglNewWorld(standalone ? PUGL_PROGRAM : PUGL_MODULE, - (standalone ? PUGL_WORLD_THREADS : 0))), + (standalone ? PUGL_WORLD_THREADS : 0) | AppTypePuglWorldFlags(type))), + #ifdef DGL_USING_X11_OR_WAYLAND + isModern(world != nullptr && puglUsingWayland(world)), + #else isModern(false), + #endif isStandalone(standalone), isStarting(true), isQuitting(false), diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp index fda302d7..75fe8f05 100644 --- a/dgl/src/pugl.cpp +++ b/dgl/src/pugl.cpp @@ -571,7 +571,19 @@ void puglWin32ShowCentered(PuglView* const view) // -------------------------------------------------------------------------------------------------------------------- -#elif defined(HAVE_X11) +#elif defined(DGL_USING_X11_OR_WAYLAND) + +// -------------------------------------------------------------------------------------------------------------------- +// X11 or Wayland specific, check if using wayland + +bool puglUsingWayland(PuglWorld* const world) +{ + // TODO + (void)world; + return false; +} + +#ifdef HAVE_X11 // -------------------------------------------------------------------------------------------------------------------- // X11 specific, update world without triggering exposure events @@ -638,9 +650,25 @@ void puglX11SetWindowType(const PuglView* const view, const bool isStandalone) numWindowTypes); } +#endif // HAVE_X11 + +#ifdef HAVE_WAYLAND + +// -------------------------------------------------------------------------------------------------------------------- +// Wayland specific, check if running wayland and if compositor supports decorations + +bool puglWaylandStatus(bool* supportsDecorations) +{ + // TODO + (void)supportsDecorations; + return false; +} + +#endif // HAVE_WAYLAND + // -------------------------------------------------------------------------------------------------------------------- -#endif // HAVE_X11 +#endif #ifndef DISTRHO_OS_MAC END_NAMESPACE_DGL diff --git a/dgl/src/pugl.hpp b/dgl/src/pugl.hpp index 41dc36ab..c71eb426 100644 --- a/dgl/src/pugl.hpp +++ b/dgl/src/pugl.hpp @@ -111,8 +111,18 @@ void puglWin32RestoreWindow(PuglView* view); // win32 specific, center view based on parent coordinates (if there is one) void puglWin32ShowCentered(PuglView* view); -#elif defined(HAVE_X11) +#elif defined(HAVE_X11) || defined(HAVE_WAYLAND) +#define DGL_USING_X11_OR_WAYLAND + +// custom flags for world creation +#define PUGL_WORLD_BACKEND_X11 0x1000 +#define PUGL_WORLD_BACKEND_WAYLAND 0x2000 + +// X11 or Wayland specific, check if using wayland +bool puglUsingWayland(PuglWorld* world); + +#ifdef HAVE_X11 #define DGL_USING_X11 // X11 specific, update world without triggering exposure events @@ -120,6 +130,14 @@ PuglStatus puglX11UpdateWithoutExposures(PuglWorld* world); // X11 specific, set dialog window type void puglX11SetWindowType(const PuglView* view, bool isStandalone); +#endif + +#ifdef HAVE_WAYLAND +#define DGL_USING_WAYLAND + +// Wayland specific, return if running wayland and check if compositor supports decorations +bool puglWaylandStatus(bool* supportsDecorations); +#endif #endif