Files
RedBear-OS/local/recipes/kde/kwin/source/tests/lockscreenoverlaytest.cpp
T
vasilito 7aeb3bb475 build: capture build script auto-stash changes from 0.2.5 kernel/relibc/base build
The build-redbear.sh script auto-stashes working tree changes
in nested relibc and base source trees before running the
build. These changes were captured by the failed kernel
build attempt that hit the json-target-spec / kernel rust
toolchain mismatch (fixed in 0.2.5 by creating the local
0.2.5 branch).

Captured changes:
- local/recipes/kde/* : KDE Frameworks 6 source CMakeLists
  whitespace changes from the autostash (preserved)
- local/recipes/qt/qtbase/* : qtypes.h whitespace from the
  autostash (preserved)
- local/sources/kernel/Cargo.lock : dependency lock from
  the kernel relibc rebuild attempt
- local/sources/kernel/src/lib.rs : touched (mtime) by the
  build script's touch + make prefix command

This is a bookkeeping commit — the actual code changes
for the threading plan are on the 4 submodule branches
(kernel, relibc, base, libredox) and will be pushed
separately.

0.2.5 branch was created from 0.2.4 (HEAD cd3950072e) to
continue Phase 0 of the multi-threading plan work in a
clean branch.
2026-07-02 13:41:03 +03:00

91 lines
2.7 KiB
C++

/*
SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "qwayland-kde-lockscreen-overlay-v1.h"
#include <KWaylandExtras>
#include <KWindowSystem>
#include <QWaylandClientExtensionTemplate>
#include <QtWidgets>
#include <qpa/qplatformnativeinterface.h>
class WaylandAboveLockscreen : public QWaylandClientExtensionTemplate<WaylandAboveLockscreen>, public QtWayland::kde_lockscreen_overlay_v1
{
public:
WaylandAboveLockscreen()
: QWaylandClientExtensionTemplate<WaylandAboveLockscreen>(1)
{
initialize();
}
void allowWindow(QWindow *window)
{
QPlatformNativeInterface *native = qGuiApp->platformNativeInterface();
wl_surface *surface = reinterpret_cast<wl_surface *>(native->nativeResourceForWindow(QByteArrayLiteral("surface"), window));
allow(surface);
}
};
class WidgetAllower : public QObject
{
public:
WidgetAllower(QWidget *widget)
: QObject(widget)
, m_widget(widget)
{
widget->installEventFilter(this);
}
bool eventFilter(QObject * /*watched*/, QEvent *event) override
{
if (auto w = m_widget->windowHandle()) {
WaylandAboveLockscreen aboveLockscreen;
Q_ASSERT(aboveLockscreen.isInitialized());
aboveLockscreen.allowWindow(w);
deleteLater();
}
return false;
}
QWidget *const m_widget;
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window1(nullptr, Qt::Window);
window1.setWindowTitle("Window 1");
window1.setLayout(new QVBoxLayout);
QPushButton p("Lock && Raise the Window 2");
window1.layout()->addWidget(&p);
window1.show();
QWidget window2(nullptr, Qt::Window);
window2.setWindowTitle("Window 2");
window2.setLayout(new QVBoxLayout);
QPushButton p2("Close");
window2.layout()->addWidget(&p2);
new WidgetAllower(&window2);
auto raiseWindow2 = [&] {
auto tokenFuture = KWaylandExtras::xdgActivationToken(window2.windowHandle(), "lockscreenoverlaytest.desktop");
tokenFuture.then(&window2, [&window2](const QString &token) {
KWindowSystem::setCurrentXdgActivationToken(token);
KWindowSystem::activateWindow(window2.windowHandle());
});
};
QObject::connect(&p, &QPushButton::clicked, &app, [&] {
QProcess::execute("loginctl", {"lock-session"});
window2.showFullScreen();
QTimer::singleShot(3000, &app, raiseWindow2);
});
QObject::connect(&p2, &QPushButton::clicked, &window2, &QWidget::close);
return app.exec();
}