X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fsession.c;h=ca45adb934e9b670e6b68b98f427e2fe6d9498d1;hb=d78ae0546dae17eda6084a1bd33e63637ba802e5;hp=267d17ef54ebb9582ca76b1f0ea5b2af8f308935;hpb=e1b4b9eb17b3ea145dbdce28dbf278437e349be1;p=chaz%2Fopenbox diff --git a/openbox/session.c b/openbox/session.c index 267d17ef..ca45adb9 100644 --- a/openbox/session.c +++ b/openbox/session.c @@ -33,6 +33,7 @@ GSList *session_desktop_names = NULL; void session_startup(gint argc, gchar **argv) {} void session_shutdown(gboolean permanent) {} GList* session_state_find(struct _ObClient *c) { return NULL; } +void session_request_logout(gboolean silent) {} #else #include "debug.h" @@ -104,7 +105,7 @@ void session_startup(gint argc, gchar **argv) obt_paths_unref(p), p = NULL; if (!obt_paths_mkdir_path(dir, 0700)) { - g_message(_("Unable to make directory '%s': %s"), + g_message(_("Unable to make directory \"%s\": %s"), dir, g_strerror(errno)); } @@ -159,7 +160,7 @@ void session_shutdown(gboolean permanent) } /*! Connect to the session manager and set up our callback functions */ -static gboolean session_connect() +static gboolean session_connect(void) { SmcCallbacks cb; gchar *oldid; @@ -193,7 +194,7 @@ static gboolean session_connect() return sm_conn != NULL; } -static void session_setup_program() +static void session_setup_program(void) { SmPropValue vals = { .value = sm_argv[0], @@ -212,7 +213,7 @@ static void session_setup_program() g_free(prop.type); } -static void session_setup_user() +static void session_setup_user(void) { char *user = g_strdup(g_get_user_name()); @@ -255,7 +256,7 @@ static void session_setup_restart_style(gboolean restart) g_free(prop.type); } -static void session_setup_pid() +static void session_setup_pid(void) { gchar *pid = g_strdup_printf("%ld", (glong) getpid()); @@ -278,7 +279,7 @@ static void session_setup_pid() } /*! This is a gnome-session-manager extension */ -static void session_setup_priority() +static void session_setup_priority(void) { gchar priority = 20; /* 20 is a lower prioity to run before other apps */ @@ -299,7 +300,7 @@ static void session_setup_priority() g_free(prop.type); } -static void session_setup_clone_command() +static void session_setup_clone_command(void) { gint i; @@ -325,7 +326,7 @@ static void session_setup_clone_command() g_free(vals); } -static void session_setup_restart_command() +static void session_setup_restart_command(void) { gint i; @@ -367,7 +368,7 @@ static void session_setup_restart_command() g_free(vals); } -static ObSMSaveData *sm_save_get_data() +static ObSMSaveData *sm_save_get_data(void) { ObSMSaveData *savedata = g_new0(ObSMSaveData, 1); /* save the active desktop and client. @@ -407,7 +408,22 @@ static void sm_save_yourself(SmcConn conn, SmPointer data, gint save_type, ObSMSaveData *savedata = NULL; gchar *vendor; - ob_debug_type(OB_DEBUG_SM, "Session save requested"); +#ifdef DEBUG + { + const gchar *sname = + (save_type == SmSaveLocal ? "SmSaveLocal" : + (save_type == SmSaveGlobal ? "SmSaveGlobal" : + (save_type == SmSaveBoth ? "SmSaveBoth" : "INVALID!!"))); + ob_debug_type(OB_DEBUG_SM, "Session save requested, type %s\n", sname); + } +#endif + + if (save_type == SmSaveGlobal) { + /* we have no data to save. we only store state to get back to where + we were, we don't keep open writable files or anything */ + SmcSaveYourselfDone(conn, TRUE); + return; + } vendor = SmcVendor(sm_conn); ob_debug_type(OB_DEBUG_SM, "Session manager's vendor: %s", vendor); @@ -452,7 +468,7 @@ static gboolean session_save_to_file(const ObSMSaveData *savedata) f = fopen(ob_sm_save_file, "w"); if (!f) { success = FALSE; - g_message(_("Unable to save the session to '%s': %s"), + g_message(_("Unable to save the session to \"%s\": %s"), ob_sm_save_file, g_strerror(errno)); } else { fprintf(f, "\n\n"); @@ -584,7 +600,7 @@ static gboolean session_save_to_file(const ObSMSaveData *savedata) if (fflush(f)) { success = FALSE; - g_message(_("Error while saving the session to '%s': %s"), + g_message(_("Error while saving the session to \"%s\": %s"), ob_sm_save_file, g_strerror(errno)); } fclose(f); @@ -813,4 +829,20 @@ static void session_load_file(const gchar *path) obt_parse_instance_unref(i); } +void session_request_logout(gboolean silent) +{ + if (sm_conn) { + SmcRequestSaveYourself(sm_conn, + SmSaveGlobal, + TRUE, /* logout */ + (silent ? + SmInteractStyleNone : SmInteractStyleAny), + TRUE, /* if false, with GSM, it shows the old + logout prompt */ + TRUE); /* global */ + } + else + g_message(_("Not connected to a session manager")); +} + #endif