mirror of
https://github.com/theCheeseboard/libtdesktopenvironment.git
synced 2025-01-22 10:22:02 -05:00
Mostly working
This commit is contained in:
parent
dfca2809b4
commit
17e3a14dd3
16 changed files with 529 additions and 61 deletions
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include <Shell>
|
||||
#include <layershellwindow.h>
|
||||
#include <tlogger.h>
|
||||
|
||||
#include "waylandwindow.h"
|
||||
|
@ -46,11 +46,11 @@ WaylandBackend::WaylandBackend() : WmBackend() {
|
|||
d->parent = this;
|
||||
d->accessibility = new WaylandAccessibility(this);
|
||||
|
||||
LayerShellQt::Shell::useLayerShell();
|
||||
// LayerShellQt::Shell::useLayerShell();
|
||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "tdesktopenvironment-layer-shell");
|
||||
|
||||
d->display = reinterpret_cast<wl_display*>(qApp->platformNativeInterface()->nativeResourceForIntegration("display"));
|
||||
|
||||
|
||||
wl_registry_listener listener = {
|
||||
[](void* data, wl_registry * registry, quint32 name, const char* interface, quint32 version) {
|
||||
if (strcmp(interface, zwlr_foreign_toplevel_manager_v1_interface.name) == 0) {
|
||||
|
@ -144,29 +144,31 @@ void WaylandBackend::setSystemWindow(QWidget* widget) {
|
|||
}
|
||||
|
||||
void WaylandBackend::setSystemWindow(QWidget* widget, DesktopWm::SystemWindowType windowType) {
|
||||
//TODO: Implement
|
||||
widget->show();
|
||||
LayerShellQt::Window* layerWindow = LayerShellQt::Window::get(widget->windowHandle());
|
||||
layerWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityOnDemand);
|
||||
LayerShellWindow* layerWindow = LayerShellWindow::forWindow(widget->windowHandle());
|
||||
layerWindow->setKeyboardInteractivity(LayerShellWindow::OnDemand);
|
||||
|
||||
switch (windowType) {
|
||||
case DesktopWm::SystemWindowTypeSkipTaskbarOnly:
|
||||
break;
|
||||
case DesktopWm::SystemWindowTypeDesktop:
|
||||
layerWindow->setLayer(LayerShellQt::Window::LayerBackground);
|
||||
// layerWindow->setAnchors(static_cast<LayerShellQt::Window::Anchors>(LayerShellQt::Window::AnchorLeft | LayerShellQt::Window::AnchorBottom | LayerShellQt::Window::AnchorRight | LayerShellQt::Window::AnchorTop));
|
||||
layerWindow->setLayer(LayerShellWindow::Background);
|
||||
layerWindow->setExclusiveZone(-1);
|
||||
layerWindow->setKeyboardInteractivity(LayerShellWindow::None);
|
||||
break;
|
||||
case DesktopWm::SystemWindowTypeTaskbar:
|
||||
layerWindow->setLayer(LayerShellQt::Window::LayerTop);
|
||||
// layerWindow->setAnchors(LayerShellQt::Window::AnchorTop);
|
||||
layerWindow->setLayer(LayerShellWindow::Top);
|
||||
layerWindow->setAnchors(LayerShellWindow::AnchorTop);
|
||||
break;
|
||||
case DesktopWm::SystemWindowTypeNotification:
|
||||
layerWindow->setLayer(LayerShellQt::Window::LayerOverlay);
|
||||
layerWindow->setLayer(LayerShellWindow::Overlay);
|
||||
layerWindow->setExclusiveZone(0);
|
||||
break;
|
||||
case DesktopWm::SystemWindowTypeMenu:
|
||||
layerWindow->setLayer(LayerShellQt::Window::LayerOverlay);
|
||||
layerWindow->setAnchors(static_cast<LayerShellQt::Window::Anchors>(LayerShellQt::Window::AnchorLeft | LayerShellQt::Window::AnchorTop | LayerShellQt::Window::AnchorBottom));
|
||||
layerWindow->setLayer(LayerShellWindow::Overlay);
|
||||
layerWindow->setExclusiveZone(-1);
|
||||
layerWindow->setAnchors(static_cast<LayerShellWindow::Anchors>(LayerShellWindow::AnchorLeft | LayerShellWindow::AnchorTop | LayerShellWindow::AnchorBottom));
|
||||
// layerWindow->setAnchors(LayerShellWindow::AnchorRight);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -177,27 +179,25 @@ void WaylandBackend::blurWindow(QWidget* widget) {
|
|||
|
||||
void WaylandBackend::setScreenMarginForWindow(QWidget* widget, QScreen* screen, Qt::Edge edge, int width) {
|
||||
//TODO: Implement
|
||||
LayerShellWindow* layerWindow = LayerShellWindow::forWindow(widget->windowHandle());
|
||||
|
||||
// QTimer::singleShot(1000, [ = ] {
|
||||
// LayerShellQt::Window::get(widget->windowHandle())->setExclusiveZone(20);
|
||||
// LayerShellQt::Window::Anchors anchors;
|
||||
// switch (edge) {
|
||||
// case Qt::TopEdge:
|
||||
// anchors = static_cast<LayerShellQt::Window::Anchors>(LayerShellQt::Window::AnchorLeft | LayerShellQt::Window::AnchorRight | LayerShellQt::Window::AnchorTop);
|
||||
// break;
|
||||
// case Qt::LeftEdge:
|
||||
// anchors = static_cast<LayerShellQt::Window::Anchors>(LayerShellQt::Window::AnchorLeft | LayerShellQt::Window::AnchorTop | LayerShellQt::Window::AnchorBottom);
|
||||
// break;
|
||||
// case Qt::RightEdge:
|
||||
// anchors = LayerShellQt::Window::AnchorRight;
|
||||
// break;
|
||||
// case Qt::BottomEdge:
|
||||
// anchors = LayerShellQt::Window::AnchorBottom;
|
||||
// break;
|
||||
// }
|
||||
// LayerShellQt::Window::get(widget->windowHandle())->setAnchors(anchors);
|
||||
// });
|
||||
|
||||
layerWindow->setExclusiveZone(width);
|
||||
LayerShellWindow::Anchors anchors;
|
||||
switch (edge) {
|
||||
case Qt::TopEdge:
|
||||
anchors = LayerShellWindow::AnchorTop;
|
||||
break;
|
||||
case Qt::LeftEdge:
|
||||
anchors = LayerShellWindow::AnchorLeft;
|
||||
break;
|
||||
case Qt::RightEdge:
|
||||
anchors = LayerShellWindow::AnchorRight;
|
||||
break;
|
||||
case Qt::BottomEdge:
|
||||
anchors = LayerShellWindow::AnchorBottom;
|
||||
break;
|
||||
}
|
||||
layerWindow->setAnchors(anchors);
|
||||
}
|
||||
|
||||
void WaylandBackend::setScreenOff(bool screenOff) {
|
||||
|
|
11
lib/lib.pro
11
lib/lib.pro
|
@ -71,11 +71,9 @@ unix {
|
|||
}
|
||||
}
|
||||
|
||||
exists($$THELIBS_INSTALL_LIB/libLayerShellQtInterface.so) : packagesExist(wayland-client) {
|
||||
packagesExist(wayland-client) {
|
||||
message("Building with Wayland support.");
|
||||
DEFINES += HAVE_WAYLAND
|
||||
LIBS += -lLayerShellQtInterface
|
||||
INCLUDEPATH += $$THELIBS_INSTALL_HEADERS/../LayerShellQt
|
||||
|
||||
QT += gui-private
|
||||
|
||||
|
@ -95,7 +93,7 @@ unix {
|
|||
wayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
wayland_scanner_sources.output = wayland-${QMAKE_FILE_BASE}-client-protocol.c
|
||||
wayland_scanner_sources.commands = wayland-scanner public-code ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
|
||||
wayland_scanner_sources.commands = wayland-scanner private-code ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
|
||||
wayland_scanner_sources.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
wayland_scanner_sources.variable_out = SOURCES
|
||||
wayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
@ -112,6 +110,11 @@ unix {
|
|||
qwayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
QMAKE_EXTRA_COMPILERS += wayland_scanner_headers wayland_scanner_sources qwayland_scanner_headers qwayland_scanner_sources
|
||||
|
||||
unix:!macx: LIBS += -L$$OUT_PWD/../wayland-layer-shell/client-lib/ -ltdesktopenvironment-wayland-layer-shell-client
|
||||
|
||||
INCLUDEPATH += $$PWD/../wayland-layer-shell/client-lib
|
||||
DEPENDPATH += $$PWD/../wayland-layer-shell/client-lib
|
||||
} else {
|
||||
message("layer-shell-qt or wayland-client not found on this system.");
|
||||
}
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
libproj.subdir = lib
|
||||
|
||||
testproj.subdir = test
|
||||
testproj.depends = libproj
|
||||
|
||||
waylandlayershellproj.subdir = wayland-layer-shell
|
||||
|
||||
libproj.subdir = lib
|
||||
libproj.depends = waylandlayershellproj
|
||||
|
||||
SUBDIRS += \
|
||||
libproj# \
|
||||
# wayland-layer-shell
|
||||
libproj \
|
||||
waylandlayershellproj
|
||||
# testproj
|
||||
|
||||
CONFIG += qt
|
||||
|
|
|
@ -1,23 +1,56 @@
|
|||
QT -= gui
|
||||
QT += waylandclient waylandclient_private
|
||||
|
||||
TEMPLATE = lib
|
||||
DEFINES += CLIENTLIB_LIBRARY
|
||||
TARGET = tdesktopenvironment-wayland-layer-shell-client
|
||||
|
||||
CONFIG += c++11
|
||||
CONFIG += c++11 link_pkgconfig
|
||||
PKGCONFIG += wayland-client
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
layershellwindow.cpp
|
||||
layershellwindow.cpp \
|
||||
private/layershellshell.cpp \
|
||||
private/layershellsurface.cpp
|
||||
|
||||
HEADERS += \
|
||||
client-lib_global.h \
|
||||
layershellwindow.h
|
||||
layershellwindow.h \
|
||||
private/layershellshell.h \
|
||||
private/layershellsurface.h
|
||||
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
WAYLAND_PROTOCOL_EXTENSIONS = ../../lib/wayland-protocols/wlr-protocols/unstable/wlr-layer-shell-unstable-v1.xml ../../lib/wayland-protocols/wayland-protocols/stable/xdg-shell/xdg-shell.xml
|
||||
|
||||
wayland_scanner_headers.output = wayland-${QMAKE_FILE_BASE}-client-protocol.h
|
||||
wayland_scanner_headers.commands = wayland-scanner client-header ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
|
||||
wayland_scanner_headers.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
wayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
wayland_scanner_sources.output = wayland-${QMAKE_FILE_BASE}-client-protocol.c
|
||||
wayland_scanner_sources.commands = wayland-scanner private-code ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
|
||||
wayland_scanner_sources.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
wayland_scanner_sources.variable_out = SOURCES
|
||||
wayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
qwayland_scanner_headers.output = qwayland-${QMAKE_FILE_BASE}.h
|
||||
qwayland_scanner_headers.commands = qtwaylandscanner client-header ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
|
||||
qwayland_scanner_headers.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
qwayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
qwayland_scanner_sources.output = qwayland-${QMAKE_FILE_BASE}.cpp
|
||||
qwayland_scanner_sources.commands = qtwaylandscanner client-code ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
|
||||
qwayland_scanner_sources.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
qwayland_scanner_sources.variable_out = SOURCES
|
||||
qwayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
QMAKE_EXTRA_COMPILERS += wayland_scanner_headers wayland_scanner_sources qwayland_scanner_headers qwayland_scanner_sources
|
||||
|
|
|
@ -19,6 +19,44 @@
|
|||
* *************************************/
|
||||
#include "layershellwindow.h"
|
||||
|
||||
LayerShellWindow::LayerShellWindow()
|
||||
{
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
#include "private/layershellsurface.h"
|
||||
|
||||
struct LayerShellWindowPrivate {
|
||||
LayerShellSurface* surface;
|
||||
};
|
||||
|
||||
LayerShellWindow* LayerShellWindow::forWindow(QWindow* window) {
|
||||
QtWaylandClient::QWaylandWindow* waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow*>(window->handle());
|
||||
if (!waylandWindow) return nullptr;
|
||||
|
||||
LayerShellSurface* surface = qobject_cast<LayerShellSurface*>(waylandWindow->shellSurface());
|
||||
if (!surface) return nullptr;
|
||||
|
||||
return new LayerShellWindow(surface);
|
||||
}
|
||||
|
||||
LayerShellWindow::~LayerShellWindow() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
void LayerShellWindow::setLayer(Layer layer) {
|
||||
d->surface->setLayer(layer);
|
||||
}
|
||||
|
||||
void LayerShellWindow::setExclusiveZone(quint32 exclusiveZone) {
|
||||
d->surface->setExclusiveZone(exclusiveZone);
|
||||
}
|
||||
|
||||
void LayerShellWindow::setAnchors(Anchors anchors) {
|
||||
d->surface->setAnchor(anchors);
|
||||
}
|
||||
|
||||
void LayerShellWindow::setKeyboardInteractivity(KeyboardInteractivity interactivity) {
|
||||
d->surface->setKeyboardInteractivity(interactivity);
|
||||
}
|
||||
|
||||
LayerShellWindow::LayerShellWindow(LayerShellSurface* surface) : QObject(surface) {
|
||||
d = new LayerShellWindowPrivate();
|
||||
d->surface = surface;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,51 @@
|
|||
#ifndef LAYERSHELLWINDOW_H
|
||||
#define LAYERSHELLWINDOW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
|
||||
#include "client-lib_global.h"
|
||||
|
||||
class CLIENTLIB_EXPORT LayerShellWindow
|
||||
{
|
||||
class LayerShellSurface;
|
||||
struct LayerShellWindowPrivate;
|
||||
class CLIENTLIB_EXPORT LayerShellWindow : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LayerShellWindow();
|
||||
static LayerShellWindow* forWindow(QWindow* window);
|
||||
~LayerShellWindow();
|
||||
|
||||
enum Layer : quint32 {
|
||||
Overlay = 3,
|
||||
Top = 2,
|
||||
Bottom = 1,
|
||||
Background = 0
|
||||
};
|
||||
|
||||
enum Anchor : quint32 {
|
||||
AnchorTop = 1,
|
||||
AnchorBottom = 2,
|
||||
AnchorLeft = 4,
|
||||
AnchorRight = 8
|
||||
};
|
||||
Q_DECLARE_FLAGS(Anchors, Anchor);
|
||||
|
||||
enum KeyboardInteractivity : quint32 {
|
||||
None = 0,
|
||||
Exclusive = 1,
|
||||
OnDemand = 2
|
||||
};
|
||||
|
||||
void setLayer(Layer layer);
|
||||
void setExclusiveZone(quint32 exclusiveZone);
|
||||
void setAnchors(Anchors anchors);
|
||||
void setKeyboardInteractivity(KeyboardInteractivity interactivity);
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
explicit LayerShellWindow(LayerShellSurface* surface);
|
||||
|
||||
LayerShellWindowPrivate* d;
|
||||
};
|
||||
|
||||
#endif // LAYERSHELLWINDOW_H
|
||||
|
|
35
wayland-layer-shell/client-lib/private/layershellshell.cpp
Normal file
35
wayland-layer-shell/client-lib/private/layershellshell.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/****************************************
|
||||
*
|
||||
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
||||
* Copyright (C) 2021 Victor Tran
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* *************************************/
|
||||
#include "layershellshell.h"
|
||||
|
||||
#include "qwayland-wlr-layer-shell-unstable-v1.h"
|
||||
|
||||
struct LayerShellShellPrivate {
|
||||
QtWayland::zwlr_layer_shell_v1* shell;
|
||||
};
|
||||
|
||||
LayerShellShell::LayerShellShell(QtWayland::zwlr_layer_shell_v1* shell) : QtWayland::zwlr_layer_shell_v1(shell->object()) {
|
||||
d = new LayerShellShellPrivate();
|
||||
}
|
||||
|
||||
LayerShellShell::~LayerShellShell() {
|
||||
this->destroy();
|
||||
delete d;
|
||||
}
|
38
wayland-layer-shell/client-lib/private/layershellshell.h
Normal file
38
wayland-layer-shell/client-lib/private/layershellshell.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/****************************************
|
||||
*
|
||||
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
||||
* Copyright (C) 2021 Victor Tran
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* *************************************/
|
||||
#ifndef LAYERSHELLSHELL_H
|
||||
#define LAYERSHELLSHELL_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qwayland-wlr-layer-shell-unstable-v1.h"
|
||||
|
||||
struct LayerShellShellPrivate;
|
||||
class LayerShellShell : public QtWayland::zwlr_layer_shell_v1 {
|
||||
public:
|
||||
explicit LayerShellShell(QtWayland::zwlr_layer_shell_v1* shell);
|
||||
~LayerShellShell();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
LayerShellShellPrivate* d;
|
||||
};
|
||||
|
||||
#endif // LAYERSHELLSHELL_H
|
89
wayland-layer-shell/client-lib/private/layershellsurface.cpp
Normal file
89
wayland-layer-shell/client-lib/private/layershellsurface.cpp
Normal file
|
@ -0,0 +1,89 @@
|
|||
/****************************************
|
||||
*
|
||||
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
||||
* Copyright (C) 2021 Victor Tran
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* *************************************/
|
||||
#include "layershellsurface.h"
|
||||
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
#include <private/qwaylandsurface_p.h>
|
||||
#include <private/qwaylandscreen_p.h>
|
||||
#include "layershellshell.h"
|
||||
|
||||
struct LayerShellSurfacePrivate {
|
||||
LayerShellShell* shell;
|
||||
QtWaylandClient::QWaylandWindow* window;
|
||||
|
||||
QSize queuedSize;
|
||||
bool configured = false;
|
||||
};
|
||||
|
||||
LayerShellSurface::LayerShellSurface(LayerShellShell* shell, QtWaylandClient::QWaylandWindow* window) : QtWaylandClient::QWaylandShellSurface(window), QtWayland::zwlr_layer_surface_v1(shell->get_layer_surface(window->waylandSurface()->object(), window->waylandScreen()->output(), QtWayland::zwlr_layer_shell_v1::layer_top, "qt")) {
|
||||
d = new LayerShellSurfacePrivate();
|
||||
set_anchor(anchor_top | anchor_bottom | anchor_left | anchor_right);
|
||||
}
|
||||
|
||||
LayerShellSurface::~LayerShellSurface() {
|
||||
this->destroy();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void LayerShellSurface::setAnchor(quint32 anchor) {
|
||||
set_anchor(anchor);
|
||||
}
|
||||
|
||||
void LayerShellSurface::setExclusiveZone(quint32 exclusiveZone) {
|
||||
set_exclusive_zone(exclusiveZone);
|
||||
}
|
||||
|
||||
void LayerShellSurface::setKeyboardInteractivity(quint32 interactivity) {
|
||||
set_keyboard_interactivity(interactivity);
|
||||
}
|
||||
|
||||
void LayerShellSurface::setLayer(quint32 layer) {
|
||||
set_layer(layer);
|
||||
}
|
||||
|
||||
void LayerShellSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) {
|
||||
ack_configure(serial);
|
||||
d->queuedSize = QSize(width, height);
|
||||
|
||||
if (!d->configured) {
|
||||
d->configured = true;
|
||||
window()->resizeFromApplyConfigure(d->queuedSize);
|
||||
window()->handleExpose(QRect(QPoint(0, 0), d->queuedSize));
|
||||
} else {
|
||||
window()->applyConfigureWhenPossible();
|
||||
}
|
||||
}
|
||||
|
||||
void LayerShellSurface::zwlr_layer_surface_v1_closed() {
|
||||
d->window->close();
|
||||
}
|
||||
|
||||
void LayerShellSurface::applyConfigure() {
|
||||
window()->resizeFromApplyConfigure(d->queuedSize);
|
||||
}
|
||||
|
||||
bool LayerShellSurface::isExposed() const {
|
||||
return d->configured;
|
||||
}
|
||||
|
||||
|
||||
void LayerShellSurface::setWindowGeometry(const QRect& rect) {
|
||||
this->set_size(rect.width(), rect.height());
|
||||
}
|
59
wayland-layer-shell/client-lib/private/layershellsurface.h
Normal file
59
wayland-layer-shell/client-lib/private/layershellsurface.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/****************************************
|
||||
*
|
||||
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
||||
* Copyright (C) 2021 Victor Tran
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* *************************************/
|
||||
#ifndef LAYERSHELLSURFACE_H
|
||||
#define LAYERSHELLSURFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <private/qwaylandshellsurface_p.h>
|
||||
#include "qwayland-wlr-layer-shell-unstable-v1.h"
|
||||
|
||||
struct LayerShellSurfacePrivate;
|
||||
|
||||
class LayerShellShell;
|
||||
class LayerShellSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1 {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayerShellSurface(LayerShellShell* shell, QtWaylandClient::QWaylandWindow* window);
|
||||
~LayerShellSurface();
|
||||
|
||||
void setAnchor(quint32 anchor);
|
||||
void setExclusiveZone(quint32 exclusiveZone);
|
||||
void setKeyboardInteractivity(quint32 interactivity);
|
||||
void setLayer(quint32 layer);
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
LayerShellSurfacePrivate* d;
|
||||
|
||||
|
||||
// zwlr_layer_surface_v1 interface
|
||||
protected:
|
||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height);
|
||||
void zwlr_layer_surface_v1_closed();
|
||||
|
||||
// QWaylandShellSurface interface
|
||||
public:
|
||||
void applyConfigure();
|
||||
bool isExposed() const;
|
||||
void setWindowGeometry(const QRect& rect);
|
||||
};
|
||||
|
||||
#endif // LAYERSHELLSURFACE_H
|
|
@ -1,7 +1,8 @@
|
|||
QT += gui waylandclient_private
|
||||
QT += gui waylandclient waylandclient_private
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
TARGET = tdesktopenvironment-layer-shell
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
|
@ -10,15 +11,49 @@ CONFIG += c++11
|
|||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
waylandlayershellintegration.cpp \
|
||||
waylandlayershellplugin.cpp
|
||||
|
||||
HEADERS += \
|
||||
waylandlayershellintegration.h \
|
||||
waylandlayershellplugin.h
|
||||
|
||||
DISTFILES += qt-plugin.json
|
||||
|
||||
|
||||
WAYLAND_PROTOCOL_EXTENSIONS = ../../lib/wayland-protocols/wlr-protocols/unstable/wlr-layer-shell-unstable-v1.xml ../../lib/wayland-protocols/wayland-protocols/stable/xdg-shell/xdg-shell.xml
|
||||
|
||||
wayland_scanner_headers.output = wayland-${QMAKE_FILE_BASE}-client-protocol.h
|
||||
wayland_scanner_headers.commands = wayland-scanner client-header ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
|
||||
wayland_scanner_headers.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
wayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
wayland_scanner_sources.output = wayland-${QMAKE_FILE_BASE}-client-protocol.c
|
||||
wayland_scanner_sources.commands = wayland-scanner private-code ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
|
||||
wayland_scanner_sources.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
wayland_scanner_sources.variable_out = SOURCES
|
||||
wayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
qwayland_scanner_headers.output = qwayland-${QMAKE_FILE_BASE}.h
|
||||
qwayland_scanner_headers.commands = qtwaylandscanner client-header ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
|
||||
qwayland_scanner_headers.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
qwayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
qwayland_scanner_sources.output = qwayland-${QMAKE_FILE_BASE}.cpp
|
||||
qwayland_scanner_sources.commands = qtwaylandscanner client-code ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
|
||||
qwayland_scanner_sources.input = WAYLAND_PROTOCOL_EXTENSIONS
|
||||
qwayland_scanner_sources.variable_out = SOURCES
|
||||
qwayland_scanner_headers.CONFIG += target_predeps no_link
|
||||
|
||||
QMAKE_EXTRA_COMPILERS += wayland_scanner_headers wayland_scanner_sources qwayland_scanner_headers qwayland_scanner_sources
|
||||
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/generic
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/wayland-shell-integration
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
unix:!macx: LIBS += -L$$OUT_PWD/../client-lib/ -ltdesktopenvironment-wayland-layer-shell-client
|
||||
|
||||
INCLUDEPATH += $$PWD/../client-lib
|
||||
DEPENDPATH += $$PWD/../client-lib
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/****************************************
|
||||
*
|
||||
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
||||
* Copyright (C) 2021 Victor Tran
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* *************************************/
|
||||
#include "waylandlayershellintegration.h"
|
||||
|
||||
#include "qwayland-wlr-layer-shell-unstable-v1.h"
|
||||
#include <private/layershellsurface.h>
|
||||
|
||||
WaylandLayerShellIntegration::WaylandLayerShellIntegration() : QtWaylandClient::QWaylandShellIntegration() {
|
||||
|
||||
}
|
||||
|
||||
bool WaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay* display) {
|
||||
QWaylandShellIntegration::initialize(display);
|
||||
display->addRegistryListener([](void* data, wl_registry * registry, quint32 name, const QString & interface, quint32 version) {
|
||||
WaylandLayerShellIntegration* integration = static_cast<WaylandLayerShellIntegration*>(data);
|
||||
if (interface == "zwlr_layer_shell_v1") {
|
||||
integration->layershellShell = new LayerShellShell(new QtWayland::zwlr_layer_shell_v1(registry, name, version));
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
return layershellShell != nullptr;
|
||||
}
|
||||
|
||||
QtWaylandClient::QWaylandShellSurface* WaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow* window) {
|
||||
return new LayerShellSurface(layershellShell, window);
|
||||
}
|
41
wayland-layer-shell/qt-plugin/waylandlayershellintegration.h
Normal file
41
wayland-layer-shell/qt-plugin/waylandlayershellintegration.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/****************************************
|
||||
*
|
||||
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
||||
* Copyright (C) 2021 Victor Tran
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* *************************************/
|
||||
#ifndef WAYLANDLAYERSHELLINTEGRATION_H
|
||||
#define WAYLANDLAYERSHELLINTEGRATION_H
|
||||
|
||||
#include <private/qwaylandshellintegration_p.h>
|
||||
#include <private/layershellshell.h>
|
||||
|
||||
class WaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegration {
|
||||
public:
|
||||
explicit WaylandLayerShellIntegration();
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
// QWaylandShellIntegration interface
|
||||
public:
|
||||
bool initialize(QtWaylandClient::QWaylandDisplay* display);
|
||||
QtWaylandClient::QWaylandShellSurface* createShellSurface(QtWaylandClient::QWaylandWindow* window);
|
||||
|
||||
LayerShellShell* layershellShell = nullptr;
|
||||
};
|
||||
|
||||
#endif // WAYLANDLAYERSHELLINTEGRATION_H
|
|
@ -19,10 +19,13 @@
|
|||
* *************************************/
|
||||
#include "waylandlayershellplugin.h"
|
||||
|
||||
WaylandLayerShellPlugin::WaylandLayerShellPlugin(QObject* parent)
|
||||
: QGenericPlugin(parent) {
|
||||
#include "waylandlayershellintegration.h"
|
||||
|
||||
WaylandLayerShellPlugin::WaylandLayerShellPlugin()
|
||||
: QtWaylandClient::QWaylandShellIntegrationPlugin() {
|
||||
}
|
||||
|
||||
QObject* WaylandLayerShellPlugin::create(const QString& name, const QString& spec) {
|
||||
|
||||
QtWaylandClient::QWaylandShellIntegration* WaylandLayerShellPlugin::create(const QString& key, const QStringList& paramList) {
|
||||
if (key == "tdesktopenvironment-layer-shell") return new WaylandLayerShellIntegration();
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -20,17 +20,19 @@
|
|||
#ifndef WAYLANDLAYERSHELLPLUGIN_H
|
||||
#define WAYLANDLAYERSHELLPLUGIN_H
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
|
||||
#include <private/qwaylandshellintegrationplugin_p.h>
|
||||
|
||||
class WaylandLayerShellPlugin : public QtWaylandClient::QWaylandShellIntegrationPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "qt-plugin.json")
|
||||
Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "qt-plugin.json")
|
||||
|
||||
public:
|
||||
explicit WaylandLayerShellPlugin(QObject* parent = nullptr);
|
||||
explicit WaylandLayerShellPlugin();
|
||||
|
||||
private:
|
||||
QObject* create(const QString& name, const QString& spec) override;
|
||||
|
||||
// QWaylandShellIntegrationPlugin interface
|
||||
public:
|
||||
QtWaylandClient::QWaylandShellIntegration* create(const QString& key, const QStringList& paramList);
|
||||
};
|
||||
|
||||
#endif // WAYLANDLAYERSHELLPLUGIN_H
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
clientproj.subdir = client-lib
|
||||
|
||||
pluginproj.subdir = qt-plugin
|
||||
pluginproj.depends = clientproj
|
||||
|
||||
SUBDIRS += \
|
||||
client-lib \
|
||||
qt-plugin
|
||||
clientproj \
|
||||
pluginproj
|
||||
|
|
Loading…
Reference in a new issue