Add KWIN_BUILD_SCREENLOCKER option

Allows to build KWin without lockscreen support and thus drops the
kscreenlocker dependency.

Signed-off-by: Eike Hein <eike.hein@mbition.io>
master
Kai Uwe Broulik 3 years ago committed by Kai Uwe Broulik
parent 5db527a053
commit d54723cbf2

@ -136,12 +136,6 @@ set_package_properties(KF5Kirigami2 PROPERTIES
find_package(KDecoration2 ${PROJECT_VERSION} CONFIG REQUIRED)
find_package(KScreenLocker CONFIG REQUIRED)
set_package_properties(KScreenLocker PROPERTIES
TYPE REQUIRED
PURPOSE "For screenlocker integration in kwin_wayland"
)
find_package(KWaylandServer ${PROJECT_VERSION} CONFIG REQUIRED)
set_package_properties(KWaylandServer PROPERTIES
TYPE REQUIRED
@ -341,6 +335,7 @@ include(CMakeDependentOption)
option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
option(KWIN_BUILD_SCREENLOCKER "Enable building of KWin lockscreen functionality" ON)
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
@ -396,6 +391,14 @@ add_feature_info("SCHED_RESET_ON_FORK"
pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3>=0.3.29)
add_feature_info(PipeWire PipeWire_FOUND "Required for Wayland screencasting")
if (KWIN_BUILD_SCREENLOCKER)
find_package(KScreenLocker CONFIG REQUIRED)
set_package_properties(KScreenLocker PROPERTIES
TYPE REQUIRED
PURPOSE "For screenlocker integration in kwin_wayland"
)
endif()
########### global ###############
include_directories(BEFORE

@ -78,7 +78,9 @@ function(integrationTest)
endfunction()
integrationTest(NAME testDontCrashGlxgears SRCS dont_crash_glxgears.cpp)
if (KWIN_BUILD_SCREENLOCKER)
integrationTest(NAME testLockScreen SRCS lockscreen.cpp)
endif()
integrationTest(WAYLAND_ONLY NAME testDecorationInput SRCS decoration_input_test.cpp)
integrationTest(WAYLAND_ONLY NAME testInternalWindow SRCS internal_window.cpp)
integrationTest(WAYLAND_ONLY NAME testTouchInput SRCS touch_input_test.cpp)

@ -6,6 +6,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "kwin_wayland_test.h"
#include "cursor.h"
#include "input.h"
@ -223,6 +224,7 @@ void ModifierOnlyShortcutTest::testTrigger()
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QCOMPARE(triggeredSpy.count(), 2);
#ifdef KWIN_BUILD_SCREENLOCKER
// now try to lock the screen while modifier key is pressed
kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++);
QVERIFY(Test::lockScreen());
@ -235,6 +237,7 @@ void ModifierOnlyShortcutTest::testTrigger()
QCOMPARE(triggeredSpy.count(), 2);
QVERIFY(Test::unlockScreen());
#endif
}
void ModifierOnlyShortcutTest::testCapsLock()

@ -20,7 +20,9 @@
#include <KWayland/Client/surface.h>
#include <KWaylandServer/seat_interface.h>
//screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
#include <QPainter>
#include <QRasterWindow>
@ -256,6 +258,7 @@ void PlasmaWindowTest::testPopupWindowNoPlasmaWindow()
void PlasmaWindowTest::testLockScreenNoPlasmaWindow()
{
#ifdef KWIN_BUILD_SCREENLOCKER
// this test verifies that lock screen windows are not exposed to PlasmaWindow
QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated);
QVERIFY(plasmaWindowCreatedSpy.isValid());
@ -284,6 +287,9 @@ void PlasmaWindowTest::testLockScreenNoPlasmaWindow()
}
QVERIFY(lockStateChangedSpy.wait());
QVERIFY(!waylandServer()->isScreenLocked());
#else
QSKIP("KWin was built without lockscreen support");
#endif
}
void PlasmaWindowTest::testDestroyedButNotUnmapped()

