Fix overlay windows in Wayland

This commit is contained in:
Victor Tran 2023-09-25 21:37:22 +10:00
parent 45837a73c4
commit 4ba1c8c00a
No known key found for this signature in database
4 changed files with 16 additions and 11 deletions

View file

@ -24,7 +24,7 @@
#include <tscrim.h>
OverlayWindow::OverlayWindow(QWidget* parent) :
QDialog(parent), ui(new Ui::OverlayWindow) {
QWidget(parent), ui(new Ui::OverlayWindow) {
ui->setupUi(this);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowFlag(Qt::WindowStaysOnTopHint);
@ -36,6 +36,7 @@ OverlayWindow::~OverlayWindow() {
delete ui;
}
void OverlayWindow::showEvent(QShowEvent* event) {
DesktopWm::setSystemWindow(this, DesktopWm::SystemWindowTypeLockScreen);
}
// void OverlayWindow::showEvent(QShowEvent* event) {
// QDialog::showEvent(event);
// DesktopWm::instance()->setSystemWindow(this, DesktopWm::SystemWindowTypeLockScreen);
//}

View file

@ -23,22 +23,23 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
namespace Ui { class OverlayWindow; }
namespace Ui {
class OverlayWindow;
}
QT_END_NAMESPACE
class OverlayWindow : public QDialog
{
class OverlayWindow : public QWidget {
Q_OBJECT
public:
OverlayWindow(QWidget *parent = nullptr);
OverlayWindow(QWidget* parent = nullptr);
~OverlayWindow();
private:
Ui::OverlayWindow *ui;
Ui::OverlayWindow* ui;
// QWidget interface
protected:
void showEvent(QShowEvent *event);
// void showEvent(QShowEvent *event);
};
#endif // OVERLAYWINDOW_H

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OverlayWindow</class>
<widget class="QDialog" name="OverlayWindow">
<widget class="QWidget" name="OverlayWindow">
<property name="geometry">
<rect>
<x>0</x>

View file

@ -20,6 +20,8 @@
#include "layershellwindow.h"
#include "private/layershellsurface.h"
#include <private/qwaylandscreen_p.h>
#include <private/qwaylandshellintegrationfactory_p.h>
#include <private/qwaylandwindow_p.h>
struct LayerShellWindowPrivate {
@ -30,6 +32,7 @@ LayerShellWindow* LayerShellWindow::forWindow(QWindow* window) {
QtWaylandClient::QWaylandWindow* waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow*>(window->handle());
if (!waylandWindow) return nullptr;
waylandWindow->setShellIntegration(QtWaylandClient::QWaylandShellIntegrationFactory::create("tdesktopenvironment-layer-shell", waylandWindow->waylandScreen()->display()));
waylandWindow->setVisible(true);
LayerShellSurface* surface = qobject_cast<LayerShellSurface*>(waylandWindow->shellSurface());