diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp index 08384fd046..19a96e9ffc 100644 --- a/kcmkwin/kwinscreenedges/main.cpp +++ b/kcmkwin/kwinscreenedges/main.cpp @@ -185,7 +185,14 @@ void KWinScreenEdgesConfig::monitorInit() monitorAddItem( i18n( "No Action" )); monitorAddItem( i18n( "Show Dashboard" )); monitorAddItem( i18n( "Show Desktop" )); - + monitorAddItem( i18n( "Lock Screen" )); + monitorAddItem( i18n( "Prevent Screen Locking" )); + //Prevent Screen Locking is not supported on some edges + m_ui->monitor->setEdgeItemEnabled( int( Monitor::Top ), 4, false ); + m_ui->monitor->setEdgeItemEnabled( int( Monitor::Left ), 4, false ); + m_ui->monitor->setEdgeItemEnabled( int( Monitor::Right ), 4, false ); + m_ui->monitor->setEdgeItemEnabled( int( Monitor::Bottom ), 4, false ); + // Search the effect names KServiceTypeTrader* trader = KServiceTypeTrader::self(); KService::List services; @@ -251,6 +258,8 @@ void KWinScreenEdgesConfig::monitorLoadAction( ElectricBorder edge, const QStrin QString lowerName = config.readEntry( configName, "None" ).toLower(); if( lowerName == "dashboard" ) monitorChangeEdge( edge, int( ElectricActionDashboard )); else if( lowerName == "showdesktop" ) monitorChangeEdge( edge, int( ElectricActionShowDesktop )); + else if( lowerName == "lockscreen" ) monitorChangeEdge( edge, int( ElectricActionLockScreen )); + else if( lowerName == "preventscreenlocking" ) monitorChangeEdge( edge, int( ElectricActionPreventScreenLocking )); } void KWinScreenEdgesConfig::monitorLoad() @@ -348,8 +357,23 @@ void KWinScreenEdgesConfig::monitorSaveAction( int edge, const QString& configNa config.writeEntry( configName, "Dashboard" ); else if( item == 2 ) config.writeEntry( configName, "ShowDesktop" ); + else if( item == 3) + config.writeEntry( configName, "LockScreen" ); + else if ( item == 4) + config.writeEntry( configName, "PreventScreenLocking" ); else // Anything else config.writeEntry( configName, "None" ); + + if ((edge == int( Monitor::TopRight )) || + (edge == int( Monitor::BottomRight )) || + (edge == int( Monitor::BottomLeft )) || + (edge == int( Monitor::TopLeft ))) + { + KConfig scrnConfig("kscreensaverrc"); + KConfigGroup scrnGroup = scrnConfig.group("ScreenSaver"); + scrnGroup.writeEntry("Action" + configName, (item == 4) ? 2 /* Prevent Screen Locking */ : 0 /* None */); + scrnGroup.sync(); + } } void KWinScreenEdgesConfig::monitorSave() diff --git a/lib/kwinglobals.h b/lib/kwinglobals.h index 600bba6417..2c3f6cb1cb 100644 --- a/lib/kwinglobals.h +++ b/lib/kwinglobals.h @@ -95,6 +95,8 @@ enum ElectricBorderAction ElectricActionNone, // No special action, not set, desktop switch or an effect ElectricActionDashboard, // Launch the Plasma dashboard ElectricActionShowDesktop, // Show desktop or restore + ElectricActionLockScreen, // Lock screen + ElectricActionPreventScreenLocking, ELECTRIC_ACTION_COUNT }; diff --git a/options.cpp b/options.cpp index a57addf081..955bbe2c25 100644 --- a/options.cpp +++ b/options.cpp @@ -278,6 +278,8 @@ ElectricBorderAction Options::electricBorderAction( const QString& name ) QString lowerName = name.toLower(); if( lowerName == "dashboard" ) return ElectricActionDashboard; else if( lowerName == "showdesktop" ) return ElectricActionShowDesktop; + else if( lowerName == "lockscreen" ) return ElectricActionLockScreen; + else if( lowerName == "preventscreenlocking" ) return ElectricActionLockScreen; return ElectricActionNone; } diff --git a/workspace.cpp b/workspace.cpp index 16a6727046..88f5e30f2d 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -2242,6 +2242,16 @@ void Workspace::checkElectricBorder(const QPoint& pos, Time now) setShowingDesktop( !showingDesktop() ); break; } + case ElectricActionLockScreen: // Lock the screen + { + QDBusInterface screenSaver( "org.kde.screensaver", "/ScreenSaver" ); + screenSaver.call( "Lock" ); + } + break; + case ElectricActionPreventScreenLocking: + { + break; + } case ElectricActionNone: // Either desktop switching or an effect default: {