File libgnomeui-bnc468821-do-not-steal-sm-connection.patch of Package libgnomeui
Index: libgnomeui/gnome-ice.c
===================================================================
--- libgnomeui/gnome-ice.c (révision 5703)
+++ libgnomeui/gnome-ice.c (copie de travail)
@@ -30,20 +30,23 @@
#ifdef HAVE_LIBSM
#include <X11/ICE/ICElib.h>
+#include <X11/SM/SMlib.h>
#endif /* HAVE_LIBSM */
#include <unistd.h>
#include <fcntl.h>
#include <gtk/gtk.h>
+#include "gnome-client.h"
#include "gnome-ice.h"
#ifdef HAVE_LIBSM
-static void gnome_ice_io_error_handler (IceConn connection);
+#define GNOME_ICE_CONN_INPUT_ID_KEY "gnome-ice-conn-input-id"
-static void new_ice_connection (IceConn connection, IcePointer client_data,
- Bool opening, IcePointer *watch_data);
+static void gnome_ice_io_error_handler (IceConn connection);
+G_GNUC_INTERNAL void _gnome_ice_start_connection_watcher (GnomeClient *client);
+G_GNUC_INTERNAL void _gnome_ice_stop_connection_watcher (GnomeClient *client);
/* This is called when data is available on an ICE connection. */
static gboolean
@@ -77,37 +80,50 @@ process_ice_messages (GIOChannel *sour
return TRUE;
}
-/* This is called when a new ICE connection is made. It arranges for
- the ICE connection to be handled via the event loop. */
-static void
-new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
- IcePointer *watch_data)
+/* This needs to be called when a new ICE connection is made. It arranges
+ for the ICE connection to be handled via the event loop. */
+G_GNUC_INTERNAL void
+_gnome_ice_start_connection_watcher (GnomeClient *client)
{
+ IceConn connection;
+ GIOChannel *channel;
guint input_id;
- if (opening)
- {
- GIOChannel *channel;
- /* Make sure we don't pass on these file descriptors to any
- exec'ed children */
- fcntl(IceConnectionNumber(connection),F_SETFD,
- fcntl(IceConnectionNumber(connection),F_GETFD,0) | FD_CLOEXEC);
-
- channel = g_io_channel_unix_new (IceConnectionNumber (connection));
- input_id = g_io_add_watch (channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
- process_ice_messages,
- connection);
- g_io_channel_unref (channel);
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (GNOME_IS_CLIENT (client));
+ g_return_if_fail (GNOME_CLIENT_CONNECTED (client));
+
+ connection = SmcGetIceConnection (client->smc_conn);
+
+ /* Make sure we don't pass on these file descriptors to any
+ exec'ed children */
+ fcntl(IceConnectionNumber(connection),F_SETFD,
+ fcntl(IceConnectionNumber(connection),F_GETFD,0) | FD_CLOEXEC);
+
+ channel = g_io_channel_unix_new (IceConnectionNumber (connection));
+ input_id = g_io_add_watch (channel,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
+ process_ice_messages,
+ connection);
+ g_io_channel_unref (channel);
- *watch_data = (IcePointer) GUINT_TO_POINTER (input_id);
- }
- else
- {
- input_id = GPOINTER_TO_UINT ((gpointer) *watch_data);
+ g_object_set_data (G_OBJECT (client),
+ GNOME_ICE_CONN_INPUT_ID_KEY, GUINT_TO_POINTER (input_id));
+}
- g_source_remove (input_id);
- }
+G_GNUC_INTERNAL void
+_gnome_ice_stop_connection_watcher (GnomeClient *client)
+{
+ guint input_id;
+
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (GNOME_IS_CLIENT (client));
+
+ input_id = GPOINTER_TO_UINT (g_object_steal_data (G_OBJECT (client),
+ GNOME_ICE_CONN_INPUT_ID_KEY));
+
+ if (input_id > 0)
+ g_source_remove (input_id);
}
static IceIOErrorHandler gnome_ice_installed_handler;
@@ -145,8 +161,6 @@ gnome_ice_init (void)
if (gnome_ice_installed_handler == default_handler)
gnome_ice_installed_handler = NULL;
- IceAddConnectionWatch (new_ice_connection, NULL);
-
ice_init = TRUE;
}
#endif /* HAVE_LIBSM */
Index: libgnomeui/gnome-client.c
===================================================================
--- libgnomeui/gnome-client.c (révision 5703)
+++ libgnomeui/gnome-client.c (copie de travail)
@@ -91,6 +91,8 @@ static const char *sm_screen G_GNUC_UNUS
#endif
G_GNUC_INTERNAL extern void _gnome_ui_gettext_init (gboolean bind_codeset);
+G_GNUC_INTERNAL extern void _gnome_ice_start_connection_watcher (GnomeClient *client);
+G_GNUC_INTERNAL extern void _gnome_ice_stop_connection_watcher (GnomeClient *client);
/* The master client. */
static GnomeClient *master_client= NULL;
@@ -1612,6 +1614,8 @@ gnome_client_connect (GnomeClient *clien
{
gint restarted= FALSE;
+ _gnome_ice_start_connection_watcher (client);
+
g_free (client->previous_id);
client->previous_id= client->client_id;
client->client_id= client_id;
@@ -2494,6 +2498,8 @@ gnome_real_client_disconnect (GnomeClien
{
SmcCloseConnection ((SmcConn) client->smc_conn, 0, NULL);
client->smc_conn = NULL;
+
+ _gnome_ice_stop_connection_watcher (client);
}
client_set_state (client, GNOME_CLIENT_DISCONNECTED);