/*! Connect to the session manager and set up our callback functions */ static gboolean session_connect(void) { SmcCallbacks cb; gchar *oldid; gchar sm_err[SM_ERR_LEN]; /* set up our callback functions */ cb.save_yourself.callback = sm_save_yourself; cb.save_yourself.client_data = NULL; cb.die.callback = sm_die; cb.die.client_data = NULL; cb.save_complete.callback = sm_save_complete; cb.save_complete.client_data = NULL; cb.shutdown_cancelled.callback = sm_shutdown_cancelled; cb.shutdown_cancelled.client_data = NULL; /* connect to the server */ oldid = ob_sm_id; ob_debug_type(OB_DEBUG_SM, "Connecting to SM with id: %s", oldid ? oldid : "(null)"); sm_conn = SmcOpenConnection(NULL, NULL, 1, 0, SmcSaveYourselfProcMask | SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, &cb, oldid, &ob_sm_id, SM_ERR_LEN-1, sm_err); g_free(oldid); ob_debug_type(OB_DEBUG_SM, "Connected to SM with id: %s", ob_sm_id); if (sm_conn == NULL) ob_debug("Failed to connect to session manager: %s", sm_err); return sm_conn != NULL; }
void actions_client_move(ObActionsData *data, gboolean start) { static gulong ignore_start = 0; if (start) ignore_start = event_start_ignore_all_enters(); else if (config_focus_follow && data->context != OB_FRAME_CONTEXT_CLIENT) { if (data->uact == OB_USER_ACTION_MOUSE_PRESS) { struct _ObClient *c; syslog(LOG_INFO,"client move"); /* usually this is sorta redundant, but with a press action that moves windows our from under the cursor, the enter event will come as a GrabNotify which is ignored, so this makes a fake enter event don't do this if there is a grab on the pointer. enter events are ignored during a grab, so don't force fake ones when they should be ignored */ if ((c = client_under_pointer()) && c != data->client && !grab_on_pointer()) { ob_debug_type(OB_DEBUG_FOCUS, "Generating fake enter because we did a " "mouse-event action"); event_enter_client(c); } } else if (!data->button && !config_focus_under_mouse) event_end_ignore_all_enters(ignore_start); } }
void session_startup(gint argc, gchar **argv) { gchar *dir; ObtPaths *p; if (!ob_sm_use) return; sm_argc = argc; sm_argv = argv; p = obt_paths_new(); dir = g_build_filename(obt_paths_cache_home(p), "openbox", "sessions", NULL); obt_paths_unref(p), p = NULL; if (!obt_paths_mkdir_path(dir, 0700)) { g_message(_("Unable to make directory \"%s\": %s"), dir, g_strerror(errno)); } if (ob_sm_save_file != NULL) { if (ob_sm_restore) { ob_debug_type(OB_DEBUG_SM, "Loading from session file %s", ob_sm_save_file); session_load_file(ob_sm_save_file); } } else { gchar *filename; /* this algo is from metacity */ filename = g_strdup_printf("%u-%u-%u.obs", (guint)time(NULL), (guint)getpid(), g_random_int()); ob_sm_save_file = g_build_filename(dir, filename, NULL); g_free(filename); } if (session_connect()) { session_setup_program(); session_setup_user(); session_setup_restart_style(TRUE); session_setup_pid(); session_setup_priority(); session_setup_clone_command(); } g_free(dir); }