-
-
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
28 changed files
with
1,619 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,42 @@ | ||
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 | ||
mousebuttons.cpp mousebuttons.h | ||
waylandcursor.cpp waylandcursor.h | ||
waylandinputmanager.cpp waylandinputmanager.h | ||
waylandintegrationplugin.cpp waylandintegrationplugin.h | ||
waylandkeyboard.cpp waylandkeyboard.h | ||
waylandintegration.cpp waylandintegration.h | ||
waylandoutput.cpp waylandoutput.h | ||
waylandpointer.cpp waylandpointer.h | ||
waylandscreenwindow.cpp waylandscreenwindow.h | ||
waylandtouch.cpp waylandtouch.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,89 @@ | ||
// 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,54 @@ | ||
// SPDX-FileCopyrightText: 2022 David Redondo <[email protected]> | ||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL | ||
|
||
#include <QHash> | ||
|
||
#include "mousebuttons.h" | ||
|
||
#include <linux/input-event-codes.h> | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
static const QHash<quint32, Qt::MouseButton> s_buttonToQtMouseButton = { | ||
{ BTN_LEFT, Qt::LeftButton }, | ||
{ BTN_MIDDLE, Qt::MiddleButton }, | ||
{ BTN_RIGHT, Qt::RightButton }, | ||
// in QtWayland mapped like that | ||
{ BTN_SIDE, Qt::ExtraButton1 }, | ||
// in QtWayland mapped like that | ||
{ BTN_EXTRA, Qt::ExtraButton2 }, | ||
{ BTN_BACK, Qt::BackButton }, | ||
{ BTN_FORWARD, Qt::ForwardButton }, | ||
{ BTN_TASK, Qt::TaskButton }, | ||
// mapped like that in QtWayland | ||
{ 0x118, Qt::ExtraButton6 }, | ||
{ 0x119, Qt::ExtraButton7 }, | ||
{ 0x11a, Qt::ExtraButton8 }, | ||
{ 0x11b, Qt::ExtraButton9 }, | ||
{ 0x11c, Qt::ExtraButton10 }, | ||
{ 0x11d, Qt::ExtraButton11 }, | ||
{ 0x11e, Qt::ExtraButton12 }, | ||
{ 0x11f, Qt::ExtraButton13 }, | ||
}; | ||
|
||
quint32 qtMouseButtonToButton(Qt::MouseButton button) | ||
{ | ||
return s_buttonToQtMouseButton.key(button); | ||
} | ||
|
||
Qt::MouseButton buttonToQtMouseButton(quint32 button) | ||
{ | ||
// All other values get mapped to ExtraButton24 | ||
// this is actually incorrect but doesn't matter in our usage | ||
// we internally doesn't use these high extra buttons anyway | ||
// it's only needed for recognizing whether buttons are pressed | ||
// if multiple buttons are mapped to the value the evaluation whether | ||
// buttons are pressed is correct and that's all we care about. | ||
return s_buttonToQtMouseButton.value(button, Qt::ExtraButton24); | ||
} | ||
|
||
} // 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,15 @@ | ||
// SPDX-FileCopyrightText: 2022 David Redondo <[email protected]> | ||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL | ||
|
||
#include <qnamespace.h> | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
quint32 qtMouseButtonToButton(Qt::MouseButton button); | ||
Qt::MouseButton buttonToQtMouseButton(quint32 button); | ||
|
||
} // 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" ] | ||
} |
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 <KWayland/Client/compositor.h> | ||
|
||
#include "waylandcursor.h" | ||
#include "waylandintegration.h" | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
WaylandCursor::WaylandCursor(WaylandIntegration *integration, QObject *parent) | ||
: QObject(parent) | ||
, m_integration(integration) | ||
, m_surface(integration->compositor()->createSurface(this)) | ||
{ | ||
} | ||
|
||
WaylandCursor::~WaylandCursor() { } | ||
|
||
} // 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,28 @@ | ||
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <KWayland/Client/surface.h> | ||
|
||
namespace Aurora { | ||
|
||
namespace Core { | ||
|
||
class WaylandIntegration; | ||
|
||
class WaylandCursor : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit WaylandCursor(WaylandIntegration *integration, QObject *parent = nullptr); | ||
~WaylandCursor(); | ||
|
||
private: | ||
WaylandIntegration *const m_integration; | ||
KWayland::Client::Surface *m_surface = nullptr; | ||
}; | ||
|
||
} // namespace Core | ||
|
||
} // namespace Aurora |
Oops, something went wrong.