don't send SmInteractDone until the warning dialog about crappy clients

2002-07-12  Havoc Pennington  <hp@pobox.com>

	* src/session.c: don't send SmInteractDone until the warning
	dialog about crappy clients has been closed.
This commit is contained in:
Havoc Pennington 2002-07-13 03:40:05 +00:00 committed by Havoc Pennington
parent 086f74fb29
commit b30802e35f
3 changed files with 71 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2002-07-12 Havoc Pennington <hp@pobox.com>
* src/session.c: don't send SmInteractDone until the warning
dialog about crappy clients has been closed.
2002-07-12 Havoc Pennington <hp@redhat.com> 2002-07-12 Havoc Pennington <hp@redhat.com>
* src/window.c (meta_window_new): try to maximize windows that * src/window.c (meta_window_new): try to maximize windows that

View File

@ -79,7 +79,7 @@ static char* load_state (const char *previous_save_file);
static void regenerate_save_file (void); static void regenerate_save_file (void);
static const char* full_save_file (void); static const char* full_save_file (void);
static const char* base_save_file (void); static const char* base_save_file (void);
static void warn_about_lame_clients (void); static void warn_about_lame_clients_and_finish_interact (gboolean shutdown);
/* This is called when data is available on an ICE connection. */ /* This is called when data is available on an ICE connection. */
static gboolean static gboolean
@ -549,11 +549,7 @@ interact_callback (SmcConn smc_conn, SmPointer client_data)
current_state = STATE_DONE_WITH_INTERACT; current_state = STATE_DONE_WITH_INTERACT;
warn_about_lame_clients (); warn_about_lame_clients_and_finish_interact (shutdown);
SmcInteractDone (session_connection, False /* don't cancel logout */);
save_yourself_possibly_done (shutdown, TRUE);
} }
static void static void
@ -1690,8 +1686,51 @@ windows_cmp_by_title (MetaWindow *a,
return g_utf8_collate (a->title, b->title); return g_utf8_collate (a->title, b->title);
} }
typedef struct
{
int child_pid;
int child_pipe;
gboolean shutdown;
} LameClientsDialogData;
static void static void
warn_about_lame_clients (void) finish_interact (gboolean shutdown)
{
if (current_state == STATE_DONE_WITH_INTERACT) /* paranoia */
{
SmcInteractDone (session_connection, False /* don't cancel logout */);
save_yourself_possibly_done (shutdown, TRUE);
}
}
static gboolean
io_from_warning_dialog (GIOChannel *channel,
GIOCondition condition,
gpointer data)
{
LameClientsDialogData *d;
d = data;
meta_topic (META_DEBUG_PING,
"IO handler from lame clients dialog, condition = %x\n",
condition);
if (condition & (G_IO_HUP | G_IO_NVAL | G_IO_ERR))
{
finish_interact (d->shutdown);
/* Remove the callback, freeing data */
return FALSE;
}
/* Keep callback installed */
return TRUE;
}
static void
warn_about_lame_clients_and_finish_interact (gboolean shutdown)
{ {
GSList *displays; GSList *displays;
GSList *display_iter; GSList *display_iter;
@ -1701,7 +1740,10 @@ warn_about_lame_clients (void)
GSList *tmp; GSList *tmp;
int len; int len;
int child_pid; int child_pid;
int child_pipe;
GError *err; GError *err;
GIOChannel *channel;
LameClientsDialogData *d;
lame = NULL; lame = NULL;
displays = meta_displays_list (); displays = meta_displays_list ();
@ -1764,6 +1806,8 @@ warn_about_lame_clients (void)
tmp = tmp->next; tmp = tmp->next;
} }
child_pipe = -1;
child_pid = -1;
err = NULL; err = NULL;
if (!g_spawn_async_with_pipes ("/", if (!g_spawn_async_with_pipes ("/",
argv, argv,
@ -1772,7 +1816,7 @@ warn_about_lame_clients (void)
NULL, NULL, NULL, NULL,
&child_pid, &child_pid,
NULL, NULL,
NULL, &child_pipe,
NULL, NULL,
&err)) &err))
{ {
@ -1784,9 +1828,17 @@ warn_about_lame_clients (void)
g_free (argv); g_free (argv);
g_slist_free (lame); g_slist_free (lame);
/* FIXME we need to keep a pipe to the child open to detect when it exits, and d = g_new0 (LameClientsDialogData, 1);
* only send InteractDone when the child has exited. d->child_pipe = child_pipe;
*/ d->child_pid = child_pid;
d->shutdown = shutdown;
channel = g_io_channel_unix_new (d->child_pipe);
g_io_add_watch_full (channel, G_PRIORITY_DEFAULT,
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
io_from_warning_dialog,
d, g_free);
g_io_channel_unref (channel);
} }
#endif /* HAVE_SM */ #endif /* HAVE_SM */