mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-14 11:04:20 -04:00
Port to QWaylandWindow::setShellIntegration()
With QWaylandWindow::setShellIntegration(), it's possible to use xdg-shell and layer-shell protocols in the same process. It's important for plasmashell, where we want to use the layer shell protocol for special surfaces such as the desktop background, and the xdg shell protocol for dialogs. In order to make a QWindow use the layer shell protocol, you need to call LayerShellQt::Window::get() before the window is mapped.
This commit is contained in:
@ -5,11 +5,15 @@
|
||||
*/
|
||||
|
||||
#include "window.h"
|
||||
#include "../qwaylandlayershellintegration_p.h"
|
||||
|
||||
#include <layershellqt_logging.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <optional>
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
|
||||
using namespace LayerShellQt;
|
||||
|
||||
class LayerShellQt::WindowPrivate
|
||||
@ -122,6 +126,27 @@ Window::Window(QWindow *window)
|
||||
, d(new WindowPrivate(window))
|
||||
{
|
||||
s_map.insert(d->parentWindow, this);
|
||||
|
||||
window->create();
|
||||
|
||||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
|
||||
if (!waylandWindow) {
|
||||
qCWarning(LAYERSHELLQT) << window << "is not a wayland window. Not creating zwlr_layer_surface";
|
||||
return;
|
||||
}
|
||||
|
||||
static QWaylandLayerShellIntegration *shellIntegration = nullptr;
|
||||
if (!shellIntegration) {
|
||||
shellIntegration = new QWaylandLayerShellIntegration();
|
||||
if (!shellIntegration->initialize(waylandWindow->display())) {
|
||||
delete shellIntegration;
|
||||
shellIntegration = nullptr;
|
||||
qCWarning(LAYERSHELLQT) << "Failed to initialize layer-shell integration, possibly because compositor does not support the layer-shell protocol";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
waylandWindow->setShellIntegration(shellIntegration);
|
||||
}
|
||||
|
||||
Window *Window::get(QWindow *window)
|
||||
|
Reference in New Issue
Block a user