-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: #42
- Loading branch information
Showing
20 changed files
with
1,213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
include(ECMQtDeclareLoggingCategory) | ||
ecm_qt_declare_logging_category( | ||
AuroraDeviceIntegrationWayland_SOURCES | ||
HEADER "waylandloggingcategories.h" | ||
IDENTIFIER "Aurora::Core::gLcWayland" | ||
CATEGORY_NAME "aurora.core.wayland" | ||
DEFAULT_SEVERITY "Info" | ||
DESCRIPTION "Aurora device integration for Wayland" | ||
) | ||
|
||
liri_add_plugin(AuroraDeviceIntegrationWayland | ||
TYPE | ||
"aurora/deviceintegration" | ||
OUTPUT_NAME | ||
wayland | ||
SOURCES | ||
eglintegration.cpp eglintegration.h | ||
waylandinputmanager.cpp waylandinputmanager.h | ||
waylandintegrationplugin.cpp waylandintegrationplugin.h | ||
waylandkeyboard.cpp waylandkeyboard.h | ||
waylandintegration.cpp waylandintegration.h | ||
waylandoutput.cpp waylandoutput.h | ||
waylandscreenwindow.cpp waylandscreenwindow.h | ||
waylandwindow.cpp waylandwindow.h | ||
wayland.json | ||
${AuroraDeviceIntegrationWayland_SOURCES} | ||
PUBLIC_LIBRARIES | ||
Qt5::Core | ||
Qt5::Gui | ||
Liri::AuroraCore | ||
Liri::AuroraCorePrivate | ||
EGL::EGL | ||
Wayland::Egl | ||
LIBRARIES | ||
KF5::WaylandClient | ||
) | ||
|
||
liri_finalize_plugin(AuroraDeviceIntegrationWayland) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include <QByteArray> | ||
#include <QList> | ||
|
||
#include "eglintegration.h" | ||
#include "waylandloggingcategories.h" | ||
#include "waylandintegration.h" | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
EglIntegration::EglIntegration(WaylandIntegration *integration) : m_integration(integration) { } | ||
|
||
EglIntegration::~EglIntegration() | ||
{ | ||
destroy(); | ||
} | ||
|
||
bool EglIntegration::isInitialized() const | ||
{ | ||
return m_initialized; | ||
} | ||
|
||
EGLDisplay EglIntegration::display() const | ||
{ | ||
return m_eglDisplay; | ||
} | ||
|
||
typedef const char *(*EGLGETERRORSTRINGPROC)(EGLint error); | ||
|
||
bool EglIntegration::initialize() | ||
{ | ||
if (m_initialized) | ||
return true; | ||
|
||
m_initialized = true; | ||
|
||
if (hasEglExtension("EGL_EXT_platform_base")) { | ||
if (hasEglExtension("EGL_KHR_platform_wayland") | ||
|| hasEglExtension("EGL_EXT_platform_wayland") | ||
|| hasEglExtension("EGL_MESA_platform_wayland")) { | ||
static PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplay = nullptr; | ||
if (!eglGetPlatformDisplay) | ||
eglGetPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>( | ||
eglGetProcAddress("eglGetPlatformDisplayEXT")); | ||
|
||
m_eglDisplay = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, m_integration->display(), | ||
nullptr); | ||
} else { | ||
qCWarning(gLcWayland) << "The EGL implementation does not support the Wayland platform"; | ||
return false; | ||
} | ||
} else { | ||
QByteArray eglPlatform = qgetenv("EGL_PLATFORM"); | ||
if (eglPlatform.isEmpty()) | ||
setenv("EGL_PLATFORM", "wayland", true); | ||
|
||
m_eglDisplay = | ||
eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(m_integration->display())); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void EglIntegration::destroy() | ||
{ | ||
if (m_eglDisplay != EGL_NO_DISPLAY) { | ||
eglTerminate(m_eglDisplay); | ||
m_eglDisplay = EGL_NO_DISPLAY; | ||
} | ||
} | ||
|
||
bool EglIntegration::hasEglExtension(const char *name, EGLDisplay display) | ||
{ | ||
QList<QByteArray> extensions = | ||
QByteArray(reinterpret_cast<const char *>(eglQueryString(display, EGL_EXTENSIONS))) | ||
.split(' '); | ||
return extensions.contains(name); | ||
} | ||
|
||
} // namespace Core | ||
|
||
} // namespace Aurora |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <QPointer> | ||
|
||
#ifndef EGL_NO_X11 | ||
# define EGL_NO_X11 | ||
#endif | ||
#ifndef MESA_EGL_NO_X11_HEADERS | ||
# define MESA_EGL_NO_X11_HEADERS | ||
#endif | ||
|
||
#include <EGL/egl.h> | ||
#include <EGL/eglext.h> | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
class WaylandIntegration; | ||
|
||
class EglIntegration | ||
{ | ||
public: | ||
EglIntegration(WaylandIntegration *integration); | ||
~EglIntegration(); | ||
|
||
bool isInitialized() const; | ||
|
||
EGLDisplay display() const; | ||
|
||
bool initialize(); | ||
void destroy(); | ||
|
||
static bool hasEglExtension(const char *name, EGLDisplay display = EGL_NO_DISPLAY); | ||
|
||
private: | ||
bool m_initialized = false; | ||
QPointer<WaylandIntegration> m_integration; | ||
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; | ||
}; | ||
|
||
} // namespace Core | ||
|
||
} // namespace Aurora |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"Keys": [ "wayland" ] | ||
} |
29 changes: 29 additions & 0 deletions
29
src/plugins/deviceintegration/wayland/waylandinputmanager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include <KWayland/Client/seat.h> | ||
|
||
#include "waylandinputmanager.h" | ||
#include "waylandintegration.h" | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
WaylandInputManager::WaylandInputManager(WaylandIntegration *integration, QObject *parent) | ||
: InputManager(parent), m_integration(integration) | ||
{ | ||
auto *seat = m_integration->seat(); | ||
connect(seat, &KWayland::Client::Seat::hasKeyboardChanged, this, | ||
[this, seat](bool hasKeyboard) { | ||
if (hasKeyboard) { | ||
auto *hostKeyboard = seat->createKeyboard(this); | ||
m_keyboard = new WaylandKeyboard(hostKeyboard, this); | ||
emit deviceAdded(m_keyboard); | ||
} | ||
}); | ||
} | ||
|
||
} // namespace Core | ||
|
||
} // namespace Aurora |
24 changes: 24 additions & 0 deletions
24
src/plugins/deviceintegration/wayland/waylandinputmanager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include <LiriAuroraCore/InputManager> | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
class WaylandIntegration; | ||
|
||
class WaylandInputManager : public InputManager | ||
{ | ||
Q_OBJECT | ||
public: | ||
WaylandInputManager(WaylandIntegration *integration, QObject *parent = nullptr); | ||
|
||
private: | ||
QPointer<WaylandIntegration> m_integration; | ||
}; | ||
|
||
} // namespace Core | ||
|
||
} // namespace Aurora |
Oops, something went wrong.