Пример #1
0
static wxString GetSM()
{
    wxX11Display dpy;
    if ( !dpy )
        return wxEmptyString;

    char smerr[256];
    char *client_id;
    SmcConn smc_conn = SmcOpenConnection(NULL, NULL,
                                         999, 999,
                                         0 /* mask */, NULL /* callbacks */,
                                         NULL, &client_id,
                                         WXSIZEOF(smerr), smerr);

    if ( !smc_conn )
    {
        wxLogDebug("Failed to connect to session manager: %s", smerr);
        return wxEmptyString;
    }

    char *vendor = SmcVendor(smc_conn);
    wxString ret = wxString::FromAscii( vendor );
    free(vendor);

    SmcCloseConnection(smc_conn, 0, NULL);
    free(client_id);

    return ret;
}
Пример #2
0
static void
disconnect (void)
{
  SmcCloseConnection (session_connection, 0, NULL);
  session_connection = NULL;
  current_state = STATE_DISCONNECTED;
}
Пример #3
0
static void
ice_exit(void)
{
   SmcCloseConnection(sm_conn, 0, NULL);
   sm_conn = NULL;
   EventFdUnregister(sm_efd);
}
Пример #4
0
/**
 * exec() ourself to restart.
 */
void
DoRestart(Time t)
{
	// Don't try to do any further animating
	StopAnimation();
	XSync(dpy, 0);

	// Replace all the windows/colormaps as if we were going away.  'cuz
	// we are.
	RestoreForShutdown(t);
	XSync(dpy, 0);

	// Shut down session management connection cleanly.
	if(smcConn) {
		SmcCloseConnection(smcConn, 0, NULL);
	}

	// Re-run ourself
	fprintf(stderr, "%s:  restarting:  %s\n", ProgramName, *Argv);
	execvp(*Argv, Argv);

	// Uh oh, we shouldn't get here...
	fprintf(stderr, "%s:  unable to restart:  %s\n", ProgramName, *Argv);

	// We should probably un-RestoreForShutdown() etc.  If that exec
	// fails, we're in a really weird state...
	XBell(dpy, 0);
}
Пример #5
0
KRequestShutdownHelper::~KRequestShutdownHelper()
    {
#if HAVE_X11
    if( conn != NULL )
        {
        delete notifier;
        SmcCloseConnection( conn, 0, NULL );
        }
#endif
    }
void
nsNativeAppSupportUnix::DisconnectFromSM()
{
  // the SM is free to exit any time after we disconnect, so callers must be
  // sure to have reached a sufficiently advanced phase of shutdown that there
  // is no risk of data loss:
  // e.g. all async writes are complete by the end of "profile-before-change"
  if (mSessionConnection) {
    SetClientState(STATE_DISCONNECTED);
    SmcCloseConnection(mSessionConnection, 0, nullptr);
    mSessionConnection = nullptr;
    gdk_x11_set_sm_client_id(nullptr);  // follow gnome-client behaviour
  }
}
Пример #7
0
static gboolean ioc_watch_callback(GIOChannel *source,
                                   GIOCondition cond, gpointer handle)
{
    SessionData *sd = handle;
    (void) source;
    (void) cond;

    if (IceProcessMessages(sd->ice_conn, NULL, NULL) ==
            IceProcessMessagesIOError)
    {
        g_warning(_("Error processing ICE (session management) messages"));
        SmcCloseConnection(sd->smc_conn, 0, NULL);
        sd->tag = 0;
        return FALSE;
    }
    return TRUE;
}
Пример #8
0
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;
		}
	}
}
Пример #9
0
void session_shutdown(gboolean permanent)
{
    if (!ob_sm_use) return;

    if (sm_conn) {
        /* if permanent is true then we will change our session state so that
           the SM won't run us again */
        if (permanent)
            session_setup_restart_style(FALSE);

        SmcCloseConnection(sm_conn, 0, NULL);

        while (session_saved_state) {
            session_state_free(session_saved_state->data);
            session_saved_state = g_list_delete_link(session_saved_state,
                                                     session_saved_state);
        }
    }
}
Пример #10
0
void mod_sm_close()
{
    if(sm_conn!=NULL){
        SmcCloseConnection(sm_conn, 0, NULL);
        sm_conn=NULL;
    }

    ice_sm_conn=NULL;

    if(sm_fd>=0){
        mainloop_unregister_input_fd(sm_fd);
        close(sm_fd);
        sm_fd=-1;
    }

    if(sm_client_id!=NULL){
        free(sm_client_id);
        sm_client_id=NULL;
    }
}
Пример #11
0
static wxString GetSM()
{
    class Dpy
    {
    public:
        Dpy() { m_dpy = XOpenDisplay(NULL); }
        ~Dpy() { if ( m_dpy ) XCloseDisplay(m_dpy); }

        operator Display *() const { return m_dpy; }
    private:
        Display *m_dpy;
    } dpy;

    if ( !dpy )
        return wxEmptyString;

    char smerr[256];
    char *client_id;
    SmcConn smc_conn = SmcOpenConnection(NULL, NULL,
                                         999, 999,
                                         0 /* mask */, NULL /* callbacks */,
                                         NULL, &client_id,
                                         WXSIZEOF(smerr), smerr);

    if ( !smc_conn )
    {
        wxLogDebug("Failed to connect to session manager: %s", smerr);
        return wxEmptyString;
    }

    char *vendor = SmcVendor(smc_conn);
    wxString ret = wxString::FromAscii( vendor );
    free(vendor);

    SmcCloseConnection(smc_conn, 0, NULL);
    free(client_id);

    return ret;
}
Пример #12
0
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;
	}
    }
}
Пример #13
0
void pa__done(pa_module*m) {
    struct userdata *u;

    pa_assert(m);

    if ((u = m->userdata)) {

        if (u->connection)
            SmcCloseConnection(u->connection, 0, NULL);

        if (u->client)
            pa_client_free(u->client);

        if (u->x11)
            pa_x11_wrapper_unref(u->x11);

        pa_xfree(u);
    }

    if (ice_in_use) {
        IceRemoveConnectionWatch(new_ice_connection, m->core);
        ice_in_use = FALSE;
    }
}
Пример #14
0
static void
smc_die_CB (SmcConn smcConn, SmPointer clientData)
{
  SmcCloseConnection (smcConn, 0, 0);
  ice_connection_closed ();
}