@ -6,8 +6,11 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "kwin_wayland_test.h"
#ifdef KWIN_BUILD_SCREENLOCKER
#include "screenlockerwatcher.h"
#endif
#include "wayland_server.h"
#include "workspace.h"
#include "inputmethod.h"
@ -32,7 +35,9 @@
#include <KWaylandServer/display.h>
//screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
#include <QThread>
@ -893,6 +898,7 @@ bool waitForWindowDestroyed(AbstractClient *client)
return destroyedSpy.wait();
}
#ifdef KWIN_BUILD_SCREENLOCKER
bool lockScreen()
{
if (waylandServer()->isScreenLocked()) {
@ -959,6 +965,7 @@ bool unlockScreen()
}
return true;
}
#endif // KWIN_BUILD_LOCKSCREEN
void initWaylandWorkspace()
{

@ -104,7 +104,6 @@ target_sources(kwin PRIVATE
rules.cpp
scene.cpp
screenedge.cpp
screenlockerwatcher.cpp
screens.cpp
scripting/v2/clientmodel.cpp
scripting/v3/clientmodel.cpp
@ -185,7 +184,6 @@ target_link_libraries(kwin
KDecoration2::KDecoration
KDecoration2::KDecoration2Private
PW::KScreenLocker
Plasma::KWaylandServer
XCB::COMPOSITE
@ -230,8 +228,11 @@ qt_add_dbus_adaptor(kwin_dbus_SRCS org.kde.KWin.VirtualDesktopManager.xml dbusin
qt_add_dbus_adaptor(kwin_dbus_SRCS org.kde.KWin.Session.xml sm.h KWin::SessionManager)
qt_add_dbus_adaptor(kwin_dbus_SRCS org.kde.KWin.Plugins.xml dbusinterface.h KWin::PluginManagerDBusInterface)
if (KWIN_BUILD_SCREENLOCKER)
qt_add_dbus_interface(kwin_dbus_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.ScreenSaver.xml screenlocker_interface)
qt_add_dbus_interface(kwin_dbus_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface)
endif()
qt_add_dbus_interface(kwin_dbus_SRCS org.kde.kappmenu.xml appmenu_interface)
target_sources(kwin PRIVATE
@ -255,6 +256,11 @@ if (KWIN_BUILD_ACTIVITIES)
target_link_libraries(kwin KF5::Activities)
endif()
if (KWIN_BUILD_SCREENLOCKER)
target_sources(kwin PRIVATE screenlockerwatcher.cpp)
target_link_libraries(kwin PW::KScreenLocker)
endif()
if (KWIN_BUILD_TABBOX)
target_sources(kwin PRIVATE
tabbox/clientmodel.cpp

@ -1,6 +1,7 @@
#define KWIN_PLUGIN_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
#cmakedefine KWIN_BUILD_DECORATIONS 1
#cmakedefine KWIN_BUILD_SCREENLOCKER 1
#cmakedefine KWIN_BUILD_TABBOX 1
#cmakedefine KWIN_BUILD_ACTIVITIES 1
#cmakedefine KWIN_BUILD_CMS 1

@ -10,6 +10,8 @@
#include "effects.h"
#include <config-kwin.h>
#include "abstract_output.h"
#include "effectsadaptor.h"
#include "effectloader.h"
@ -32,7 +34,9 @@
#include "screenedge.h"
#include "scripting/scriptedeffect.h"
#include "screens.h"
#ifdef KWIN_BUILD_SCREENLOCKER
#include "screenlockerwatcher.h"
#endif
#include "virtualdesktops.h"
#include "window_property_notify_x11_filter.h"
#include "workspace.h"
@ -209,8 +213,10 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
connect(tabBox, &TabBox::TabBox::tabBoxKeyEvent, this, &EffectsHandler::tabBoxKeyEvent);
#endif
connect(ScreenEdges::self(), &ScreenEdges::approaching, this, &EffectsHandler::screenEdgeApproaching);
#ifdef KWIN_BUILD_SCREENLOCKER
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged);
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::aboutToLock, this, &EffectsHandler::screenAboutToLock);
#endif
connect(kwinApp(), &Application::x11ConnectionChanged, this,
[this] {
@ -1607,7 +1613,11 @@ QString EffectsHandlerImpl::supportInformation(const QString &name) const
bool EffectsHandlerImpl::isScreenLocked() const
{
#ifdef KWIN_BUILD_SCREENLOCKER
return ScreenLockerWatcher::self()->isLocked();
#else
return false;
#endif
}
QString EffectsHandlerImpl::debug(const QString& name, const QString& parameter) const

@ -8,6 +8,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "input.h"
#include "backends/fakeinput/fakeinputbackend.h"
#include "backends/libinput/connection.h"
@ -53,7 +54,9 @@
#include <decorations/decoratedclient.h>
//screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
// Qt
#include <QDBusConnection>
#include <QDBusMessage>
@ -381,11 +384,13 @@ public:
// send event to KSldApp for global accel
// if event is set to accepted it means a whitelisted shortcut was triggered
// in that case we filter it out and don't process it further
#ifdef KWIN_BUILD_SCREENLOCKER
event->setAccepted(false);
QCoreApplication::sendEvent(ScreenLocker::KSldApp::self(), event);
if (event->isAccepted()) {
return true;
}
#endif
// continue normal processing
input()->keyboard()->update();

@ -6,6 +6,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "inputmethod.h"
#include "abstract_client.h"
#include "virtualkeyboard_dbus.h"
@ -16,7 +17,9 @@
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#ifdef KWIN_BUILD_SCREENLOCKER
#include "screenlockerwatcher.h"
#endif
#include "deleted.h"
#include "touch_input.h"
#include "tablet_input.h"
@ -76,7 +79,9 @@ void InputMethod::init()
connect(&m_inputMethodCrashTimer, &QTimer::timeout, this, [this] {
m_inputMethodCrashes = 0;
});
#ifdef KWIN_BUILD_SCREENLOCKER
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::aboutToLock, this, &InputMethod::hide);
#endif
new VirtualKeyboardDBus(this);
qCDebug(KWIN_VIRTUALKEYBOARD) << "Registering the DBus interface";

@ -6,6 +6,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "keyboard_input.h"
#include "abstract_client.h"
#include "input_event.h"
@ -14,7 +15,6 @@
#include "keyboard_layout.h"
#include "keyboard_repeat.h"
#include "modifier_only_shortcuts.h"
#include "screenlockerwatcher.h"
#include "toplevel.h"
#include "utils/common.h"
#include "wayland_server.h"
@ -24,7 +24,9 @@
#include <KWaylandServer/keyboard_interface.h>
#include <KWaylandServer/seat_interface.h>
//screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
// Frameworks
#include <KGlobalAccel>
// Qt
@ -141,9 +143,11 @@ void KeyboardInputRedirection::init()
update();
}
);
#ifdef KWIN_BUILD_SCREENLOCKER
if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &KeyboardInputRedirection::update);
}
#endif
reconfigure();
}

