aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/LSession.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-06-27 08:20:14 -0400
committerKen Moore <ken@ixsystems.com>2017-06-27 08:20:14 -0400
commit79ed54ff31ed654b953d46987851ce4f572245c2 (patch)
treeb61de25f0ece7cfdb266f396a826b271c47ed0dd /src-qt5/core/lumina-desktop-unified/LSession.cpp
parentQuick fix for the mkport.sh script (diff)
downloadlumina-79ed54ff31ed654b953d46987851ce4f572245c2.tar.gz
lumina-79ed54ff31ed654b953d46987851ce4f572245c2.tar.bz2
lumina-79ed54ff31ed654b953d46987851ce4f572245c2.zip
Another large batch of re-organization for lumina-desktop-unified.
This gets the new "NativeWindowSystem" and associated Native* classes all integrated (untested)
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/LSession.cpp')
-rw-r--r--src-qt5/core/lumina-desktop-unified/LSession.cpp131
1 files changed, 93 insertions, 38 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp
index e511d7ad..c67156c6 100644
--- a/src-qt5/core/lumina-desktop-unified/LSession.cpp
+++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp
@@ -15,7 +15,9 @@
#endif
//Initialize all the global objects to null pointers
-EventFilter* Lumina::EFILTER = 0;
+NativeWindowSystem* Lumina::NWS = 0;
+NativeEventFilter* Lumina::NEF = 0;
+//EventFilter* Lumina::EFILTER = 0;
LScreenSaver* Lumina::SS = 0;
DesktopSettings* Lumina::SETTINGS = 0;
//Lumina::WM = 0;
@@ -42,32 +44,29 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu
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::NEF = new NativeEventFilter();
+ Lumina::NWS = new NativeWindowSystem();
+ //Lumina::EFILTER = new EventFilter(); //Need the XCB Event filter first
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
Lumina::EVThread = new QThread();
- Lumina::EFILTER->moveToThread(Lumina::EVThread);
+ Lumina::NEF->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(); }
@@ -106,35 +105,39 @@ void LSession::setupSession(){
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");
+ 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(); }
@@ -180,7 +183,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()) );
@@ -201,7 +204,7 @@ void LSession::CleanupSession(){
bool playaudio = Lumina::SETTINGS->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 +222,60 @@ 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()) );
+
+ //Root window connections
+ connect(Lumina::ROOTWIN, SIGNAL(RegisterVirtualRoot(WId)), Lumina::NWS, SLOT(RegisterVirtualRoot(WId)) );
+
+ //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(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(WId)), 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, int);), this, SLOT(KeyPress(WId, int)) );
+ connect(Lumina::NWS, SIGNAL(KeyReleaseDetected(WId, int)), this, SLOT(KeyRelease(WId, int)) );
+ connect(Lumina::NWS, SIGNAL(MousePressDetected(WId, NativeWindowSystem::MouseButton)), this, SLOT(MousePress(WId, NativeWindowSystem::MouseButton)) );
+ connect(Lumina::NWS, SIGNAL(MouseReleaseDetected(WId, NativeWindowSystem::MouseButton)), this, 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 +286,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 +312,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(){
@@ -275,32 +330,32 @@ void LSession::launchStartupApps(){
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()){
//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
bool changed = LDesktopUtils::checkUserFiles(OVS);
@@ -322,26 +377,26 @@ 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::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();
bgstack15