static void saveYourselfCallback(SmcConn connection, SmPointer client_data, int saveType, Bool shutdown, int interact_Style, Bool fast) { CompOption args[4]; args[0].type = CompOptionTypeInt; args[0].name = "save_type"; args[0].value.i = saveType; args[1].type = CompOptionTypeBool; args[1].name = "shutdown"; args[1].value.b = shutdown; args[2].type = CompOptionTypeInt; args[2].name = "interact_style"; args[2].value.i = interact_Style; args[3].type = CompOptionTypeBool; args[3].name = "fast"; args[3].value.b = fast; (*core.sessionEvent)(&core, CompSessionEventSaveYourself, args, 4); setCloneRestartCommands(connection); setRestartStyle(connection, SmRestartImmediately); setProgramInfo(connection, getpid(), getuid()); SmcSaveYourselfDone(connection, 1); }
static void saveYourselfCallback (SmcConn connection, SmPointer client_data, int saveType, Bool shutdown, int interact_Style, Bool fast) { CompOption::Vector args; args.push_back (CompOption ("save_type", CompOption::TypeInt)); args.push_back (CompOption ("shutdown", CompOption::TypeBool)); args.push_back (CompOption ("interact_style", CompOption::TypeInt)); args.push_back (CompOption ("fast", CompOption::TypeBool)); args[0].value ().set (saveType); args[1].value ().set ((bool) shutdown); args[2].value ().set (interact_Style); args[3].value ().set ((bool) fast); screen->sessionEvent (CompSession::EventSaveYourself, args); setCloneRestartCommands (connection); setRestartStyle (connection, SmRestartImmediately); setProgramInfo (connection, getpid (), getuid ()); SmcSaveYourselfDone (connection, 1); }
void CompSession::init (char *prevClientId) { static SmcCallbacks callbacks; if (getenv ("SESSION_MANAGER")) { char errorBuffer[1024]; iceInit (); callbacks.save_yourself.callback = saveYourselfCallback; callbacks.save_yourself.client_data = NULL; callbacks.die.callback = dieCallback; callbacks.die.client_data = NULL; callbacks.save_complete.callback = saveCompleteCallback; callbacks.save_complete.client_data = NULL; callbacks.shutdown_cancelled.callback = shutdownCancelledCallback; callbacks.shutdown_cancelled.client_data = NULL; smcConnection = SmcOpenConnection (NULL, NULL, SmProtoMajor, SmProtoMinor, SmcSaveYourselfProcMask | SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, &callbacks, prevClientId, &smClientId, sizeof (errorBuffer), errorBuffer); if (!smcConnection) compLogMessage ("core", CompLogLevelWarn, "SmcOpenConnection failed: %s", errorBuffer); else { connected = true; if (prevClientId) smPrevClientId = strdup (prevClientId); setRestartStyle (smcConnection, SmRestartImmediately); } } }
void closeSession(void) { if (connected) { setRestartStyle(smcConnection, SmRestartIfRunning); if (SmcCloseConnection(smcConnection, 0, NULL) != SmcConnectionInUse) connected = FALSE; if (smClientId) { free(smClientId); smClientId = NULL; } if (smPrevClientId) { free(smPrevClientId); smPrevClientId = NULL; } } }
void CompSession::close () { if (connected) { setRestartStyle (smcConnection, SmRestartIfRunning); if (SmcCloseConnection (smcConnection, 0, NULL) != SmcConnectionInUse) connected = false; if (smClientId) { free (smClientId); smClientId = NULL; } if (smPrevClientId) { free (smPrevClientId); smPrevClientId = NULL; } } }