Skip to content

Commit e78fe84

Browse files
committed
Preparations for supporting wayland
Signed-off-by: falkTX <falktx@falktx.com>
1 parent dbf5ce3 commit e78fe84

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

dgl/Application.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class DISTRHO_API Application
8787
Type of application to setup, either "classic" or "modern".
8888
8989
What this means depends on the OS.
90+
For now it's only relevant on X11 vs Wayland systems, where X11 is kTypeClassic and Wayland is kTypeModern.
9091
*/
9192
enum Type {
9293
kTypeAuto,

dgl/src/ApplicationPrivateData.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ static bool isThisTheMainThread(const d_ThreadHandle mainThreadHandle) noexcept
4444
#endif
4545
}
4646

47+
static constexpr inline uint32_t AppTypePuglWorldFlags(const Application::Type type) noexcept
48+
{
49+
#ifdef DGL_USING_X11_OR_WAYLAND
50+
return type == Application::kTypeClassic ? PUGL_WORLD_BACKEND_X11 :
51+
type == Application::kTypeModern ? PUGL_WORLD_BACKEND_WAYLAND : 0;
52+
#else
53+
return 0 & type;
54+
#endif
55+
}
56+
4757
// --------------------------------------------------------------------------------------------------------------------
4858

4959
const char* Application::getClassName() const noexcept
@@ -55,8 +65,12 @@ const char* Application::getClassName() const noexcept
5565

5666
Application::PrivateData::PrivateData(const bool standalone, const Type type)
5767
: world(puglNewWorld(standalone ? PUGL_PROGRAM : PUGL_MODULE,
58-
(standalone ? PUGL_WORLD_THREADS : 0))),
68+
(standalone ? PUGL_WORLD_THREADS : 0) | AppTypePuglWorldFlags(type))),
69+
#ifdef DGL_USING_X11_OR_WAYLAND
70+
isModern(world != nullptr && puglUsingWayland(world)),
71+
#else
5972
isModern(false),
73+
#endif
6074
isStandalone(standalone),
6175
isStarting(true),
6276
isQuitting(false),

dgl/src/pugl.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,19 @@ void puglWin32ShowCentered(PuglView* const view)
571571

572572
// --------------------------------------------------------------------------------------------------------------------
573573

574-
#elif defined(HAVE_X11)
574+
#elif defined(DGL_USING_X11_OR_WAYLAND)
575+
576+
// --------------------------------------------------------------------------------------------------------------------
577+
// X11 or Wayland specific, check if using wayland
578+
579+
bool puglUsingWayland(PuglWorld* const world)
580+
{
581+
// TODO
582+
(void)world;
583+
return false;
584+
}
585+
586+
#ifdef HAVE_X11
575587

576588
// --------------------------------------------------------------------------------------------------------------------
577589
// X11 specific, update world without triggering exposure events
@@ -638,9 +650,25 @@ void puglX11SetWindowType(const PuglView* const view, const bool isStandalone)
638650
numWindowTypes);
639651
}
640652

653+
#endif // HAVE_X11
654+
655+
#ifdef HAVE_WAYLAND
656+
657+
// --------------------------------------------------------------------------------------------------------------------
658+
// Wayland specific, check if running wayland and if compositor supports decorations
659+
660+
bool puglWaylandStatus(bool* supportsDecorations)
661+
{
662+
// TODO
663+
(void)supportsDecorations;
664+
return false;
665+
}
666+
667+
#endif // HAVE_WAYLAND
668+
641669
// --------------------------------------------------------------------------------------------------------------------
642670

643-
#endif // HAVE_X11
671+
#endif
644672

645673
#ifndef DISTRHO_OS_MAC
646674
END_NAMESPACE_DGL

dgl/src/pugl.hpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,33 @@ void puglWin32RestoreWindow(PuglView* view);
111111
// win32 specific, center view based on parent coordinates (if there is one)
112112
void puglWin32ShowCentered(PuglView* view);
113113

114-
#elif defined(HAVE_X11)
114+
#elif defined(HAVE_X11) || defined(HAVE_WAYLAND)
115115

116+
#define DGL_USING_X11_OR_WAYLAND
117+
118+
// custom flags for world creation
119+
#define PUGL_WORLD_BACKEND_X11 0x1000
120+
#define PUGL_WORLD_BACKEND_WAYLAND 0x2000
121+
122+
// X11 or Wayland specific, check if using wayland
123+
bool puglUsingWayland(PuglWorld* world);
124+
125+
#ifdef HAVE_X11
116126
#define DGL_USING_X11
117127

118128
// X11 specific, update world without triggering exposure events
119129
PuglStatus puglX11UpdateWithoutExposures(PuglWorld* world);
120130

121131
// X11 specific, set dialog window type
122132
void puglX11SetWindowType(const PuglView* view, bool isStandalone);
133+
#endif
134+
135+
#ifdef HAVE_WAYLAND
136+
#define DGL_USING_WAYLAND
137+
138+
// Wayland specific, return if running wayland and check if compositor supports decorations
139+
bool puglWaylandStatus(bool* supportsDecorations);
140+
#endif
123141

124142
#endif
125143

0 commit comments

Comments
 (0)