Browse Source

Preparations for supporting wayland

Signed-off-by: falkTX <falktx@falktx.com>
wayland-v2
falkTX 1 month ago
parent
commit
e4c4179861
4 changed files with 65 additions and 4 deletions
  1. +1
    -0
      dgl/Application.hpp
  2. +15
    -1
      dgl/src/ApplicationPrivateData.cpp
  3. +30
    -2
      dgl/src/pugl.cpp
  4. +19
    -1
      dgl/src/pugl.hpp

+ 1
- 0
dgl/Application.hpp View File

@@ -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,


+ 15
- 1
dgl/src/ApplicationPrivateData.cpp View File

@@ -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),


+ 30
- 2
dgl/src/pugl.cpp View File

@@ -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


+ 19
- 1
dgl/src/pugl.hpp View File

@@ -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



Loading…
Cancel
Save