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

View file

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

View file

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

View file

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