[Xfce4-commits] <libxfce4ui:new-sm-client> make the XSMP-related stuff private
Brian J. Tarricone
brian at tarricone.org
Thu Sep 17 07:58:02 CEST 2009
Updating branch refs/heads/kelnos/new-sm-client
to 44db1a6572d7078ed00e9625a1aefc47f85e9854 (commit)
from e15b732f3990b6717a9fe02935d18ac2ae66fa63 (commit)
commit 44db1a6572d7078ed00e9625a1aefc47f85e9854
Author: Brian J. Tarricone <brian at tarricone.org>
Date: Wed Sep 16 22:40:13 2009 -0700
make the XSMP-related stuff private
docs/libxfce4ui-sections.txt | 1 -
docs/libxfce4ui.types | 1 -
libxfce4ui/libxfce4ui.symbols | 2 -
libxfce4ui/xfce-sm-client.c | 143 ++++++++++++----------------------------
libxfce4ui/xfce-sm-client.h | 17 +-----
5 files changed, 44 insertions(+), 120 deletions(-)
diff --git a/docs/libxfce4ui-sections.txt b/docs/libxfce4ui-sections.txt
index ef8f4e3..b4427ae 100644
--- a/docs/libxfce4ui-sections.txt
+++ b/docs/libxfce4ui-sections.txt
@@ -123,5 +123,4 @@ xfce_sm_client_get_type
xfce_sm_client_priority_get_type
xfce_sm_client_restart_style_get_type
xfce_sm_client_shutdown_hint_get_type
-xfce_sm_client_state_get_type
</SECTION>
diff --git a/docs/libxfce4ui.types b/docs/libxfce4ui.types
index 7816d40..a32bcf1 100644
--- a/docs/libxfce4ui.types
+++ b/docs/libxfce4ui.types
@@ -5,4 +5,3 @@ xfce_sm_client_get_type
xfce_sm_client_priority_get_type
xfce_sm_client_restart_style_get_type
xfce_sm_client_shutdown_hint_get_type
-xfce_sm_client_state_get_type
diff --git a/libxfce4ui/libxfce4ui.symbols b/libxfce4ui/libxfce4ui.symbols
index 5f9fd3d..a4236b5 100644
--- a/libxfce4ui/libxfce4ui.symbols
+++ b/libxfce4ui/libxfce4ui.symbols
@@ -50,7 +50,6 @@ libxfce4ui_check_version
#if IN_HEADER(__LIBXFCE4UI_ENUM_TYPES_H__)
#if IN_SOURCE(__LIBXFCE4UI_ENUM_TYPES_C__)
xfce_sm_client_restart_style_get_type
-xfce_sm_client_state_get_type
xfce_sm_client_priority_get_type
xfce_sm_client_shutdown_hint_get_type
#endif
@@ -104,7 +103,6 @@ xfce_sm_client_get_full
xfce_sm_client_connect
xfce_sm_client_disconnect
xfce_sm_client_request_shutdown
-xfce_sm_client_get_state
xfce_sm_client_get_client_id
xfce_sm_client_get_state_file
xfce_sm_client_set_restart_style
diff --git a/libxfce4ui/xfce-sm-client.c b/libxfce4ui/xfce-sm-client.c
index e07d518..68b2434 100644
--- a/libxfce4ui/xfce-sm-client.c
+++ b/libxfce4ui/xfce-sm-client.c
@@ -64,6 +64,19 @@
? -1 : (!s2 \
? 1 : strcmp(s1, s2))) )
+typedef enum
+{
+ XFCE_SM_CLIENT_STATE_DISCONNECTED = 0,
+ XFCE_SM_CLIENT_STATE_REGISTERING,
+ XFCE_SM_CLIENT_STATE_IDLE,
+ XFCE_SM_CLIENT_STATE_SAVING_PHASE_1,
+ XFCE_SM_CLIENT_STATE_WAITING_FOR_INTERACT,
+ XFCE_SM_CLIENT_STATE_INTERACTING,
+ XFCE_SM_CLIENT_STATE_WAITING_FOR_PHASE_2,
+ XFCE_SM_CLIENT_STATE_SAVING_PHASE_2,
+ XFCE_SM_CLIENT_STATE_FROZEN,
+} XfceSMClientState;
+
struct _XfceSMClient
{
GObject parent;
@@ -111,10 +124,6 @@ typedef struct _XfceSMClientClass
void (*quit)(XfceSMClient *sm_client);
void (*quit_cancelled)(XfceSMClient *sm_client);
-
- void (*state_changed)(XfceSMClient *sm_client,
- XfceSMClientState old_state,
- XfceSMClientState new_state);
} XfceSMClientClass;
typedef struct
@@ -132,15 +141,12 @@ enum
SIG_QUIT_REQUESTED,
SIG_QUIT,
SIG_QUIT_CANCELLED,
- SIG_STATE_CHANGED,
N_SIGS
};
enum
{
PROP0 = 0,
- PROP_SESSION_CONNECTION,
- PROP_STATE,
PROP_RESUMED,
PROP_RESTART_STYLE,
PROP_PRIORITY,
@@ -271,10 +277,10 @@ xfce_sm_client_class_init(XfceSMClientClass *klass)
* Emitted when the application is required to quit. This is not
* optional: if the client does not quit a short time after receiving
* this signal, it will likely be terminated in some other way. While
- * not required, the applicatiokn will usually receive quit-requested
+ * not required, the application will usually receive quit-requested
* before receiving quit. If the application does not connect to this
- * signal, #XfceSMClient will call exit(3) with an exit code of zero
- * on behalf of the application.
+ * signal, #XfceSMClient will call <function>exit(3)</function> with
+ * an exit code of zero on behalf of the application.
**/
signals[SIG_QUIT] = g_signal_new("quit",
G_TYPE_FROM_CLASS(klass),
@@ -301,41 +307,6 @@ xfce_sm_client_class_init(XfceSMClientClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- /**
- * XfceSMClient::state-changed
- * @sm_client: An #XfceSMClient
- * @old_state: The client's previous state
- * @new_state: The client's new (current) state
- *
- * Emitted whenever the client's internal session management state
- * changes. This is mainly useful for debugging and other informative
- * purposes. No actual actions should be taken based on the emission
- * of this signal; instead, the application should make use of the other
- * signals emitted on the object.
- **/
- signals[SIG_STATE_CHANGED] = g_signal_new("state-changed",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(XfceSMClientClass,
- state_changed),
- NULL, NULL,
- _libxfce4ui_marshal_VOID__ENUM_ENUM,
- G_TYPE_NONE, 2,
- XFCE_TYPE_SM_CLIENT_STATE,
- XFCE_TYPE_SM_CLIENT_STATE);
-
- g_object_class_install_property(gobject_class, PROP_SESSION_CONNECTION,
- g_param_spec_pointer("session-connection",
- "Session connection descriptor",
- "The raw pointer to the SmcConnection",
- G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, PROP_STATE,
- g_param_spec_enum("state",
- "State",
- "The client's current XSMP state",
- XFCE_TYPE_SM_CLIENT_STATE,
- XFCE_SM_CLIENT_STATE_DISCONNECTED,
- G_PARAM_READABLE));
g_object_class_install_property(gobject_class, PROP_RESUMED,
g_param_spec_boolean("resumed",
"Resumed",
@@ -435,18 +406,6 @@ xfce_sm_client_get_property(GObject *obj,
XfceSMClient *sm_client = XFCE_SM_CLIENT(obj);
switch(property_id) {
- case PROP_SESSION_CONNECTION:
-#ifdef HAVE_LIBSM
- g_value_set_pointer(value, sm_client->session_connection);
-#else
- g_value_set_pointer(value, NULL);
-#endif
- break;
-
- case PROP_STATE:
- g_value_set_enum(value, sm_client->state);
- break;
-
case PROP_RESUMED:
g_value_set_boolean(value, sm_client->resumed);
break;
@@ -572,8 +531,6 @@ xfce_sm_client_set_property(GObject *obj,
}
break;
- case PROP_SESSION_CONNECTION:
- case PROP_STATE:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
}
@@ -634,24 +591,24 @@ static inline const gchar *
str_from_state(XfceSMClientState state)
{
switch(state) {
+ case XFCE_SM_CLIENT_STATE_DISCONNECTED:
+ return "DISCONNECTED";
+ case XFCE_SM_CLIENT_STATE_REGISTERING:
+ return "REGISTERING";
case XFCE_SM_CLIENT_STATE_IDLE:
return "IDLE";
case XFCE_SM_CLIENT_STATE_SAVING_PHASE_1:
return "SAVING_PHASE_1";
- case XFCE_SM_CLIENT_STATE_WAITING_FOR_PHASE_2:
- return "WAITING_FOR_PHASE_2";
- case XFCE_SM_CLIENT_STATE_SAVING_PHASE_2:
- return "SAVING_PHASE_2";
case XFCE_SM_CLIENT_STATE_WAITING_FOR_INTERACT:
return "WAITING_FOR_INTERACT";
case XFCE_SM_CLIENT_STATE_INTERACTING:
return "INTERACTING";
+ case XFCE_SM_CLIENT_STATE_WAITING_FOR_PHASE_2:
+ return "WAITING_FOR_PHASE_2";
+ case XFCE_SM_CLIENT_STATE_SAVING_PHASE_2:
+ return "SAVING_PHASE_2";
case XFCE_SM_CLIENT_STATE_FROZEN:
return "FROZEN";
- case XFCE_SM_CLIENT_STATE_DISCONNECTED:
- return "DISCONNECTED";
- case XFCE_SM_CLIENT_STATE_REGISTERING:
- return "REGISTERING";
default:
return "(unknown)";
}
@@ -749,8 +706,8 @@ xfce_sm_client_set_state(XfceSMClient *sm_client,
sm_client->state = new_state;
- g_signal_emit(G_OBJECT(sm_client), signals[SIG_STATE_CHANGED], 0,
- old_state, new_state);
+ g_debug("XfceSMClient: state change: %s -> %s",
+ str_from_state(old_state), str_from_state(new_state));
}
static inline char
@@ -1010,9 +967,15 @@ xsmp_save_yourself(SmcConn smc_conn,
return;
}
- if(sm_client->state != XFCE_SM_CLIENT_STATE_IDLE) {
- g_warning("Got SaveYourself while in state %s, ignoring",
- str_from_state(sm_client->state));
+ /* the spec says we can receive a SaveYourself even if we
+ * haven't responded with SaveYourselfDone to a previous
+ * SaveYourself. in that case, we're supposed to immediately end
+ * the previous SaveYourself and start handling the new one. that's
+ * a bit of a pain, so we're just gonna try to fixup our state on
+ * this side and let things go. */
+ if(sm_client->state != XFCE_SM_CLIENT_STATE_IDLE
+ && sm_client->state != XFCE_SM_CLIENT_STATE_FROZEN)
+ {
SmcSaveYourselfDone(sm_client->session_connection, True);
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_FROZEN);
return;
@@ -1576,14 +1539,14 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
callbacks.shutdown_cancelled.client_data = (SmPointer)sm_client;
sm_client->session_connection = SmcOpenConnection(NULL, NULL,
- SmProtoMajor,
- SmProtoMinor,
- mask,
- &callbacks,
- (char *)sm_client->client_id,
- &given_client_id,
- sizeof(buf)-1,
- buf);
+ SmProtoMajor,
+ SmProtoMinor,
+ mask,
+ &callbacks,
+ (char *)sm_client->client_id,
+ &given_client_id,
+ sizeof(buf)-1,
+ buf);
if(!sm_client->session_connection) {
if(error) {
@@ -2086,26 +2049,6 @@ xfce_sm_client_set_shutdown_command(XfceSMClient *sm_client,
}
/**
- * xfce_sm_client_get_state:
- * @sm_client: An #XfceSMClient
- *
- * Retrieves the session client's state. Note that this value
- * is very specific to the X Session Management Protocol.
- *
- * If the state is %XFCE_SM_CLIENT_STATE_FROZEN, the application
- * should attempt to disallow user interaction.
- *
- * Returns: a value from the #XfceSMClientState enum
- **/
-XfceSMClientState
-xfce_sm_client_get_state(XfceSMClient *sm_client)
-{
- g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client),
- XFCE_SM_CLIENT_STATE_DISCONNECTED);
- return sm_client->state;
-}
-
-/**
* xfce_sm_client_get_restart_style:
* @sm_client: An #XfceSMClient
*
diff --git a/libxfce4ui/xfce-sm-client.h b/libxfce4ui/xfce-sm-client.h
index 5651330..06b6a84 100644
--- a/libxfce4ui/xfce-sm-client.h
+++ b/libxfce4ui/xfce-sm-client.h
@@ -46,19 +46,6 @@ typedef enum
typedef enum
{
- XFCE_SM_CLIENT_STATE_IDLE = 0,
- XFCE_SM_CLIENT_STATE_SAVING_PHASE_1,
- XFCE_SM_CLIENT_STATE_WAITING_FOR_PHASE_2,
- XFCE_SM_CLIENT_STATE_SAVING_PHASE_2,
- XFCE_SM_CLIENT_STATE_WAITING_FOR_INTERACT,
- XFCE_SM_CLIENT_STATE_INTERACTING,
- XFCE_SM_CLIENT_STATE_FROZEN,
- XFCE_SM_CLIENT_STATE_DISCONNECTED,
- XFCE_SM_CLIENT_STATE_REGISTERING,
-} XfceSMClientState;
-
-typedef enum
-{
XFCE_SM_CLIENT_PRIORITY_HIGH = 0,
XFCE_SM_CLIENT_PRIORITY_WM = 15,
XFCE_SM_CLIENT_PRIORITY_CORE = 25,
@@ -103,12 +90,10 @@ gboolean xfce_sm_client_connect(XfceSMClient *sm_client,
GError **error);
void xfce_sm_client_disconnect(XfceSMClient *sm_client);
-gboolean xfce_sm_client_is_resumed(XfceSMClient *sm_client);
-
void xfce_sm_client_request_shutdown(XfceSMClient *sm_client,
XfceSMClientShutdownHint shutdown_hint);
-XfceSMClientState xfce_sm_client_get_state(XfceSMClient *sm_client);
+gboolean xfce_sm_client_is_resumed(XfceSMClient *sm_client);
G_CONST_RETURN gchar *xfce_sm_client_get_client_id(XfceSMClient *sm_client);
More information about the Xfce4-commits
mailing list