diff --git a/src/servers/input/AddOnManager.cpp b/src/servers/input/AddOnManager.cpp index 38bd3ba115..3cadf738c8 100644 --- a/src/servers/input/AddOnManager.cpp +++ b/src/servers/input/AddOnManager.cpp @@ -735,7 +735,11 @@ AddOnManager::HandleSystemShuttingDown(BMessage* message, { CALLED(); - // TODO + device_info *pinfo; + for (fDeviceList.Rewind(); fDeviceList.GetNext(&pinfo);) { + pinfo->device->SystemShuttingDown(); + } + return B_OK; } diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 1309ce5998..bf66cc399c 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -366,8 +366,6 @@ InputServer::QuitRequested() if (!BApplication::QuitRequested()) return false; - PostMessage(SYSTEM_SHUTTING_DOWN); - fAddOnManager->SaveState(); gDeviceManager.SaveState(); diff --git a/src/servers/registrar/Jamfile b/src/servers/registrar/Jamfile index 3f2cf549f2..6523312a55 100644 --- a/src/servers/registrar/Jamfile +++ b/src/servers/registrar/Jamfile @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src servers registrar ; UsePrivateHeaders app ; +UsePrivateHeaders input ; UsePrivateHeaders kernel ; UsePrivateHeaders shared ; UsePrivateHeaders storage ; diff --git a/src/servers/registrar/ShutdownProcess.cpp b/src/servers/registrar/ShutdownProcess.cpp index 70725ebf71..460b01a42e 100644 --- a/src/servers/registrar/ShutdownProcess.cpp +++ b/src/servers/registrar/ShutdownProcess.cpp @@ -34,6 +34,7 @@ #include "AppInfoListMessagingTargetSet.h" #include "Debug.h" #include "EventQueue.h" +#include "InputServerTypes.h" #include "MessageDeliverer.h" #include "MessageEvent.h" #include "Registrar.h" @@ -703,7 +704,7 @@ ShutdownProcess::Init(BMessage *request) // get a list of all applications to shut down and sort them error = fRoster->GetShutdownApps(fUserApps, fSystemApps, fBackgroundApps, - fVitalSystemApps); + fVitalSystemApps, fInputServer); if (error != B_OK) { fRoster->RemoveWatcher(this); fRoster->SetShuttingDown(false); @@ -1263,6 +1264,14 @@ ShutdownProcess::_WorkerDoShutdown() // sync sync(); + // notify the input server we are shutting down + if (fInputServer.registration_time != 0) { + // The SYSTEM_SHUTTING_DOWN message is defined in InputServerTypes.h + BMessage message(SYSTEM_SHUTTING_DOWN); + SingleMessagingTargetSet target(fInputServer.port, B_PREFERRED_TOKEN); + MessageDeliverer::Default()->DeliverMessage(&message, target); + } + // phase 1: terminate the user apps _SetPhase(USER_APP_TERMINATION_PHASE); _QuitApps(fUserApps, false); diff --git a/src/servers/registrar/ShutdownProcess.h b/src/servers/registrar/ShutdownProcess.h index c20aedc4c7..df0bdf129f 100644 --- a/src/servers/registrar/ShutdownProcess.h +++ b/src/servers/registrar/ShutdownProcess.h @@ -13,6 +13,7 @@ #include "AppInfoList.h" #include "EventMaskWatcher.h" +#include "RosterAppInfo.h" #if __GNUC__ >= 4 using __gnu_cxx::hash_set; @@ -96,6 +97,7 @@ private: AppInfoList fSystemApps; AppInfoList fUserApps; AppInfoList fBackgroundApps; + RosterAppInfo fInputServer; TimeoutEvent *fTimeoutEvent; InternalEventList *fInternalEvents; sem_id fInternalEventSemaphore; diff --git a/src/servers/registrar/TRoster.cpp b/src/servers/registrar/TRoster.cpp index 8669f4276b..8d4f462d4d 100644 --- a/src/servers/registrar/TRoster.cpp +++ b/src/servers/registrar/TRoster.cpp @@ -1321,7 +1321,7 @@ TRoster::SetShuttingDown(bool shuttingDown) */ status_t TRoster::GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps, - AppInfoList &backgroundApps, hash_set &vitalSystemApps) + AppInfoList &backgroundApps, hash_set &vitalSystemApps, RosterAppInfo &inputServer) { BAutolock _(fLock); @@ -1353,8 +1353,10 @@ TRoster::GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps, // input server RosterAppInfo *info = fRegisteredApps.InfoFor("application/x-vnd.Be-input_server"); - if (info) + if (info) { + inputServer = *info; vitalSystemApps.insert(info->team); + } // debug server info = fRegisteredApps.InfoFor("application/x-vnd.haiku-debug-server"); diff --git a/src/servers/registrar/TRoster.h b/src/servers/registrar/TRoster.h index 13a683afd2..2256f69424 100644 --- a/src/servers/registrar/TRoster.h +++ b/src/servers/registrar/TRoster.h @@ -92,7 +92,8 @@ public: void SetShuttingDown(bool shuttingDown); status_t GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps, - AppInfoList &backgroundApps, hash_set &vitalSystemApps); + AppInfoList &backgroundApps, hash_set &vitalSystemApps, + RosterAppInfo &inputServer); status_t AddWatcher(Watcher *watcher); void RemoveWatcher(Watcher *watcher);