diff options
author | Weblate <noreply@weblate.org> | 2017-07-19 19:01:31 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2017-07-19 19:01:31 +0000 |
commit | b687e491eea208afba43b67a072ddf430bfeb1fc (patch) | |
tree | 80c24ebc2a04e3d20e74004ebf9e5411252a697d /src-qt5/core/lumina-desktop-unified | |
parent | Push local changes (diff) | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-b687e491eea208afba43b67a072ddf430bfeb1fc.tar.gz lumina-b687e491eea208afba43b67a072ddf430bfeb1fc.tar.bz2 lumina-b687e491eea208afba43b67a072ddf430bfeb1fc.zip |
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
41 files changed, 570 insertions, 2007 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index e511d7ad..0b9a9b35 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -11,13 +11,14 @@ #include "BootSplash.h" #ifndef DEBUG -#define DEBUG 1 +#define DEBUG 0 #endif //Initialize all the global objects to null pointers -EventFilter* Lumina::EFILTER = 0; +NativeWindowSystem* Lumina::NWS = 0; +NativeEventFilter* Lumina::NEF = 0; LScreenSaver* Lumina::SS = 0; -DesktopSettings* Lumina::SETTINGS = 0; +//DesktopSettings* Lumina::SETTINGS = 0; //Lumina::WM = 0; QThread* Lumina::EVThread = 0; RootWindow* Lumina::ROOTWIN = 0; @@ -26,6 +27,10 @@ LShortcutEvents* Lumina::SHORTCUTS = 0; LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lumina-desktop-unified"){ //Initialize the global objects to null pointers + qRegisterMetaType< Qt::Key >("Qt::Key"); + qRegisterMetaType< NativeWindow::Property >("NativeWindow::Property"); + qRegisterMetaType< QList< NativeWindow::Property > >("QList<NativeWindow::Property>"); + mediaObj = 0; //private object used for playing login/logout chimes if(this->isPrimaryProcess()){ //Setup the global registrations @@ -38,42 +43,37 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu this->setEffectEnabled( Qt::UI_AnimateMenu, true); this->setEffectEnabled( Qt::UI_AnimateCombo, true); this->setEffectEnabled( Qt::UI_AnimateTooltip, true); - //this->setAttribute(Qt::AA_UseDesktopOpenGL); + this->setAttribute(Qt::AA_UseDesktopOpenGL); this->setAttribute(Qt::AA_UseHighDpiPixmaps); //allow pixmaps to be scaled up as well as down //Now initialize the global objects (but do not start them yet) - Lumina::EFILTER = new EventFilter(); //Need the XCB Event filter first - Lumina::SETTINGS = new DesktopSettings(); + Lumina::NEF = new NativeEventFilter(); + Lumina::NWS = new NativeWindowSystem(); + //Lumina::SETTINGS = new DesktopSettings(); Lumina::SS = new LScreenSaver(); - //Lumina::WM = new LWindowManager(); - //Now put the Event Filter into it's own thread to keep things snappy + //Now put the Native Window System into it's own thread to keep things snappy Lumina::EVThread = new QThread(); - Lumina::EFILTER->moveToThread(Lumina::EVThread); + Lumina::NWS->moveToThread(Lumina::EVThread); Lumina::EVThread->start(); Lumina::ROOTWIN = new RootWindow(); Lumina::APPLIST = new XDGDesktopList(0, true); //keep this list up to date Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well - //Setup the basic connections between the shortcuts class and the session itself - connect(Lumina::SHORTCUTS, SIGNAL(StartLogout()), this, SLOT(StartLogout()) ); - connect(Lumina::SHORTCUTS, SIGNAL(StartReboot()), this, SLOT(StartReboot()) ); - connect(Lumina::SHORTCUTS, SIGNAL(StartShutdown()), this, SLOT(StartShutdown()) ); - //Setup the various connections between the global classes - // NOTE: Most of these connections will only become "active" as the global objects get started during the setupSession routine - connect(Lumina::ROOTWIN, SIGNAL(RegisterVirtualRoot(WId)), Lumina::EFILTER, SLOT(RegisterVirtualRoot(WId)) ); - connect(Lumina::EFILTER, SIGNAL(WindowCreated(NativeWindow*)), Lumina::ROOTWIN, SLOT(NewWindow(NativeWindow*)) ); - } //end check for primary process + setupGlobalConnections(); + } //end check for primary process } LSession::~LSession(){ //Clean up the global objects as needed - if(Lumina::EFILTER!=0){ Lumina::EFILTER->deleteLater(); } + if(Lumina::NEF!=0){ Lumina::NEF->deleteLater(); } + if(Lumina::NWS!=0){ Lumina::NWS->deleteLater(); } + //if(Lumina::EFILTER!=0){ Lumina::EFILTER->deleteLater(); } if(Lumina::SS!=0){ Lumina::SS->deleteLater(); } if(Lumina::EVThread!=0){ if(Lumina::EVThread->isRunning()){ Lumina::EVThread->quit(); } Lumina::EVThread->deleteLater(); } - if(Lumina::SETTINGS!=0){ Lumina::SETTINGS->deleteLater(); } + if(DesktopSettings::instance()!=0){ DesktopSettings::instance()->deleteLater(); } if(Lumina::ROOTWIN!=0){ Lumina::ROOTWIN->deleteLater(); } if(Lumina::APPLIST!=0){ Lumina::APPLIST->deleteLater(); } } @@ -92,49 +92,40 @@ void LSession::setupSession(){ //Setup the QSettings default paths splash.showScreen("settings"); if(DEBUG){ qDebug() << " - Init QSettings:" << timer->elapsed();} - Lumina::SETTINGS->start(); - /*sessionsettings = new QSettings("lumina-desktop", "sessionsettings"); - DPlugSettings = new QSettings("lumina-desktop","pluginsettings/desktopsettings"); - //Load the proper translation files - if(sessionsettings->value("ForceInitialLocale",false).toBool()){ - //Some system locale override it in place - change the env first - LUtils::setLocaleEnv( sessionsettings->value("InitLocale/LANG","").toString(), \ - sessionsettings->value("InitLocale/LC_MESSAGES","").toString(), \ - sessionsettings->value("InitLocale/LC_TIME","").toString(), \ - sessionsettings->value("InitLocale/LC_NUMERIC","").toString(), \ - sessionsettings->value("InitLocale/LC_MONETARY","").toString(), \ - sessionsettings->value("InitLocale/LC_COLLATE","").toString(), \ - sessionsettings->value("InitLocale/LC_CTYPE","").toString() ); - }*/ - if(DEBUG){ qDebug() << " - Load Localization Files:" << timer->elapsed();} - currTranslator = LUtils::LoadTranslation(this, "lumina-desktop"); + DesktopSettings::instance(); //don't do anything other than init/start the static object here + if(DEBUG){ qDebug() << " - Load Localization Files:" << timer->elapsed();} + currTranslator = LUtils::LoadTranslation(this, "lumina-desktop"); if(DEBUG){ qDebug() << " - Start Event Filter:" << timer->elapsed(); } - Lumina::EFILTER->start(); + Lumina::NEF->start(); + if( !Lumina::NWS->start() ){ + qWarning() << "Could not start the Lumina desktop. Is another desktop or window manager running?"; + this->exit(1); + return; + } //use the system settings //Setup the user's lumina settings directory as necessary splash.showScreen("user"); - if(DEBUG){ qDebug() << " - Init User Files:" << timer->elapsed();} + if(DEBUG){ qDebug() << " - Init User Files:" << timer->elapsed();} //checkUserFiles(); //adds these files to the watcher as well //Initialize the internal variables //DESKTOPS.clear(); - + //Start the background system tray splash.showScreen("systray"); - //Initialize the global menus qDebug() << " - Initialize system menus"; splash.showScreen("apps"); if(DEBUG){ qDebug() << " - Populate App List:" << timer->elapsed();} Lumina::APPLIST->updateList(); //appmenu = new AppMenu(); - + splash.showScreen("menus"); //if(DEBUG){ qDebug() << " - Init SettingsMenu:" << timer->elapsed();} //settingsmenu = new SettingsMenu(); //if(DEBUG){ qDebug() << " - Init SystemWindow:" << timer->elapsed();} //sysWindow = new SystemWindow(); - + //Initialize the desktops splash.showScreen("desktop"); if(DEBUG){ qDebug() << " - Init Desktops:" << timer->elapsed(); } @@ -144,6 +135,9 @@ void LSession::setupSession(){ Lumina::ROOTWIN->ChangeWallpaper(scrns[i]->name(), RootWindow::Stretch, LOS::LuminaShare()+"desktop-background.jpg"); } Lumina::ROOTWIN->start(); + Lumina::NWS->setRoot_numberOfWorkspaces(QStringList() << "one" << "two"); + Lumina::NWS->setRoot_currentWorkspace(0); + DesktopContextMenu *cmenu = new DesktopContextMenu(Lumina::ROOTWIN); connect(cmenu, SIGNAL(showLeaveDialog()), this, SLOT(StartLogout()) ); cmenu->start(); @@ -180,7 +174,7 @@ void LSession::setupSession(){ QTimer::singleShot(500, this, SLOT(launchStartupApps()) ); splash.hide(); LSession::processEvents(); - splash.close(); + splash.close(); LSession::processEvents(); //DEBUG: Wait a bit then close down the session //QTimer::singleShot(15000, this, SLOT(StartLogout()) ); @@ -197,11 +191,11 @@ void LSession::CleanupSession(){ //Create a temporary flag to prevent crash dialogs from opening during cleanup LUtils::writeFile("/tmp/.luminastopping",QStringList() << "yes", true); //Start the logout chimes (if necessary) - LOS::setAudioVolume( LOS::audioVolume() ); //make sure the audio volume is saved in the backend for the next login - bool playaudio = Lumina::SETTINGS->value(DesktopSettings::Session,"PlayLogoutAudio",true).toBool(); + //LOS::setAudioVolume( LOS::audioVolume() ); //make sure the audio volume is saved in the backend for the next login + bool playaudio = DesktopSettings::instance()->value(DesktopSettings::Session,"PlayLogoutAudio",true).toBool(); if( playaudio ){ playAudioFile(LOS::LuminaShare()+"Logout.ogg"); } //Now perform any other cleanup - Lumina::EFILTER->stop(); + //Lumina::NEF->stop(); //Now wait a moment for things to close down before quitting if(playaudio){ //wait a max of 5 seconds for audio to finish @@ -219,10 +213,68 @@ void LSession::CleanupSession(){ if(QFile::exists("/tmp/.luminastopping")){ QFile::remove("/tmp/.luminastopping"); } } +//================= + +void LSession::setupGlobalConnections(){ + //Setup the various connections between the global classes + // NOTE: Most of these connections will only become "active" as the global objects get started during the setupSession routine + + //Setup the basic connections between the shortcuts class and the session itself + connect(Lumina::SHORTCUTS, SIGNAL(StartLogout()), this, SLOT(StartLogout()) ); + connect(Lumina::SHORTCUTS, SIGNAL(StartReboot()), this, SLOT(StartReboot()) ); + connect(Lumina::SHORTCUTS, SIGNAL(StartShutdown()), this, SLOT(StartShutdown()) ); + connect(Lumina::SHORTCUTS, SIGNAL(LaunchApplication(QString)), this, SLOT(LaunchApplication(QString)) ); + connect(Lumina::SHORTCUTS, SIGNAL(LaunchStandardApplication(QString)), this, SLOT(LaunchStandardApplication(QString)) ); + connect(Lumina::SHORTCUTS, SIGNAL(LockSession()), Lumina::SS, SLOT(LockScreenNow()) ); + + //Root window connections + connect(Lumina::ROOTWIN, SIGNAL(RegisterVirtualRoot(WId)), Lumina::NWS, SLOT(RegisterVirtualRoot(WId)) ); + connect(Lumina::ROOTWIN, SIGNAL(RootResized(QRect)), Lumina::NWS, SLOT(setRoot_desktopGeometry(QRect)) ); + + //Native Window Class connections + connect(Lumina::NEF, SIGNAL(WindowCreated(WId)), Lumina::NWS, SLOT(NewWindowDetected(WId))); + connect(Lumina::NEF, SIGNAL(WindowDestroyed(WId)), Lumina::NWS, SLOT(WindowCloseDetected(WId))); + connect(Lumina::NEF, SIGNAL(WindowPropertyChanged(WId, NativeWindow::Property)), Lumina::NWS, SLOT(WindowPropertyChanged(WId, NativeWindow::Property))); + connect(Lumina::NEF, SIGNAL(WindowPropertyChanged(WId, NativeWindow::Property, QVariant)), Lumina::NWS, SLOT(WindowPropertyChanged(WId, NativeWindow::Property, QVariant))); + connect(Lumina::NEF, SIGNAL(WindowPropertiesChanged(WId, QList<NativeWindow::Property>, QList<QVariant>)), Lumina::NWS, SLOT(WindowPropertiesChanged(WId, QList<NativeWindow::Property>, QList<QVariant>)) ); + connect(Lumina::NEF, SIGNAL(RequestWindowPropertyChange(WId, NativeWindow::Property, QVariant)), Lumina::NWS, SLOT(RequestPropertyChange(WId, NativeWindow::Property, QVariant))); + connect(Lumina::NEF, SIGNAL(RequestWindowPropertiesChange(WId, QList<NativeWindow::Property>, QList<QVariant>)), Lumina::NWS, SLOT(RequestPropertiesChange(WId, QList<NativeWindow::Property>, QList<QVariant>))); + connect(Lumina::NEF, SIGNAL(TrayWindowCreated(WId)), Lumina::NWS, SLOT(NewTrayWindowDetected(WId))); + connect(Lumina::NEF, SIGNAL(TrayWindowDestroyed(WId)), Lumina::NWS, SLOT(WindowCloseDetected(WId))); + connect(Lumina::NEF, SIGNAL(PossibleDamageEvent(WId)), Lumina::NWS, SLOT(CheckDamageID(WId))); + connect(Lumina::NEF, SIGNAL(KeyPressed(int, WId)), Lumina::NWS, SLOT(NewKeyPress(int, WId))); + connect(Lumina::NEF, SIGNAL(KeyReleased(int, WId)), Lumina::NWS, SLOT(NewKeyRelease(int, WId))); + connect(Lumina::NEF, SIGNAL(MousePressed(int, WId)), Lumina::NWS, SLOT(NewMousePress(int, WId))); + connect(Lumina::NEF, SIGNAL(MouseReleased(int, WId)), Lumina::NWS, SLOT(NewMouseRelease(int, WId))); + //connect(Lumina::NEF, SIGNAL(MouseMovement(WId)), Lumina::NWS, SLOT()); + //connect(Lumina::NEF, SIGNAL(MouseEnterWindow(WId)), Lumina::NWS, SLOT()); + //connect(Lumina::NEF, SIGNAL(MouseLeaveWindow(WId)), Lumina::NWS, SLOT()); + + //Input Events for ScreenSaver + connect(Lumina::NEF, SIGNAL(KeyPressed(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(KeyReleased(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(MousePressed(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(MouseReleased(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(MouseMovement()), Lumina::SS, SLOT(newInputEvent())); + + connect(Lumina::SS, SIGNAL(LockStatusChanged(bool)), Lumina::NWS, SLOT(ScreenLockChanged(bool)) ); + + //Mouse/Keyboard Shortcut Events (Make sure to connect to the NWS - the raw events need to be ignored sometimes) + connect(Lumina::NWS, SIGNAL(KeyPressDetected(WId, Qt::Key)), Lumina::SHORTCUTS, SLOT(KeyPress(WId, Qt::Key)) ); + connect(Lumina::NWS, SIGNAL(KeyReleaseDetected(WId, Qt::Key)), Lumina::SHORTCUTS, SLOT(KeyRelease(WId, Qt::Key)) ); + connect(Lumina::NWS, SIGNAL(MousePressDetected(WId, NativeWindowSystem::MouseButton)), Lumina::SHORTCUTS, SLOT(MousePress(WId, NativeWindowSystem::MouseButton)) ); + connect(Lumina::NWS, SIGNAL(MouseReleaseDetected(WId, NativeWindowSystem::MouseButton)), Lumina::SHORTCUTS, SLOT(MouseRelease(WId, NativeWindowSystem::MouseButton)) ); + + //NWS Events to the window system + connect(Lumina::NWS, SIGNAL(NewWindowAvailable(NativeWindow*)), Lumina::ROOTWIN, SLOT(NewWindow(NativeWindow*)) ); +} + +//================= + int LSession::VersionStringToNumber(QString version){ version = version.section("-",0,0); //trim any extra labels off the end int maj, mid, min; //major/middle/minor version numbers (<Major>.<Middle>.<Minor>) - maj = mid = min = 0; + maj = mid = min = 0; bool ok = true; maj = version.section(".",0,0).toInt(&ok); if(ok){ mid = version.section(".",1,1).toInt(&ok); }else{ maj = 0; } @@ -233,6 +285,8 @@ int LSession::VersionStringToNumber(QString version){ return (maj*1000000 + mid*1000 + min); } +//================= + //Play System Audio void LSession::playAudioFile(QString filepath){ if( !QFile::exists(filepath) ){ return; } @@ -257,10 +311,10 @@ void LSession::NewCommunication(QStringList list){ for(int i=0; i<list.length(); i++){ if(list[i]=="--logout"){ QTimer::singleShot(0, this, SLOT(StartLogout()) ); - }else if(list[i]=="--lock-session"){ + }else if(list[i]=="--lock-session"){ Lumina::SS->LockScreenNow(); } - } + } } void LSession::launchStartupApps(){ @@ -269,44 +323,44 @@ void LSession::launchStartupApps(){ //Enable Numlock if(LUtils::isValidBinary("numlockx")){ //make sure numlockx is installed - if(Lumina::SETTINGS->value(DesktopSettings::System,"EnableNumlock",false).toBool()){ + if(DesktopSettings::instance()->value(DesktopSettings::System,"EnableNumlock",false).toBool()){ QProcess::startDetached("numlockx on"); }else{ QProcess::startDetached("numlockx off"); } } - int tmp = LOS::ScreenBrightness(); - if(tmp>0){ + /*int tmp = LOS::ScreenBrightness(); + if(tmp>0){ LOS::setScreenBrightness( tmp ); qDebug() << " - - Screen Brightness:" << QString::number(tmp)+"%"; } //ExternalProcess::launch("nice lumina-open -autostart-apps"); - + //Re-load the screen brightness and volume settings from the previous session // Wait until after the XDG-autostart functions, since the audio system might be started that way qDebug() << " - Loading previous settings"; tmp = LOS::audioVolume(); LOS::setAudioVolume(tmp); qDebug() << " - - Audio Volume:" << QString::number(tmp)+"%"; - + */ //Now play the login music since we are finished - if(Lumina::SETTINGS->value(DesktopSettings::System,"PlayStartupAudio",true).toBool()){ + if(DesktopSettings::instance()->value(DesktopSettings::System,"PlayStartupAudio",true).toBool()){ //Make sure to re-set the system volume to the last-used value at outset - int vol = LOS::audioVolume(); - if(vol>=0){ LOS::setAudioVolume(vol); } + /*int vol = LOS::audioVolume(); + if(vol>=0){ LOS::setAudioVolume(vol); }*/ LSession::playAudioFile(LOS::LuminaShare()+"Login.ogg"); } qDebug() << " - Finished with startup routines"; } void LSession::checkUserFiles(){ - //internal version conversion examples: + //internal version conversion examples: // [1.0.0 -> 1000000], [1.2.3 -> 1002003], [0.6.1 -> 6001] - QString OVS = Lumina::SETTINGS->value(DesktopSettings::System,"DesktopVersion","0").toString(); //Old Version String + QString OVS = DesktopSettings::instance()->value(DesktopSettings::System,"DesktopVersion","0").toString(); //Old Version String bool changed = LDesktopUtils::checkUserFiles(OVS); if(changed){ //Save the current version of the session to the settings file (for next time) - Lumina::SETTINGS->setValue(DesktopSettings::System,"DesktopVersion", this->applicationVersion()); + DesktopSettings::instance()->setValue(DesktopSettings::System,"DesktopVersion", this->applicationVersion()); } } @@ -322,26 +376,34 @@ void LSession::StartLogout(){ void LSession::StartShutdown(bool skipupdates){ CleanupSession(); LOS::systemShutdown(skipupdates); - QCoreApplication::exit(0); + QCoreApplication::exit(0); } void LSession::StartReboot(bool skipupdates){ CleanupSession(); LOS::systemRestart(skipupdates); - QCoreApplication::exit(0); + QCoreApplication::exit(0); +} + +void LSession::LaunchApplication(QString app){ + +} + +void LSession::LaunchStandardApplication(QString app){ + } void LSession::reloadIconTheme(){ //Wait a moment for things to settle before sending out the signal to the interfaces QApplication::processEvents(); QApplication::processEvents(); - emit IconThemeChanged(); + emit IconThemeChanged(); } //Temporarily change the session locale (nothing saved between sessions) void LSession::switchLocale(QString localeCode){ - currTranslator = LUtils::LoadTranslation(this, "lumina-desktop", localeCode, currTranslator); - if(currTranslator!=0 || localeCode=="en_US"){ + currTranslator = LUtils::LoadTranslation(this, "lumina-desktop", localeCode, currTranslator); + if(currTranslator!=0 || localeCode=="en_US"){ LUtils::setLocaleEnv(localeCode); //will set everything to this locale (no custom settings) } emit LocaleChanged(); diff --git a/src-qt5/core/lumina-desktop-unified/LSession.h b/src-qt5/core/lumina-desktop-unified/LSession.h index c791c66b..0d666bfa 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.h +++ b/src-qt5/core/lumina-desktop-unified/LSession.h @@ -17,7 +17,8 @@ public: private: void CleanupSession(); - + void setupGlobalConnections(); + int VersionStringToNumber(QString version); QMediaPlayer *mediaObj; void playAudioFile(QString filepath); @@ -27,9 +28,12 @@ private: public slots: void setupSession(); //called during startup only + //Slots for public access/usage void StartLogout(); void StartShutdown(bool skipupdates = false); void StartReboot(bool skipupdates = false); + void LaunchApplication(QString app); + void LaunchStandardApplication(QString app); void reloadIconTheme(); //will emit the IconThemeChanged signal when ready void switchLocale(QString localeCode); //will emit the LocaleChanged signal when ready @@ -45,7 +49,7 @@ signals: //General Signals void LocaleChanged(); void IconThemeChanged(); - + }; #endif diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/desktop.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/desktop.conf new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/desktop.conf diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/environment.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/environment.conf new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/environment.conf diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/favorites.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/favorites.conf new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/favorites.conf diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf new file mode 100644 index 00000000..c1417b85 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf @@ -0,0 +1,8 @@ +[strict] +Ctrl+Alt+Backspace=Logout +Pause=Lockscreen +Alt+L=Lockscreen + +[desktop] +Alt+F1=Launch: terminal +Print=Launch: screenshot diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/session.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/session.conf new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/session.conf diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/theme.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/theme.conf new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/theme.conf diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h index 867076db..1d0ab068 100644 --- a/src-qt5/core/lumina-desktop-unified/global-includes.h +++ b/src-qt5/core/lumina-desktop-unified/global-includes.h @@ -33,6 +33,7 @@ #include <QPropertyAnimation> #include <QAnimationGroup> #include <QParallelAnimationGroup> +#include <QSequentialAnimationGroup> #include <QWindow> #include <QWidget> #include <QWidgetAction> @@ -59,15 +60,13 @@ #include <RootWindow.h> #include <ExternalProcess.h> #include <NativeWindow.h> +#include <NativeWindowSystem.h> +#include <NativeEventFilter.h> // Standard C includes #include <unistd.h> //Setup any global defines (no classes or global objects: use "global-objects.h" for that) -namespace Lumina{ - //Flags/enumerations - enum WindowAction{MoveResize, Show, Hide, TryClose, Closed, WA_NONE}; - enum MouseButton{NoButton, LeftButton, RightButton, MidButton, BackButton, ForwardButton, TaskButton, WheelUp, WheelDown, WheelLeft, WheelRight}; -}; + #endif diff --git a/src-qt5/core/lumina-desktop-unified/global-objects.h b/src-qt5/core/lumina-desktop-unified/global-objects.h index 2f298e27..474412eb 100644 --- a/src-qt5/core/lumina-desktop-unified/global-objects.h +++ b/src-qt5/core/lumina-desktop-unified/global-objects.h @@ -19,7 +19,7 @@ //Load the appropriate "EventFilter" class for the graphics subsystem //#ifndef USE_WAYLAND -#include "src-events/LXcbEventFilter.h" +//#include "src-events/LXcbEventFilter.h" //#endif #include "src-events/LShortcutEvents.h" @@ -30,11 +30,15 @@ #define ANIMTIME 80 //animation time in milliseconds //Global flags/structures -namespace Lumina{ +namespace Lumina{ //Data structures and objects - extern EventFilter *EFILTER; //Native Event Watcher + // -- Native Window System Objects + extern NativeWindowSystem *NWS; + extern NativeEventFilter *NEF; + + //extern EventFilter *EFILTER; //Native Event Watcher extern LShortcutEvents *SHORTCUTS; //Keyboard/mouse shortcut events - extern DesktopSettings *SETTINGS; //All Settings files + //extern DesktopSettings *SETTINGS; //All Settings files //ScreenSaver extern LScreenSaver *SS; //Root Window @@ -43,7 +47,7 @@ namespace Lumina{ //LWindowManager *WM; //Application List extern XDGDesktopList *APPLIST; - + extern QThread *EVThread; //X Event thread }; diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro index 1de8308d..defa66f4 100644 --- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro +++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro @@ -12,12 +12,13 @@ target.path = $${L_BINDIR} include(../libLumina/ResizeMenu.pri) include(../libLumina/LDesktopUtils.pri) #includes LUtils and LOS include(../libLumina/LuminaXDG.pri) -include(../libLumina/LuminaX11.pri) +#include(../libLumina/LuminaX11.pri) include(../libLumina/LuminaSingleApplication.pri) include(../libLumina/LuminaThemes.pri) include(../libLumina/DesktopSettings.pri) include(../libLumina/RootWindow.pri) include(../libLumina/ExternalProcess.pri) +include(../libLumina/NativeWindow.pri) #include all the main individual source groups include(src-screensaver/screensaver.pri) @@ -43,10 +44,12 @@ FORMS += BootSplash.ui #include(panel-plugins/panel-plugins.pri) #include(desktop-plugins/desktop-plugins.pri) - +# Install all the various files for the desktop itself desktop.path = $${L_SESSDIR} desktop.files = lumina-desktop.desktop +defaults.path = $${L_SHAREDIR}/lumina-desktop +defaults.files = defaults/* TRANSLATIONS = i18n/lumina-desktop_af.ts \ i18n/lumina-desktop_ar.ts \ @@ -114,7 +117,7 @@ TRANSLATIONS = i18n/lumina-desktop_af.ts \ dotrans.path=$${L_SHAREDIR}/lumina-desktop/i18n/ dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$${L_SHAREDIR}/lumina-desktop/i18n/ -INSTALLS += target desktop +INSTALLS += target desktop defaults WITH_I18N{ INSTALLS += dotrans diff --git a/src-qt5/core/lumina-desktop-unified/main.cpp b/src-qt5/core/lumina-desktop-unified/main.cpp index 6141f1ea..0b67de46 100644 --- a/src-qt5/core/lumina-desktop-unified/main.cpp +++ b/src-qt5/core/lumina-desktop-unified/main.cpp @@ -8,10 +8,11 @@ #include "global-includes.h" #include "LSession.h" -#define DEBUG 0 +#define DEBUG 1 int main(int argc, char ** argv) { + qDebug() << "Starting lumina-desktop-unified..."; if (argc > 1) { if (QString(argv[1]) == QString("--version")){ qDebug() << LDesktopUtils::LuminaDesktopVersion(); @@ -27,8 +28,10 @@ int main(int argc, char ** argv) LXDG::setEnvironmentVars(); setenv("DESKTOP_SESSION","Lumina",1); setenv("XDG_CURRENT_DESKTOP","Lumina",1); + setenv("QT_NO_GLIB", "1", 1); //Disable the glib event loop within Qt at runtime (performance hit + bugs) unsetenv("QT_QPA_PLATFORMTHEME"); //causes issues with Lumina themes - not many people have this by default... //Startup the session + if(DEBUG){ qDebug() << "Starting unified session"; } LSession a(argc, argv); if(!a.isPrimaryProcess()){ return 0; } QTime *timer=0; @@ -41,6 +44,6 @@ int main(int argc, char ** argv) theme.refresh(); if(DEBUG){ qDebug() << "Exec Time:" << timer->elapsed(); delete timer;} int retCode = a.exec(); - qDebug() << "Finished Closing Down Lumina"; + qDebug() << "Finished Closing Down Unified Lumina"; return retCode; } diff --git a/src-qt5/core/lumina-desktop-unified/src-DE/panel-plugins/systemdashboard/LSysDashboard.cpp b/src-qt5/core/lumina-desktop-unified/src-DE/panel-plugins/systemdashboard/LSysDashboard.cpp index 267a7cb0..b9d70e97 100644 --- a/src-qt5/core/lumina-desktop-unified/src-DE/panel-plugins/systemdashboard/LSysDashboard.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-DE/panel-plugins/systemdashboard/LSysDashboard.cpp @@ -77,7 +77,7 @@ void LSysDashboard::updateIcon(bool force){ } void LSysDashboard::resetIcon(){ - button->setIcon( LXDG::findIcon("dashboard-show","")); + button->setIcon( LXDG::findIcon("arrow-down-drop-circle","")); } void LSysDashboard::openMenu(){ diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/DEPENDENCIES b/src-qt5/core/lumina-desktop-unified/src-WM/DEPENDENCIES deleted file mode 100644 index fa0ce486..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/DEPENDENCIES +++ /dev/null @@ -1,17 +0,0 @@ -Most dependencies required to build Lumina are listed in the -DEPENDENCIES file in the directory above this one. The following -are dependencies specific to Lumina's window manager. - - -FreeBSD/TrueOS -======================= - - - - -Linux (Debian/Ubuntu) -======================= - -libxcb-screensaver0-dev - - diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/GlobalDefines.h b/src-qt5/core/lumina-desktop-unified/src-WM/GlobalDefines.h deleted file mode 100644 index 3ec278ac..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/GlobalDefines.h +++ /dev/null @@ -1,74 +0,0 @@ -//=========================================== -// Lumina-DE source code -// Copyright (c) 2015, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -// Global defines and enumerations for the window manager -//=========================================== -#ifndef _LUMINA_WINDOW_MANAGER_GLOBAL_DEFINES_H -#define _LUMINA_WINDOW_MANAGER_GLOBAL_DEFINES_H - -//Qt includes -#include <QObject> -#include <QFrame> -#include <QLabel> -#include <QToolButton> -#include <QMenu> -#include <QHBoxLayout> -#include <QMouseEvent> -#include <QAction> -#include <QPoint> -#include <QFile> -#include <QDir> -#include <QString> -#include <QTextStream> -#include <QUrl> -#include <QDebug> -#include <QStringList> -#include <QAbstractNativeEventFilter> -#include <QList> -#include <QX11Info> -#include <QCoreApplication> -#include <QPropertyAnimation> -#include <QAnimationGroup> -#include <QParallelAnimationGroup> -#include <QWindow> -#include <QWidget> -#include <QBackingStore> -#include <QPaintEvent> -#include <QPainter> -#include <QSettings> -#include <QHostInfo> -#include <QDesktopWidget> -#include <QStyleOption> -#include <QThread> - -// libLumina includes -#include <LuminaX11.h> -#include <LuminaXDG.h> -#include <LuminaOS.h> -#include <LuminaThemes.h> -#include <LuminaUtils.h> -#include <LuminaSingleApplication.h> - -//XCB Includes -#include <xcb/xcb.h> -#include <xcb/xproto.h> -#include <xcb/damage.h> -#include <xcb/xcb_atom.h> -#include <xcb/xcb_aux.h> //included in libxcb-util.so - -#define ANIMTIME 80 //animation time in milliseconds -//Global flags/structures -namespace LWM{ - //Flags/enumerations - enum WindowAction{MoveResize, Show, Hide, TryClose, Closed, WA_NONE}; - - //Data structures - extern LXCB *SYSTEM; -}; - - - -#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/LWindow.cpp b/src-qt5/core/lumina-desktop-unified/src-WM/LWindow.cpp deleted file mode 100644 index 84ff2ffd..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/LWindow.cpp +++ /dev/null @@ -1,474 +0,0 @@ -//=========================================== -// Lumina-DE source code -// Copyright (c) 2015, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -#include "LWindow.h" - -LWindowFrame::LWindowFrame(WId client, QWidget *parent) : QFrame(parent, Qt::X11BypassWindowManagerHint){ - activeState = LWindowFrame::Normal; - CID = client; - lastAction = LWM::WA_NONE; - Closing = false; - //qDebug() << "New Window:" << CID << "Frame:" << this->winId(); - this->setMouseTracking(true); //need this to determine mouse location when not clicked - this->setObjectName("LWindowFrame"); - this->setStyleSheet("LWindowFrame#LWindowFrame{ border: 2px solid white; border-radius:3px; } QWidget#TitleBar{background: grey; } QLabel{ color: black; }"); - InitWindow(); //initially create all the child widgets - //LWM::SYSTEM->setupEventsForFrame(this->winId()); - updateAppearance(); //this loads the appearance based on window/theme settings - //QApplication::processEvents(); - //Now set the frame size on this window - SyncSize(); - SyncText(); - this->show(); -} - -LWindowFrame::~LWindowFrame(){ -} - -// ================= -// PRIVATE -// ================= -void LWindowFrame::InitWindow(){ - anim = new QPropertyAnimation(this); //For simple window animations - anim->setTargetObject(this); - anim->setDuration(ANIMTIME); //In milliseconds - connect(anim, SIGNAL(finished()), this, SLOT(finishedAnimation()) ); - titleBar = new QLabel(this); //This is the "container" for all the title buttons/widgets - titleBar->setObjectName("TitleBar"); - titleBar->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - titleBar->setFocusPolicy(Qt::NoFocus); - titleBar->setCursor(Qt::ArrowCursor); - title = new QLabel(this); //Shows the window title/text - title->setObjectName("Title"); - title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - title->setCursor(Qt::ArrowCursor); - title->setFocusPolicy(Qt::NoFocus); - icon = new QLabel(this); //Contains the window icon - icon->setObjectName("Icon"); - icon->setCursor(Qt::ArrowCursor); - icon->setFocusPolicy(Qt::NoFocus); - minB = new QToolButton(this); //Minimize Button - minB->setObjectName("Minimize"); - minB->setCursor(Qt::ArrowCursor); - minB->setFocusPolicy(Qt::NoFocus); - connect(minB, SIGNAL(clicked()), this, SLOT(minClicked()) ); - maxB = new QToolButton(this); //Maximize Button - maxB->setObjectName("Maximize"); - maxB->setCursor(Qt::ArrowCursor); - maxB->setFocusPolicy(Qt::NoFocus); - connect(maxB, SIGNAL(clicked()), this, SLOT(maxClicked()) ); - closeB = new QToolButton(this); - closeB->setObjectName("Close"); - closeB->setCursor(Qt::ArrowCursor); - closeB->setFocusPolicy(Qt::NoFocus); - connect(closeB, SIGNAL(clicked()), this, SLOT(closeClicked()) ); - otherB = new QToolButton(this); //Button to place any other actions - otherB->setObjectName("Options"); - otherB->setCursor(Qt::ArrowCursor); - otherB->setPopupMode(QToolButton::InstantPopup); - otherB->setStyleSheet("QToolButton::menu-indicator{ image: none; }"); - otherB->setFocusPolicy(Qt::NoFocus); - otherM = new QMenu(this); //menu of "other" actions for the window - otherB->setMenu(otherM); - connect(otherM, SIGNAL(triggered(QAction*)), this, SLOT(otherClicked(QAction*)) ); - //Now assemble the titlebar - QHBoxLayout *HL = new QHBoxLayout(this); - HL->setContentsMargins(0,0,0,0); - HL->addWidget(otherB); - HL->addWidget(icon); - HL->addWidget(title); - HL->addWidget(minB); - HL->addWidget(maxB); - HL->addWidget(closeB); - titleBar->setLayout(HL); - QVBoxLayout *VL = new QVBoxLayout(this); - this->setLayout(VL); - //The WinWidget container appears shifted right/down by 1 pixel for some reason - // Adjust the margins to account for this variation - VL->setContentsMargins(1,1,2,2); - VL->setSpacing(0); - //Have the window take the same initial size of the client window - QRect geom = LWM::SYSTEM->WM_Window_Geom(CID); - qDebug() << " - Load Size Hints" << "initial size:" << geom.size(); - icccm_size_hints SH = LWM::SYSTEM->WM_ICCCM_GetNormalHints(CID); - qDebug() << " - - Got Normal Hints"; - if(!SH.isValid()){ SH = LWM::SYSTEM->WM_ICCCM_GetSizeHints(CID); } - qDebug() << " - - Start resizing..."; - if(SH.base_width>geom.width() && SH.base_height>geom.height()){ this->resize(SH.base_width, SH.base_height); } - else if(SH.min_width>geom.width() && SH.min_height>geom.height()){ this->resize(SH.min_width, SH.min_height); } - else if(SH.width>geom.width() && SH.height>geom.height()){ this->resize(SH.width, SH.height); } - else if(geom.isNull()){ this->resize(100,80); } - else{ this->resize( geom.size() ); } - qDebug() << " - done"; - - //Now embed the native window into the frame - WIN = QWindow::fromWinId(CID); - WinWidget = QWidget::createWindowContainer( WIN, this); - WinWidget->setCursor(Qt::ArrowCursor); //this is just a fallback - the window itself will adjust it - //WINBACK = new QBackingStore(WIN); //create a data backup for the widget - - //Now assemble te initial layout for the window (all while still invisible) - /*VL->addWidget(titleBar); - VL->addWidget(WinWidget); - VL->setStretch(1,1);*/ -} - -LWindowFrame::ModState LWindowFrame::getStateAtPoint(QPoint pt, bool setoffset){ - //Note: pt should be in widget-relative coordinates, not global - if(!this->layout()->geometry().contains(pt)){ - //above the frame itself - need to figure out which quadrant it is in (8-directions) - if(pt.y() < 3){ - //One of the top options - if(pt.x() < 3){ - if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()); } //difference from top-left corner - return ResizeTopLeft; - }else if(pt.x() > (this->width()-3)){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(pt.y()); } //difference from top-right corner - return ResizeTopRight; - }else{ - if(setoffset){ offset.setX(0); offset.setY(pt.y()); } //difference from top edge (X does not matter) - return ResizeTop; - } - }else if(pt.y() > (this->height()-3) ){ - //One of the bottom options - if(pt.x() < 3){ - if(setoffset){ offset.setX(pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-left corner - return ResizeBottomLeft; - }else if(pt.x() > (this->width()-3)){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-right corner - return ResizeBottomRight; - }else{ - if(setoffset){ offset.setX(0); offset.setY(this->height() - pt.y()); } //difference from bottom edge (X does not matter) - return ResizeBottom; - } - }else{ - //One of the side options - if(pt.x() < 3){ - if(setoffset){ offset.setX(pt.x()); offset.setY(0); } //difference from left edge (Y does not matter) - return ResizeLeft; - }else if(pt.x() > (this->width()-3) ){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(0); } //difference from right edge (Y does not matter) - return ResizeRight; - }else{ - return Normal; - } - } - } - return Normal; -} - -void LWindowFrame::setMouseCursor(ModState state, bool override){ - Qt::CursorShape shape; - switch(state){ - case Normal: - shape = Qt::ArrowCursor; - break; - case Move: - shape = Qt::SizeAllCursor; - break; - case ResizeTop: - shape = Qt::SizeVerCursor; - break; - case ResizeTopRight: - shape = Qt::SizeBDiagCursor; - break; - case ResizeRight: - shape = Qt::SizeHorCursor; - break; - case ResizeBottomRight: - shape = Qt::SizeFDiagCursor; - break; - case ResizeBottom: - shape = Qt::SizeVerCursor; - break; - case ResizeBottomLeft: - shape = Qt::SizeBDiagCursor; - break; - case ResizeLeft: - shape = Qt::SizeHorCursor; - break; - case ResizeTopLeft: - shape = Qt::SizeFDiagCursor; - break; - } - if(override){ - QApplication::setOverrideCursor(QCursor(shape)); - }else{ - this->setCursor(shape); - } -} - -// ========================== -// WINDOW INTERACTIONS -//========================== -void LWindowFrame::SyncSize(bool fromwin){ - //sync the window/frame geometries (generally only done before embedding the client window) - int frame = this->frameWidth(); - int TH = titleBar->height(); - //Now load the information about the window and adjust the frame to match - if(fromwin){ lastGeom = LWM::SYSTEM->WM_Window_Geom(CID); } - else{ lastGeom = this->geometry(); } - qDebug() << "Initial Size:" << lastGeom << frame << TH; - //Add in the frame size - lastGeom.moveTop(lastGeom.y()-frame-TH); - lastGeom.setHeight(lastGeom.height()+(2*frame)+TH); - lastGeom.moveLeft(lastGeom.x()-frame); - lastGeom.setWidth( lastGeom.width()+(2*frame)); - QList<unsigned int> margins; - margins << frame << frame << frame+TH << frame; //L/R/Top/Bottom - qDebug() << " - With Frame:" << lastGeom; - //Now adjust for a out-of-bounds location - if(lastGeom.x() < 0){ lastGeom.moveLeft(0); } - if(lastGeom.y() < 0){ lastGeom.moveTop(0); } - qDebug() << " - Adjusted:" << lastGeom; - this->setGeometry(lastGeom); - LWM::SYSTEM->WM_Set_Frame_Extents(CID, margins); -} - -void LWindowFrame::SyncText(){ - QString txt = WIN->title(); - if(txt.isEmpty()){ txt = LWM::SYSTEM->WindowName(CID); } - if(txt.isEmpty()){ txt = LWM::SYSTEM->OldWindowName(CID); } - if(txt.isEmpty()){ txt = LWM::SYSTEM->WindowVisibleName(CID); } - if(txt.isEmpty()){ txt = LWM::SYSTEM->WindowIconName(CID); } - if(txt.isEmpty()){ txt = LWM::SYSTEM->WindowVisibleIconName(CID); } - if(txt.isEmpty()){ txt = LWM::SYSTEM->WM_ICCCM_GetClass(CID); } - title->setText(txt); -} - -// SIMPLE ANIMATIONS -void LWindowFrame::showAnimation(LWM::WindowAction act){ - bool useanimation = (act!=lastAction); - if(anim->state()==QAbstractAnimation::Running){ - qDebug() << "New Animation Event:" << act; - return; - } - //Setup the animation routine - if(act==LWM::Show){ - if(useanimation){ - lastGeom = this->geometry(); - //Expand out from center point - anim->setPropertyName("geometry"); - anim->setStartValue( QRect(lastGeom.center(), QSize(0,0) ) ); - anim->setEndValue( this->geometry() ); - //Fade in gradually - //anim->setPropertyName("windowOpacity"); - //anim->setStartValue( 0.0 ); - //anim->setEndValue( 1.0 ); - }else{ - ShowClient(true); - this->raise(); - this->show(); //just show it right away - } - - }else if(act==LWM::Hide){ - if(useanimation){ - //Collapse in on center point - lastGeom = this->geometry(); - anim->setPropertyName("geometry"); - anim->setStartValue( QRect(this->geometry()) ); - anim->setEndValue( QRect(this->geometry().center(), QSize(0,0) ) ); - }else{ - this->hide(); //just hide it right away - } - }else if(act==LWM::Closed){ - //Need to clean up the container widget first to prevent XCB errors - //qDebug() << "Window Closed:" << WIN->winId() << CID; - if(useanimation){ - //Collapse in on center line - lastGeom = this->geometry(); - anim->setPropertyName("geometry"); - anim->setStartValue( QRect(this->geometry()) ); - anim->setEndValue( QRect(this->geometry().x(), this->geometry().center().y(), this->width(), 0 ) ); - }else{ - CloseAll(); //just hide it right away - } - } - if(useanimation){ - ShowClient(false); - this->show(); - qDebug() << " - Starting Animation:" << act; - lastAction = act; - anim->start(); - }; -} - -void LWindowFrame::ShowClient(bool show){ - if(show && this->layout()->indexOf(WinWidget)<0 && !Closing){ - while(this->layout()->count()>0){ this->layout()->removeItem(0); } - this->layout()->addWidget(titleBar); - this->layout()->setAlignment(titleBar, Qt::AlignTop); - this->layout()->addWidget(WinWidget); - static_cast<QVBoxLayout*>(this->layout())->setStretch(1,1); - LWM::SYSTEM->WM_ShowWindow(CID); - }else if( !show && this->layout()->indexOf(WinWidget)>=0){ - LWM::SYSTEM->WM_HideWindow(CID); - this->layout()->removeWidget(WinWidget); - } -} - -void LWindowFrame::finishedAnimation(){ - //Also set any final values - qDebug() << " - Finished Animation:" << lastAction; - switch(lastAction){ - case LWM::Show: - ShowClient(true); - break; - case LWM::Closed: - case LWM::Hide: - this->lower(); - this->hide(); - LWM::SYSTEM->WM_HideWindow(this->winId()); - default: - break; - } - if(Closing){ - qDebug() << "Emitting finished signal"; - emit Finished(); - } -} - -// ================= -// PUBLIC SLOTS -// ================= -void LWindowFrame::updateAppearance(){ - //Reload any button icons and such - minB->setIcon(LXDG::findIcon("window-suppressed","")); - maxB->setIcon(LXDG::findIcon("view-fullscreen","")); - closeB->setIcon(LXDG::findIcon("application-exit","")); - otherB->setIcon(LXDG::findIcon("configure","")); -} - -void LWindowFrame::windowChanged(LWM::WindowAction act){ - //A window property was changed - update accordingly - switch(act){ - case LWM::Closed: - Closing = true; - case LWM::Hide: - case LWM::Show: - showAnimation(act); - break; - case LWM::MoveResize: - //Re-adjust to the new position/size of the window - SyncSize(true); - break; - default: - break; //do nothing - } -} -// ================= -// PRIVATE SLOTS -// ================= -void LWindowFrame::closeClicked(){ - qDebug() << "Closing Window" << LWM::SYSTEM->WM_ICCCM_GetClass(CID); - //First try the close event to let the client app do cleanup/etc - LWM::SYSTEM->WM_CloseWindow(CID); -} - -void LWindowFrame::minClicked(){ - qDebug() << "Minimize Window"; - windowChanged(LWM::Hide); -} - -void LWindowFrame::maxClicked(){ - if(normalGeom.isNull()){ - qDebug() << "Maximize Window"; - normalGeom = this->geometry(); //save for later - this->showMaximized(); - }else{ - qDebug() << "Restore Window"; - this->showNormal(); - this->setGeometry(normalGeom); - normalGeom = QRect(); //clear it - } -} - -void LWindowFrame::otherClicked(QAction* act){ - QString action = act->whatsThis(); -} - -void LWindowFrame::CloseAll(){ - qDebug() << " - Closing Frame"; - this->hide(); - emit Finished(); -} -// ===================== -// PROTECTED -// ===================== -void LWindowFrame::mousePressEvent(QMouseEvent *ev){ - qDebug() << "Frame Mouse Press Event"; - offset.setX(0); offset.setY(0); - if(activeState != Normal){ return; } // do nothing - already in a state of grabbed mouse - this->activateWindow(); - LWM::SYSTEM->WM_Set_Active_Window(CID); - if(this->childAt(ev->pos())!=0){ - //Check for any non-left-click event and skip it - if(ev->button()!=Qt::LeftButton){ return; } - activeState = Move; - offset.setX(ev->pos().x()); offset.setY(ev->pos().y()); - }else{ - //Clicked on the frame somewhere - activeState = getStateAtPoint(ev->pos(), true); //also have it set the offset variable - } - setMouseCursor(activeState, true); //this one is an override cursor - -} - -void LWindowFrame::mouseMoveEvent(QMouseEvent *ev){ - ev->accept(); - if(activeState == Normal){ - setMouseCursor( getStateAtPoint(ev->pos()) ); //just update the mouse cursor - - }else{ - //Currently in a modification state - QRect geom = this->geometry(); - switch(activeState){ - case Move: - geom.moveTopLeft(ev->globalPos()-offset); //will not change size - break; - case ResizeTop: - geom.setTop(ev->globalPos().y()-offset.y()); - break; - case ResizeTopRight: - geom.setTopRight(ev->globalPos()-offset); - break; - case ResizeRight: - geom.setRight(ev->globalPos().x()-offset.x()); - break; - case ResizeBottomRight: - geom.setBottomRight(ev->globalPos()-offset); - break; - case ResizeBottom: - geom.setBottom(ev->globalPos().y()-offset.y()); - break; - case ResizeBottomLeft: - geom.setBottomLeft(ev->globalPos()-offset); - break; - case ResizeLeft: - geom.setLeft(ev->globalPos().x()-offset.x()); - break; - case ResizeTopLeft: - geom.setTopLeft(ev->globalPos()-offset); - break; - default: - break; - } - this->setGeometry(geom); - } -} - -void LWindowFrame::mouseReleaseEvent(QMouseEvent *ev){ - //Check for a right-click event - qDebug() << "Frame Mouse Release Event"; - ev->accept(); - if( (activeState==Normal) && (this->childAt(ev->pos())==titleBar) && (ev->button()==Qt::RightButton) ){ - otherM->popup(ev->globalPos()); - return; - } - activeState = Normal; - QApplication::restoreOverrideCursor(); - setMouseCursor( getStateAtPoint(ev->pos()) ); -} diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/LWindow.h b/src-qt5/core/lumina-desktop-unified/src-WM/LWindow.h deleted file mode 100644 index ceefca83..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/LWindow.h +++ /dev/null @@ -1,114 +0,0 @@ -//=========================================== -// 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_WINDOW_FRAME_H -#define _LUMINA_DESKTOP_WINDOW_FRAME_H - -#include "GlobalDefines.h" - -class LWindowFrame : public QFrame{ - Q_OBJECT -public: - LWindowFrame(WId client, QWidget *parent = 0); //MUST have a valid client window - ~LWindowFrame(); - -private: - void InitWindow(); //Initialize all the internal widgets - - //Window status - enum ModState{Normal, Move, ResizeTop, ResizeTopRight, ResizeRight, ResizeBottomRight, ResizeBottom, ResizeBottomLeft, ResizeLeft, ResizeTopLeft}; - ModState activeState; - QPoint offset; //needed for movement calculations (offset from mouse click to movement point) - //Functions for getting/setting state - ModState getStateAtPoint(QPoint pt, bool setoffset = false); //generally used for mouse location detection - void setMouseCursor(ModState, bool override = false); //Update the mouse cursor based on state - - //General Properties/Modifications - WId CID; //Client ID - QWindow *WIN; //Embedded window container - QWidget *WinWidget; - bool Closing; - LWM::WindowAction lastAction; - //QBackingStore *WINBACK; - void SyncSize(bool fromwin = false); //sync the window/frame geometries - void SyncText(); - - //Window Frame Widgets/Items - QLabel *titleBar, *title, *icon; - QToolButton *minB, *maxB, *closeB, *otherB; - QMenu *otherM; //menu of "other" actions for the window - QRect normalGeom; //used for restoring back to original size after maximization/fullscreen - - //Animations - QPropertyAnimation *anim; //used for appear/disappear animations - QRect lastGeom; //used for appear/disappear animations - void showAnimation(LWM::WindowAction); //sets lastAction - void ShowClient(bool show); - -public slots: - //These slots are generally used for the outside event watcher to prod for changes - void updateAppearance(); //reload the theme and change styling as necessary - void windowChanged(LWM::WindowAction); - -private slots: - void finishedAnimation(); //uses lastAction - void closeClicked(); - void minClicked(); - void maxClicked(); - void otherClicked(QAction*); - - void CloseAll(); - -protected: - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - -signals: - void Finished(); //This means the window is completely finished (with animations and such) and should be removed from any lists - -}; - -class LWindow : public QObject{ - Q_OBJECT -signals: - void Finished(WId client); //ready to be removed -private: - WId CID; - LWindowFrame *FID; - bool needsFrame(QList<LXCB::WINDOWTYPE> list){ - if(list.isEmpty()){ return !LWM::SYSTEM->WM_ICCCM_GetClass(CID).contains("Lumina-DE"); } //assume a normal window (fallback) - return !(list.contains(LXCB::T_DESKTOP) || list.contains(LXCB::T_DOCK) || list.contains(LXCB::T_TOOLBAR) \ - || list.contains(LXCB::T_SPLASH) || list.contains(LXCB::T_DROPDOWN_MENU) \ - || list.contains(LXCB::T_TOOLTIP) || list.contains(LXCB::T_POPUP_MENU) || list.contains(LXCB::T_TOOLTIP) \ - || list.contains(LXCB::T_COMBO) || list.contains(LXCB::T_DND) ); - } -private slots: - void frameclosed(){ - qDebug() << " - Window got frame closed signal"; - //FID->close(); - //delete FID; - emit Finished(CID); - } -public: - LWindow(WId client){ - FID= 0; - CID = client; - if( needsFrame(LWM::SYSTEM->WM_Get_Window_Type(CID)) ){ - FID = new LWindowFrame(CID); - connect(FID, SIGNAL(Finished()), this, SLOT(frameclosed()) ); - } - } - ~LWindow(){ - if(FID!=0){delete FID;} - } - - WId clientID(){ return CID; } - bool hasFrame(){ return FID!=0; } - LWindowFrame* frame(){ return FID; } - -}; -#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/LWindowManager.cpp b/src-qt5/core/lumina-desktop-unified/src-WM/LWindowManager.cpp deleted file mode 100644 index 14ce6897..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/LWindowManager.cpp +++ /dev/null @@ -1,186 +0,0 @@ -//=========================================== -// Lumina-DE source code -// Copyright (c) 2015, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -#include "LWindowManager.h" - -#define DEBUG 1 - -LWindowManager::LWindowManager(){ - -} - -LWindowManager::~LWindowManager(){ - -} - -bool LWindowManager::start(){ - //Setup the initial screen/session values - LWM::SYSTEM->WM_Set_Root_Supported(); - LWM::SYSTEM->WM_SetNumber_Desktops(1); - LWM::SYSTEM->WM_Set_Current_Desktop(0); - LWM::SYSTEM->WM_Set_Desktop_Names(QStringList() << "one"); - QRect totgeom; - QList<QPoint> viewports; - QList<QRect> geoms; - for(int i=0; i<QApplication::desktop()->screenCount(); i++){ - geoms << QApplication::desktop()->screen(i)->geometry(); - viewports << QPoint(0,0); - totgeom = QApplication::desktop()->screen(i)->geometry(); - } - LWM::SYSTEM->WM_Set_Desktop_Geometry(totgeom.size()); - LWM::SYSTEM->WM_Set_Desktop_Viewport(viewports); - LWM::SYSTEM->WM_Set_Workarea(geoms); - //Should probably do a quick loop over any existing windows with the root as parent (just in case) - QList<WId> initial = LWM::SYSTEM->WM_RootWindows(); - for(int i=0; i<initial.length(); i++){ - NewWindow(initial[i], false); //These ones did not explicitly request to be mapped - } - RestackWindows(); - return true; -} - -void LWindowManager::stop(){ - for(int i=0; i<WINS.length(); i++){ - if(WINS[i]->hasFrame()){ - LWM::SYSTEM->UnembedWindow(WINS[i]->clientID()); - WINS[i]->frame()->close(); - } - } -} -//=============== -// PUBLIC SLOTS -//=============== -void LWindowManager::NewWindow(WId win, bool requested){ - //Verify that this window can/should be managed first - //if(DEBUG){ qDebug() << "New Window:" << LWM::SYSTEM->WM_ICCCM_GetClass(win); } - QString wclass = LWM::SYSTEM->WM_ICCCM_GetClass(win); - if( wclass.contains("lumina-wm",Qt::CaseInsensitive) ){ return; } //just in case: prevent recursion - else{ - bool ok = (wclass.isEmpty() ? false : LWM::SYSTEM->WM_ManageWindow(win, requested) ); - if(!ok){ - //See if this window is just a transient pointing to some other window - WId tran = LWM::SYSTEM->WM_ICCCM_GetTransientFor(win); - if(tran!=win && tran!=0){ - win = tran; - ok = LWM::SYSTEM->WM_ManageWindow(win); - } - } - if(!ok){ return; } - } - if(DEBUG){ qDebug() << "New Managed Window:" << LWM::SYSTEM->WM_ICCCM_GetClass(win); } - LWM::SYSTEM->WM_Set_Active_Window(win); - LWindow *lwin = new LWindow(win); - connect(lwin, SIGNAL(Finished(WId)), this, SLOT(FinishedWindow(WId)) ); - WINS << lwin; - if(lwin->hasFrame()){ - lwin->frame()->windowChanged(LWM::Show); //Make sure to show it right away - }else{ - LWM::SYSTEM->WM_ShowWindow(win); //just map the window right now - } -} - -void LWindowManager::ClosedWindow(WId win){ - for(int i=0; i<WINS.length(); i++){ - if(WINS[i]->clientID()==win){ - qDebug() << " - Closed Window"; - if(WINS[i]->hasFrame()){ WINS[i]->frame()->windowChanged(LWM::Closed); } //do any animations/cleanup - else{ FinishedWindow(win); } - break; - } - } -} - -void LWindowManager::ModifyWindow(WId win, LWM::WindowAction act){ - for(int i=0; i<WINS.length(); i++){ - if(WINS[i]->clientID()==win){ - if(WINS[i]->hasFrame()){ WINS[i]->frame()->windowChanged(act); } - return; - } - } - //If it gets this far - it is an unmanaged window - if(act==LWM::Show){ - NewWindow(win); - } - RestackWindows(); -} - -void LWindowManager::RestackWindows(){ - Stack_Desktop.clear(); Stack_Below.clear(); Stack_Normal.clear(); Stack_Above.clear(); Stack_Fullscreen.clear(); - QList<WId> currwins; - int cwork = LWM::SYSTEM->WM_Get_Current_Desktop(); - int winwork = -1; - QList<LXCB::WINDOWSTATE> states; - QList<LXCB::WINDOWTYPE> types; - for(int i=0; i<WINS.length(); i++){ - //Only show windows on the current desktop - winwork = LWM::SYSTEM->WM_Get_Desktop(WINS[i]->clientID()); - states = LWM::SYSTEM->WM_Get_Window_States(WINS[i]->clientID()); - types = LWM::SYSTEM->WM_Get_Window_Type(WINS[i]->clientID()); - WId id = WINS[i]->clientID(); - if(WINS[i]->hasFrame()){ id = WINS[i]->frame()->winId(); } - if(winwork<0 || winwork == cwork || states.contains(LXCB::S_STICKY) ){ - //Now check the state/type and put it in the proper stack - currwins << WINS[i]->clientID(); //add this to the overall "age" list - //Now add it to the proper stack - if(types.contains(LXCB::T_DESKTOP)){ Stack_Desktop << id; } - else if(states.contains(LXCB::S_BELOW)){ Stack_Below << id; } - else if(types.contains(LXCB::T_DOCK) || states.contains(LXCB::S_ABOVE) ){ Stack_Above << id; } - else if(states.contains(LXCB::S_FULLSCREEN)){ Stack_Fullscreen << id; } - else{ Stack_Normal << id; } - } - } - //Active Window management - WId active = LWM::SYSTEM->WM_Get_Active_Window(); - if(Stack_Desktop.contains(active)){ Stack_Desktop.removeAll(active); Stack_Desktop << active; } - else if(Stack_Below.contains(active)){ Stack_Below.removeAll(active); Stack_Below << active; } - else if(Stack_Normal.contains(active)){ Stack_Normal.removeAll(active); Stack_Normal << active; } - else if(Stack_Above.contains(active)){ Stack_Above.removeAll(active); Stack_Above << active; } - else if(Stack_Fullscreen.contains(active)){ Stack_Fullscreen.removeAll(active); Stack_Fullscreen << active; } - - //Now set the root properties for these lists - LWM::SYSTEM->WM_Set_Client_List(currwins, false); //age-ordered version - LWM::SYSTEM->WM_Set_Client_List(QList<WId>() << Stack_Desktop << Stack_Below << Stack_Normal << Stack_Above << Stack_Fullscreen, true); //stacking order version - //Now re-paint (in order) the windows - RepaintWindows(); -} - -void LWindowManager::RepaintWindows(){ - //Go through all the current windows (in stacking order) and re-paint them - for(int i=0; i<Stack_Desktop.length(); i++){ - LWM::SYSTEM->WM_ShowWindow(Stack_Desktop[i]); - } - for(int i=0; i<Stack_Below.length(); i++){ - LWM::SYSTEM->WM_ShowWindow(Stack_Below[i]); - } - for(int i=0; i<Stack_Normal.length(); i++){ - LWM::SYSTEM->WM_ShowWindow(Stack_Normal[i]); - } - for(int i=0; i<Stack_Above.length(); i++){ - LWM::SYSTEM->WM_ShowWindow(Stack_Above[i]); - } - for(int i=0; i<Stack_Fullscreen.length(); i++){ - LWM::SYSTEM->WM_ShowWindow(Stack_Fullscreen[i]); - } -} - -//================= -// PRIVATE SLOTS -//================= -void LWindowManager::FinishedWindow(WId win){ - for(int i=0; i<WINS.length(); i++){ - if(WINS[i]->clientID() == win){ - qDebug() << " - Finished Window"; - if(win == LWM::SYSTEM->WM_Get_Active_Window()){ - if(i==0 && WINS.length()>1){ LWM::SYSTEM->WM_Set_Active_Window(WINS[i+1]->clientID()); } - else if(i>0){ LWM::SYSTEM->WM_Set_Active_Window(WINS[i-1]->clientID()); } - else{ LWM::SYSTEM->WM_Set_Active_Window( QX11Info::appRootWindow()); } - } - delete WINS.takeAt(i); break; - } - } - //Now update the list of clients - RestackWindows(); -} diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/LWindowManager.h b/src-qt5/core/lumina-desktop-unified/src-WM/LWindowManager.h deleted file mode 100644 index 203efa1b..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/LWindowManager.h +++ /dev/null @@ -1,40 +0,0 @@ -//=========================================== -// 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_WINDOW_MANAGER_MAIN_CLASS_H -#define _LUMINA_DESKTOP_WINDOW_MANAGER_MAIN_CLASS_H - -#include "GlobalDefines.h" -#include "LWindow.h" - -class LWindowManager : public QObject{ - Q_OBJECT -public: - LWindowManager(); - ~LWindowManager(); - - bool start(); - void stop(); - -private: - QList<LWindow*> WINS; - QList<WId> Stack_Desktop, Stack_Below, Stack_Normal, Stack_Above, Stack_Fullscreen; -public slots: - void NewWindow(WId win, bool requested = true); - void ClosedWindow(WId win); - void ModifyWindow(WId win, LWM::WindowAction act); - - void RestackWindows(); - void RepaintWindows(); - -private slots: - void FinishedWindow(WId win); //This is used for LWindow connections/animations - -signals: - void NewFullScreenWindows(QList<WId>); -}; - -#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/WMSession.cpp b/src-qt5/core/lumina-desktop-unified/src-WM/WMSession.cpp deleted file mode 100644 index 4a7c6e02..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/WMSession.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//=========================================== -// Lumina-DE source code -// Copyright (c) 2015, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -#include "WMSession.h" - -#define DEBUG 1 -// ========== -// PUBLIC -// ========== -WMSession::WMSession(){ - if(DEBUG){ qDebug() << "Creating Event Filter..."; } - EFILTER = new EventFilter(); - if(DEBUG){ qDebug() << "Creating Screen Saver..."; } - SS = new LScreenSaver(); - if(DEBUG){ qDebug() << "Creating Window Manager..."; } - WM = new LWindowManager(); - EVThread = new QThread(); - EFILTER->moveToThread(EVThread); - //Setup connections - connect(EFILTER, SIGNAL(NewInputEvent()), SS, SLOT(newInputEvent()) ); - connect(EFILTER, SIGNAL(NewManagedWindow(WId)), WM, SLOT(NewWindow(WId)) ); - connect(EFILTER, SIGNAL(WindowClosed(WId)), WM, SLOT(ClosedWindow(WId)) ); - connect(EFILTER, SIGNAL(ModifyWindow(WId, LWM::WindowAction)), WM, SLOT(ModifyWindow(WId,LWM::WindowAction)) ); - connect(SS, SIGNAL(StartingScreenSaver()), EFILTER, SLOT(StartedSS()) ); - connect(SS, SIGNAL(ClosingScreenSaver()), EFILTER, SLOT(StoppedSS()) ); - connect(WM, SIGNAL(NewFullScreenWindows(QList<WId>)), EFILTER, SLOT(FullScreenChanged(QList<WId>)) ); -} - -WMSession::~WMSession(){ -} - -void WMSession::start(bool SSONLY){ - //Get the screensaver initialized/ready - if(DEBUG){ qDebug() << "Starting Screen Saver..."; } - SS->start(); - if(SSONLY){ return; } - //Now start pulling/filtering events - if(DEBUG){ qDebug() << "Starting Window Manager..."; } - WM->start(); - if(DEBUG){ qDebug() << "Starting Event Filter..."; } - EVThread->start(); - EFILTER->start(); - if(DEBUG){ qDebug() << "Done Starting WM session..."; } -} - -// ========== -// Public Slots -// ========== -void WMSession::reloadIcons(){ - -} - -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/src-qt5/core/lumina-desktop-unified/src-WM/WMSession.h b/src-qt5/core/lumina-desktop-unified/src-WM/WMSession.h deleted file mode 100644 index 5b511326..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/WMSession.h +++ /dev/null @@ -1,42 +0,0 @@ -//=========================================== -// 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_WINDOW_MANAGER_SESSION_H -#define _LUMINA_DESKTOP_WINDOW_MANAGER_SESSION_H - -#include "GlobalDefines.h" - -#include "LScreenSaver.h" -#include "LXcbEventFilter.h" -#include "LWindowManager.h" - -class WMSession : public QObject{ - Q_OBJECT -public: - WMSession(); - ~WMSession(); - - void start(bool SSONLY = false); - -private: - //XCB Event Watcher - EventFilter *EFILTER; - //ScreenSaver - LScreenSaver *SS; - //Window Manager - LWindowManager *WM; - - QThread *EVThread; //X Event thread - -public slots: - void reloadIcons(); - void newInputsAvailable(QStringList); - -private slots: - -}; - -#endif
\ No newline at end of file diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/lumina-wm.pro b/src-qt5/core/lumina-desktop-unified/src-WM/lumina-wm.pro deleted file mode 100644 index 928f8744..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/lumina-wm.pro +++ /dev/null @@ -1,107 +0,0 @@ -include("$${PWD}/../../OS-detect.pri") - -QT += core gui network -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras - -TARGET = lumina-wm -target.path = $${L_BINDIR} - -LIBS += -lLuminaUtils -lxcb -lxcb-damage -lxcb-composite -lxcb-screensaver -lxcb-util - -DEPENDPATH += ../libLumina - -SOURCES += main.cpp \ - WMSession.cpp \ - LScreenSaver.cpp \ - SSBaseWidget.cpp \ - LLockScreen.cpp \ - LXcbEventFilter.cpp \ - LWindow.cpp \ - LWindowManager.cpp - - -HEADERS += GlobalDefines.h \ - WMSession.h \ - LScreenSaver.h \ - SSBaseWidget.h \ - LLockScreen.h \ - LXcbEventFilter.h \ - LWindow.h \ - LWindowManager.h - -FORMS += LLockScreen.ui - -#Now add in all the screensaver animation plugins -include(animations/animations.pri) - -TRANSLATIONS = i18n/lumina-wm_af.ts \ - i18n/lumina-wm_ar.ts \ - i18n/lumina-wm_az.ts \ - i18n/lumina-wm_bg.ts \ - i18n/lumina-wm_bn.ts \ - i18n/lumina-wm_bs.ts \ - i18n/lumina-wm_ca.ts \ - i18n/lumina-wm_cs.ts \ - i18n/lumina-wm_cy.ts \ - i18n/lumina-wm_da.ts \ - i18n/lumina-wm_de.ts \ - i18n/lumina-wm_el.ts \ - i18n/lumina-wm_en_GB.ts \ - i18n/lumina-wm_en_ZA.ts \ - i18n/lumina-wm_es.ts \ - i18n/lumina-wm_et.ts \ - i18n/lumina-wm_eu.ts \ - i18n/lumina-wm_fa.ts \ - i18n/lumina-wm_fi.ts \ - i18n/lumina-wm_fr.ts \ - i18n/lumina-wm_fr_CA.ts \ - i18n/lumina-wm_gl.ts \ - i18n/lumina-wm_he.ts \ - i18n/lumina-wm_hi.ts \ - i18n/lumina-wm_hr.ts \ - i18n/lumina-wm_hu.ts \ - i18n/lumina-wm_id.ts \ - i18n/lumina-wm_is.ts \ - i18n/lumina-wm_it.ts \ - i18n/lumina-wm_ja.ts \ - i18n/lumina-wm_ka.ts \ - i18n/lumina-wm_ko.ts \ - i18n/lumina-wm_lt.ts \ - i18n/lumina-wm_lv.ts \ - i18n/lumina-wm_mk.ts \ - i18n/lumina-wm_mn.ts \ - i18n/lumina-wm_ms.ts \ - i18n/lumina-wm_mt.ts \ - i18n/lumina-wm_nb.ts \ - i18n/lumina-wm_nl.ts \ - i18n/lumina-wm_pa.ts \ - i18n/lumina-wm_pl.ts \ - i18n/lumina-wm_pt.ts \ - i18n/lumina-wm_pt_BR.ts \ - i18n/lumina-wm_ro.ts \ - i18n/lumina-wm_ru.ts \ - i18n/lumina-wm_sk.ts \ - i18n/lumina-wm_sl.ts \ - i18n/lumina-wm_sr.ts \ - i18n/lumina-wm_sv.ts \ - i18n/lumina-wm_sw.ts \ - i18n/lumina-wm_ta.ts \ - i18n/lumina-wm_tg.ts \ - i18n/lumina-wm_th.ts \ - i18n/lumina-wm_tr.ts \ - i18n/lumina-wm_uk.ts \ - i18n/lumina-wm_uz.ts \ - i18n/lumina-wm_vi.ts \ - i18n/lumina-wm_zh_CN.ts \ - i18n/lumina-wm_zh_HK.ts \ - i18n/lumina-wm_zh_TW.ts \ - i18n/lumina-wm_zu.ts - -dotrans.path=$${L_SHAREDIR}/lumina-desktop/i18n/ -dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$${L_SHAREDIR}/lumina-desktop/i18n/ - -INSTALLS += target - -WITH_I18N{ - INSTALLS += dotrans -} diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/main.cpp b/src-qt5/core/lumina-desktop-unified/src-WM/main.cpp deleted file mode 100644 index 02e48b7b..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-WM/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//=========================================== -// Lumina-DE source code -// Copyright (c) 2015, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== - -#include "GlobalDefines.h" -//Initialize any global structures here -LXCB *LWM::SYSTEM = 0; - -//Local includes -#include "WMSession.h" -#include "LWindow.h" -#include <QDialog> - - -//#define DEBUG 0 -int main(int argc, char ** argv) -{ - qDebug() << "Starting lumina-wm..."; - LTHEME::LoadCustomEnvSettings(); - LSingleApplication a(argc, argv, "lumina-wm"); - if(!a.isPrimaryProcess()){ return 0; } //Inputs forwarded on to the primary already - LuminaThemeEngine themes(&a); - - //Setup the global structures - LWM::SYSTEM = new LXCB(); - if( a.inputlist.contains("--test-win") ){ - //Simple override to test out the window class - qDebug() << "Starting window test..."; - QLabel dlg(0, Qt::Window | Qt::BypassWindowManagerHint); //this test should be ignored by the current WM - dlg.setText("Sample Window"); - dlg.setWindowTitle("Test"); - dlg.resize(200,100); - dlg.setStyleSheet("background: rgba(255,255,255,100); color: black;"); - dlg.move(100,100); - dlg.show(); - //dlg.move(100,100); - qDebug() << " - Loading window frame..."; - LWindow win(dlg.winId()); //have it wrap around the dialog - qDebug() << " - Show frame..."; - win.frame()->windowChanged(LWM::Show); - qDebug() << " - Start event loop..."; - a.setQuitOnLastWindowClosed(true); - return a.exec(); - } - WMSession w; - 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; -} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp index e363af01..c3e9a1db 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp @@ -13,13 +13,13 @@ void DesktopContextMenu::SettingsChanged(DesktopSettings::File file){ void DesktopContextMenu::UpdateMenu(){ //Put a label at the top - unsigned int num = Lumina::EFILTER->currentWorkspace(); //LX11::GetCurrentDesktop(); + unsigned int num = Lumina::NWS->currentWorkspace(); workspaceLabel->setText( "<b>"+QString(tr("Workspace %1")).arg(QString::number(num+1))+"</b>"); this->clear(); //clear it for refresh this->addAction(wkspaceact); this->addSeparator(); //Now load the user's menu setup and fill the menu - QStringList items = Lumina::SETTINGS->value(DesktopSettings::ContextMenu, "itemlist", QStringList()<< "terminal" << "filemanager" << "line" << "settings" <<"lockdesktop").toStringList(); + QStringList items = DesktopSettings::instance()->value(DesktopSettings::ContextMenu, "itemlist", QStringList()<< "terminal" << "filemanager" << "line" << "settings" <<"lockdesktop").toStringList(); //usewinmenu=false; for(int i=0; i<items.length(); i++){ if(items[i]=="terminal"){ this->addAction(LXDG::findIcon("utilities-terminal",""), tr("Terminal"))->setWhatsThis("lumina-open -terminal"); } @@ -76,7 +76,7 @@ DesktopContextMenu::~DesktopContextMenu(){ } void DesktopContextMenu::start(){ - connect(Lumina::SETTINGS, SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(SettingsChanged(DesktopSettings::File)) ); + connect(DesktopSettings::instance(), SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(SettingsChanged(DesktopSettings::File)) ); connect(this, SIGNAL(LockSession()), Lumina::SS, SLOT(LockScreenNow()) ); //Still need to connect to some "workspaceChanged(int)" signal @@ -85,6 +85,7 @@ void DesktopContextMenu::start(){ // === PRIVATE SLOTS === void DesktopContextMenu::LaunchAction(QAction *act){ + //qDebug() << "Launch Action Triggered:" << act->whatsThis(); if(act->whatsThis().isEmpty() || act->parent()!=this ){ return; } qDebug() << "Launch Menu Action:" << act->whatsThis(); QString cmd = act->whatsThis(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h index 8b0509fb..1e3165ec 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h @@ -19,7 +19,7 @@ private: QLabel *workspaceLabel; QWidgetAction *wkspaceact; -public: +public: DesktopContextMenu(QWidget *parent = 0); ~DesktopContextMenu(); diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp index b09a1a5b..3d50112c 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp @@ -25,18 +25,9 @@ void LShortcutEvents::start(){ clearTimer->setSingleShot(true); connect(clearTimer, SIGNAL(timeout()), this, SLOT(clearKeys()) ); } - //Now connect this object to the global EFILTER object signals - connect(Lumina::EFILTER, SIGNAL(KeyPressed(WId, int)), this, SLOT(KeyPress(WId, int)) ); - connect(Lumina::EFILTER, SIGNAL(KeyReleased(WId, int)), this, SLOT(KeyRelease(WId, int)) ); - connect(Lumina::EFILTER, SIGNAL(MousePressed(WId, Lumina::MouseButton)), this, SLOT(MousePress(WId, Lumina::MouseButton)) ); - connect(Lumina::EFILTER, SIGNAL(MouseReleased(WId, Lumina::MouseButton)), this, SLOT(MouseRelease(WId, Lumina::MouseButton)) ); } void LShortcutEvents::stop(){ - disconnect(Lumina::EFILTER, SIGNAL(KeyPressed(WId, int)), this, SLOT(KeyPress(WId, int)) ); - disconnect(Lumina::EFILTER, SIGNAL(KeyReleased(WId, int)), this, SLOT(KeyRelease(WId, int)) ); - disconnect(Lumina::EFILTER, SIGNAL(MousePressed(WId, Lumina::MouseButton)), this, SLOT(MousePress(WId, Lumina::MouseButton)) ); - disconnect(Lumina::EFILTER, SIGNAL(MouseReleased(WId, Lumina::MouseButton)), this, SLOT(MouseRelease(WId, Lumina::MouseButton)) ); clearKeys(); } @@ -46,11 +37,11 @@ void LShortcutEvents::CheckKeySequence(WId win){ QString shortcut = keylistToString(); //Now see if there is a match for this shortcut // "strict" actions (operate even if a non-desktop window is active/focused) - QString action = Lumina::SETTINGS->value(DesktopSettings::Keys, "strict/"+shortcut, "").toString(); + QString action = DesktopSettings::instance()->value(DesktopSettings::Keys, "strict/"+shortcut, "").toString(); qDebug() << "Strict Action:" << "strict/"+shortcut << action; if(action.isEmpty() && win==0){ //"loose" actions (operating on the desktop or root window itself) - action = Lumina::SETTINGS->value(DesktopSettings::Keys, "desktop/"+shortcut, "").toString(); + action = DesktopSettings::instance()->value(DesktopSettings::Keys, "desktop/"+shortcut, "").toString(); qDebug() << "Desktop Action:" << "desktop/"+shortcut << action; } if(!action.isEmpty()){ @@ -59,42 +50,42 @@ void LShortcutEvents::CheckKeySequence(WId win){ } } -void LShortcutEvents::CheckMouseSequence(WId win, Lumina::MouseButton button, bool release){ - if(release && (button == Lumina::WheelUp || button == Lumina::WheelDown || button == Lumina::WheelLeft || button == Lumina::WheelRight)){ +void LShortcutEvents::CheckMouseSequence(WId win, NativeWindowSystem::MouseButton button, bool release){ + if(release && (button == NativeWindowSystem::WheelUp || button == NativeWindowSystem::WheelDown || button == NativeWindowSystem::WheelLeft || button == NativeWindowSystem::WheelRight)){ return; //skip mouse release events for wheel actions (always come in pairs of press/release) - }else if(keylist.isEmpty() || button == Lumina::NoButton){ return; } //Never overwrite mouse clicks themselves - just combinations with key presses + }else if(keylist.isEmpty() || button == NativeWindowSystem::NoButton){ return; } //Never overwrite mouse clicks themselves - just combinations with key presses //Get the keyboard modifiers QString shortcut = keylistToString(); //Add the mouse button to the shortcut switch(button){ - case Lumina::LeftButton: + case NativeWindowSystem::LeftButton: shortcut.append("+LeftMouse"); break; - case Lumina::RightButton: + case NativeWindowSystem::RightButton: shortcut.append("+RightMouse"); break; - case Lumina::MidButton: + case NativeWindowSystem::MidButton: shortcut.append("+MiddleMouse"); break; - case Lumina::BackButton: + case NativeWindowSystem::BackButton: shortcut.append("+BackMouse"); break; - case Lumina::ForwardButton: + case NativeWindowSystem::ForwardButton: shortcut.append("+ForwardMouse"); break; - case Lumina::TaskButton: + case NativeWindowSystem::TaskButton: shortcut.append("+TaskMouse"); break; - case Lumina::WheelUp: + case NativeWindowSystem::WheelUp: shortcut.append("+WheelUp"); break; - case Lumina::WheelDown: + case NativeWindowSystem::WheelDown: shortcut.append("+WheelDown"); break; - case Lumina::WheelLeft: + case NativeWindowSystem::WheelLeft: shortcut.append("+WheelLeft"); break; - case Lumina::WheelRight: + case NativeWindowSystem::WheelRight: shortcut.append("+WheelRight"); break; default: @@ -103,10 +94,10 @@ void LShortcutEvents::CheckMouseSequence(WId win, Lumina::MouseButton button, bo if(shortcut.isEmpty()){ return; } //Now see if there is a match for this shortcut // "strict" actions (operate even if a non-desktop window is active/focused) - QString action = Lumina::SETTINGS->value(DesktopSettings::Keys, "strict/"+shortcut, "").toString(); + QString action = DesktopSettings::instance()->value(DesktopSettings::Keys, "strict/"+shortcut, "").toString(); if(action.isEmpty() && win==0){ //"loose" actions (operating on the desktop or root window itself) - action = Lumina::SETTINGS->value(DesktopSettings::Keys, "desktop/"+shortcut, "").toString(); + action = DesktopSettings::instance()->value(DesktopSettings::Keys, "desktop/"+shortcut, "").toString(); } if(!action.isEmpty()){ //Found a valid action - go ahead and evaluate it @@ -115,23 +106,44 @@ void LShortcutEvents::CheckMouseSequence(WId win, Lumina::MouseButton button, bo } QString LShortcutEvents::keylistToString(){ + if(keylist.isEmpty()){ return ""; } QString shortcut; + QList<int> keys; int ckey = 0; for(int i=0; i<keylist.length(); i++){ - if(i>0){ shortcut.append("+"); } - shortcut.append( QString::number(keylist[i]) ); + if(i == keylist.length()-1){ ckey+=keylist[i]; } //always treat the last key as a non-modifier + else if(keylist[i] == Qt::Key_Control){ ckey+=Qt::CTRL; } //use the modifier form of the key + else if(keylist[i] == Qt::Key_Alt){ ckey += Qt::ALT; } + else if(keylist[i] == Qt::Key_Shift){ ckey += Qt::SHIFT; } + else if(keylist[i] == Qt::Key_Meta){ ckey += Qt::META; } + else{ ckey+= keylist[i]; keys << ckey; ckey = 0; } //non-modifier - need to finish current mod+key combo and start a new one + } + if(ckey!=0){ keys << ckey; } //add in the last one as well + if(keys.length() < 1){ return ""; } + QKeySequence seq; + switch(keys.length()){ + case 1: + seq = QKeySequence(keys[0]); break; + case 2: + seq = QKeySequence(keys[0], keys[1]); break; + case 3: + seq = QKeySequence(keys[0], keys[1], keys[2]); break; + default: + seq = QKeySequence(keys[0],keys[1], keys[2], keys[3]); break; } /*qDebug() << "KeyList to String:"; - qDebug() << " keys:" << keylist; - qDebug() << " string:" << shortcut;*/ - return shortcut; + qDebug() << " keys:" << seq; + qDebug() << " string:" << seq.toString();*/ + return seq.toString(); } void LShortcutEvents::evaluateShortcutAction(QString action){ qDebug() << "Found Shortcut Action:" << action; evaluated = true; - if(action.startsWith("Exec=")){ - emit LaunchApplication(action.section("=",1,-1)); + if(action.startsWith("Exec:")){ + emit LaunchApplication(action.section(":",1,-1)); return; + }else if(action.startsWith("Launch:")){ + emit LaunchStandardApplication(action.section(":",1,-1)); } //Specific Internal actions action = action.toLower(); @@ -140,13 +152,14 @@ void LShortcutEvents::evaluateShortcutAction(QString action){ else if(action=="reboot"){ emit StartReboot(); } else if(action=="shutdown"){ emit StartShutdown(); } else if(action=="show_leave_options"){ emit OpenLeaveDialog(); } + else if(action=="lockscreen"){ emit LockSession(); } } // === PUBLIC SLOTS === -void LShortcutEvents::KeyPress(WId window, int key){ +void LShortcutEvents::KeyPress(WId window, Qt::Key key){ if(window!=WIN){ keylist.clear(); WIN = window; } - if(!keylist.contains(key)){ + /*if(!keylist.contains(key)){ //Put it in the list in ascending order bool found = false; for(int i=0; i<keylist.length() && !found; i++){ @@ -154,28 +167,35 @@ void LShortcutEvents::KeyPress(WId window, int key){ } if(!found){ keylist << key; } evaluated = false; + }*/ + if(!keylist.isEmpty()){ + if( keylist.last()!=key ){ keylist << key; } + }else{ + keylist << key; } //Evaluate the key sequence only when the first one is released - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } -void LShortcutEvents::KeyRelease(WId window, int key){ +void LShortcutEvents::KeyRelease(WId window, Qt::Key key){ if(window!=WIN){ keylist.clear(); return; } if(!evaluated){ CheckKeySequence(WIN); } //run this "before" removing the key from the list - keylist.removeAll(key); - clearTimer->start(); //will "restart" if already running + for(int i=keylist.length()-1; i>=0; i--){ + if(keylist[i] == key){ keylist.removeAt(i); break; } + } + clearTimer->start(); //will "restart" if already running } -void LShortcutEvents::MousePress(WId window, Lumina::MouseButton button){ +void LShortcutEvents::MousePress(WId window, NativeWindowSystem::MouseButton button){ //We do not provide shortcuts for combinations of mouse buttons - just mouse+keyboard combinations CheckMouseSequence(window, button, false); - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } -void LShortcutEvents::MouseRelease(WId window, Lumina::MouseButton button){ +void LShortcutEvents::MouseRelease(WId window, NativeWindowSystem::MouseButton button){ //We do not provide shortcuts for combinations of mouse buttons - just mouse+keyboard combinations CheckMouseSequence(window, button, true); - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } void LShortcutEvents::clearKeys(){ diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h index d1c3b4e0..4560cb1f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h +++ b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h @@ -22,22 +22,22 @@ public: void stop(); private: - QList<int> keylist; //keys currently held down (NOTE: QKeySequence has a max of 4 keys for combinations) + QList< Qt::Key > keylist; //keys currently held down WId WIN; //current window being acted on by the keys QTimer *clearTimer; //used to clear the internal keylist every once in a while if no events come in. bool evaluated; //Actual check functions void CheckKeySequence(WId win); - void CheckMouseSequence(WId win, Lumina::MouseButton, bool release); + void CheckMouseSequence(WId win, NativeWindowSystem::MouseButton, bool release); QString keylistToString(); void evaluateShortcutAction(QString action); public slots: - void KeyPress(WId window, int key); - void KeyRelease(WId window, int key); - void MousePress(WId window, Lumina::MouseButton); - void MouseRelease(WId window, Lumina::MouseButton); + void KeyPress(WId window, Qt::Key key); + void KeyRelease(WId window, Qt::Key key); + void MousePress(WId window, NativeWindowSystem::MouseButton); + void MouseRelease(WId window, NativeWindowSystem::MouseButton); void clearKeys(); signals: @@ -50,7 +50,7 @@ signals: // Session Options void ChangeWorkspace(int); // +/- 1 from current void LockSession(); - + //Active Window Options void ActiveWindowMoveToWorkspace(int); //number of workspace void ActiveWindowTakeToWorkspace(int); //number of workspace @@ -66,6 +66,7 @@ signals: //General Utility Launch void LaunchApplication(QString exec); + void LaunchStandardApplication(QString app); //standard app like "terminal", "browser", "email", "settings", etc.. }; diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LXcbEventFilter.cpp b/src-qt5/core/lumina-desktop-unified/src-events/LXcbEventFilter.cpp deleted file mode 100644 index 7031f3df..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-events/LXcbEventFilter.cpp +++ /dev/null @@ -1,500 +0,0 @@ -//=========================================== -// Lumina-desktop source code -// Copyright (c) 2015-2017, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -#include "LXcbEventFilter.h" - -#include <xcb/xcb_aux.h> -#include <xcb/damage.h> - -//================================================== -// NOTE: All the XCB interactions and atoms are accessed via: -// obj->XCB->EWMH.(atom name) -// obj->XCB->(do something) -//================================================== -#include "global-objects.h" - -//SYSTEM TRAY STANDARD DEFINITIONS -#define SYSTEM_TRAY_REQUEST_DOCK 0 -#define SYSTEM_TRAY_BEGIN_MESSAGE 1 -#define SYSTEM_TRAY_CANCEL_MESSAGE 2 - -#include <xcb/xcb_keysyms.h> - -#define DEBUG 0 - -// Also keep the root window/screen around for use in the filters -namespace L_XCB{ - xcb_screen_t *root_screen; - xcb_window_t root; -} - -//Constructor for the Event Filter wrapper -EventFilter::EventFilter() : QObject(){ - XCB = new LXCB(); - EF = new XCBEventFilter(this); - L_XCB::root_screen = xcb_aux_get_screen(QX11Info::connection(), QX11Info::appScreen()); - L_XCB::root = L_XCB::root_screen->root; - WMFlag = 0; -} - -void EventFilter::start(){ - if(DEBUG){ qDebug() << " - Install event filter..."; } - QCoreApplication::instance()->installNativeEventFilter(EF); - if(DEBUG){ qDebug() << " - Run request check..."; } - if(!XCB->setupEventsForRoot()){ - qCritical() << "[ERROR] Unable to setup WM event retrieval. Is another WM running?"; - exit(1); - } - if(DEBUG){ qDebug() << " - Create WM ID Window"; } - WMFlag = XCB->WM_CreateWindow(); - XCB->setupEventsForRoot(WMFlag); - XCB->WM_Set_Supporting_WM(WMFlag); - - XCB->WM_Set_Root_Supported(); //announce all the various options that the WM supports - static_cast<XCBEventFilter*>(EF)->startSystemTray(); - - QCoreApplication::instance()->flush(); -} - -void EventFilter::stop(){ - static_cast<XCBEventFilter*>(EF)->stopSystemTray(); -} - -//Session Interaction/Information -QList<WId> EventFilter::currentTrayApps(){ - return static_cast<XCBEventFilter*>(EF)->trayApps(); -} - -unsigned int EventFilter::currentWorkspace(){ -return XCB->CurrentWorkspace(); -} - -QList<NativeWindow*> EventFilter::currentWindows(){ - return static_cast<XCBEventFilter*>(EF)->windowList(); -} - -// === PUBLIC SLOTS === -void EventFilter::RegisterVirtualRoot(WId id){ - XCB->WM_Set_Virtual_Roots( QList<WId>() << id ); -} - -void EventFilter::TryCloseWindow(WId id){ - XCB->WM_CloseWindow(id, false); //do not force close -} - -void EventFilter::TryActivateWindow(WId id){ - XCB->WM_Set_Active_Window(id); -} -//============================= -// XCBEventFilter Class -//============================= - -//Constructor for the XCB event filter -XCBEventFilter::XCBEventFilter(EventFilter *parent) : QAbstractNativeEventFilter(){ - obj = parent; - SystemTrayID = 0; - TrayDmgID = 0; - InitAtoms(); -} - -void XCBEventFilter::InitAtoms(){ - //Initialize any special atoms that we need to save/use regularly - //NOTE: All the EWMH atoms are already saved globally in obj->XCB->EWMH - WinNotifyAtoms.clear(); - WinNotifyAtoms << obj->XCB->EWMH._NET_WM_NAME \ - << obj->XCB->EWMH._NET_WM_VISIBLE_NAME \ - << obj->XCB->EWMH._NET_WM_ICON_NAME \ - << obj->XCB->EWMH._NET_WM_VISIBLE_ICON_NAME \ - << obj->XCB->EWMH._NET_WM_ICON \ - << obj->XCB->EWMH._NET_WM_ICON_GEOMETRY; - - SysNotifyAtoms.clear(); - SysNotifyAtoms << obj->XCB->EWMH._NET_CLIENT_LIST \ - << obj->XCB->EWMH._NET_CLIENT_LIST_STACKING \ - << obj->XCB->EWMH._NET_CURRENT_DESKTOP \ - << obj->XCB->EWMH._NET_WM_STATE \ - << obj->XCB->EWMH._NET_ACTIVE_WINDOW \ - << obj->XCB->EWMH._NET_WM_ICON \ - << obj->XCB->EWMH._NET_WM_ICON_GEOMETRY; - - //_NET_SYSTEM_TRAY_OPCODE - xcb_intern_atom_cookie_t cookie = xcb_intern_atom(QX11Info::connection(), 0, 23,"_NET_SYSTEM_TRAY_OPCODE"); - xcb_intern_atom_reply_t *r = xcb_intern_atom_reply(QX11Info::connection(), cookie, NULL); - if(r){ - _NET_SYSTEM_TRAY_OPCODE = r->atom; - free(r); - } -} - -//This function format taken directly from the Qt5.3 documentation -bool XCBEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *){ - //if(stopping){ return false; } //don't do any parsing - //qDebug() << "New Event"; - bool stopevent = false; - if(eventType=="xcb_generic_event_t"){ - //Convert to known event type (for X11 systems) - xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message); - //Now parse the event and emit signals as necessary - switch( ev->response_type & ~0x80){ -//============================== -// INTERACTIVITY EVENTS -//============================== - case XCB_KEY_PRESS: - //This is a keyboard key press - //qDebug() << "Key Press Event"; - stopevent = BlockInputEvent( ((xcb_key_press_event_t *) ev)->root ); //use the main "root" window - not the child widget - if(!stopevent){ obj->emit KeyPressed( InputWindow(((xcb_key_press_event_t *) ev)->root), ((xcb_key_press_event_t *) ev)->detail ); } - break; - case XCB_KEY_RELEASE: - //This is a keyboard key release - //qDebug() << "Key Release Event"; - stopevent = BlockInputEvent( ((xcb_key_release_event_t *) ev)->root ); //use the main "root" window - not the child widget - if(!stopevent){ obj->emit KeyReleased( InputWindow(((xcb_key_release_event_t *) ev)->root), ((xcb_key_release_event_t *) ev)->detail ); } - break; - case XCB_BUTTON_PRESS: - //This is a mouse button press - qDebug() << "Button Press Event"; - stopevent = BlockInputEvent( ((xcb_button_press_event_t *) ev)->root ); //use the main "root" window - not the child widget - if(!stopevent){ - //Activate the window right now if needed - obj->emit MousePressed( InputWindow(((xcb_button_press_event_t *) ev)->root), MouseKey(((xcb_key_press_event_t *) ev)->detail) ); - if(obj->XCB->WM_Get_Active_Window()!=((xcb_button_press_event_t *) ev)->root){ - obj->XCB->WM_Set_Active_Window( ((xcb_button_press_event_t *) ev)->root); - } - } - break; - case XCB_BUTTON_RELEASE: - //This is a mouse button release - qDebug() << "Button Release Event"; - //xcb_button_release_event_t *tmp = (xcb_button_release_event_t *)ev; - stopevent = BlockInputEvent( ((xcb_button_release_event_t *) ev)->root ); //use the main "root" window - not the child widget - if(!stopevent){ obj->emit MouseReleased( InputWindow(((xcb_button_release_event_t *) ev)->root), MouseKey(((xcb_key_press_event_t *) ev)->detail) ); } - break; - case XCB_MOTION_NOTIFY: - //This is a mouse movement event - //qDebug() << "Motion Notify Event"; - stopevent = BlockInputEvent( ((xcb_motion_notify_event_t *) ev)->root ); //use the main "root" window - not the child widget); - break; - case XCB_ENTER_NOTIFY: - //This is a mouse movement event when mouse goes over a new window - //qDebug() << "Enter Notify Event"; - stopevent = BlockInputEvent( ((xcb_enter_notify_event_t *) ev)->root ); - break; - case XCB_LEAVE_NOTIFY: - //This is a mouse movement event when mouse goes leaves a window - //qDebug() << "Leave Notify Event"; - stopevent = BlockInputEvent(); - break; -//============================== - case XCB_EXPOSE: - //qDebug() << "Expose Notify Event:"; - //qDebug() << " - Given Window:" << ((xcb_property_notify_event_t*)ev)->window; - break; -//============================== - case XCB_MAP_NOTIFY: - //qDebug() << "Window Map Event:" << ((xcb_map_notify_event_t *)ev)->window; - if(Lumina::SS->isLocked()){ waitingToShow << ((xcb_map_notify_event_t *)ev)->window ; } - else{ - for(int i=0; i<windows.length(); i++){ - if(windows[i]->id() == ((xcb_map_notify_event_t *)ev)->window){ windows[i]->setProperty(NativeWindow::Visible, true); break; } - } - } - break; //This is just a notification that a window was mapped - nothing needs to change here - case XCB_MAP_REQUEST: - //qDebug() << "Window Map Request Event"; - SetupNewWindow( ((xcb_map_request_event_t *) ev) ); - break; -//============================== - case XCB_CREATE_NOTIFY: - //qDebug() << "Window Create Event"; - break; -//============================== - case XCB_UNMAP_NOTIFY: - //qDebug() << "Window Unmap Event:" << ((xcb_unmap_notify_event_t *)ev)->window; - if(waitingToShow.contains(((xcb_unmap_notify_event_t *)ev)->window)){ waitingToShow.removeAll(((xcb_unmap_notify_event_t *)ev)->window); } - for(int i=0; i<windows.length(); i++){ - if(windows[i]->id() == ((xcb_unmap_notify_event_t *)ev)->window){ windows[i]->setProperty(NativeWindow::Visible, false); break; } - } - break; -//============================== - case XCB_DESTROY_NOTIFY: - //qDebug() << "Window Closed Event:" << ((xcb_destroy_notify_event_t *)ev)->window; - if( !rmTrayApp( ((xcb_destroy_notify_event_t *) ev)->window ) ){ - //qDebug() <<" - Non-tray window"; - for(int i=0; i<windows.length(); i++){ - if(windows[i]->id() == ((xcb_destroy_notify_event_t *)ev)->window){ - windows[i]->emit WindowClosed(windows[i]->id()); - QTimer::singleShot(500, windows.takeAt(i), SLOT(deleteLater()) ); //give a few moments first, then clean up the object - break; - } - } - } - break; -//============================== - case XCB_FOCUS_IN: - //qDebug() << "Focus In Event:"; - break; -//============================== - case XCB_FOCUS_OUT: - //qDebug() << "Focus Out Event:"; - break; -//============================== - case XCB_PROPERTY_NOTIFY: - //qDebug() << "Property Notify Event:"; - ParsePropertyEvent((xcb_property_notify_event_t*)ev); - break; -//============================== - case XCB_CLIENT_MESSAGE: - //qDebug() << "Client Message Event"; - //qDebug() << " - Given Window:" << ((xcb_client_message_event_t*)ev)->window; - if( ((xcb_client_message_event_t*)ev)->type == _NET_SYSTEM_TRAY_OPCODE && ((xcb_client_message_event_t*)ev)->format == 32){ - //data32[0] is timestamp, [1] is opcode, [2] is window handle - if(SYSTEM_TRAY_REQUEST_DOCK == ((xcb_client_message_event_t*)ev)->data.data32[1]){ - addTrayApp( ((xcb_client_message_event_t*)ev)->data.data32[2] ); - } - //Ignore the System Tray messages at the moment - - } - break; -//============================== - case XCB_CONFIGURE_NOTIFY: - //qDebug() << "Configure Notify Event"; - break; -//============================== - case XCB_CONFIGURE_REQUEST: - //qDebug() << "Configure Request Event"; - break; -//============================== - case XCB_SELECTION_CLEAR: - //qDebug() << "Selection Clear Event"; - break; -//============================== - case 85: //not sure what event this is - but it seems to come up very often (just hide the notice) - case 0: - case XCB_GE_GENERIC: - break; //generic event - don't do anything special - default: - //if( (ev->response_type & ~0x80)==TrayDmgID){ - checkDamageID( ((xcb_damage_notify_event_t*)ev)->drawable ); - //}else{ - qDebug() << "Default Event:" << (ev->response_type & ~0x80); - //} -//============================== - } - } - return false; - //never stop event handling (this will not impact the X events themselves - just the internal screensaver/WM/widgets) -} - -//System Tray Functions -QList<WId> XCBEventFilter::trayApps(){ - //return the list of all current tray apps - //Check the validity of all the current tray apps (make sure nothing closed erratically) - for(int i=0; i<RunningTrayApps.length(); i++){ - if(obj->XCB->WindowClass(RunningTrayApps[i]).isEmpty()){ - obj->emit Tray_AppClosed(RunningTrayApps.takeAt(i) ); - i--; - } - } - return RunningTrayApps; -} - -bool XCBEventFilter::startSystemTray(){ - if(SystemTrayID != 0){ return true; } //already started - RunningTrayApps.clear(); //nothing running yet - SystemTrayID = obj->XCB->startSystemTray(0); - if(SystemTrayID!=0){ - obj->XCB->SelectInput(SystemTrayID); //make sure TrayID events get forwarded here - TrayDmgID = obj->XCB->GenerateDamageID(SystemTrayID); - qDebug() << "System Tray Started Successfully"; - if(DEBUG){ qDebug() << " - System Tray Flags:" << TrayDmgID; } - } - return (SystemTrayID!=0); -} - -bool XCBEventFilter::stopSystemTray(){ - if(SystemTrayID==0){ return true; } //already stopped - qDebug() << "Stopping system tray..."; - //Close all the running Tray Apps - QList<WId> tmpApps = RunningTrayApps; - //RunningTrayApps.clear(); //clear this ahead of time so tray's do not attempt to re-access the apps - //Close all the running tray apps - for(int i=0; i<tmpApps.length(); i++){ - qDebug() << " - Stopping tray app:" << obj->XCB->WindowClass(tmpApps[i]); - //Tray apps are special and closing the window does not close the app - obj->XCB->KillClient(tmpApps[i]); - } - //Now close down the tray backend - obj->XCB->closeSystemTray(SystemTrayID); - SystemTrayID = 0; - TrayDmgID = 0; - return true; -} - -QList<NativeWindow*> XCBEventFilter::windowList(){ - return windows; -} - -//========= -// PRIVATE -//========= -bool XCBEventFilter::BlockInputEvent(WId){ - //Checks the current state of the WM and sets the stop flag as needed - // - Always let the screensaver know about the event first (need to reset timers and such) - obj->emit NewInputEvent(); - // - Check the state of the screensaver - if(Lumina::SS->isLocked()){ qDebug() << "SS Locked"; return true; } - // - Check the state of any fullscreen apps - /*else if( win!=0 && !obj->FS_WINS.isEmpty()){ - if(!obj->FS_WINS.contains(win) ){ - //If this event is for an app underneath a fullscreen window - stop it - if(obj->FS_WINS.length() == QApplication::desktop()->screenCount()){ qDebug() << "Screens Covered"; return true; } //all screens covered right now - } - }*/ - return false; -} - -WId XCBEventFilter::InputWindow(WId win){ - //check window and see if it is a desktop/root window (return 0) or an external app window - if(win == L_XCB::root){ return 0; } - QString cl = obj->XCB->WindowClass(win); - qDebug() << "Got Input Event on window:" << cl; - if(cl.toLower()=="lumina-desktop"){ return 0; } - return win; //external app window -} - -Lumina::MouseButton XCBEventFilter::MouseKey(int keycode){ - switch(keycode){ - case 1: - return Lumina::LeftButton; - case 3: - return Lumina::RightButton; - case 2: - return Lumina::MidButton; - case 4: - return Lumina::WheelUp; - case 5: - return Lumina::WheelDown; - case 6: - return Lumina::WheelLeft; - case 7: - return Lumina::WheelRight; - case 8: - return Lumina::BackButton; //Not sure if this is correct yet (1/27/17) - case 9: - return Lumina::ForwardButton; //Not sure if this is correct yet (1/27/17) - default: - return Lumina::NoButton; - } -} - -//System Tray functions -void XCBEventFilter::addTrayApp(WId win){ - if(SystemTrayID==0){ return; } - if(RunningTrayApps.contains(win)){ return; } //already managed - qDebug() << "Session Tray: Window Added" << obj->XCB->WindowClass(win); - RunningTrayApps << win; - if(DEBUG){ qDebug() << "Tray List Changed"; } - obj->emit Tray_AppAdded(win); -} - -bool XCBEventFilter::rmTrayApp(WId win){ - //returns "true" if the tray app was found and removed - if(SystemTrayID==0){ return false; } - for(int i=0; i<RunningTrayApps.length(); i++){ - if(win==RunningTrayApps[i]){ - qDebug() << "Session Tray: Window Removed"; - RunningTrayApps.removeAt(i); - obj->emit Tray_AppClosed(win); - return true; - } - } - return false; -} - -void XCBEventFilter::checkDamageID(WId id){ - if(RunningTrayApps.contains(id)){ - obj->emit Tray_AppUpdated(id); - }else{ - //Could check for window damage ID's - but we should not need this - } -} - -// WINDOW HANDLING FUNCTIONS -void XCBEventFilter::SetupNewWindow(xcb_map_request_event_t *ev){ - WId win = ev->window; - - bool ok = obj->XCB->WM_ManageWindow(win, true); - //Quick check if this is a transient window if we could not manage it directly - if(!ok){ - WId tran = obj->XCB->WM_ICCCM_GetTransientFor(win); - if(tran!=win && tran!=0){ - win = tran; - ok = obj->XCB->WM_ManageWindow(win); - } - } - qDebug() << "New Window:" << win << obj->XCB->WM_ICCCM_GetClass(win) << " Managed:" << ok; - obj->XCB->WM_Set_Active_Window(win); - //Determing the requested geometry/location/management within the event, - NativeWindow *nwin = new NativeWindow(win); - QObject::connect(nwin, SIGNAL(RequestClose(WId)), obj, SLOT(TryCloseWindow(WId)) ); - QObject::connect(nwin, SIGNAL(RequestActivate(WId)), obj, SLOT(TryActivateWindow(WId)) ); - windows << nwin; - bool show_now = !Lumina::SS->isLocked(); - if(!show_now){ waitingToShow << win; } //add to the list to get set visible later - //populate the native window settings as they are right now - nwin->setProperty(NativeWindow::Active, true); - nwin->setProperty(NativeWindow::Visible, show_now); - nwin->setProperty(NativeWindow::Workspace, obj->XCB->CurrentWorkspace()); - icccm_size_hints hints = obj->XCB->WM_ICCCM_GetNormalHints(win); - if(!hints.isValid()){ hints = obj->XCB->WM_ICCCM_GetSizeHints(win); } - if(hints.validMinSize()){ nwin->setProperty(NativeWindow::MinSize, QSize(hints.min_width,hints.min_height)); } - if(hints.validMaxSize()){ nwin->setProperty(NativeWindow::MaxSize, QSize(hints.max_width,hints.max_height)); } - if(hints.validBaseSize()){ nwin->setProperty(NativeWindow::Size, QSize(hints.base_width,hints.base_height)); } - else if(hints.validSize()){ nwin->setProperty(NativeWindow::Size, QSize(hints.width, hints.height)); } - nwin->setProperty(NativeWindow::Icon, obj->XCB->WM_Get_Icon(win)); - QString title = obj->XCB->WM_Get_Name(win); - if(title.isEmpty()){ title = obj->XCB->WM_Get_Visible_Name(win); } - if(title.isEmpty()){ title = obj->XCB->WM_ICCCM_GetName(win); } - nwin->setProperty(NativeWindow::Title, title); - title = obj->XCB->WM_Get_Icon_Name(win); - if(title.isEmpty()){ title = obj->XCB->WM_Get_Visible_Icon_Name(win); } - if(title.isEmpty()){ title = obj->XCB->WM_ICCCM_GetIconName(win); } - nwin->setProperty(NativeWindow::ShortTitle, title); - - obj->emit WindowCreated(nwin); -} - -void XCBEventFilter::ParsePropertyEvent(xcb_property_notify_event_t *ev){ - //First find the NativeWindow associated with the event - NativeWindow *nwin = 0; - for(int i=0; i<windows.length() && nwin==0; i++){ - if(windows[i]->id() == ev->window){ nwin = windows[i]; } - } - if(nwin==0){ return; } //unmanaged window - ignore this event - qDebug() << "Got Property Event:" << ev->window << ev->atom; - //Now determine which properties are getting changed, and update the native window as appropriate - if(ev->atom == obj->XCB->EWMH._NET_WM_NAME){ - qDebug() << " - Found _NET_WM_NAME atom"; - nwin->setProperty(NativeWindow::Title, obj->XCB->WM_Get_Name(nwin->id())); - }else if(ev->atom == obj->XCB->EWMH._NET_WM_ICON){ - qDebug() << " - Found _NET_WM_ICON atom"; - nwin->setProperty(NativeWindow::Icon, obj->XCB->WM_Get_Icon(nwin->id())); - }else if(ev->atom == obj->XCB->EWMH._NET_WM_ICON_NAME){ - qDebug() << " - Found _NET_WM_ICON_NAME atom"; - nwin->setProperty(NativeWindow::ShortTitle, obj->XCB->WM_Get_Icon_Name(nwin->id())); - }else if(ev->atom == obj->XCB->EWMH._NET_WM_DESKTOP){ - qDebug() << " - Found _NET_WM_DESKTOP atom"; - nwin->setProperty(NativeWindow::Workspace, obj->XCB->WM_Get_Desktop(nwin->id())); - }else if(ev->atom == obj->XCB->EWMH._NET_WM_WINDOW_TYPE ){ - qDebug() << " - Found _NET_WM_WINDOW_TYPE atom"; - - }else if( ev->atom == obj->XCB->EWMH._NET_WM_STATE){ - qDebug() << " - Found _NET_WM_STATE atom"; - - } - -} diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LXcbEventFilter.h b/src-qt5/core/lumina-desktop-unified/src-events/LXcbEventFilter.h deleted file mode 100644 index 9f2530e8..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-events/LXcbEventFilter.h +++ /dev/null @@ -1,151 +0,0 @@ -//=========================================== -// Lumina-DE source code -// Copyright (c) 2012-2017, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -// This class provides the XCB event handling/registrations that are needed -//=========================================== -#ifndef _LUMINA_DESKTOP_XCB_FILTER_H -#define _LUMINA_DESKTOP_XCB_FILTER_H - -#include "global-includes.h" - - -/* -List of XCB response types (since almost impossible to find good docs on XCB) -switch (xcb_generic_event_t*->response_type & ~0x80) -case values: -XCB_KEY_[PRESS | RELEASE] -XCB_BUTTON_[PRESS | RELEASE] -XCB_MOTION_NOTIFY -XCB_ENTER_NOTIFY -XCB_LEAVE_NOTIFY -XCB_FOCUS_[IN | OUT] -XCB_KEYMAP_NOTIFY -XCB_EXPOSE -XCB_GRAPHICS_EXPOSURE -XCB_VISIBILITY_NOTIFY -XCB_CREATE_NOTIFY -XCB_DESTROY_NOTIFY -XCB_UNMAP_NOTIFY -XCB_MAP_[NOTIFY | REQUEST] -XCB_REPARENT_NOTIFY -XCB_CONFIGURE_[NOTIFY | REQUEST] -XCB_GRAVITY_NOTIFY -XCB_RESIZE_REQUEST -XCB_CIRCULATE_[NOTIFY | REQUEST] -XCB_PROPERTY_NOTIFY -XCB_SELECTION_[CLEAR | REQUEST | NOTIFY] -XCB_COLORMAP_NOTIFY -XCB_CLIENT_MESSAGE -*/ - - -class EventFilter : public QObject{ - Q_OBJECT -private: - QAbstractNativeEventFilter* EF; - WId WMFlag; //used to flag a running WM process - -public: - EventFilter(); - ~EventFilter(){} - - void start(); - void stop(); - - //Public System Tray Functions - QList<WId> currentTrayApps(); - - //Public Session Interaction Functions - unsigned int currentWorkspace(); - - //Public Window Management Lists - QList<NativeWindow*> currentWindows(); //always returned in creation-order (oldest first) - - //Variables/Functions needed by the XCBEventFilter class only (not really needed by anything else) - LXCB *XCB; //used to interact with the X11 graphics subsystem - -public slots: - void RegisterVirtualRoot(WId); - void TryCloseWindow(WId); - void TryActivateWindow(WId); - -signals: - void NewInputEvent(); - void WindowCreated(NativeWindow*); - - // Session Signals - void WorkspaceChanged(unsigned int); - - // System Tray Signals - void Tray_AppAdded(WId); //new tray app registered - void Tray_AppClosed(WId); //tray app de-registered - void Tray_AppUpdated(WId); //tray app appearance changed (damage event) - // Shortcut Signals - void KeyPressed(WId, int); - void KeyReleased(WId, int); - void MousePressed(WId, Lumina::MouseButton); - void MouseReleased(WId, Lumina::MouseButton); -}; - -class XCBEventFilter : public QAbstractNativeEventFilter{ -public: - XCBEventFilter(EventFilter *parent); - ~XCBEventFilter(){} - - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *); - - //System Tray Functions - QList<WId> trayApps(); //return the list of all current tray apps - bool startSystemTray(); - bool stopSystemTray(); - - //Window List Functions - QList<NativeWindow*> windowList(); - -private: - EventFilter *obj; - QList<xcb_atom_t> WinNotifyAtoms, SysNotifyAtoms; - xcb_atom_t _NET_SYSTEM_TRAY_OPCODE; - void InitAtoms(); - - bool BlockInputEvent(WId win = 0); //Checks the current state of the system to see if the event should be stopped - WId InputWindow(WId win = 0); //Checks the window ID and determines if this is an external window or returns 0 (for desktop/root windows) - Lumina::MouseButton MouseKey(int keycode); //convert the keycode into the mouse button code - - - //System Tray Variables - WId SystemTrayID; - int TrayDmgID; - QList<WId> RunningTrayApps; - //System Tray functions - void addTrayApp(WId); - bool rmTrayApp(WId); //returns "true" if the tray app was found and removed - void checkDamageID(WId); - - //Window List Variables - QList<NativeWindow*> windows; - QList<WId> waitingToShow; - - //Longer Event handling functions - void SetupNewWindow(xcb_map_request_event_t *ev); - - //bool ParseKeyPressEvent(); - //bool ParseKeyReleaseEvent(); - //bool ParseButtonPressEvent(); - //bool ParseButtonReleaseEvent(); - //bool ParseMotionEvent(); - void ParsePropertyEvent(xcb_property_notify_event_t *ev); - //bool ParseClientMessageEvent(); - //bool ParseDestroyEvent(); - //bool ParseConfigureEvent(); - //bool ParseKeySelectionClearEvent(); - - - - -}; - -#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-events/events.pri b/src-qt5/core/lumina-desktop-unified/src-events/events.pri index 9eec91ca..48d500ed 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/events.pri +++ b/src-qt5/core/lumina-desktop-unified/src-events/events.pri @@ -1,6 +1,6 @@ -SOURCES *= $${PWD}/LXcbEventFilter.cpp +#SOURCES *= $${PWD}/LXcbEventFilter.cpp -HEADERS *= $${PWD}/LXcbEventFilter.h +#HEADERS *= $${PWD}/LXcbEventFilter.h #Shortcut event files SOURCES *= $${PWD}/LShortcutEvents.cpp diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp index cdcf2434..0ff70142 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp @@ -10,17 +10,15 @@ #include <unistd.h> #define NUMTRIES 3 -//#define WAITMINS 1 #define DEBUG 1 LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScreen()){ ui->setupUi(this); waittime = new QTimer(this); - //waittime->setInterval(WAITMINS*60000); //(too many attempts in short time) waittime->setSingleShot(true); refreshtime = new QTimer(this); //timer to update the wait time display refreshtime->setInterval(6000); //6 seconds (1/10 second) - + 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()) ); @@ -30,7 +28,7 @@ LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScr } LLockScreen::~LLockScreen(){ - + } void LLockScreen::LoadSystemDetails(){ @@ -47,7 +45,7 @@ void LLockScreen::aboutToHide(){ ui->line_password->clear(); ui->line_password->clearFocus(); if(refreshtime->isActive()){ refreshtime->stop(); } -} +} void LLockScreen::aboutToShow(){ if(!waittime->isActive()){ @@ -61,21 +59,17 @@ void LLockScreen::aboutToShow(){ UpdateLockInfo(); ui->line_password->clear(); ui->line_password->setFocus(); -} +} // ================= // PRIVATE SLOTS // ================= void LLockScreen::UpdateLockInfo(){ QString info; - /*if(triesleft>0 && triesleft<NUMTRIES ){ - if(triesleft==1){info = tr("1 Attempt Left"); } - else{info = QString(tr("%1 Attempts Left")).arg(QString::number(triesleft)); } - }else*/ - if(waittime->isActive()){ + if(waittime->isActive()){ info = tr("Too Many Failures")+"\n"+ QString(tr("Wait %1 Minutes")).arg( QString::number(qRound(waittime->remainingTime()/6000.0)/10.0) ); }else if(attempts>0){ info.append("\n"+QString(tr("Failed Attempts: %1")).arg(QString::number(attempts)) ); } - ui->label_info->setText(info); + ui->label_info->setText(info); } void LLockScreen::TryUnlock(){ @@ -89,11 +83,11 @@ void LLockScreen::TryUnlock(){ this->setEnabled(true); }else{ triesleft--; - if(triesleft>0){ + if(triesleft>0){ this->setEnabled(true); - }else{ + }else{ waittime->setInterval( (attempts/NUMTRIES)*60000); - waittime->start(); + waittime->start(); refreshtime->start(); } ui->line_password->setFocus(); diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp index 3dcbf85e..bfcfa54d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp @@ -8,7 +8,7 @@ #include <QScreen> #include <QApplication> -#define DEBUG 1 +#define DEBUG 0 LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint){ starttimer = new QTimer(this); @@ -17,7 +17,7 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo locktimer->setSingleShot(true); hidetimer = new QTimer(this); hidetimer->setSingleShot(true); - + LOCKER = new LLockScreen(this); LOCKER->hide(); settings = new QSettings("lumina-desktop","lumina-screensaver",this); @@ -33,7 +33,7 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo } LScreenSaver::~LScreenSaver(){ - + } bool LScreenSaver::isLocked(){ @@ -66,7 +66,7 @@ void LScreenSaver::reloadSettings(){ hidetimer->setInterval( settings->value("hidesecs",15).toInt() * 1000 ); } -void LScreenSaver::newInputEvent(){ +void LScreenSaver::newInputEvent(){ if(updating){ return; } //in the middle of making changes which could cause an event if(DEBUG){ qDebug() << "New Input Event"; } if(SSRunning && SSLocked){ @@ -79,7 +79,6 @@ void LScreenSaver::newInputEvent(){ HideScreenSaver(); } UpdateTimers(); - } void LScreenSaver::LockScreenNow(){ @@ -119,7 +118,7 @@ void LScreenSaver::ShowScreenSaver(){ if(!this->isActiveWindow()){ this->raise(); this->show(); - this->activateWindow(); + this->activateWindow(); } for(int i=0; i<BASES.length(); i++){ BASES[i]->show(); @@ -149,10 +148,11 @@ void LScreenSaver::HideScreenSaver(){ if(!SSLocked){ this->hide(); emit ClosingScreenSaver(); + emit LockStatusChanged(false); } - for(int i=0; i<BASES.length(); i++){ + for(int i=0; i<BASES.length(); i++){ BASES[i]->hide(); - BASES[i]->stopPainting(); + BASES[i]->stopPainting(); } UpdateTimers(); } @@ -171,6 +171,7 @@ void LScreenSaver::LockScreen(){ if(SSLocked){ return; } if(DEBUG){ qDebug() << "Locking Screen:" << QDateTime::currentDateTime().toString(); } SSLocked = true; + emit LockStatusChanged(true); LOCKER->LoadSystemDetails(); UpdateTimers(); } @@ -178,6 +179,7 @@ void LScreenSaver::LockScreen(){ void LScreenSaver::SSFinished(){ if(DEBUG){ qDebug() << "Screensaver Finished:" << QDateTime::currentDateTime().toString(); } SSLocked = false; + emit LockStatusChanged(false); HideLockScreen(); HideScreenSaver(); } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h index d27db37e..18f12fab 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h @@ -19,7 +19,7 @@ public: ~LScreenSaver(); bool isLocked(); - + private: QTimer *starttimer, *locktimer, *hidetimer; QSettings *settings; @@ -48,6 +48,7 @@ private slots: signals: void StartingScreenSaver(); void ClosingScreenSaver(); + void LockStatusChanged(bool locked); protected: void mouseMoveEvent(QMouseEvent*){ diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp index 943fe0a1..b31ef793 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp @@ -25,7 +25,7 @@ SSBaseWidget::SSBaseWidget(QWidget *parent, QSettings *set) : QWidget(parent){ SSBaseWidget::~SSBaseWidget(){ if(ANIM!=0){ this->stopPainting(); } } - + void SSBaseWidget::setPlugin(QString plug){ plug = plug.toLower(); if(validPlugs.contains(plug) || plug=="random"){ plugType = plug; } @@ -38,12 +38,12 @@ void SSBaseWidget::setPlugin(QString plug){ void SSBaseWidget::startPainting(){ cplug = plugType; //free up any old animation instance - if(ANIM!=0){ + if(ANIM!=0){ ANIM->stop(); ANIM->clear(); - delete ANIM; ANIM = 0; - } + delete ANIM; ANIM = 0; + } //If a random plugin - grab one of the known plugins - if(cplug=="random"){ + if(cplug=="random"){ QStringList valid = BaseAnimGroup::KnownAnimations(); valid.removeAll("none"); //they want a screensaver - remove the "none" option from the valid list if(valid.isEmpty()){ cplug = "none"; } //no known plugins @@ -67,9 +67,9 @@ void SSBaseWidget::startPainting(){ } //Now start the animation(s) if(ANIM!=0){ - if(ANIM->animationCount()>0){ + if(ANIM->animationCount()>0){ if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); } - ANIM->start(); + ANIM->start(); } } } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp index 2abd1f90..017eaf9f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp @@ -9,6 +9,9 @@ //Include all the known subclasses here, then add a unique ID for it to the functions at the bottom //#include "SampleAnimation.h" #include "Fireflies.h" +#include "Grav.h" +#include "SampleAnimation.h" +#include "Text.h" //============================== // PLUGIN LOADING/LISTING @@ -17,14 +20,16 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti //This is where we place all the known plugin ID's, and load the associated subclass if(type=="fireflies"){ return (new FirefliesAnimation(parent,set)); - /*}else if(type == "sample"){ - return (new SampleAnimation(parent, set));*/ - }else{ + }else if(type == "grav") { + return (new GravAnimation(parent, set)); + }else if(type == "text") { + return (new TextAnimation(parent, set)); + }else { //Unknown screensaver, return a blank animation group return (new BaseAnimGroup(parent, set)); } } - + QStringList BaseAnimGroup::KnownAnimations(){ - return (QStringList() << "fireflies" << "none"); + return (QStringList() << "fireflies" << "grav" << "text"); } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h index 8798577f..b1324e78 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h @@ -26,13 +26,13 @@ public: canvas->setCursor( QCursor(Qt::BlankCursor) ); } ~BaseAnimGroup(){} - + //============================== // PLUGIN LOADING/LISTING (Change in the .cpp file) //============================== static BaseAnimGroup* NewAnimation(QString type, QWidget *parent, QSettings *set); static QStringList KnownAnimations(); - + }; #endif diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h index f1ef5fa3..75dfb1ae 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h @@ -46,7 +46,7 @@ public: fly = new QWidget(parent); range = parent->size(); maxX = range.width()/4; maxY = range.height()/4; - fly->setStyleSheet("background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(215, 215, 143, 255), stop:0.83871 rgba(221, 235, 64, 140), stop:1 rgba(0, 0, 0, 255));"); + fly->setStyleSheet("background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(215, 215, 143, 255), stop:0.83871 rgba(221, 235, 64, 140), stop:0.99 rgba(0, 0, 0, 255), stop:1 transparent);"); //setup the movement animation movement = new QPropertyAnimation(fly); movement->setTargetObject(fly); @@ -79,8 +79,8 @@ private: public: FirefliesAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} - ~FirefliesAnimation(){ - this->stop(); + ~FirefliesAnimation(){ + this->stop(); //while(fireflies.length()>0){ fireflies.takeAt(0)->deleteLater(); } } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h new file mode 100644 index 00000000..ad1b1122 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h @@ -0,0 +1,185 @@ +//=========================================== +// 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_SCREEN_SAVER_GRAV_ANIMATION_H +#define _LUMINA_DESKTOP_SCREEN_SAVER_GRAV_ANIMATION_H + +//PI is equal to 2*pi +#define PI 6.2832 + +#include "global-includes.h" +#include "BaseAnimGroup.h" +#include <QParallelAnimationGroup> +#include <QtMath> + +class Grav: public QParallelAnimationGroup{ + Q_OBJECT +private: + QWidget *planet; + QPropertyAnimation *orbit; + QSize range; + QList<QPoint> path; + double radius; + + void setupLoop(QPoint start, QPoint *ref){ + orbit->setStartValue(start); + + //Used to find overall speed. Distance from the planet to the sun + radius = qSqrt( (qPow(start.x()-ref->x(),2) + qPow(start.y()-ref->y(),2) )); + + //Number of frames in animation. Increase for smother motion + double step = 1000.0; + + //Random values that give the eliptical pattern to the orbit. Between 0.4 and 2.3 + double xrand = (qrand()%20+4)/10.0; + double yrand = (qrand()%20+4)/10.0; + + QPoint firstP = QPoint(ref->x() + xrand*start.x()*(qCos(0/step) -qSin(0/step)), ref->y() + yrand*start.y()*(qCos(0/step) -qSin(0/step))); + QPoint lastP = QPoint(ref->x() + xrand*start.x()*(qCos(PI/step) -qSin(PI/step)), ref->y() + yrand*start.y()*(qCos(PI/step) -qSin(PI/step))); + //orbit->setKeyValueAt(0, firstP); + //orbit->setKeyValueAt(1, lastP); + path.push_back(firstP); + + //Loops through all steps and creates all the points of the orbit + for(int i=1; i<step; i++) { + //Calculates the new point, including gravitational pull and eccentricity. Goes from 0 to 2PI in steps. + double newX = ref->x() + xrand*start.x()*(qCos((PI*i)/step) -qSin((PI*i)/step)); + double newY = ref->y() + yrand*start.y()*(qSin((PI*i)/step) + qCos((PI*i)/step)); + + //Calculates the radius from the sun as the distance between the points + radius = (qSqrt( (qPow(newX-ref->x(),2) + qPow(newY-ref->y(),2) ))); + + //Creates a new point and creates a key as part of the animation + QPoint newLoc = QPoint(newX, newY); + //orbit->setKeyValueAt(i/step, newLoc); + path.push_back(newLoc); + } + + //Sets the time for a full orbit. Increasing makes the orbit slower. + path.push_back(lastP); + } +private slots: + void LoopChanged(int loop){ + //Adjust the orbit animation a bit + if(loop >= 0) { + orbit->setStartValue(orbit->endValue()); //start at the previous end point + orbit->setEndValue(path.at(loop%1000)); + orbit->setDuration(10); + } + } + void stopped(){ qDebug() << "Planet stopped"; planet->hide();} + +public: + Grav(QWidget *parent) : QParallelAnimationGroup(parent){ + planet = new QWidget(parent); + range = parent->size(); + QPoint center = parent->geometry().center(); + + //Creates a random planet size. Between 12 and 45 pixels + double planet_radius = 1.75* ((qrand()%20)+7); + + //Creates a random color in RGB, then creates a circular gradient + QString color = "rgba(" + QString::number(qrand() % 256) + ", " + QString::number(qrand() % 256) + ", " + QString::number(qrand() % 256); + QString style = "background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 " + color+ + ", 255)" + " , stop:0.83871 " + color + ", 140)" + " , stop:0.99 rgba(0, 0, 0, 255), stop:1 transparent);"; + planet->setStyleSheet(style); + + //setup the orbit animation + orbit = new QPropertyAnimation(planet); + orbit->setPropertyName("pos"); + orbit->setTargetObject(planet); + + //Creates the random position of the planet, making sure it isn't too close to the sun + int randwidth = qrand()%(range.width()/2); + if(randwidth < range.width() + 100 and randwidth > range.width() - 100) randwidth = 100; + int randheight= qrand()%(range.height()/2); + if(randheight < range.height() + 100 and randheight > range.height() - 100) randheight = 100; + + //Creates all frames for the animation + setupLoop(QPoint(randwidth, randheight), ¢er); + this->addAnimation(orbit); + planet->show(); + + //Ensures the screensaver will not stop until the user wishes to login or it times out + this->setLoopCount(2000); //number of orbits + orbit->setEndValue(path.at(0)); + LoopChanged(0); //load initial values + + //Sets the initial size and location of the planet + planet->setGeometry(QRect(orbit->startValue().toPoint(), QSize(planet_radius, planet_radius))); + connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged(int)) ); + connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + } + ~Grav(){} + +}; + +class GravAnimation : public BaseAnimGroup{ + Q_OBJECT +private: + QList<Grav*> planets; + QWidget *sun; + QPropertyAnimation *wobble; + +private slots: + void checkFinished(){ + int running = 0; + for(int i=0; i<this->animationCount(); i++){ + if(this->animationAt(i)->state()==QAbstractAnimation::Running){ running++; } + } + if(running<=1){ wobble->stop(); emit wobble->finished();} + } + +public: + GravAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + ~GravAnimation(){ + //this->stop(); + } + + void LoadAnimations(){ + //Creates the sun, which is a thin shell with a gradient from green to yellow + sun = new QWidget(canvas); + QPoint center = canvas->geometry().center(); + QString sunstyle = QStringLiteral("background-color:qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, ") + + QStringLiteral("stop:0 rgba(0, 0, 0, 0), stop:0.38 rgba(0, 0, 0, 0), stop:0.4 rgba(82, 121, 76, 33), stop:0.5 rgba(159, 235, 148, 64), ") + + QStringLiteral("stop:0.6 rgba(255, 238, 150, 129), stop:0.7 rgba(0, 0, 0, 0));"); + sun->setStyleSheet(sunstyle); + + //Creates the sun's pulsing animation + wobble = new QPropertyAnimation(sun); + wobble->setPropertyName("geometry"); + wobble->setTargetObject(sun); + QRect initgeom = QRect(center-QPoint(12,12), QSize(60, 60)); + wobble->setStartValue(initgeom); + wobble->setKeyValueAt(0, initgeom ); //starting point + wobble->setKeyValueAt(1, initgeom ); //starting point + wobble->setKeyValueAt(0.5, QRect(center-QPoint(18,18), QSize(90, 90))); //starting point + wobble->setDuration(2000); + wobble->setLoopCount(-1); + this->addAnimation(wobble); + sun->show(); + sun->setGeometry(initgeom); + while(planets.length()>0){ planets.takeAt(0)->deleteLater(); } + + //Gives the screensaver a black background + canvas->setStyleSheet("background: black;"); + + //Pulls number of planets from settings, with 10 as default + int number = settings->value("planets/number",10).toInt(); + + //Loops through all planets and sets up the animations, then adds them to the base group and vector, which + for(int i=0; i<number; i++){ + if(planets.length()>number){ continue; } + Grav *tmp = new Grav(canvas); + this->addAnimation(tmp); + connect(tmp, SIGNAL(finished()), this, SLOT(checkFinished())); + planets << tmp; + } + while(planets.length()>number){planets.takeAt(number)->deleteLater(); } + } + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h index 972a5109..c2bb0c96 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h @@ -20,7 +20,7 @@ private: public: SampleAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} ~SampleAnimation(){ this->stop(); delete ball; } - + void LoadAnimations(){ //qDebug() << "Loading Sample Animation"; ball = new QWidget(canvas); diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h new file mode 100644 index 00000000..a4c49692 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h @@ -0,0 +1,93 @@ +//=========================================== +// 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_SCREEN_SAVER_Text_ANIMATION_H +#define _LUMINA_DESKTOP_SCREEN_SAVER_Text_ANIMATION_H + +//PI is equal to 2*pi +#define PI 6.2832 + +#include "global-includes.h" +#include "BaseAnimGroup.h" +#include <QParallelAnimationGroup> +#include <QtMath> + +class Text: public QParallelAnimationGroup{ + Q_OBJECT +private: + QLabel *text; + QPropertyAnimation *movement; + QSize range; + QPoint v; + bool bounce; + +private slots: + void LoopChanged(){ + movement->setStartValue(movement->endValue()); + QPoint currLoc = movement->startValue().toPoint(); + bounce = !(currLoc.y() < 100 or currLoc.y() > range.height()-100 or currLoc.x() > range.width()-100 or currLoc.x() < 100); + if((currLoc.y() < 10 or currLoc.y() > range.height()-40) and !bounce) { + v.setY((v.y() * -1) + (qrand() % 20 - 10)); + }else if((currLoc.x() > range.width()-10 or currLoc.x() < 10) and !bounce) { + v.setX((v.x() * -1) + (qrand() % 20 - 10)); + } + currLoc.setX(currLoc.x() + v.x()); + currLoc.setY(currLoc.y() + v.y()); + movement->setEndValue(currLoc); + } + void stopped(){ qDebug() << "text stopped"; text->hide();} + +public: + Text(QWidget *parent) : QParallelAnimationGroup(parent){ + text = new QLabel(parent); + range = parent->size(); + QPoint center = parent->geometry().center(); + + QString color = "rgba(" + QString::number(qrand() % 206 + 50) + ", " + QString::number(qrand() % 206 + 50) + ", " + QString::number(qrand() % 206 + 50); + text->setStyleSheet("QLabel {background-color: rgba(255, 255, 255, 10); color: " + color + "); }"); + text->setFont(QFont("Courier", 24, QFont::Bold)); + text->setText("test"); + QFontMetrics metrics(text->font()); + text->setMinimumSize(QSize( metrics.width(text->text())+10, metrics.height()*text->text().count("\n") +10)); + + movement = new QPropertyAnimation(text); + movement->setPropertyName("pos"); + movement->setTargetObject(text); + + this->addAnimation(movement); + text->show(); + v.setX((qrand() % 100 + 50) * qPow(-1, qrand() % 2)); + v.setY((qrand() % 100 + 50) * qPow(-1, qrand() % 2)); + movement->setStartValue(center); + //Ensures the screensaver will not stop until the user wishes to login or it times out + this->setLoopCount(2000); //number of movements + movement->setDuration(200); + movement->setEndValue(QPoint(qrand() % (int)range.height(), qrand() % range.width())); + LoopChanged(); //load initial values + + connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) ); + connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + } + ~Text(){} + +}; + +class TextAnimation : public BaseAnimGroup{ + Q_OBJECT +public: + TextAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + ~TextAnimation(){ + this->stop(); + } + + void LoadAnimations(){ + canvas->setStyleSheet("background: black;"); + Text *tmp = new Text(canvas); + this->addAnimation(tmp); + } + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri index 919ec4e0..35141a0e 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri @@ -1,7 +1,8 @@ SOURCES += $$PWD/BaseAnimGroup.cpp HEADERS += $$PWD/BaseAnimGroup.h \ -# $$PWD/SampleAnimation.h \ - $${PWD}/Fireflies.h - + $$PWD/SampleAnimation.h \ + $${PWD}/Fireflies.h \ + $${PWD}/Grav.h \ + $${PWD}/Text.h #FORMS += |