Mercurial > emacs
annotate src/xsmfns.c @ 83376:de684325b343
Merged in changes from CVS trunk.
Patches applied:
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-6
Update from CVS
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-7
Sync with miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-539.
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--version-0
Branch closed. Use miles@gnu.org--gnu-2005/emacs--cvs-trunk--0 instead.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-475
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-476
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-477
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-478
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-479
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-480
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-481
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-482
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-483
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-484
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-485
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-486
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-487
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-488
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-489
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-490
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-491
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-492
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-493
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-494
Update from CVS: lisp/startup.el (command-line): Fix typo.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-495
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-496
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-497
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-498
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-499
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-500
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-501
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-502
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-503
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-504
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-505
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-506
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-507
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-508
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-509
Update from CVS: .cvsignore: Add `lock'.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-510
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-511
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-512
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-514
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-515
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-516
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-517
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-518
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-519
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-520
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-521
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-522
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-523
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-524
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-525
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-526
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-527
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-528
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-529
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-531
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-532
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-533
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-534
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-535
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-537
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-538
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-539
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-88
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-89
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-90
Update FSF's address in GPL notices
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-91
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-92
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-93
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-94
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-95
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-96
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-97
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-98
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-99
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-100
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-101
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-102
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-103
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-104
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-105
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-106
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-107
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-108
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-109
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-110
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-111
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-112
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-113
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-114
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-416
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 11 Sep 2005 08:23:50 +0000 |
parents | 532e0a9335a9 8763a59d5982 |
children | 2a679c81f552 |
rev | line source |
---|---|
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
1 /* Session management module for systems which understand the X Session |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
2 management protocol. |
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
4 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
5 This file is part of GNU Emacs. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
6 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
7 GNU Emacs is free software; you can redistribute it and/or modify |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
10 any later version. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
11 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
12 GNU Emacs is distributed in the hope that it will be useful, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
16 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
18 along with GNU Emacs; see the file COPYING. If not, write to |
64084 | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
21 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
22 #include <config.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
23 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
24 #ifdef HAVE_X_SM |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
25 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
26 #include <X11/SM/SMlib.h> |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
27 #include <X11/Xlib.h> |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
28 #include <X11/Xutil.h> |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
29 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
30 #ifdef HAVE_STRING_H |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
31 #include <string.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
32 #else |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
33 #ifdef HAVE_STRINGS_H |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
34 #include <strings.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
35 #endif |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
36 #endif |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
37 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
38 #ifdef HAVE_UNISTD_H |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
39 #include <unistd.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
40 #endif |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
41 #ifdef HAVE_STDLIB_H |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
42 #include <stdlib.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
43 #endif |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
44 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
45 #include <sys/param.h> |
43848
1690ab476469
Include stdio.h because termhooks.h needs it.
Gerd Moellmann <gerd@gnu.org>
parents:
43810
diff
changeset
|
46 #include <stdio.h> |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
47 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
48 #include "systime.h" |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
49 #include "sysselect.h" |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
50 #include "lisp.h" |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
51 #include "frame.h" |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
52 #include "termhooks.h" |
43848
1690ab476469
Include stdio.h because termhooks.h needs it.
Gerd Moellmann <gerd@gnu.org>
parents:
43810
diff
changeset
|
53 #include "termopts.h" |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
54 #include "xterm.h" |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
55 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
56 /* The user login name. */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
57 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
58 extern Lisp_Object Vuser_login_name; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
59 |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
60 /* This is the event used when SAVE_SESSION_EVENT occurs. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
61 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
62 static struct input_event emacs_event; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
63 |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
64 /* The descriptor that we use to check for data from the session manager. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
65 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
66 static int ice_fd = -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
67 |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
68 /* A flag that says if we are in shutdown interactions or not. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
69 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
70 static int doing_interact = False; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
71 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
72 /* The session manager object for the session manager connection. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
73 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
74 static SmcConn smc_conn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
75 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
76 /* The client session id for this session. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
77 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
78 static char *client_id; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
79 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
80 /* The full path name to the Emacs program. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
81 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
82 static char *emacs_program; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
83 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
84 /* The client session id for this session as a lisp object. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
85 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
86 Lisp_Object Vx_session_id; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
87 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
88 /* The id we had the previous session. This is only available if we |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
89 have been started by the session manager with SMID_OPT. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
90 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
91 Lisp_Object Vx_session_previous_id; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
92 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
93 /* The option we tell the session manager to start Emacs with when |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
94 restarting Emacs. The client_id is appended. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
95 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
96 #define SMID_OPT "--smid=" |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
97 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
98 |
50016
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
99 /* The option to start Emacs without the splash screen when |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
100 restarting Emacs. */ |
50016
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
101 |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
102 #define NOSPLASH_OPT "--no-splash" |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
103 |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
104 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
105 /* Handle any messages from the session manager. If no connection is |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
106 open to a session manager, just return 0. |
54172
6851117e8d89
(x_session_check_input): Remove numchars arg.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
107 Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */ |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
108 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
109 int |
54172
6851117e8d89
(x_session_check_input): Remove numchars arg.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
110 x_session_check_input (bufp) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
111 struct input_event *bufp; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
112 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
113 SELECT_TYPE read_fds; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
114 EMACS_TIME tmout; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
115 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
116 if (ice_fd == -1) return 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
117 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
118 FD_ZERO (&read_fds); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
119 FD_SET (ice_fd, &read_fds); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
120 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
121 tmout.tv_sec = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
122 tmout.tv_usec = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
123 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
124 /* Reset this so wo can check kind after callbacks have been called by |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
125 IceProcessMessages. The smc_interact_CB sets the kind to |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
126 SAVE_SESSION_EVENT, but we don't know beforehand if that callback |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
127 will be called. */ |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
128 emacs_event.kind = NO_EVENT; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
129 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
130 if (select (ice_fd+1, &read_fds, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
131 (SELECT_TYPE *)0, (SELECT_TYPE *)0, &tmout) < 0) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
132 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
133 ice_fd = -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
134 return 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
135 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
136 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
137 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
138 if (FD_ISSET (ice_fd, &read_fds)) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
139 IceProcessMessages (SmcGetIceConnection (smc_conn), |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
140 (IceReplyWaitInfo *)0, (Bool *)0); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
141 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
142 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
143 /* Check if smc_interact_CB was called and we shall generate a |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
144 SAVE_SESSION_EVENT. */ |
54172
6851117e8d89
(x_session_check_input): Remove numchars arg.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
145 if (emacs_event.kind == NO_EVENT) |
6851117e8d89
(x_session_check_input): Remove numchars arg.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
146 return 0; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
147 |
54172
6851117e8d89
(x_session_check_input): Remove numchars arg.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
148 bcopy (&emacs_event, bufp, sizeof (struct input_event)); |
6851117e8d89
(x_session_check_input): Remove numchars arg.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
149 return 1; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
150 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
151 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
152 /* Return non-zero if we have a connection to a session manager. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
153 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
154 int |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
155 x_session_have_connection () |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
156 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
157 return ice_fd != -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
158 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
159 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
160 /* This is called when the session manager says it is OK to interact with the |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
161 user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated. |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
162 Then lisp code can interact with the user. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
163 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
164 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
165 smc_interact_CB (smcConn, clientData) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
166 SmcConn smcConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
167 SmPointer clientData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
168 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
169 doing_interact = True; |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
170 emacs_event.kind = SAVE_SESSION_EVENT; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
171 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
172 |
49421
381ccbf15cd9
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
47942
diff
changeset
|
173 /* This is called when the session manager tells us to save ourselves. |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
174 We set the required properties so the session manager can restart us, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
175 plus the current working directory property (not mandatory) so we |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
176 are started in the correct directory. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
177 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
178 If this is a shutdown and we can request to interact with the user, |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
179 we do so, because we don't know what the lisp code might do. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
180 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
181 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
182 smc_save_yourself_CB (smcConn, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
183 clientData, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
184 saveType, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
185 shutdown, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
186 interactStyle, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
187 fast) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
188 SmcConn smcConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
189 SmPointer clientData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
190 int saveType; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
191 Bool shutdown; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
192 int interactStyle; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
193 Bool fast; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
194 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
195 #define NR_PROPS 5 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
196 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
197 SmProp *props[NR_PROPS]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
198 SmProp prop_ptr[NR_PROPS]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
199 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
200 SmPropValue values[20]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
201 int val_idx = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
202 int props_idx = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
203 |
65412
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
204 char *cwd = NULL; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
205 char *smid_opt; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
206 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
207 /* How to start a new instance of Emacs. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
208 props[props_idx] = &prop_ptr[props_idx]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
209 props[props_idx]->name = SmCloneCommand; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
210 props[props_idx]->type = SmLISTofARRAY8; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
211 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
212 props[props_idx]->vals = &values[val_idx++]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
213 props[props_idx]->vals[0].length = strlen (emacs_program); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
214 props[props_idx]->vals[0].value = emacs_program; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
215 ++props_idx; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
216 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
217 /* The name of the program. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
218 props[props_idx] = &prop_ptr[props_idx]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
219 props[props_idx]->name = SmProgram; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
220 props[props_idx]->type = SmARRAY8; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
221 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
222 props[props_idx]->vals = &values[val_idx++]; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
223 props[props_idx]->vals[0].length = strlen (SDATA (Vinvocation_name)); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
224 props[props_idx]->vals[0].value = SDATA (Vinvocation_name); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
225 ++props_idx; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
226 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
227 /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
228 props[props_idx] = &prop_ptr[props_idx]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
229 props[props_idx]->name = SmRestartCommand; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
230 props[props_idx]->type = SmLISTofARRAY8; |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
231 props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
232 props[props_idx]->vals = &values[val_idx]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
233 props[props_idx]->vals[0].length = strlen (emacs_program); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
234 props[props_idx]->vals[0].value = emacs_program; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
235 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
236 smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
237 strcpy (smid_opt, SMID_OPT); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
238 strcat (smid_opt, client_id); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
239 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
240 props[props_idx]->vals[1].length = strlen (smid_opt); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
241 props[props_idx]->vals[1].value = smid_opt; |
50016
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
242 |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
243 props[props_idx]->vals[2].length = strlen (NOSPLASH_OPT); |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
244 props[props_idx]->vals[2].value = NOSPLASH_OPT; |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
245 val_idx += 3; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
246 ++props_idx; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
247 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
248 /* User id. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
249 props[props_idx] = &prop_ptr[props_idx]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
250 props[props_idx]->name = SmUserID; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
251 props[props_idx]->type = SmARRAY8; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
252 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
253 props[props_idx]->vals = &values[val_idx++]; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
254 props[props_idx]->vals[0].length = strlen (SDATA (Vuser_login_name)); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
255 props[props_idx]->vals[0].value = SDATA (Vuser_login_name); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
256 ++props_idx; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
257 |
65412
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
258 cwd = get_current_dir_name (); |
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
259 |
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
260 if (cwd) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
261 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
262 props[props_idx] = &prop_ptr[props_idx]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
263 props[props_idx]->name = SmCurrentDirectory; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
264 props[props_idx]->type = SmARRAY8; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
265 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
266 props[props_idx]->vals = &values[val_idx++]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
267 props[props_idx]->vals[0].length = strlen (cwd); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
268 props[props_idx]->vals[0].value = cwd; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
269 ++props_idx; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
270 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
271 |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
272 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
273 SmcSetProperties (smcConn, props_idx, props); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
274 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
275 xfree (smid_opt); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
276 |
65412
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
277 if (cwd) |
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
278 free (cwd); |
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
279 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
280 /* See if we maybe shall interact with the user. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
281 if (interactStyle != SmInteractStyleAny |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
282 || ! shutdown |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
283 || saveType == SmSaveLocal |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
284 || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0)) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
285 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
286 /* No interaction, we are done saving ourself. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
287 SmcSaveYourselfDone (smcConn, True); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
288 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
289 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
290 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
291 /* According to the SM specification, this shall close the connection. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
292 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
293 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
294 smc_die_CB (smcConn, clientData) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
295 SmcConn smcConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
296 SmPointer clientData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
297 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
298 SmcCloseConnection (smcConn, 0, 0); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
299 ice_fd = -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
300 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
301 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
302 /* We don't use the next two but they are mandatory, leave them empty. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
303 According to the SM specification, we should not interact with the |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
304 user between smc_save_yourself_CB is called and until smc_save_complete_CB |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
305 is called. It seems like a lot of job to implement this and it doesn't |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
306 even seem necessary. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
307 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
308 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
309 smc_save_complete_CB (smcConn, clientData) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
310 SmcConn smcConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
311 SmPointer clientData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
312 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
313 /* Empty */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
314 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
315 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
316 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
317 smc_shutdown_cancelled_CB (smcConn, clientData) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
318 SmcConn smcConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
319 SmPointer clientData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
320 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
321 /* Empty */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
322 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
323 |
49421
381ccbf15cd9
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
47942
diff
changeset
|
324 /* Error handlers for SM and ICE. We don't want to exit Emacs just |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
325 because there is some error in the session management. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
326 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
327 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
328 smc_error_handler (smcConn, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
329 swap, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
330 offendingMinorOpcode, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
331 offendingSequence, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
332 errorClass, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
333 severity, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
334 values) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
335 SmcConn smcConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
336 Bool swap; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
337 int offendingMinorOpcode; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
338 unsigned long offendingSequence; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
339 int errorClass; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
340 int severity; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
341 SmPointer values; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
342 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
343 /* Empty */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
344 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
345 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
346 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
347 ice_error_handler (iceConn, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
348 swap, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
349 offendingMinorOpcode, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
350 offendingSequence, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
351 errorClass, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
352 severity, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
353 values) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
354 IceConn iceConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
355 Bool swap; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
356 int offendingMinorOpcode; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
357 unsigned long offendingSequence; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
358 int errorClass; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
359 int severity; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
360 IcePointer values; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
361 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
362 /* Empty */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
363 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
364 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
365 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
366 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
367 ice_io_error_handler (iceConn) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
368 IceConn iceConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
369 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
370 /* Connection probably gone. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
371 ice_fd = -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
372 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
373 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
374 /* This is called when the ICE connection is created or closed. The SM library |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
375 uses ICE as it transport protocol. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
376 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
377 static void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
378 ice_conn_watch_CB (iceConn, clientData, opening, watchData) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
379 IceConn iceConn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
380 IcePointer clientData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
381 Bool opening; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
382 IcePointer *watchData; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
383 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
384 if (! opening) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
385 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
386 ice_fd = -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
387 return; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
388 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
389 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
390 ice_fd = IceConnectionNumber (iceConn); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
391 #ifndef F_SETOWN_BUG |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
392 #ifdef F_SETOWN |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
393 #ifdef F_SETOWN_SOCK_NEG |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
394 /* stdin is a socket here */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
395 fcntl (ice_fd, F_SETOWN, -getpid ()); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
396 #else /* ! defined (F_SETOWN_SOCK_NEG) */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
397 fcntl (ice_fd, F_SETOWN, getpid ()); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
398 #endif /* ! defined (F_SETOWN_SOCK_NEG) */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
399 #endif /* ! defined (F_SETOWN) */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
400 #endif /* F_SETOWN_BUG */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
401 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
402 #ifdef SIGIO |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
403 if (interrupt_input) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
404 init_sigio (ice_fd); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
405 #endif /* ! defined (SIGIO) */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
406 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
407 |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
408 /* Create the client leader window. */ |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
409 |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
410 static void |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
411 create_client_leader_window (dpyinfo, client_id) |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
412 struct x_display_info *dpyinfo; |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
413 char *client_id; |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
414 { |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
415 Window w; |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
416 XClassHint class_hints; |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
417 Atom sm_id; |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
418 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
419 w = XCreateSimpleWindow (dpyinfo->display, |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
420 dpyinfo->root_window, |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
421 -1, -1, 1, 1, |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
422 CopyFromParent, CopyFromParent, CopyFromParent); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
423 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
424 class_hints.res_name = (char *) SDATA (Vx_resource_name); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
425 class_hints.res_class = (char *) SDATA (Vx_resource_class); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
426 XSetClassHint (dpyinfo->display, w, &class_hints); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
427 XStoreName (dpyinfo->display, w, class_hints.res_name); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
428 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
429 sm_id = XInternAtom (dpyinfo->display, "SM_CLIENT_ID", False); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
430 XChangeProperty (dpyinfo->display, w, sm_id, XA_STRING, 8, PropModeReplace, |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
431 client_id, strlen (client_id)); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
432 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
433 dpyinfo->client_leader_window = w; |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
434 } |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
435 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
436 /* Try to open a connection to the session manager. */ |
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
437 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
438 void |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
439 x_session_initialize (dpyinfo) |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
440 struct x_display_info *dpyinfo; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
441 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
442 #define SM_ERRORSTRING_LEN 512 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
443 char errorstring[SM_ERRORSTRING_LEN]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
444 char* previous_id = NULL; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
445 SmcCallbacks callbacks; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
446 int name_len = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
447 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
448 /* Check if we where started by the session manager. If so, we will |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
449 have a previous id. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
450 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
451 previous_id = SDATA (Vx_session_previous_id); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
452 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
453 /* Construct the path to the Emacs program. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
454 if (! EQ (Vinvocation_directory, Qnil)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
455 name_len += strlen (SDATA (Vinvocation_directory)); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
456 name_len += strlen (SDATA (Vinvocation_name)); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
457 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
458 /* This malloc will not be freed, but it is only done once, and hopefully |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
459 not very large */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
460 emacs_program = xmalloc (name_len + 1); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
461 emacs_program[0] = '\0'; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
462 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
463 if (! EQ (Vinvocation_directory, Qnil)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
464 strcpy (emacs_program, SDATA (Vinvocation_directory)); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
465 strcat (emacs_program, SDATA (Vinvocation_name)); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
466 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
467 /* The SM protocol says all callbacks are mandatory, so set up all |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
468 here and in the mask passed to SmcOpenConnection. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
469 callbacks.save_yourself.callback = smc_save_yourself_CB; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
470 callbacks.save_yourself.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
471 callbacks.die.callback = smc_die_CB; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
472 callbacks.die.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
473 callbacks.save_complete.callback = smc_save_complete_CB; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
474 callbacks.save_complete.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
475 callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
476 callbacks.shutdown_cancelled.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
477 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
478 /* Set error handlers. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
479 SmcSetErrorHandler (smc_error_handler); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
480 IceSetErrorHandler (ice_error_handler); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
481 IceSetIOErrorHandler (ice_io_error_handler); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
482 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
483 /* Install callback for when connection status changes. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
484 IceAddConnectionWatch (ice_conn_watch_CB, 0); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
485 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
486 /* Open the connection to the session manager. A failure is not |
49421
381ccbf15cd9
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
47942
diff
changeset
|
487 critical, it usually means that no session manager is running. |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
488 The errorstring is here for debugging. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
489 smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
490 (SmcSaveYourselfProcMask| |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
491 SmcDieProcMask| |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
492 SmcSaveCompleteProcMask| |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
493 SmcShutdownCancelledProcMask), |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
494 &callbacks, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
495 previous_id, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
496 &client_id, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
497 SM_ERRORSTRING_LEN, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
498 errorstring); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
499 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
500 if (smc_conn != 0) |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
501 { |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
502 Vx_session_id = make_string (client_id, strlen (client_id)); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
503 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
504 #ifdef USE_GTK |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
505 /* GTK creats a leader window by itself, but we need to tell |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
506 it about our client_id. */ |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
507 gdk_set_sm_client_id (client_id); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
508 #else |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
509 create_client_leader_window (dpyinfo, client_id); |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
510 #endif |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
511 } |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
512 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
513 |
83350
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
514 /* Ensure that the session manager is not contacted again. */ |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
515 |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
516 void |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
517 x_session_close () |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
518 { |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
519 ice_fd = -1; |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
520 } |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
521 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
522 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
523 DEFUN ("handle-save-session", Fhandle_save_session, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
524 Shandle_save_session, 1, 1, "e", |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
525 doc: /* Handle the save_yourself event from a session manager. |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
526 A session manager can tell Emacs that the window system is shutting down |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
527 by sending Emacs a save_yourself message. Emacs executes this function when |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
528 such an event occurs. This function then executes `emacs-session-save'. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
529 After that, this function informs the session manager that it can continue |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
530 or abort shutting down the window system depending on the return value |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
531 from `emacs-session-save' If the return value is non-nil the session manager |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
532 is told to abort the window system shutdown. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
533 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
534 Do not call this function yourself. */) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
535 (event) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
536 Lisp_Object event; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
537 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
538 /* Check doing_interact so that we don't do anything if someone called |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
539 this at the wrong time. */ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
540 if (doing_interact) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
541 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
542 Bool cancel_shutdown = False; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
543 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
544 cancel_shutdown = ! EQ (call0 (intern ("emacs-session-save")), Qnil); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
545 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
546 SmcInteractDone (smc_conn, cancel_shutdown); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
547 SmcSaveYourselfDone (smc_conn, True); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
548 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
549 doing_interact = False; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
550 } |
43919
833c0585a612
Added return value to Fhandle_save_session to avoid compiler warning.
Jan Djärv <jan.h.d@swipnet.se>
parents:
43848
diff
changeset
|
551 |
833c0585a612
Added return value to Fhandle_save_session to avoid compiler warning.
Jan Djärv <jan.h.d@swipnet.se>
parents:
43848
diff
changeset
|
552 return Qnil; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
553 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
554 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
555 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
556 /*********************************************************************** |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
557 Initialization |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
558 ***********************************************************************/ |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
559 void |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
560 syms_of_xsmfns () |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
561 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
562 DEFVAR_LISP ("x-session-id", &Vx_session_id, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
563 doc: /* The session id Emacs got from the session manager for this session. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
564 Changing the value does not change the session id used by Emacs. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
565 The value is nil if no session manager is running. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
566 See also `x-session-previous-id', `emacs-save-session-functions', |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
567 `emacs-session-save' and `emacs-session-restore'." */); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
568 Vx_session_id = Qnil; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
569 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
570 DEFVAR_LISP ("x-session-previous-id", &Vx_session_previous_id, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
571 doc: /* The previous session id Emacs got from session manager. |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
572 If Emacs is running on a window system that has a session manager, the |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
573 session manager gives Emacs a session id. It is feasible for Emacs lisp |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
574 code to use the session id to save configuration in, for example, a file |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
575 with a file name based on the session id. If Emacs is running when the |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
576 window system is shut down, the session manager remembers that Emacs was |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
577 running and saves the session id Emacs had. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
578 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
579 When the window system is started again, the session manager restarts |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
580 Emacs and hands Emacs the session id it had the last time it was |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
581 running. This is now the previous session id and the value of this |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
582 variable. If configuration was saved in a file as stated above, the |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
583 previous session id shall be used to reconstruct the file name. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
584 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
585 The session id Emacs has while it is running is in the variable |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
586 `x-session-id'. The value of this variable and `x-session-id' may be the |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
587 same, depending on how the session manager works. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
588 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
589 See also `emacs-save-session-functions', `emacs-session-save' and |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
590 `emacs-session-restore'." */); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
591 Vx_session_previous_id = Qnil; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
592 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
593 defsubr (&Shandle_save_session); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
594 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
595 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
596 #endif /* HAVE_X_SM */ |
52401 | 597 |
598 /* arch-tag: 56a2c58c-adfa-430a-b772-130abd29fd2e | |
599 (do not change this comment) */ |