@ -8,6 +8,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "main.h"
// kwin
#include "platform.h"
@ -22,7 +23,9 @@
#include "options.h"
#include "pluginmanager.h"
#include "screens.h"
#ifdef KWIN_BUILD_SCREENLOCKER
#include "screenlockerwatcher.h"
#endif
#include "sm.h"
#include "utils/xcbutils.h"
#include "workspace.h"
@ -284,7 +287,9 @@ void Application::createWorkspace()
void Application::createInput()
{
#ifdef KWIN_BUILD_SCREENLOCKER
ScreenLockerWatcher::create(this);
#endif
auto input = InputRedirection::create(this);
input->init();
m_platform->createPlatformCursor(this);

@ -506,6 +506,7 @@ int main(int argc, char * argv[])
i18n("List all available backends and quit."));
parser.addOption(listBackendsOption);
#ifdef KWIN_BUILD_SCREENLOCKER
QCommandLineOption screenLockerOption(QStringLiteral("lockscreen"),
i18n("Starts the session in locked mode."));
parser.addOption(screenLockerOption);
@ -513,6 +514,7 @@ int main(int argc, char * argv[])
QCommandLineOption noScreenLockerOption(QStringLiteral("no-lockscreen"),
i18n("Starts the session without lock screen support."));
parser.addOption(noScreenLockerOption);
#endif
QCommandLineOption noGlobalShortcutsOption(QStringLiteral("no-global-shortcuts"),
i18n("Starts the session without global shortcuts support."));
@ -634,11 +636,13 @@ int main(int argc, char * argv[])
KWin::WaylandServer *server = KWin::WaylandServer::create(&a);
KWin::WaylandServer::InitializationFlags flags;
#ifdef KWIN_BUILD_SCREENLOCKER
if (parser.isSet(screenLockerOption)) {
flags = KWin::WaylandServer::InitializationFlag::LockScreen;
} else if (parser.isSet(noScreenLockerOption)) {
flags = KWin::WaylandServer::InitializationFlag::NoLockScreenIntegration;
}
#endif
if (parser.isSet(noGlobalShortcutsOption)) {
flags |= KWin::WaylandServer::InitializationFlag::NoGlobalShortcuts;
}

