diff options
author | mor <empty> | 1994-11-14 15:30:27 +0000 |
---|---|---|
committer | mor <empty> | 1994-11-14 15:30:27 +0000 |
commit | 0aff87034386dd24259195aaccecc1485d2829d2 (patch) | |
tree | 699e5ff246eaebfad20f695d2db0613589190a2b | |
parent | 58bfb34e9e39dd6e6b5d29046471678d2d179015 (diff) |
allow restarting of non-session-aware clients
-rw-r--r-- | xc/workInProgress/xsm/XSm.ad | 3 | ||||
-rw-r--r-- | xc/workInProgress/xsm/globals.c | 7 | ||||
-rw-r--r-- | xc/workInProgress/xsm/info.c | 38 | ||||
-rw-r--r-- | xc/workInProgress/xsm/restart.c | 30 | ||||
-rw-r--r-- | xc/workInProgress/xsm/restart.h | 3 | ||||
-rw-r--r-- | xc/workInProgress/xsm/saveutil.c | 114 | ||||
-rw-r--r-- | xc/workInProgress/xsm/xsm.c | 27 | ||||
-rw-r--r-- | xc/workInProgress/xsm/xsm.h | 9 | ||||
-rw-r--r-- | xc/workInProgress/xsm/xsm.man | 72 |
9 files changed, 266 insertions, 37 deletions
diff --git a/xc/workInProgress/xsm/XSm.ad b/xc/workInProgress/xsm/XSm.ad index 1eeaca887..af17c8f89 100644 --- a/xc/workInProgress/xsm/XSm.ad +++ b/xc/workInProgress/xsm/XSm.ad @@ -1,4 +1,4 @@ -! $XConsortium: XSm.ad,v 1.19 94/08/17 20:05:18 mor Exp mor $ +! $XConsortium: XSm.ad,v 1.20 94/08/25 17:36:52 mor Exp mor $ *chooseSessionPopup*font: 12x24 *chooseSessionLabel.label: Session Menu *chooseSessionMessageLabel.label: Press button again to confirm... @@ -26,6 +26,7 @@ *restartNever.label: Never *clientInfoDoneButton.label: Done +*manualRestartLabel.label: Restart the following non-session-aware clients... *clientPropTextWidget.width: 500 *clientPropTextWidget.height: 300 diff --git a/xc/workInProgress/xsm/globals.c b/xc/workInProgress/xsm/globals.c index ed9c70ec8..96b961f74 100644 --- a/xc/workInProgress/xsm/globals.c +++ b/xc/workInProgress/xsm/globals.c @@ -1,4 +1,4 @@ -/* $XConsortium: globals.c,v 1.14 94/08/25 17:23:47 mor Exp mor $ */ +/* $XConsortium: globals.c,v 1.15 94/08/30 17:21:19 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -65,6 +65,9 @@ String *sessionNames = NULL; int num_clients_in_last_session = -1; +char **non_session_aware_clients = NULL; +int non_session_aware_count = 0; + char *display_env = NULL, *non_local_display_env = NULL; char *session_env = NULL, *non_local_session_env = NULL; char *audio_env = NULL; @@ -123,6 +126,8 @@ Widget restartAnyway; Widget restartImmediately; Widget restartNever; Widget clientListWidget; +Widget manualRestartLabel; +Widget manualRestartCommands; Widget clientPropPopup; diff --git a/xc/workInProgress/xsm/info.c b/xc/workInProgress/xsm/info.c index fc30b1365..8d4691a97 100644 --- a/xc/workInProgress/xsm/info.c +++ b/xc/workInProgress/xsm/info.c @@ -1,4 +1,4 @@ -/* $XConsortium: info.c,v 1.16 94/08/25 17:27:57 mor Exp mor $ */ +/* $XConsortium: info.c,v 1.17 94/09/14 16:14:15 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -675,11 +675,16 @@ ClientInfoXtProc (w, client_data, callData) { UpdateClientList (); - current_client_selected = 0; - XawListHighlight (clientListWidget, 0); - ShowHint (clientListRecs[0]); - if (client_prop_visible) - DisplayProps (clientListRecs[0]); + if (clientListRecs && clientListRecs[0]) + { + current_client_selected = 0; + XawListHighlight (clientListWidget, 0); + ShowHint (clientListRecs[0]); + if (client_prop_visible) + DisplayProps (clientListRecs[0]); + } + else + current_client_selected = -1; XtVaGetValues (mainWindow, XtNx, &x, XtNy, &y, NULL); XtTranslateCoords (mainWindow, x, y, &rootx, &rooty); @@ -839,6 +844,27 @@ create_client_info_popup () XtAddCallback (clientListWidget, XtNcallback, ClientListXtProc, 0); + manualRestartLabel = XtVaCreateManagedWidget ( + "manualRestartLabel", labelWidgetClass, clientInfoForm, + XtNfromHoriz, NULL, + XtNfromVert, clientListWidget, + XtNborderWidth, 0, + XtNvertDistance, 20, + NULL); + + manualRestartCommands = XtVaCreateManagedWidget ( + "manualRestartCommands", asciiTextWidgetClass, clientInfoForm, + XtNfromHoriz, NULL, + XtNfromVert, manualRestartLabel, + XtNeditType, XawtextEdit, + XtNresizable, True, + XtNresize, XawtextResizeWidth, + XtNscrollVertical, XawtextScrollAlways, + XtNwidth, 350, + XtNheight, 100, + XtNtop, XawChainTop, + XtNbottom, XawChainBottom, + NULL); /* * Pop up for viewing client properties diff --git a/xc/workInProgress/xsm/restart.c b/xc/workInProgress/xsm/restart.c index 79b7c056a..9055a2f1b 100644 --- a/xc/workInProgress/xsm/restart.c +++ b/xc/workInProgress/xsm/restart.c @@ -1,4 +1,4 @@ -/* $XConsortium: restart.c,v 1.16 94/08/10 15:05:00 mor Exp mor $ */ +/* $XConsortium: restart.c,v 1.17 94/08/17 18:02:00 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -550,3 +550,31 @@ StartDefaultApps () system (buf); } } + + + +void +StartNonSessionAwareApps () + +{ + int i; + + for (i = 0; i < non_session_aware_count; i++) + { + /* + * Let the shell parse the stupid args. We need to add an "&" + * at the end of the command. We previously allocated an extra + * byte for this. + */ + + strcat (non_session_aware_clients[i], "&"); + system (non_session_aware_clients[i]); + free ((char *) non_session_aware_clients[i]); + } + + if (non_session_aware_clients) + { + free ((char *) non_session_aware_clients); + non_session_aware_clients = NULL; + } +} diff --git a/xc/workInProgress/xsm/restart.h b/xc/workInProgress/xsm/restart.h index b7abc4dd8..1e029fabd 100644 --- a/xc/workInProgress/xsm/restart.h +++ b/xc/workInProgress/xsm/restart.h @@ -1,4 +1,4 @@ -/* $XConsortium: restart.h,v 1.2 94/07/15 10:01:46 mor Exp $ */ +/* $XConsortium: restart.h,v 1.3 94/07/26 14:13:02 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -26,5 +26,6 @@ in this Software without prior written authorization from the X Consortium. ******************************************************************************/ extern void StartDefaultApps (); +extern void StartNonSessionAwareApps (); extern Status Restart (); extern void Clone (); diff --git a/xc/workInProgress/xsm/saveutil.c b/xc/workInProgress/xsm/saveutil.c index 87f64a385..a6f44ef91 100644 --- a/xc/workInProgress/xsm/saveutil.c +++ b/xc/workInProgress/xsm/saveutil.c @@ -1,4 +1,4 @@ -/* $XConsortium: saveutil.c,v 1.20 94/08/17 18:17:03 mor Exp mor $ */ +/* $XConsortium: saveutil.c,v 1.21 94/08/25 17:26:05 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -69,7 +69,7 @@ char **sm_id; Prop *prop; PropValue *val; FILE *f; - int state; + int state, i; int version_number; f = fopen(session_save_file, "r"); @@ -116,9 +116,19 @@ char **sm_id; for(p = buf; *p && isspace(*p); p++) /* LOOP */; if(*p == '#') continue; - if(!*p) { - state = 0; - continue; + if(!*p) + { + if (version_number >= 3 && + ListCount (PendingList) == num_clients_in_last_session) + { + state = 5; + break; + } + else + { + state = 0; + continue; + } } if(!isspace(buf[0])) { @@ -193,6 +203,50 @@ char **sm_id; if(!ListAddLast(prop->values, (void *)val)) nomem(); } } + + /* Read commands for non-session aware clients */ + + if (state == 5) + { + String strbuf; + int bufsize = 0; + + getline(&buf, &buflen, f); + if(p = strchr(buf, '\n')) *p = '\0'; + non_session_aware_count = atoi (buf); + + if (non_session_aware_count > 0) + { + non_session_aware_clients = (char **) malloc ( + non_session_aware_count * sizeof (char *)); + + for (i = 0; i < non_session_aware_count; i++) + { + getline(&buf, &buflen, f); + if(p = strchr(buf, '\n')) *p = '\0'; + non_session_aware_clients[i] = (char *) malloc ( + strlen (buf) + 2); + strcpy (non_session_aware_clients[i], buf); + bufsize += (strlen (buf) + 1); + } + + strbuf = (String) malloc (bufsize + 1); + strbuf[0] = NULL; + + for (i = 0; i < non_session_aware_count; i++) + { + strcat (strbuf, non_session_aware_clients[i]); + strcat (strbuf, "\n"); + } + + XtVaSetValues (manualRestartCommands, + XtNstring, strbuf, + NULL); + + free ((char *) strbuf); + } + } + fclose(f); return 1; @@ -257,6 +311,9 @@ char *sm_id; ClientRec *client; FILE *f; List *cl; + String commands; + char *p, *c; + int count; f = fopen (session_save_file, "w"); @@ -288,7 +345,52 @@ char *sm_id; SaveClient (f, client); } - fclose(f); + + /* Save the non-session aware clients */ + + XtVaGetValues (manualRestartCommands, + XtNstring, &commands, + NULL); + + p = c = commands; + count = 0; + + while (*p) + { + if (*p == '\n') + { + if (p != c) + count++; + c = p + 1; + } + p++; + } + if (p != c) + count++; + + fprintf (f, "%d\n", count); + + p = c = commands; + + while (*p) + { + if (*p == '\n') + { + if (p != c) + { + *p = NULL; + fprintf (f, "%s\n", c); + *p = '\n'; + } + c = p + 1; + } + p++; + } + + if (p != c) + fprintf (f, "%s\n", c); + + fclose (f); } } diff --git a/xc/workInProgress/xsm/xsm.c b/xc/workInProgress/xsm/xsm.c index c87850163..e3f21b2d1 100644 --- a/xc/workInProgress/xsm/xsm.c +++ b/xc/workInProgress/xsm/xsm.c @@ -1,4 +1,4 @@ -/* $XConsortium: xsm.c,v 1.65 94/08/30 17:57:49 mor Exp mor $ */ +/* $XConsortium: xsm.c,v 1.66 94/09/14 16:24:59 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -265,7 +265,19 @@ Boolean *continue_to_dispatch; XtRemoveEventHandler (topLevel, PropertyChangeMask, False, PropertyChangeXtHandler, NULL); + /* + * Restart the rest of the session aware clients. + */ + Restart (RESTART_REST_OF_CLIENTS); + + + /* + * Start apps that aren't session aware that were specified + * by the user. + */ + + StartNonSessionAwareApps (); } } @@ -476,7 +488,18 @@ Bool use_default; XtRemoveEventHandler (topLevel, PropertyChangeMask, False, PropertyChangeXtHandler, NULL); + /* + * Restart the rest of the session aware clients. + */ + Restart (RESTART_REST_OF_CLIENTS); + + /* + * Start apps that aren't session aware that were specified + * by the user. + */ + + StartNonSessionAwareApps (); } } } @@ -1169,7 +1192,7 @@ Bool on; XtSetSensitive (clientInfoPopup, on); XtSetSensitive (clientPropPopup, on); - if (on) + if (on && current_client_selected >= 0) XawListHighlight (clientListWidget, current_client_selected); } diff --git a/xc/workInProgress/xsm/xsm.h b/xc/workInProgress/xsm/xsm.h index bf5284908..ea36b13b9 100644 --- a/xc/workInProgress/xsm/xsm.h +++ b/xc/workInProgress/xsm/xsm.h @@ -1,4 +1,4 @@ -/* $XConsortium: xsm.h,v 1.28 94/08/25 17:24:15 mor Exp mor $ */ +/* $XConsortium: xsm.h,v 1.29 94/08/30 17:21:46 mor Exp mor $ */ /****************************************************************************** Copyright (c) 1993 X Consortium @@ -76,7 +76,7 @@ extern FILE *fdopen(int, char const *); * the version. */ -#define SAVEFILE_VERSION 2 +#define SAVEFILE_VERSION 3 #define DEFAULT_SESSION_NAME "Default" #define FAILSAFE_SESSION_NAME "Fail Safe" @@ -165,6 +165,9 @@ extern String *sessionNames; extern int num_clients_in_last_session; +extern char **non_session_aware_clients; +extern int non_session_aware_count; + extern Widget topLevel; extern Widget chooseSessionPopup; @@ -210,6 +213,8 @@ extern Widget restartAnyway; extern Widget restartImmediately; extern Widget restartNever; extern Widget clientListWidget; +extern Widget manualRestartLabel; +extern Widget manualRestartCommands; extern Widget clientPropPopup; diff --git a/xc/workInProgress/xsm/xsm.man b/xc/workInProgress/xsm/xsm.man index 0c52ddf9f..566299b69 100644 --- a/xc/workInProgress/xsm/xsm.man +++ b/xc/workInProgress/xsm/xsm.man @@ -1,4 +1,4 @@ -.\" $XConsortium: xsm.man,v 1.6 94/08/02 17:07:36 mor Exp mor $ +.\" $XConsortium: xsm.man,v 1.7 94/08/02 17:51:51 mor Exp mor $ .\" Copyright (c) 1994 X Consortium .\" .\" Permission is hereby granted, free of charge, to any person obtaining @@ -44,7 +44,7 @@ Causes \fIxsm\fP to load the specified session, bypassing the session menu. Turns on debugging information. .SH SETUP .SS .xsession file -Using \fIxsm\fP requires a few changes to your \fI.xsession\fP file: +Using \fIxsm\fP requires a change to your \fI.xsession\fP file: .PP The last program executed by your \fI.xsession\fP file should be \fIxsm\fP. With this configuration, when the user chooses to shut @@ -55,11 +55,9 @@ logging into a session, your .xsession file, in general, should not directly start up applications. Rather, the applications should be started within a session. When \fIxsm\fP shuts down the session, \fIxsm\fP will know to restart these applications. Note however that there are some types of -applications that are not "session aware", and these applications should be -started within the \fI.xsession\fP file. Applications that are not session -aware are ones that do not support the X Session Management Protocol, or -they do not create any top level windows for the Session Management Proxy -to detect (see the section titled \fITHE PROXY\fP). +applications that are not "session aware". \fIxsm\fP allows you to +manually add these applications to your session (see the section titled +\fIClient List\fP). .PP .SS SM_SAVE_DIR environment variable If the \fISM_SAVE_DIR\fP environment variable is defined, \fIxsm\fP will @@ -137,9 +135,10 @@ The following options are available from \fIxsm\fP's main window: .TP 18 .B Client List Pressing this button brings up a window containing a list of all clients that -are in the session. For each client, the host machine that the client is -running on is presented. As clients are added and removed from the session, -this list is updated to reflect the changes. +are in the current session. For each client, the host machine that the client +is running on is presented. As clients are added and removed from the session, +this list is updated to reflect the changes. The user is able to control how +these clients are restarted (see below). .br .sp By pressing the \fBView Properties\fR @@ -155,13 +154,52 @@ By pressing the \fBKill Client\fR button, the user can remove a client from the session. .br .sp +By selecting a restart hint from the \fBRestart Hint\fR menu, the user can +control the restarting of a client. The following hints are available: +.br +.sp +.B \- +The \fBRestart If Running\fR hint indicates that the client should be +restarted in the next session if it is connected to the session manager at +the end of the current session. +.br +.sp +.B \- +The \fBRestart Anyway\fR hint indicates that the client should be restarted +in the next session even if it exits before the current session is terminated. +.br +.sp +.B \- +The \fBRestart Immediately\fR hint is similar to the \fBRestart Anyway\fR hint, +but in addition, the client is meant to run continuously. If the client exits, +the session manager will try to restart it in the current session. +.br +.sp +.B \- +The \fBRestart Never\fR hint indicates that the client should not be restarted +in the next session. +.br +.sp +Note that all X applications may not be "session aware". Applications that +are not session aware are ones that do not support the X Session Management +Protocol, or they do not create any top level windows with the WM_COMMAND +property for the Session Management Proxy to detect (see the section titled +\fITHE PROXY\fP). \fIxsm\fP allows the user to manually add such applications +to the session. The bottom of the \fIClient List\fP window contains a text +entry field in which application commands can be typed in. Each command +should go on its own line. When the session is restarted, \fIxsm\fP will +restart these applications in addition to the regular "session aware" +applications. +.br +.sp Pressing the \fBDone\fR button removes the \fBClient List\fR window. .TP 18 -.B Name Session... -This option allows the user to assign a new name to the session. Note -that once a session's name is changed, any state changes will only affect -the new session. The user can take a "snapshot" of a useful session by -naming the session and performing a checkpoint (see below). +.B Rename Session... +This option allows the user to assign a new name to the session, with the +option of checkpointing the original session. Note that once a session's +name is changed, any state changes will only affect the new session. The +user can take a "snapshot" of a useful session by naming the session and +performing a checkpoint (see below). .TP 18 .B Checkpoint By performing a checkpoint, all applications that are in the session are @@ -218,8 +256,8 @@ can cause the session to exit. Note that if the interaction style is \fBErrors\fR or \fBAny\fR, the user may cancel the shutdown. .br .sp -The user may choose to exit the session without performing a checkpoint -(an additional save type \fBNone\fR is available). +The user may choose to exit the session with our without performing a +checkpoint. .PP .SH THE PROXY Since not all applications have been ported to support the X Session |