diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/xsmfns.c | 82 |
2 files changed, 52 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1490b34b4a9..97d336e77e3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xsmfns.c: Put empty line between comment and function body. | ||
| 4 | Use two spaces before comment end. | ||
| 5 | |||
| 1 | 2004-10-25 Kenichi Handa <handa@m17n.org> | 6 | 2004-10-25 Kenichi Handa <handa@m17n.org> |
| 2 | 7 | ||
| 3 | * fontset.c (fontset_pattern_regexp): Optimize for the case that | 8 | * fontset.c (fontset_pattern_regexp): Optimize for the case that |
diff --git a/src/xsmfns.c b/src/xsmfns.c index 9a6a7ccefb8..5b53c0ca34d 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -73,33 +73,35 @@ static int ice_fd = -1; | |||
| 73 | 73 | ||
| 74 | static int doing_interact = False; | 74 | static int doing_interact = False; |
| 75 | 75 | ||
| 76 | /* The session manager object for the session manager connection */ | 76 | /* The session manager object for the session manager connection. */ |
| 77 | 77 | ||
| 78 | static SmcConn smc_conn; | 78 | static SmcConn smc_conn; |
| 79 | 79 | ||
| 80 | /* The client session id for this session */ | 80 | /* The client session id for this session. */ |
| 81 | |||
| 81 | static char *client_id; | 82 | static char *client_id; |
| 82 | 83 | ||
| 83 | /* The full path name to the Emacs program */ | 84 | /* The full path name to the Emacs program. */ |
| 85 | |||
| 84 | static char *emacs_program; | 86 | static char *emacs_program; |
| 85 | 87 | ||
| 86 | /* The client session id for this session as a lisp object. */ | 88 | /* The client session id for this session as a lisp object. */ |
| 87 | 89 | ||
| 88 | Lisp_Object Vx_session_id; | 90 | Lisp_Object Vx_session_id; |
| 89 | 91 | ||
| 90 | /* The id we had the previous session. This is only available if we | 92 | /* The id we had the previous session. This is only available if we |
| 91 | have been started by the session manager with SMID_OPT. */ | 93 | have been started by the session manager with SMID_OPT. */ |
| 92 | 94 | ||
| 93 | Lisp_Object Vx_session_previous_id; | 95 | Lisp_Object Vx_session_previous_id; |
| 94 | 96 | ||
| 95 | /* The option we tell the session manager to start Emacs with when | 97 | /* The option we tell the session manager to start Emacs with when |
| 96 | restarting Emacs. The client_id is appended. */ | 98 | restarting Emacs. The client_id is appended. */ |
| 97 | 99 | ||
| 98 | #define SMID_OPT "--smid=" | 100 | #define SMID_OPT "--smid=" |
| 99 | 101 | ||
| 100 | 102 | ||
| 101 | /* The option to start Emacs without the splash screen when | 103 | /* The option to start Emacs without the splash screen when |
| 102 | restarting Emacs. */ | 104 | restarting Emacs. */ |
| 103 | 105 | ||
| 104 | #define NOSPLASH_OPT "--no-splash" | 106 | #define NOSPLASH_OPT "--no-splash" |
| 105 | 107 | ||
| @@ -107,6 +109,7 @@ Lisp_Object Vx_session_previous_id; | |||
| 107 | /* Handle any messages from the session manager. If no connection is | 109 | /* Handle any messages from the session manager. If no connection is |
| 108 | open to a session manager, just return 0. | 110 | open to a session manager, just return 0. |
| 109 | Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */ | 111 | Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */ |
| 112 | |||
| 110 | int | 113 | int |
| 111 | x_session_check_input (bufp) | 114 | x_session_check_input (bufp) |
| 112 | struct input_event *bufp; | 115 | struct input_event *bufp; |
| @@ -125,7 +128,7 @@ x_session_check_input (bufp) | |||
| 125 | /* Reset this so wo can check kind after callbacks have been called by | 128 | /* Reset this so wo can check kind after callbacks have been called by |
| 126 | IceProcessMessages. The smc_interact_CB sets the kind to | 129 | IceProcessMessages. The smc_interact_CB sets the kind to |
| 127 | SAVE_SESSION_EVENT, but we don't know beforehand if that callback | 130 | SAVE_SESSION_EVENT, but we don't know beforehand if that callback |
| 128 | will be called. */ | 131 | will be called. */ |
| 129 | emacs_event.kind = NO_EVENT; | 132 | emacs_event.kind = NO_EVENT; |
| 130 | 133 | ||
| 131 | if (select (ice_fd+1, &read_fds, | 134 | if (select (ice_fd+1, &read_fds, |
| @@ -142,7 +145,7 @@ x_session_check_input (bufp) | |||
| 142 | 145 | ||
| 143 | 146 | ||
| 144 | /* Check if smc_interact_CB was called and we shall generate a | 147 | /* Check if smc_interact_CB was called and we shall generate a |
| 145 | SAVE_SESSION_EVENT. */ | 148 | SAVE_SESSION_EVENT. */ |
| 146 | if (emacs_event.kind == NO_EVENT) | 149 | if (emacs_event.kind == NO_EVENT) |
| 147 | return 0; | 150 | return 0; |
| 148 | 151 | ||
| @@ -150,7 +153,8 @@ x_session_check_input (bufp) | |||
| 150 | return 1; | 153 | return 1; |
| 151 | } | 154 | } |
| 152 | 155 | ||
| 153 | /* Return non-zero if we have a connection to a session manager.*/ | 156 | /* Return non-zero if we have a connection to a session manager. */ |
| 157 | |||
| 154 | int | 158 | int |
| 155 | x_session_have_connection () | 159 | x_session_have_connection () |
| 156 | { | 160 | { |
| @@ -159,7 +163,8 @@ x_session_have_connection () | |||
| 159 | 163 | ||
| 160 | /* This is called when the session manager says it is OK to interact with the | 164 | /* This is called when the session manager says it is OK to interact with the |
| 161 | user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated. | 165 | user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated. |
| 162 | Then lisp code can interact with the user. */ | 166 | Then lisp code can interact with the user. */ |
| 167 | |||
| 163 | static void | 168 | static void |
| 164 | smc_interact_CB (smcConn, clientData) | 169 | smc_interact_CB (smcConn, clientData) |
| 165 | SmcConn smcConn; | 170 | SmcConn smcConn; |
| @@ -175,7 +180,8 @@ smc_interact_CB (smcConn, clientData) | |||
| 175 | are started in the correct directory. | 180 | are started in the correct directory. |
| 176 | 181 | ||
| 177 | If this is a shutdown and we can request to interact with the user, | 182 | If this is a shutdown and we can request to interact with the user, |
| 178 | we do so, because we don't know what the lisp code might do. */ | 183 | we do so, because we don't know what the lisp code might do. */ |
| 184 | |||
| 179 | static void | 185 | static void |
| 180 | smc_save_yourself_CB (smcConn, | 186 | smc_save_yourself_CB (smcConn, |
| 181 | clientData, | 187 | clientData, |
| @@ -202,7 +208,7 @@ smc_save_yourself_CB (smcConn, | |||
| 202 | char cwd[MAXPATHLEN+1]; | 208 | char cwd[MAXPATHLEN+1]; |
| 203 | char *smid_opt; | 209 | char *smid_opt; |
| 204 | 210 | ||
| 205 | /* How to start a new instance of Emacs */ | 211 | /* How to start a new instance of Emacs. */ |
| 206 | props[props_idx] = &prop_ptr[props_idx]; | 212 | props[props_idx] = &prop_ptr[props_idx]; |
| 207 | props[props_idx]->name = SmCloneCommand; | 213 | props[props_idx]->name = SmCloneCommand; |
| 208 | props[props_idx]->type = SmLISTofARRAY8; | 214 | props[props_idx]->type = SmLISTofARRAY8; |
| @@ -212,7 +218,7 @@ smc_save_yourself_CB (smcConn, | |||
| 212 | props[props_idx]->vals[0].value = emacs_program; | 218 | props[props_idx]->vals[0].value = emacs_program; |
| 213 | ++props_idx; | 219 | ++props_idx; |
| 214 | 220 | ||
| 215 | /* The name of the program */ | 221 | /* The name of the program. */ |
| 216 | props[props_idx] = &prop_ptr[props_idx]; | 222 | props[props_idx] = &prop_ptr[props_idx]; |
| 217 | props[props_idx]->name = SmProgram; | 223 | props[props_idx]->name = SmProgram; |
| 218 | props[props_idx]->type = SmARRAY8; | 224 | props[props_idx]->type = SmARRAY8; |
| @@ -222,11 +228,11 @@ smc_save_yourself_CB (smcConn, | |||
| 222 | props[props_idx]->vals[0].value = SDATA (Vinvocation_name); | 228 | props[props_idx]->vals[0].value = SDATA (Vinvocation_name); |
| 223 | ++props_idx; | 229 | ++props_idx; |
| 224 | 230 | ||
| 225 | /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ | 231 | /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ |
| 226 | props[props_idx] = &prop_ptr[props_idx]; | 232 | props[props_idx] = &prop_ptr[props_idx]; |
| 227 | props[props_idx]->name = SmRestartCommand; | 233 | props[props_idx]->name = SmRestartCommand; |
| 228 | props[props_idx]->type = SmLISTofARRAY8; | 234 | props[props_idx]->type = SmLISTofARRAY8; |
| 229 | props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ | 235 | props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ |
| 230 | props[props_idx]->vals = &values[val_idx]; | 236 | props[props_idx]->vals = &values[val_idx]; |
| 231 | props[props_idx]->vals[0].length = strlen (emacs_program); | 237 | props[props_idx]->vals[0].length = strlen (emacs_program); |
| 232 | props[props_idx]->vals[0].value = emacs_program; | 238 | props[props_idx]->vals[0].value = emacs_program; |
| @@ -243,7 +249,7 @@ smc_save_yourself_CB (smcConn, | |||
| 243 | val_idx += 3; | 249 | val_idx += 3; |
| 244 | ++props_idx; | 250 | ++props_idx; |
| 245 | 251 | ||
| 246 | /* User id */ | 252 | /* User id. */ |
| 247 | props[props_idx] = &prop_ptr[props_idx]; | 253 | props[props_idx] = &prop_ptr[props_idx]; |
| 248 | props[props_idx]->name = SmUserID; | 254 | props[props_idx]->name = SmUserID; |
| 249 | props[props_idx]->type = SmARRAY8; | 255 | props[props_idx]->type = SmARRAY8; |
| @@ -253,7 +259,7 @@ smc_save_yourself_CB (smcConn, | |||
| 253 | props[props_idx]->vals[0].value = SDATA (Vuser_login_name); | 259 | props[props_idx]->vals[0].value = SDATA (Vuser_login_name); |
| 254 | ++props_idx; | 260 | ++props_idx; |
| 255 | 261 | ||
| 256 | /* The current directory property, not mandatory */ | 262 | /* The current directory property, not mandatory. */ |
| 257 | #ifdef HAVE_GETCWD | 263 | #ifdef HAVE_GETCWD |
| 258 | if (getcwd (cwd, MAXPATHLEN+1) != 0) | 264 | if (getcwd (cwd, MAXPATHLEN+1) != 0) |
| 259 | #else | 265 | #else |
| @@ -275,18 +281,19 @@ smc_save_yourself_CB (smcConn, | |||
| 275 | 281 | ||
| 276 | xfree (smid_opt); | 282 | xfree (smid_opt); |
| 277 | 283 | ||
| 278 | /* See if we maybe shall interact with the user. */ | 284 | /* See if we maybe shall interact with the user. */ |
| 279 | if (interactStyle != SmInteractStyleAny | 285 | if (interactStyle != SmInteractStyleAny |
| 280 | || ! shutdown | 286 | || ! shutdown |
| 281 | || saveType == SmSaveLocal | 287 | || saveType == SmSaveLocal |
| 282 | || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0)) | 288 | || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0)) |
| 283 | { | 289 | { |
| 284 | /* No interaction, we are done saving ourself. */ | 290 | /* No interaction, we are done saving ourself. */ |
| 285 | SmcSaveYourselfDone (smcConn, True); | 291 | SmcSaveYourselfDone (smcConn, True); |
| 286 | } | 292 | } |
| 287 | } | 293 | } |
| 288 | 294 | ||
| 289 | /* According to the SM specification, this shall close the connection */ | 295 | /* According to the SM specification, this shall close the connection. */ |
| 296 | |||
| 290 | static void | 297 | static void |
| 291 | smc_die_CB (smcConn, clientData) | 298 | smc_die_CB (smcConn, clientData) |
| 292 | SmcConn smcConn; | 299 | SmcConn smcConn; |
| @@ -300,7 +307,8 @@ smc_die_CB (smcConn, clientData) | |||
| 300 | According to the SM specification, we should not interact with the | 307 | According to the SM specification, we should not interact with the |
| 301 | user between smc_save_yourself_CB is called and until smc_save_complete_CB | 308 | user between smc_save_yourself_CB is called and until smc_save_complete_CB |
| 302 | is called. It seems like a lot of job to implement this and it doesn't | 309 | is called. It seems like a lot of job to implement this and it doesn't |
| 303 | even seem necessary. */ | 310 | even seem necessary. */ |
| 311 | |||
| 304 | static void | 312 | static void |
| 305 | smc_save_complete_CB (smcConn, clientData) | 313 | smc_save_complete_CB (smcConn, clientData) |
| 306 | SmcConn smcConn; | 314 | SmcConn smcConn; |
| @@ -318,7 +326,8 @@ smc_shutdown_cancelled_CB (smcConn, clientData) | |||
| 318 | } | 326 | } |
| 319 | 327 | ||
| 320 | /* Error handlers for SM and ICE. We don't want to exit Emacs just | 328 | /* Error handlers for SM and ICE. We don't want to exit Emacs just |
| 321 | because there is some error in the session management. */ | 329 | because there is some error in the session management. */ |
| 330 | |||
| 322 | static void | 331 | static void |
| 323 | smc_error_handler (smcConn, | 332 | smc_error_handler (smcConn, |
| 324 | swap, | 333 | swap, |
| @@ -335,7 +344,7 @@ smc_error_handler (smcConn, | |||
| 335 | int severity; | 344 | int severity; |
| 336 | SmPointer values; | 345 | SmPointer values; |
| 337 | { | 346 | { |
| 338 | /* Empty */ | 347 | /* Empty */ |
| 339 | } | 348 | } |
| 340 | 349 | ||
| 341 | static void | 350 | static void |
| @@ -354,7 +363,7 @@ ice_error_handler (iceConn, | |||
| 354 | int severity; | 363 | int severity; |
| 355 | IcePointer values; | 364 | IcePointer values; |
| 356 | { | 365 | { |
| 357 | /* Empty */ | 366 | /* Empty */ |
| 358 | } | 367 | } |
| 359 | 368 | ||
| 360 | 369 | ||
| @@ -362,12 +371,13 @@ static void | |||
| 362 | ice_io_error_handler (iceConn) | 371 | ice_io_error_handler (iceConn) |
| 363 | IceConn iceConn; | 372 | IceConn iceConn; |
| 364 | { | 373 | { |
| 365 | /* Connection probably gone. */ | 374 | /* Connection probably gone. */ |
| 366 | ice_fd = -1; | 375 | ice_fd = -1; |
| 367 | } | 376 | } |
| 368 | 377 | ||
| 369 | /* This is called when the ICE connection is created or closed. The SM library | 378 | /* This is called when the ICE connection is created or closed. The SM library |
| 370 | uses ICE as it transport protocol. */ | 379 | uses ICE as it transport protocol. */ |
| 380 | |||
| 371 | static void | 381 | static void |
| 372 | ice_conn_watch_CB (iceConn, clientData, opening, watchData) | 382 | ice_conn_watch_CB (iceConn, clientData, opening, watchData) |
| 373 | IceConn iceConn; | 383 | IceConn iceConn; |
| @@ -400,6 +410,7 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData) | |||
| 400 | } | 410 | } |
| 401 | 411 | ||
| 402 | /* Create the client leader window. */ | 412 | /* Create the client leader window. */ |
| 413 | |||
| 403 | static void | 414 | static void |
| 404 | create_client_leader_window (dpyinfo, client_id) | 415 | create_client_leader_window (dpyinfo, client_id) |
| 405 | struct x_display_info *dpyinfo; | 416 | struct x_display_info *dpyinfo; |
| @@ -426,7 +437,8 @@ create_client_leader_window (dpyinfo, client_id) | |||
| 426 | dpyinfo->client_leader_window = w; | 437 | dpyinfo->client_leader_window = w; |
| 427 | } | 438 | } |
| 428 | 439 | ||
| 429 | /* Try to open a connection to the session manager. */ | 440 | /* Try to open a connection to the session manager. */ |
| 441 | |||
| 430 | void | 442 | void |
| 431 | x_session_initialize (dpyinfo) | 443 | x_session_initialize (dpyinfo) |
| 432 | struct x_display_info *dpyinfo; | 444 | struct x_display_info *dpyinfo; |
| @@ -438,17 +450,17 @@ x_session_initialize (dpyinfo) | |||
| 438 | int name_len = 0; | 450 | int name_len = 0; |
| 439 | 451 | ||
| 440 | /* Check if we where started by the session manager. If so, we will | 452 | /* Check if we where started by the session manager. If so, we will |
| 441 | have a previous id. */ | 453 | have a previous id. */ |
| 442 | if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) | 454 | if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) |
| 443 | previous_id = SDATA (Vx_session_previous_id); | 455 | previous_id = SDATA (Vx_session_previous_id); |
| 444 | 456 | ||
| 445 | /* Construct the path to the Emacs program. */ | 457 | /* Construct the path to the Emacs program. */ |
| 446 | if (! EQ (Vinvocation_directory, Qnil)) | 458 | if (! EQ (Vinvocation_directory, Qnil)) |
| 447 | name_len += strlen (SDATA (Vinvocation_directory)); | 459 | name_len += strlen (SDATA (Vinvocation_directory)); |
| 448 | name_len += strlen (SDATA (Vinvocation_name)); | 460 | name_len += strlen (SDATA (Vinvocation_name)); |
| 449 | 461 | ||
| 450 | /* This malloc will not be freed, but it is only done once, and hopefully | 462 | /* This malloc will not be freed, but it is only done once, and hopefully |
| 451 | not very large */ | 463 | not very large */ |
| 452 | emacs_program = xmalloc (name_len + 1); | 464 | emacs_program = xmalloc (name_len + 1); |
| 453 | emacs_program[0] = '\0'; | 465 | emacs_program[0] = '\0'; |
| 454 | 466 | ||
| @@ -457,7 +469,7 @@ x_session_initialize (dpyinfo) | |||
| 457 | strcat (emacs_program, SDATA (Vinvocation_name)); | 469 | strcat (emacs_program, SDATA (Vinvocation_name)); |
| 458 | 470 | ||
| 459 | /* The SM protocol says all callbacks are mandatory, so set up all | 471 | /* The SM protocol says all callbacks are mandatory, so set up all |
| 460 | here and in the mask passed to SmcOpenConnection */ | 472 | here and in the mask passed to SmcOpenConnection. */ |
| 461 | callbacks.save_yourself.callback = smc_save_yourself_CB; | 473 | callbacks.save_yourself.callback = smc_save_yourself_CB; |
| 462 | callbacks.save_yourself.client_data = 0; | 474 | callbacks.save_yourself.client_data = 0; |
| 463 | callbacks.die.callback = smc_die_CB; | 475 | callbacks.die.callback = smc_die_CB; |
| @@ -467,17 +479,17 @@ x_session_initialize (dpyinfo) | |||
| 467 | callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; | 479 | callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; |
| 468 | callbacks.shutdown_cancelled.client_data = 0; | 480 | callbacks.shutdown_cancelled.client_data = 0; |
| 469 | 481 | ||
| 470 | /* Set error handlers. */ | 482 | /* Set error handlers. */ |
| 471 | SmcSetErrorHandler (smc_error_handler); | 483 | SmcSetErrorHandler (smc_error_handler); |
| 472 | IceSetErrorHandler (ice_error_handler); | 484 | IceSetErrorHandler (ice_error_handler); |
| 473 | IceSetIOErrorHandler (ice_io_error_handler); | 485 | IceSetIOErrorHandler (ice_io_error_handler); |
| 474 | 486 | ||
| 475 | /* Install callback for when connection status changes. */ | 487 | /* Install callback for when connection status changes. */ |
| 476 | IceAddConnectionWatch (ice_conn_watch_CB, 0); | 488 | IceAddConnectionWatch (ice_conn_watch_CB, 0); |
| 477 | 489 | ||
| 478 | /* Open the connection to the session manager. A failure is not | 490 | /* Open the connection to the session manager. A failure is not |
| 479 | critical, it usually means that no session manager is running. | 491 | critical, it usually means that no session manager is running. |
| 480 | The errorstring is here for debugging. */ | 492 | The errorstring is here for debugging. */ |
| 481 | smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, | 493 | smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, |
| 482 | (SmcSaveYourselfProcMask| | 494 | (SmcSaveYourselfProcMask| |
| 483 | SmcDieProcMask| | 495 | SmcDieProcMask| |