Commit 1409f426 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

logout greeter: Port to LayerShellQt

It's less involved than KWayland::Client::PlasmaShell.
parent d532b56c
......@@ -19,9 +19,9 @@ target_link_libraries(ksmserver-logout-greeter
KF5::I18n
KF5::Package
KF5::QuickAddons
KF5::WaylandClient
KF5::WindowSystem
X11::X11
LayerShellQt::Interface
)
install(TARGETS ksmserver-logout-greeter DESTINATION ${KDE_INSTALL_LIBEXECDIR})
kdbusaddons_generate_dbus_service_file(ksmserver-logout-greeter org.kde.LogoutPrompt ${KDE_INSTALL_FULL_LIBEXECDIR})
......
......@@ -36,14 +36,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <KQuickAddons/QtQuickSettings>
#include <KWindowSystem>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/registry.h>
#include <LayerShellQt/Shell>
Greeter::Greeter()
: QObject()
, m_waylandPlasmaShell(nullptr)
{
new LogoutPromptAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/LogoutPrompt"), this);
......@@ -60,18 +56,7 @@ void Greeter::setupWaylandIntegration()
if (!KWindowSystem::isPlatformWayland()) {
return;
}
using namespace KWayland::Client;
ConnectionThread *connection = ConnectionThread::fromApplication(this);
if (!connection) {
return;
}
Registry *registry = new Registry(this);
registry->create(connection);
connect(registry, &Registry::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) {
m_waylandPlasmaShell = registry->createPlasmaShell(name, version, this);
});
registry->setup();
connection->roundtrip();
LayerShellQt::Shell::useLayerShell();
}
void Greeter::init()
......@@ -88,7 +73,7 @@ void Greeter::init()
void Greeter::adoptScreen(QScreen *screen)
{
// TODO: last argument is the theme, maybe add command line option for it?
KSMShutdownDlg *w = new KSMShutdownDlg(nullptr, m_shutdownType, m_waylandPlasmaShell);
KSMShutdownDlg *w = new KSMShutdownDlg(nullptr, m_shutdownType);
w->installEventFilter(this);
m_dialogs << w;
......
......@@ -31,13 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <kworkspace.h>
class KSMShutdownDlg;
namespace KWayland
{
namespace Client
{
class PlasmaShell;
}
}
class QScreen;
......@@ -66,5 +59,4 @@ private:
KWorkSpace::ShutdownType m_shutdownType = KWorkSpace::ShutdownTypeHalt;
QVector<KSMShutdownDlg *> m_dialogs;
KWayland::Client::PlasmaShell *m_waylandPlasmaShell;
};
......@@ -53,6 +53,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <KUser>
#include <KWindowEffects>
#include <KWindowSystem>
#include <LayerShellQt/Window>
#include <netwm.h>
#include <stdio.h>
......@@ -64,19 +65,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <config-workspace.h>
#include <debug.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/surface.h>
static const QString s_login1Service = QStringLiteral("org.freedesktop.login1");
static const QString s_login1Path = QStringLiteral("/org/freedesktop/login1");
static const QString s_dbusPropertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties");
static const QString s_login1ManagerInterface = QStringLiteral("org.freedesktop.login1.Manager");
static const QString s_login1RebootToFirmwareSetup = QStringLiteral("RebootToFirmwareSetup");
KSMShutdownDlg::KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype, KWayland::Client::PlasmaShell *plasmaShell)
KSMShutdownDlg::KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype)
: QuickViewSharedEngine(parent)
, m_result(false)
, m_waylandPlasmaShell(plasmaShell)
// this is a WType_Popup on purpose. Do not change that! Not
// having a popup here has severe side effects.
{
......@@ -211,6 +208,10 @@ void KSMShutdownDlg::init()
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
setKeyboardGrabEnabled(true);
KWindowEffects::enableBlurBehind(winId(), true);
if (auto w = LayerShellQt::Window::get(this)) {
w->setKeyboardInteractivity(true);
}
}
void KSMShutdownDlg::resizeEvent(QResizeEvent *e)
......@@ -225,47 +226,6 @@ void KSMShutdownDlg::resizeEvent(QResizeEvent *e)
}
}
bool KSMShutdownDlg::event(QEvent *e)
{
if (e->type() == QEvent::PlatformSurface) {
switch (static_cast<QPlatformSurfaceEvent *>(e)->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
KWindowEffects::enableBlurBehind(winId(), true);
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
}
return KQuickAddons::QuickViewSharedEngine::event(e);
}
void KSMShutdownDlg::setupWaylandIntegration()
{
if (m_shellSurface) {
// already setup
return;
}
if (!m_waylandPlasmaShell) {
return;
}
using namespace KWayland::Client;
Surface *s = Surface::fromWindow(this);
if (!s) {
return;
}
m_shellSurface = m_waylandPlasmaShell->createSurface(s, this);
// Use Role::Panel to make it go above all other windows
// see allso KSplash splashwindow.cpp
m_shellSurface->setPosition(geometry().topLeft());
m_shellSurface->setRole(PlasmaShellSurface::Role::Panel);
m_shellSurface->setPanelTakesFocus(true);
m_shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsGoBelow);
}
void KSMShutdownDlg::slotLogout()
{
m_session.requestLogout(SessionManagement::ConfirmationMode::Skip);
......
......@@ -29,22 +29,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <kworkspace.h>
#include <sessionmanagement.h>
namespace KWayland
{
namespace Client
{
class PlasmaShell;
class PlasmaShellSurface;
}
}
// The confirmation dialog
class KSMShutdownDlg : public KQuickAddons::QuickViewSharedEngine
{
Q_OBJECT
public:
KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype, KWayland::Client::PlasmaShell *plasmaShell = nullptr);
KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype);
void init();
bool result() const;
......@@ -65,16 +56,12 @@ Q_SIGNALS:
protected:
void resizeEvent(QResizeEvent *e) override;
bool event(QEvent *e) override;
private:
void setupWaylandIntegration();
QString m_bootOption;
QStringList rebootOptions;
bool m_result : 1;
SessionManagement m_session;
KWayland::Client::PlasmaShell *m_waylandPlasmaShell;
KWayland::Client::PlasmaShellSurface *m_shellSurface = nullptr;
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment