aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lumina-wm-INCOMPLETE/GlobalDefines.h2
-rw-r--r--lumina-wm-INCOMPLETE/LLockScreen.cpp157
-rw-r--r--lumina-wm-INCOMPLETE/LLockScreen.h45
-rw-r--r--lumina-wm-INCOMPLETE/LLockScreen.ui141
-rw-r--r--lumina-wm-INCOMPLETE/LSScreen.ui173
-rw-r--r--lumina-wm-INCOMPLETE/LScreenSaver.cpp104
-rw-r--r--lumina-wm-INCOMPLETE/LScreenSaver.h17
-rw-r--r--lumina-wm-INCOMPLETE/SSBaseWidget.cpp17
-rw-r--r--lumina-wm-INCOMPLETE/SSBaseWidget.h11
-rw-r--r--lumina-wm-INCOMPLETE/WMSession.cpp8
-rw-r--r--lumina-wm-INCOMPLETE/animations/SampleAnimation.h4
-rw-r--r--lumina-wm-INCOMPLETE/lumina-wm.pro8
-rw-r--r--lumina-wm-INCOMPLETE/main.cpp1
13 files changed, 462 insertions, 226 deletions
diff --git a/lumina-wm-INCOMPLETE/GlobalDefines.h b/lumina-wm-INCOMPLETE/GlobalDefines.h
index 4376a891..0ba05f88 100644
--- a/lumina-wm-INCOMPLETE/GlobalDefines.h
+++ b/lumina-wm-INCOMPLETE/GlobalDefines.h
@@ -39,6 +39,8 @@
#include <QPaintEvent>
#include <QPainter>
#include <QSettings>
+#include <QHostInfo>
+#include <QDesktopWidget>
// libLumina includes
#include <LuminaX11.h>
diff --git a/lumina-wm-INCOMPLETE/LLockScreen.cpp b/lumina-wm-INCOMPLETE/LLockScreen.cpp
new file mode 100644
index 00000000..3778042f
--- /dev/null
+++ b/lumina-wm-INCOMPLETE/LLockScreen.cpp
@@ -0,0 +1,157 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "LLockScreen.h"
+#include "ui_LLockScreen.h"
+
+//Standard C libary for username/system fetch
+#include <unistd.h>
+//#include <sys/param.h>
+
+//PAM libraries
+#include <sys/types.h>
+#include <security/pam_appl.h>
+#include <security/openpam.h>
+//#include <sys/wait.h>
+//#include <pwd.h>
+//#include <login_cap.h>
+
+#define DEBUG 1
+
+LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScreen()){
+ ui->setupUi(this);
+ waittime = new QTimer(this);
+ waittime->setInterval(300000); //5 minutes (too many attempts in short time)
+ waittime->setSingleShot(true);
+ connect(ui->tool_unlock, SIGNAL(clicked()), this, SLOT(TryUnlock()) );
+ connect(ui->line_password, SIGNAL(returnPressed()), this, SLOT(TryUnlock()) );
+ connect(ui->line_password, SIGNAL(textEdited(QString)), this, SIGNAL(InputDetected()) );
+ connect(ui->line_password, SIGNAL(cursorPositionChanged(int,int)), this, SIGNAL(InputDetected()) );
+ connect(waittime, SIGNAL(timeout()), this, SLOT(aboutToShow()) );
+}
+
+LLockScreen::~LLockScreen(){
+
+}
+
+void LLockScreen::LoadSystemDetails(){
+ //Run every time the screen is initially locked
+ QString user = QString(getlogin());
+ ui->label_username->setText( QString(tr("Locked by: %1")).arg(user) );
+ ui->label_hostname->setText( QHostInfo::localHostName() );
+ ui->tool_unlock->setIcon( LXDG::findIcon("document-decrypt","") );
+ attempts = 0;
+ bool ok = PAM_lockSession(user);
+ qDebug() << "Closed PAM session:" << ok;
+}
+
+void LLockScreen::aboutToHide(){
+ //auto-hide timeout - clear display
+ ui->line_password->clear();
+ ui->line_password->clearFocus();
+ if(!waittime->isActive()){ ui->label_info->clear(); } //could be obsolete the next time the lock screen is shown
+
+}
+
+void LLockScreen::aboutToShow(){
+ if(!waittime->isActive()){
+ ui->label_info->setText( PAM_checkLockInfo( QString(getlogin()) ) );
+ this->setEnabled(true);
+ triesleft = 4; //back to initial number of tries
+ }
+ ui->line_password->clear();
+ ui->line_password->setFocus();
+}
+
+// =================
+// PRIVATE
+// =================
+// PAM structures for the functions below
+static struct pam_conv pamc = { openpam_nullconv, NULL };
+pam_handle_t *pamh;
+
+bool LLockScreen::PAM_checkpass(QString user, QString pass, QString &info){
+ //Convert the inputs to C character arrays for use in PAM
+ if(DEBUG){qDebug() << "Check Password w/PAM:" << user << pass;}
+ QByteArray tmp2 = pass.toUtf8();
+ char* cPassword = tmp2.data();
+ //initialize variables
+ bool result = false;
+ //Place the user-supplied password into the structure
+ int ret = pam_set_item(pamh, PAM_AUTHTOK, cPassword);
+ //Set the TTY
+ //Authenticate with PAM
+ ret = pam_authenticate(pamh,0);
+ if( ret == PAM_SUCCESS ){
+ //Check for valid, unexpired account and verify access restrictions
+ ret = pam_acct_mgmt(pamh,0);
+ if( ret == PAM_SUCCESS ){
+ result = true;
+ ret = pam_setcred(pamh,PAM_REINITIALIZE_CRED);
+ ret = pam_end(pamh,ret);
+ }else{ info = PAM_getError(ret); }
+ }else{
+ info = PAM_getError(ret);
+ }
+ if(DEBUG){ qDebug() << " - Result:" << result << ret; }
+ //return verification result
+ return result;
+}
+
+QString LLockScreen::PAM_checkLockInfo(QString user){
+ //Return info string with any account lock/reset info
+ return ""; //not implemented yet
+}
+
+QString LLockScreen::PAM_getError(int ret){
+ QString err;
+ //Interpret a PAM error message and log it
+ //qWarning() << "PAM Error: " << ret;
+ switch( ret ){
+ case PAM_MAXTRIES:
+ err = tr("Too Many Failures: Try again later.");
+ break;
+ case PAM_NEW_AUTHTOK_REQD:
+ err = tr("Password Expired: Contact System Admin");
+ break;
+ default:
+ triesleft--;
+ if(triesleft>0){ err = QString(tr("Failure: %1 Attempts Remaining")).arg( QString::number(triesleft) ); }
+ else{err = tr("Too Many Failures: Try again in 5 minutes"); }
+ if(DEBUG){ err.append("\n"+QString(pam_strerror(pamh, ret)) ); }
+ }
+ return err;
+}
+
+bool LLockScreen::PAM_lockSession(QString user){
+ QByteArray tmp = user.toUtf8();
+ char* cUser = tmp.data();
+ int ret = pam_start( user=="root" ? "system": "login", cUser, &pamc, &pamh);
+ //if(ret == PAM_SUCCESS){ ret = pam_setcred(pamh,PAM_DELETE_CRED); }
+ return (ret== PAM_SUCCESS);
+}
+// =================
+// PRIVATE SLOTS
+// =================
+void LLockScreen::TryUnlock(){
+ attempts++;
+ this->setEnabled(false);
+ QString pass = ui->line_password->text();
+ ui->line_password->clear();
+ QString user = QString(getlogin());
+ QString info;
+ bool ok = PAM_checkpass(user, pass, info);
+ if(ok){
+ emit ScreenUnlocked();
+ this->setEnabled(true);
+ }else if(triesleft>1){
+ this->setEnabled(true);
+ ui->label_info->setText(info);
+ }else{
+ ui->label_info->setText(info);
+ waittime->start();
+ }
+}
diff --git a/lumina-wm-INCOMPLETE/LLockScreen.h b/lumina-wm-INCOMPLETE/LLockScreen.h
new file mode 100644
index 00000000..e7ded6a0
--- /dev/null
+++ b/lumina-wm-INCOMPLETE/LLockScreen.h
@@ -0,0 +1,45 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_DESKTOP_LOCK_SCREEN_WIDGET_H
+#define _LUMINA_DESKTOP_LOCK_SCREEN_WIDGET_H
+
+#include "GlobalDefines.h"
+
+namespace Ui{
+ class LLockScreen;
+};
+
+class LLockScreen : public QWidget{
+ Q_OBJECT
+public:
+ LLockScreen(QWidget *parent = 0);
+ ~LLockScreen();
+
+ void LoadSystemDetails(); //Run right after the screen is initially locked
+
+public slots:
+ void aboutToHide(); //auto-hide timeout (can happen multiple times per lock)
+ void aboutToShow(); //about to be re-shown (can happen multiple times per lock)
+
+private:
+ Ui::LLockScreen *ui;
+ int triesleft, attempts;
+ QTimer *waittime;
+
+ bool PAM_checkpass(QString user, QString pass, QString &info);
+ QString PAM_checkLockInfo(QString user); //info string with any password reset countdown info
+ QString PAM_getError(int ret);
+ bool PAM_lockSession(QString user);
+
+private slots:
+ void TryUnlock();
+
+signals:
+ void ScreenUnlocked();
+ void InputDetected();
+};
+#endif
diff --git a/lumina-wm-INCOMPLETE/LLockScreen.ui b/lumina-wm-INCOMPLETE/LLockScreen.ui
new file mode 100644
index 00000000..0e5cca5e
--- /dev/null
+++ b/lumina-wm-INCOMPLETE/LLockScreen.ui
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LLockScreen</class>
+ <widget class="QWidget" name="LLockScreen">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>236</width>
+ <height>151</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="frame_unlock">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_hostname">
+ <property name="font">
+ <font>
+ <weight>50</weight>
+ <italic>true</italic>
+ <bold>false</bold>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true">hostname</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_username">
+ <property name="text">
+ <string notr="true">Locked by username</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_info">
+ <property name="font">
+ <font>
+ <italic>true</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLineEdit" name="line_password">
+ <property name="inputMask">
+ <string notr="true"/>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="placeholderText">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="tool_unlock">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Unlock Session</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/lumina-wm-INCOMPLETE/LSScreen.ui b/lumina-wm-INCOMPLETE/LSScreen.ui
deleted file mode 100644
index 6a4f0e44..00000000
--- a/lumina-wm-INCOMPLETE/LSScreen.ui
+++ /dev/null
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Form</class>
- <widget class="QWidget" name="Form">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>442</width>
- <height>366</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QFrame" name="frame_screen">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2">
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1">
- <widget class="QFrame" name="frame_unlock">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label_hostname">
- <property name="font">
- <font>
- <italic>true</italic>
- </font>
- </property>
- <property name="text">
- <string notr="true">hostname</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label_username">
- <property name="text">
- <string notr="true">Locked by username</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_password">
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="lineEdit"/>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QProgressBar" name="progress_hide">
- <property name="value">
- <number>24</number>
- </property>
- <property name="format">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QQuickWidget" name="quick_screen">
- <property name="resizeMode">
- <enum>QQuickWidget::SizeRootObjectToView</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>QQuickWidget</class>
- <extends>QWidget</extends>
- <header>QQuickWidget</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/lumina-wm-INCOMPLETE/LScreenSaver.cpp b/lumina-wm-INCOMPLETE/LScreenSaver.cpp
index 62221abb..a1c10f79 100644
--- a/lumina-wm-INCOMPLETE/LScreenSaver.cpp
+++ b/lumina-wm-INCOMPLETE/LScreenSaver.cpp
@@ -18,11 +18,17 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo
hidetimer = new QTimer(this);
hidetimer->setSingleShot(true);
+ LOCKER = new LLockScreen(this);
+ LOCKER->hide();
settings = new QSettings("LuminaDE","lumina-screensaver",this);
SSRunning = SSLocked = false;
this->setObjectName("LSCREENSAVERBASE");
this->setStyleSheet("LScreenSaver#LSCREENSAVERBASE{ background: black; }");
connect(starttimer, SIGNAL(timeout()), this, SLOT(ShowScreenSaver()) );
+ connect(locktimer, SIGNAL(timeout()), this, SLOT(LockScreen()) );
+ connect(hidetimer, SIGNAL(timeout()), this, SLOT(HideLockScreen()) );
+ connect(LOCKER, SIGNAL(ScreenUnlocked()), this, SLOT(SSFinished()) );
+ connect(LOCKER, SIGNAL(InputDetected()), this, SLOT(newInputEvent()) );
}
LScreenSaver::~LScreenSaver(){
@@ -33,12 +39,23 @@ bool LScreenSaver::isLocked(){
return SSLocked;
}
+void LScreenSaver::UpdateTimers(){
+ //This is generally used for programmatic changes
+ if(starttimer->isActive()){ starttimer->stop();}
+ if(locktimer->isActive()){ locktimer->stop(); }
+ if(hidetimer->isActive()){ hidetimer->stop(); }
+
+ if(!SSRunning && !SSLocked && (starttimer->interval() > 1000) ){ starttimer->start(); } //time to SS start
+ else if( SSRunning && !SSLocked && (locktimer->interval() > 1000 ) ){ locktimer->start(); } //time to lock
+ else if( !SSRunning && SSLocked ){ hidetimer->start(); } //time to hide lock screen
+}
+
// ===========
// PUBLIC SLOTS
// ===========
void LScreenSaver::start(){
reloadSettings(); //setup all the initial time frames
- starttimer->start(1000);// one second delay (for testing)
+ starttimer->start();
}
void LScreenSaver::reloadSettings(){
@@ -48,62 +65,47 @@ void LScreenSaver::reloadSettings(){
hidetimer->setInterval( settings->value("hidesecs",15).toInt() * 1000 );
}
-void LScreenSaver::newInputEvent(){
- //First stop any timers that are running
- if(starttimer->isActive()){ starttimer->stop();}
- if(locktimer->isActive()){ locktimer->stop(); }
- if(hidetimer->isActive()){ hidetimer->stop(); }
-
+void LScreenSaver::newInputEvent(){
if(SSRunning && SSLocked){
//Running and locked
// Hide the running setting, and display the lock screen
HideScreenSaver();
ShowLockScreen();
- //Start the timer for restarting the SS and hiding the lockscreen
- hidetimer->start();
-
}else if(SSRunning){
//Only running, not locked
- //De-activate the screensaver and start the main timer
HideScreenSaver();
- starttimer->start();
-
- }else if(SSLocked){
- //Only locked, not running
- hidetimer->start(); //restart the time to hide the lock screen
-
- }else{
- //Neither running nor locked
- if( settings->value("timedelaymin",10).toInt() > 0 ){ starttimer->start(); }
}
+ UpdateTimers();
}
+void LScreenSaver::LockScreenNow(){
+ ShowScreenSaver();
+ LockScreen();
+}
+
// ===========
// PRIVATE SLOTS
// ===========
void LScreenSaver::ShowScreenSaver(){
if(DEBUG){ qDebug() << "Showing Screen Saver:" << QDateTime::currentDateTime().toString(); }
SSRunning = true;
- //Start the lock timer if necessary
- if(!SSLocked && (settings->value("lockdelaymin",10).toInt()>0) ){ locktimer->start(); }
+ //Now remove any current Base widgets (prevent any lingering painting between sessions)
+ for(int i=0; i<BASES.length(); i++){
+ if(DEBUG){ qDebug() << " - Removing SS Base"; }
+ delete BASES.takeAt(i); i--;
+ }
//Now go through and create/show all the various widgets
QList<QScreen*> SCREENS = QApplication::screens();
QRect bounds;
for(int i=0; i<SCREENS.length(); i++){
bounds = bounds.united(SCREENS[i]->geometry());
- if( (BASES.length()-1) < i){
- //Nothing for this screen yet - go ahead and create one
- BASES << new SSBaseWidget(this, settings);
- }
+ if(DEBUG){ qDebug() << " - New SS Base:" << i; }
+ BASES << new SSBaseWidget(this, settings);
+ connect(BASES[i], SIGNAL(InputDetected()), this, SLOT(newInputEvent()) );
//Setup the geometry of the base to match the screen
BASES[i]->setGeometry(SCREENS[i]->geometry()); //match this screen geometry
BASES[i]->setPlugin(settings->value("screenplugin"+QString::number(i+1), settings->value("defaultscreenplugin","random").toString() ).toString() );
-
- }
- //Now remove any extra Base widgets (in case a screen was removed)
- for(int i=SCREENS.length(); i<BASES.length(); i++){
- delete BASES.takeAt(i); i--;
}
//Now set the overall parent widget geometry and show everything
this->setGeometry(bounds); //overall background widget
@@ -112,15 +114,21 @@ void LScreenSaver::ShowScreenSaver(){
this->activateWindow();
for(int i=0; i<BASES.length(); i++){
BASES[i]->show();
- QTimer::singleShot(100, BASES[i], SLOT(startPainting()) ); //start in 1/2 second
+ BASES[i]->startPainting();
}
+ UpdateTimers();
}
void LScreenSaver::ShowLockScreen(){
- if(DEBUG){ qDebug() << "Locking Screen Saver:" << QDateTime::currentDateTime().toString(); }
- //SSLocked = true;
+ if(DEBUG){ qDebug() << "Showing Lock Screen:" << QDateTime::currentDateTime().toString(); }
+ LOCKER->aboutToShow();
+ //Move the screen locker to the appropriate spot
+ QPoint ctr = QApplication::desktop()->screenGeometry(QCursor::pos()).center();
+ LOCKER->resize(LOCKER->sizeHint());
+ LOCKER->move(ctr - QPoint(LOCKER->width()/2, LOCKER->height()/2) );
+ LOCKER->show();
//Start the timer for hiding the lock screen due to inactivity
- if(settings->value("hidesecs",15).toInt() > 0 ){ hidetimer->start(); }
+ UpdateTimers();
}
void LScreenSaver::HideScreenSaver(){
@@ -130,10 +138,34 @@ void LScreenSaver::HideScreenSaver(){
this->hide();
emit ClosingScreenSaver();
}
- for(int i=0; i<BASES.length(); i++){ QTimer::singleShot(0,BASES[i], SLOT(stopPainting())); }
+ for(int i=0; i<BASES.length(); i++){
+ BASES[i]->hide();
+ BASES[i]->stopPainting();
+ }
+ UpdateTimers();
}
void LScreenSaver::HideLockScreen(){
if(DEBUG){ qDebug() << "Hiding Lock Screen:" << QDateTime::currentDateTime().toString(); }
//Leave the Locked flag set (still locked, just not visible)
+ LOCKER->aboutToHide();
+ LOCKER->hide();
+ this->repaint();
+ if(SSLocked){ ShowScreenSaver(); }
+ UpdateTimers();
}
+
+void LScreenSaver::LockScreen(){
+ if(SSLocked){ return; }
+ if(DEBUG){ qDebug() << "Locking Screen:" << QDateTime::currentDateTime().toString(); }
+ SSLocked = true;
+ LOCKER->LoadSystemDetails();
+ UpdateTimers();
+}
+
+void LScreenSaver::SSFinished(){
+ if(DEBUG){ qDebug() << "Screensaver Finished:" << QDateTime::currentDateTime().toString(); }
+ SSLocked = false;
+ HideLockScreen();
+ HideScreenSaver();
+} \ No newline at end of file
diff --git a/lumina-wm-INCOMPLETE/LScreenSaver.h b/lumina-wm-INCOMPLETE/LScreenSaver.h
index a0595a7c..82950156 100644
--- a/lumina-wm-INCOMPLETE/LScreenSaver.h
+++ b/lumina-wm-INCOMPLETE/LScreenSaver.h
@@ -7,12 +7,10 @@
#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_H
#define _LUMINA_DESKTOP_SCREEN_SAVER_H
-#include <QWidget>
-#include <QStringList>
-#include <QTimer>
-#include <QSettings>
+#include "GlobalDefines.h"
#include "SSBaseWidget.h"
+#include "LLockScreen.h"
class LScreenSaver : public QWidget{
Q_OBJECT
@@ -21,18 +19,22 @@ public:
~LScreenSaver();
bool isLocked();
-
+
private:
QTimer *starttimer, *locktimer, *hidetimer;
QSettings *settings;
QList<SSBaseWidget*> BASES;
-
+ LLockScreen *LOCKER;
+
bool SSRunning, SSLocked;
+ void UpdateTimers();
+
public slots:
void start();
void reloadSettings();
void newInputEvent();
+ void LockScreenNow();
private slots:
void ShowScreenSaver();
@@ -40,6 +42,9 @@ private slots:
void HideScreenSaver();
void HideLockScreen();
+ void LockScreen();
+ void SSFinished();
+
signals:
void StartingScreenSaver();
void ClosingScreenSaver();
diff --git a/lumina-wm-INCOMPLETE/SSBaseWidget.cpp b/lumina-wm-INCOMPLETE/SSBaseWidget.cpp
index 4beb905f..599d71fb 100644
--- a/lumina-wm-INCOMPLETE/SSBaseWidget.cpp
+++ b/lumina-wm-INCOMPLETE/SSBaseWidget.cpp
@@ -17,10 +17,11 @@ SSBaseWidget::SSBaseWidget(QWidget *parent, QSettings *set) : QWidget(parent){
if(validPlugs.isEmpty()){ validPlugs << "none"; } //add more later
settings = set; //needed to pass along for plugins to read any special options/settings
ANIM = 0;
+ this->setMouseTracking(true);
}
SSBaseWidget::~SSBaseWidget(){
-
+ if(ANIM!=0){ this->stopPainting(); }
}
void SSBaseWidget::setPlugin(QString plug){
@@ -34,7 +35,11 @@ void SSBaseWidget::setPlugin(QString plug){
// =============
void SSBaseWidget::startPainting(){
cplug = plugType;
- if(ANIM!=0){ ANIM->clear(); }
+ //free up any old animation instance
+ if(ANIM!=0){
+ ANIM->stop(); ANIM->clear();
+ delete ANIM; ANIM = 0;
+ }
//If a random plugin - grab one of the known plugins
if(cplug=="random"){
QStringList valid = BaseAnimGroup::KnownAnimations();
@@ -45,11 +50,13 @@ void SSBaseWidget::startPainting(){
//Now list all the various plugins and start them appropriately
QString style;
if(cplug=="none"){
- style = "background: transparent"; //show the underlying black parent widget
+ style = "background: transparent;"; //show the underlying black parent widget
+ }else{
+ style = "background: black;";
}
this->setStyleSheet(style);
+ this->repaint();
//If not a stylesheet-based plugin - set it here
- if(ANIM!=0){ free(ANIM); ANIM = 0; } //free up the old instance
if(cplug!="none"){
ANIM = BaseAnimGroup::NewAnimation(cplug, this, settings);
connect(ANIM, SIGNAL(finished()), this, SLOT(startPainting()) ); //repeat the plugin as needed
@@ -69,5 +76,7 @@ void SSBaseWidget::stopPainting(){
if(ANIM!=0){
ANIM->stop();
ANIM->clear();
+ delete ANIM;
+ ANIM = 0;
}
}
diff --git a/lumina-wm-INCOMPLETE/SSBaseWidget.h b/lumina-wm-INCOMPLETE/SSBaseWidget.h
index 9858b52f..1649cdd5 100644
--- a/lumina-wm-INCOMPLETE/SSBaseWidget.h
+++ b/lumina-wm-INCOMPLETE/SSBaseWidget.h
@@ -32,6 +32,17 @@ private:
private slots:
signals:
+ void InputDetected(); //just in case no event handling setup at the WM level
+
+protected:
+ void mouseMoveEvent(QMouseEvent *ev){
+ ev->accept();
+ emit InputDetected();
+ }
+ void keyPressEvent(QKeyEvent *ev){
+ ev->accept();
+ emit InputDetected();
+ }
};
diff --git a/lumina-wm-INCOMPLETE/WMSession.cpp b/lumina-wm-INCOMPLETE/WMSession.cpp
index 23dd963a..bed31ed9 100644
--- a/lumina-wm-INCOMPLETE/WMSession.cpp
+++ b/lumina-wm-INCOMPLETE/WMSession.cpp
@@ -41,6 +41,10 @@ void WMSession::reloadIcons(){
}
-void WMSession::newInputsAvailable(QStringList){
-
+void WMSession::newInputsAvailable(QStringList inputs){
+ for(int i=0; i<inputs.length(); i++){
+ if(inputs[i]=="--lock-now" || inputs[i]=="--test-ss"){
+ QTimer::singleShot(0,SS, SLOT(LockScreenNow()) );
+ }
+ }
}
diff --git a/lumina-wm-INCOMPLETE/animations/SampleAnimation.h b/lumina-wm-INCOMPLETE/animations/SampleAnimation.h
index 7b027ce7..e0f11ba5 100644
--- a/lumina-wm-INCOMPLETE/animations/SampleAnimation.h
+++ b/lumina-wm-INCOMPLETE/animations/SampleAnimation.h
@@ -19,10 +19,10 @@ private:
public:
SampleAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
- ~SampleAnimation(){}
+ ~SampleAnimation(){ this->stop(); delete ball; }
void LoadAnimations(){
- qDebug() << "Loading Sample Animation";
+ //qDebug() << "Loading Sample Animation";
ball = new QWidget(canvas);
//This creates a red "ball" on the widget which is going to expand/contract in the center of the screen
ball->setStyleSheet("background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.341, fy:0.796, stop:0.00531915 rgba(107, 10, 10, 255), stop:0.521277 rgba(170, 10, 10, 255), stop:0.957447 rgba(200, 0, 0, 255), stop:0.994681 rgba(0, 0, 0, 225), stop:1 rgba(255, 255, 255, 0));");
diff --git a/lumina-wm-INCOMPLETE/lumina-wm.pro b/lumina-wm-INCOMPLETE/lumina-wm.pro
index 3fd5026e..593c64fd 100644
--- a/lumina-wm-INCOMPLETE/lumina-wm.pro
+++ b/lumina-wm-INCOMPLETE/lumina-wm.pro
@@ -1,6 +1,6 @@
QT += core gui network
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras
TARGET = lumina-wm
isEmpty(PREFIX) {
@@ -12,7 +12,7 @@ isEmpty(LIBPREFIX) {
LIBPREFIX = $$PREFIX/lib
}
-LIBS += -L../libLumina -L$$LIBPREFIX -lLuminaUtils -lxcb -lxcb-damage -lxcb-composite -lxcb-screensaver -lxcb-util
+LIBS += -L../libLumina -L$$LIBPREFIX -lLuminaUtils -lxcb -lxcb-damage -lxcb-composite -lxcb-screensaver -lxcb-util -lpam
QMAKE_LIBDIR = ../libLumina
DEPENDPATH += ../libLumina
@@ -29,6 +29,7 @@ SOURCES += main.cpp \
WMSession.cpp \
LScreenSaver.cpp \
SSBaseWidget.cpp \
+ LLockScreen.cpp \
LXcbEventFilter.cpp \
LWindow.cpp
@@ -37,10 +38,11 @@ HEADERS += GlobalDefines.h \
WMSession.h \
LScreenSaver.h \
SSBaseWidget.h \
+ LLockScreen.h \
LXcbEventFilter.h \
LWindow.h
-FORMS +=
+FORMS += LLockScreen.ui
#Now add in all the screensaver animation plugins
include(animations/animations.pri)
diff --git a/lumina-wm-INCOMPLETE/main.cpp b/lumina-wm-INCOMPLETE/main.cpp
index 53079a2f..9ac227c8 100644
--- a/lumina-wm-INCOMPLETE/main.cpp
+++ b/lumina-wm-INCOMPLETE/main.cpp
@@ -51,6 +51,7 @@ int main(int argc, char ** argv)
w.start(a.inputlist.contains("--test-ss"));
QObject::connect(&themes, SIGNAL(updateIcons()), &w, SLOT(reloadIcons()) );
QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &w, SLOT(newInputsAvailable(QStringList)) );
+ if(!a.inputlist.isEmpty()){ w.newInputsAvailable(a.inputlist); }
int retCode = a.exec();
return retCode;
bgstack15