@ -6,10 +6,13 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "modifier_only_shortcuts.h"
#include "input_event.h"
#include "options.h"
#ifdef KWIN_BUILD_SCREENLOCKER
#include "screenlockerwatcher.h"
#endif
#include "wayland_server.h"
#include "workspace.h"
@ -24,7 +27,9 @@ ModifierOnlyShortcuts::ModifierOnlyShortcuts()
: QObject()
, InputEventSpy()
{
#ifdef KWIN_BUILD_SCREENLOCKER
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &ModifierOnlyShortcuts::reset);
#endif
}
ModifierOnlyShortcuts::~ModifierOnlyShortcuts() = default;
@ -38,7 +43,9 @@ void ModifierOnlyShortcuts::keyEvent(KeyEvent *event)
const bool wasEmpty = m_pressedKeys.isEmpty();
m_pressedKeys.insert(event->nativeScanCode());
if (wasEmpty && m_pressedKeys.size() == 1 &&
#ifdef KWIN_BUILD_SCREENLOCKER
!ScreenLockerWatcher::self()->isLocked() &&
#endif
m_pressedButtons == Qt::NoButton &&
m_cachedMods == Qt::NoModifier) {
m_modifier = Qt::KeyboardModifier(int(event->modifiersRelevantForGlobalShortcuts()));

@ -8,6 +8,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "pointer_input.h"
#include "abstract_output.h"
#include "platform.h"
@ -31,7 +32,9 @@
#include <KWaylandServer/seat_interface.h>
#include <KWaylandServer/surface_interface.h>
// screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
#include <KLocalizedString>
@ -140,6 +143,7 @@ void PointerInputRedirection::init()
Q_EMIT m_cursor->changed();
connect(screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange);
#ifdef KWIN_BUILD_SCREENLOCKER
if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this,
[this] {
@ -151,6 +155,7 @@ void PointerInputRedirection::init()
}
);
}
#endif
connect(workspace(), &QObject::destroyed, this, [this] { setInited(false); });
connect(waylandServer(), &QObject::destroyed, this, [this] { setInited(false); });
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragEnded, this,
@ -948,9 +953,11 @@ CursorImage::CursorImage(PointerInputRedirection *parent)
reevaluteSource();
}
);
#ifdef KWIN_BUILD_SCREENLOCKER
if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource);
}
#endif
connect(m_pointer, &PointerInputRedirection::decorationChanged, this, &CursorImage::updateDecoration);
// connect the move resize of all window
auto setupMoveResizeConnection = [this] (AbstractClient *c) {

@ -19,6 +19,7 @@
#include "screenedge.h"
// KWin
#include <config-kwin.h>
#include "abstract_output.h"
#include "gestures.h"
#include <x11client.h>
@ -29,10 +30,13 @@
#include <workspace.h>
#include "virtualdesktops.h"
// DBus generated
#ifdef KWIN_BUILD_SCREENLOCKER
#include "screenlocker_interface.h"
#endif
// frameworks
#include <KConfigGroup>
// Qt
#include <QAbstractEventDispatcher>
#include <QAction>
#include <QMouseEvent>
#include <QSharedPointer>
@ -329,6 +333,7 @@ bool Edge::handleAction(ElectricBorderAction action)
return true;
}
case ElectricActionLockScreen: { // Lock the screen
#ifdef KWIN_BUILD_SCREENLOCKER
OrgFreedesktopScreenSaverInterface interface(QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("/ScreenSaver"),
QDBusConnection::sessionBus());
@ -336,6 +341,9 @@ bool Edge::handleAction(ElectricBorderAction action)
interface.Lock();
}
return true;
#else
return false;
#endif
}
case ElectricActionKRunner: { // open krunner
QDBusConnection::sessionBus().asyncCall(

@ -20,8 +20,6 @@
// KWayland
#include <KWaylandServer/seat_interface.h>
#include <KWaylandServer/surface_interface.h>
// screenlocker
#include <KScreenLocker/KsldApp>
// Qt
#include <QHoverEvent>
#include <QWindow>

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "touch_input.h"
#include "abstract_client.h"
#include "pointer_input.h"
@ -20,7 +21,9 @@
// KWayland
#include <KWaylandServer/seat_interface.h>
// screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
// Qt
#include <QHoverEvent>
#include <QWindow>
@ -45,6 +48,7 @@ void TouchInputRedirection::init()
setInited(true);
InputDeviceHandler::init();
#ifdef KWIN_BUILD_SCREENLOCKER
if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this,
[this] {
@ -54,6 +58,7 @@ void TouchInputRedirection::init()
}
);
}
#endif
connect(workspace(), &QObject::destroyed, this, [this] { setInited(false); });
connect(waylandServer(), &QObject::destroyed, this, [this] { setInited(false); });
}

