Skip to content

Commit

Permalink
Fix backgrounding and add code to autostart applications
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Sep 22, 2020
1 parent 333922b commit 486cefe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 5 additions & 3 deletions applications/system-service/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void Application::pause(bool startIfNone){
timer.restart();
delayUpTo(1000);
api->disconnectSignals(this, 2);
if(!timer.isValid()){
if(timer.isValid()){
qDebug() << "Application took too long to background" << name();
kill(m_process->processId(), SIGSTOP);
}else{
Expand Down Expand Up @@ -81,8 +81,10 @@ void Application::resume(){
kill(m_process->processId(), SIGUSR1);
delayUpTo(1000);
api->disconnectSignals(this, 1);
// No need to fall through, we've just assumed it continued
qDebug() << "Warning: application took too long to forground" << name();
if(timer.isValid()){
// No need to fall through, we've just assumed it continued
qDebug() << "Warning: application took too long to forground" << name();
}
m_backgrounded = false;
break;
case AppsAPI::Foreground:
Expand Down
3 changes: 2 additions & 1 deletion applications/system-service/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ private slots:
return instance;
}
void delayUpTo(int milliseconds){
timer.restart();
timer.invalidate();
timer.start();
while(timer.isValid() && !timer.hasExpired(milliseconds)){
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
Expand Down
8 changes: 8 additions & 0 deletions applications/system-service/appsapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class AppsAPI : public APIBase {
path = app->qPath();
}
m_startupApplication = path;
for(auto app : applications){
if(app->autoStart()){
app->launch();
if(app->type() == Backgroundable){
app->pause();
}
}
}
app->launch();
}
~AppsAPI() {
Expand Down

0 comments on commit 486cefe

Please sign in to comment.