@ -6,6 +6,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "wayland_server.h"
#include "abstract_wayland_output.h"
#include "x11client.h"
@ -80,7 +81,9 @@
#include <unistd.h>
//screenlocker
#ifdef KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
using namespace KWaylandServer;
@ -587,6 +590,7 @@ void WaylandServer::initWorkspace()
void WaylandServer::initScreenLocker()
{
#ifdef KWIN_BUILD_SCREENLOCKER
auto *screenLockerApp = ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
@ -639,6 +643,7 @@ void WaylandServer::initScreenLocker()
if (m_initFlags.testFlag(InitializationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
}
#endif
}
WaylandServer::SocketPairConnection WaylandServer::createConnection()
@ -746,16 +751,24 @@ XdgSurfaceClient *WaylandServer::findXdgSurfaceClient(SurfaceInterface *surface)
bool WaylandServer::isScreenLocked() const
{
#ifdef KWIN_BUILD_SCREENLOCKER
if (!hasScreenLockerIntegration()) {
return false;
}
return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked ||
ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock;
#else
return false;
#endif
}
bool WaylandServer::hasScreenLockerIntegration() const
{
#ifdef KWIN_BUILD_SCREENLOCKER
return !m_initFlags.testFlag(InitializationFlag::NoLockScreenIntegration);
#else
return false;
#endif
}
bool WaylandServer::hasGlobalShortcutSupport() const

Loading…
Cancel
Save