Mercurial > emacs
annotate src/xsmfns.c @ 112372:539ff9c0e704
gnus-art.el (gnus-article-add-buttons): Simplify condition.
(gnus-button-push): Remove gnus-button-entry function, it fails heavily if you have the same regexp several times.
(gnus-button-push): Fix matching when regexp is symbol.
spam.el (spam-spamassassin-register-with-sa-learn): Insert a full From header with a date and "nobody" as the sender.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Wed, 19 Jan 2011 22:22:18 +0000 |
parents | 42e22c4f06b7 |
children | 9de5a68b57e1 |
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. |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
111934
diff
changeset
|
3 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
79759 | 4 Free Software Foundation, Inc. |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
5 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
6 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
|
7 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
8 GNU Emacs is free software: you can redistribute it and/or modify |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
9 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
11 (at your option) any later version. |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
12 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
13 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
|
14 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
|
15 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
|
16 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
|
17 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
20 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
21 #include <config.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
22 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
23 #ifdef HAVE_X_SM |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
24 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
25 #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
|
26 #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
|
27 #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
|
28 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
29 #include <unistd.h> |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
30 #include <sys/param.h> |
43848
1690ab476469
Include stdio.h because termhooks.h needs it.
Gerd Moellmann <gerd@gnu.org>
parents:
43810
diff
changeset
|
31 #include <stdio.h> |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100951
diff
changeset
|
32 #include <setjmp.h> |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
33 |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
65421
diff
changeset
|
34 #include "lisp.h" |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
35 #include "systime.h" |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
36 #include "sysselect.h" |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
37 #include "frame.h" |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
38 #include "termhooks.h" |
43848
1690ab476469
Include stdio.h because termhooks.h needs it.
Gerd Moellmann <gerd@gnu.org>
parents:
43810
diff
changeset
|
39 #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
|
40 #include "xterm.h" |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
41 |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
42 /* Avoid "differ in sign" warnings */ |
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
43 #define SSDATA(x) ((char *) SDATA (x)) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
44 |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
45 /* 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
|
46 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
47 static struct input_event emacs_event; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
48 |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
49 /* 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
|
50 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
51 static int ice_fd; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
52 |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
53 /* 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
|
54 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
55 static int doing_interact; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
56 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
57 /* 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
|
58 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
59 static SmcConn smc_conn; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
60 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
61 /* 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
|
62 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
63 static char *client_id; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
64 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
65 /* 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
|
66 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
67 static char *emacs_program; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
68 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
69 /* 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
|
70 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
|
71 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
72 #define SMID_OPT "--smid=" |
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 |
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
|
75 /* 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
|
76 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
|
77 |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
78 static char NOSPLASH_OPT[] = "--no-splash"; |
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
|
79 |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
80 /* The option to make Emacs start in the given directory. */ |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
81 |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
82 #define CHDIR_OPT "--chdir=" |
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
|
83 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
84 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
85 ice_connection_closed (void) |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
86 { |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
87 if (ice_fd >= 0) |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
88 delete_keyboard_wait_descriptor (ice_fd); |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
89 ice_fd = -1; |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
90 } |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
91 |
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
|
92 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
93 /* 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
|
94 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
|
95 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
|
96 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
97 int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
98 x_session_check_input (struct input_event *bufp) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
99 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
100 SELECT_TYPE read_fds; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
101 EMACS_TIME tmout; |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
102 int ret; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
103 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
104 if (ice_fd == -1) return 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
105 FD_ZERO (&read_fds); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
106 FD_SET (ice_fd, &read_fds); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
107 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
108 tmout.tv_sec = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
109 tmout.tv_usec = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
110 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
111 /* 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
|
112 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
|
113 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
|
114 will be called. */ |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
115 emacs_event.kind = NO_EVENT; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
116 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
117 ret = select (ice_fd+1, &read_fds, |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
118 (SELECT_TYPE *)0, (SELECT_TYPE *)0, &tmout); |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
119 |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
120 if (ret < 0) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
121 { |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
122 ice_connection_closed (); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
123 } |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
124 else if (ret > 0 && FD_ISSET (ice_fd, &read_fds)) |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
125 { |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
126 ret = IceProcessMessages (SmcGetIceConnection (smc_conn), |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
127 (IceReplyWaitInfo *)0, (Bool *)0); |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
128 if (ret != IceProcessMessagesSuccess) |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
129 { |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
130 /* Either IO error or Connection closed. */ |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
131 if (ret == IceProcessMessagesIOError) |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
132 IceCloseConnection (SmcGetIceConnection (smc_conn)); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
133 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
134 ice_connection_closed (); |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
135 } |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
136 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
137 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
138 /* 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
|
139 SAVE_SESSION_EVENT. */ |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
140 if (emacs_event.kind != NO_EVENT) |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109141
diff
changeset
|
141 memcpy (bufp, &emacs_event, sizeof (struct input_event)); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
142 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
143 return emacs_event.kind != NO_EVENT ? 1 : 0; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
144 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
145 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
146 /* 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
|
147 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
148 int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
149 x_session_have_connection (void) |
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 return ice_fd != -1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
152 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
153 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
154 /* 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
|
155 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
|
156 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
|
157 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
158 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
159 smc_interact_CB (SmcConn smcConn, SmPointer clientData) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
160 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
161 doing_interact = True; |
45803
9484de301252
Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents:
43919
diff
changeset
|
162 emacs_event.kind = SAVE_SESSION_EVENT; |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
163 emacs_event.arg = Qnil; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
164 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
165 |
49421
381ccbf15cd9
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
47942
diff
changeset
|
166 /* 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
|
167 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
|
168 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
|
169 are started in the correct directory. |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
170 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
171 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
|
172 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
|
173 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
174 static void |
109139
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
175 smc_save_yourself_CB (SmcConn smcConn, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
176 SmPointer clientData, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
177 int saveType, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
178 Bool shutdown, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
179 int interactStyle, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
180 Bool fast) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
181 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
182 #define NR_PROPS 5 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
183 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
184 SmProp *props[NR_PROPS]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
185 SmProp prop_ptr[NR_PROPS]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
186 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
187 SmPropValue values[20]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
188 int val_idx = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
189 int props_idx = 0; |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
190 int i; |
65412
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
191 char *cwd = NULL; |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
192 char *smid_opt, *chdir_opt = NULL; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
193 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
194 /* 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
|
195 props[props_idx] = &prop_ptr[props_idx]; |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
196 props[props_idx]->name = xstrdup (SmCloneCommand); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
197 props[props_idx]->type = xstrdup (SmLISTofARRAY8); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
198 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 ++props_idx; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
203 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
204 /* The name of the program. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
205 props[props_idx] = &prop_ptr[props_idx]; |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
206 props[props_idx]->name = xstrdup (SmProgram); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
207 props[props_idx]->type = xstrdup (SmARRAY8); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
208 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
209 props[props_idx]->vals = &values[val_idx++]; |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
210 props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name)); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45803
diff
changeset
|
211 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
|
212 ++props_idx; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
213 |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
214 /* How to restart Emacs. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
215 props[props_idx] = &prop_ptr[props_idx]; |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
216 props[props_idx]->name = xstrdup (SmRestartCommand); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
217 props[props_idx]->type = xstrdup (SmLISTofARRAY8); |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
218 /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */ |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
219 props[props_idx]->num_vals = 4; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
224 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
|
225 strcpy (smid_opt, SMID_OPT); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
226 strcat (smid_opt, client_id); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
227 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
228 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
|
229 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
|
230 |
03e0aadb68a0
xsmfns.c (smc_save_yourself_CB): Add --no-splash to options
Jan Djärv <jan.h.d@swipnet.se>
parents:
49421
diff
changeset
|
231 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
|
232 props[props_idx]->vals[2].value = NOSPLASH_OPT; |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
233 |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
234 cwd = get_current_dir_name (); |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
235 if (cwd) |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
236 { |
108237
4f8f06b9b90b
xsmfns.c (smc_save_yourself_CB): strlen(client_id) => strlen(cwd).
Jan D. <jan.h.d@swipnet.se>
parents:
108213
diff
changeset
|
237 chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1); |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
238 strcpy (chdir_opt, CHDIR_OPT); |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
239 strcat (chdir_opt, cwd); |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
240 |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
241 props[props_idx]->vals[3].length = strlen (chdir_opt); |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
242 props[props_idx]->vals[3].value = chdir_opt; |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
243 } |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
244 |
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
245 val_idx += cwd ? 4 : 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]; |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
250 props[props_idx]->name = xstrdup (SmUserID); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
251 props[props_idx]->type = xstrdup (SmARRAY8); |
43810
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++]; |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
254 props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name)); |
46370
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 |
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
259 if (cwd) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
260 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
261 props[props_idx] = &prop_ptr[props_idx]; |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
262 props[props_idx]->name = xstrdup (SmCurrentDirectory); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
263 props[props_idx]->type = xstrdup (SmARRAY8); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
264 props[props_idx]->num_vals = 1; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 ++props_idx; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
269 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
270 |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
271 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
272 SmcSetProperties (smcConn, props_idx, props); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
273 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
274 xfree (smid_opt); |
108213
e6266e624471
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Jan D. <jan.h.d@swipnet.se>
parents:
107121
diff
changeset
|
275 xfree (chdir_opt); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
276 |
95479
9588c3703f38
remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents:
95252
diff
changeset
|
277 free (cwd); |
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
278 for (i = 0; i < props_idx; ++i) |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
279 { |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
280 xfree (props[i]->type); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
281 xfree (props[i]->name); |
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109573
diff
changeset
|
282 } |
65412
3a9693f993b2
(smc_save_yourself_CB): Use get_current_dir_name.
Eli Zaretskii <eliz@gnu.org>
parents:
64770
diff
changeset
|
283 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
284 /* 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
|
285 if (interactStyle != SmInteractStyleAny |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
286 || ! shutdown |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
287 || saveType == SmSaveLocal |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
288 || ! 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
|
289 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
290 /* 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
|
291 SmcSaveYourselfDone (smcConn, True); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
292 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
293 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
294 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
295 /* 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
|
296 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
297 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
298 smc_die_CB (SmcConn smcConn, SmPointer clientData) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
299 { |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
300 emacs_event.kind = SAVE_SESSION_EVENT; |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
301 emacs_event.arg = Qt; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
302 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
303 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
304 /* 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
310 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
311 smc_save_complete_CB (SmcConn smcConn, SmPointer clientData) |
43810
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 |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
317 smc_shutdown_cancelled_CB (SmcConn smcConn, SmPointer clientData) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
318 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
319 /* Empty */ |
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 |
49421
381ccbf15cd9
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
47942
diff
changeset
|
322 /* 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
|
323 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
|
324 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
325 static void |
109139
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
326 smc_error_handler (SmcConn smcConn, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
327 Bool swap, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
328 int offendingMinorOpcode, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
329 unsigned long offendingSequence, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
330 int errorClass, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
331 int severity, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
332 SmPointer values) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
333 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
334 /* Empty */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
335 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
336 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
337 static void |
109139
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
338 ice_error_handler (IceConn iceConn, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
339 Bool swap, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
340 int offendingMinorOpcode, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
341 unsigned long offendingSequence, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
342 int errorClass, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
343 int severity, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
344 IcePointer values) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
345 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
346 /* Empty */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
347 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
348 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
349 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
350 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
351 ice_io_error_handler (IceConn iceConn) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
352 { |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
353 /* Connection probably gone. */ |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
354 ice_connection_closed (); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
355 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
356 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
357 /* 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
|
358 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
|
359 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
360 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
361 ice_conn_watch_CB (IceConn iceConn, IcePointer clientData, int opening, IcePointer *watchData) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
362 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
363 if (! opening) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
364 { |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
365 ice_connection_closed (); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
366 return; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
367 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
368 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
369 ice_fd = IceConnectionNumber (iceConn); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
370 #ifdef F_SETOWN |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
371 fcntl (ice_fd, F_SETOWN, getpid ()); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
372 #endif /* ! defined (F_SETOWN) */ |
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 #ifdef SIGIO |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
375 if (interrupt_input) |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
376 init_sigio (ice_fd); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
377 #endif /* ! defined (SIGIO) */ |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
378 |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
379 add_keyboard_wait_descriptor (ice_fd); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
380 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
381 |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
382 /* 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
|
383 |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
384 #ifndef USE_GTK |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
385 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
386 create_client_leader_window (struct x_display_info *dpyinfo, char *client_id) |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
387 { |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
392 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
|
393 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
|
394 -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
|
395 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
|
396 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
397 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
|
398 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
|
399 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
|
400 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
|
401 |
111512
4f757d8e8ed7
Apply XAtom revork patches from Julien Danjou.
Jan D. <jan.h.d@swipnet.se>
parents:
109748
diff
changeset
|
402 XChangeProperty (dpyinfo->display, w, dpyinfo->Xatom_SM_CLIENT_ID, |
4f757d8e8ed7
Apply XAtom revork patches from Julien Danjou.
Jan D. <jan.h.d@swipnet.se>
parents:
109748
diff
changeset
|
403 XA_STRING, 8, PropModeReplace, |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
404 (unsigned char *)client_id, strlen (client_id)); |
52298
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
405 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
406 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
|
407 } |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
408 #endif /* ! USE_GTK */ |
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
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 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
411 /* 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
|
412 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
413 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
414 x_session_initialize (struct x_display_info *dpyinfo) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
415 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
416 #define SM_ERRORSTRING_LEN 512 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
417 char errorstring[SM_ERRORSTRING_LEN]; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
418 char* previous_id = NULL; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
419 SmcCallbacks callbacks; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
420 int name_len = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
421 |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
422 ice_fd = -1; |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
423 doing_interact = False; |
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
424 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
425 /* 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
|
426 have a previous id. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
427 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
428 previous_id = SSDATA (Vx_session_previous_id); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
429 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
430 /* 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
|
431 if (! EQ (Vinvocation_directory, Qnil)) |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
432 name_len += strlen (SSDATA (Vinvocation_directory)); |
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
433 name_len += strlen (SSDATA (Vinvocation_name)); |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
434 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
435 /* 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
|
436 not very large */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
437 emacs_program = xmalloc (name_len + 1); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
438 emacs_program[0] = '\0'; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
439 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
440 if (! EQ (Vinvocation_directory, Qnil)) |
109141
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
441 strcpy (emacs_program, SSDATA (Vinvocation_directory)); |
fa173b9bd9ce
Fix some bad prototypes and formatting after conversion from K&R declaration.
Jan D <jan.h.d@swipnet.se>
parents:
109139
diff
changeset
|
442 strcat (emacs_program, SSDATA (Vinvocation_name)); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
443 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
444 /* 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
|
445 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
|
446 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
|
447 callbacks.save_yourself.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
448 callbacks.die.callback = smc_die_CB; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
449 callbacks.die.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
450 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
|
451 callbacks.save_complete.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
452 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
|
453 callbacks.shutdown_cancelled.client_data = 0; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
454 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
455 /* Set error handlers. */ |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
456 SmcSetErrorHandler (smc_error_handler); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
457 IceSetErrorHandler (ice_error_handler); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
458 IceSetIOErrorHandler (ice_io_error_handler); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
459 |
57704
4ff1d695430a
* xsmfns.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
56135
diff
changeset
|
460 /* 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
|
461 IceAddConnectionWatch (ice_conn_watch_CB, 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 /* 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
|
464 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
|
465 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
|
466 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
|
467 (SmcSaveYourselfProcMask| |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
468 SmcDieProcMask| |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
469 SmcSaveCompleteProcMask| |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
470 SmcShutdownCancelledProcMask), |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
471 &callbacks, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
472 previous_id, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
473 &client_id, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
474 SM_ERRORSTRING_LEN, |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
475 errorstring); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
476 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
477 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
|
478 { |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
479 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
|
480 |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
481 #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
|
482 /* 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
|
483 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
|
484 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
|
485 #else |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
486 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
|
487 #endif |
1a4bd2bec861
Create and initialize a client leader window so session management
Jan Djärv <jan.h.d@swipnet.se>
parents:
50016
diff
changeset
|
488 } |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
489 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
490 |
83350
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
491 /* 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
|
492 |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
493 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
494 x_session_close (void) |
83350
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
495 { |
107121
c7c70f9fa3d7
Fix for bug#5512, don't rely on SIGIO alone.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
496 ice_connection_closed (); |
83350
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
497 } |
e7d5238afe52
Work around crashes in X session management after normal shutdown of X server.
Karoly Lorentey <lorentey@elte.hu>
parents:
83332
diff
changeset
|
498 |
43810
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 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
|
501 Shandle_save_session, 1, 1, "e", |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
511 Do not call this function yourself. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
512 (Lisp_Object event) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
513 { |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
514 int kill_emacs = CONSP (event) && CONSP (XCDR (event)) |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
515 && EQ (Qt, XCAR (XCDR (event))); |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
516 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
517 /* 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
|
518 this at the wrong time. */ |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
519 if (doing_interact && ! kill_emacs) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
520 { |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
521 Bool cancel_shutdown = False; |
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 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
|
524 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
525 SmcInteractDone (smc_conn, cancel_shutdown); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
526 SmcSaveYourselfDone (smc_conn, True); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
527 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
528 doing_interact = False; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
529 } |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
530 else if (kill_emacs) |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
531 { |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
532 /* We should not do user interaction here, but it is not easy to |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
533 prevent. Fix this in next version. */ |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
534 Fkill_emacs (Qnil); |
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
|
535 |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
536 /* This will not be reached, but we want kill-emacs-hook to be run. */ |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
537 SmcCloseConnection (smc_conn, 0, 0); |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
538 ice_connection_closed (); |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
539 } |
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
540 |
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
|
541 return Qnil; |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
542 } |
111934
898651f66853
Move call to Fkill_emacs from signal handler (session event) (Bug#7552).
Jan D. <jan.h.d@swipnet.se>
parents:
111917
diff
changeset
|
543 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
544 |
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 /*********************************************************************** |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
547 Initialization |
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 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108237
diff
changeset
|
550 syms_of_xsmfns (void) |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
551 { |
112364
42e22c4f06b7
Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents:
112330
diff
changeset
|
552 DEFVAR_LISP ("x-session-id", Vx_session_id, |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
553 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
|
554 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
|
555 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
|
556 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
|
557 `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
|
558 Vx_session_id = Qnil; |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
559 |
112364
42e22c4f06b7
Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents:
112330
diff
changeset
|
560 DEFVAR_LISP ("x-session-previous-id", Vx_session_previous_id, |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
561 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
|
562 If Emacs is running on a window system that has a session manager, the |
73801
14ab09766fec
(syms_of_xsmfns): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
563 session manager gives Emacs a session id. It is feasible for Emacs Lisp |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
564 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
|
565 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
|
566 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
|
567 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
|
568 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
569 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
|
570 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
|
571 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
|
572 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
|
573 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
|
574 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
575 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
|
576 `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
|
577 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
|
578 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
579 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
|
580 `emacs-session-restore'." */); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
581 Vx_session_previous_id = Qnil; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
582 |
43810
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
583 defsubr (&Shandle_save_session); |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
584 } |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
585 |
3d8039f847f5
New file for X session management.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff
changeset
|
586 #endif /* HAVE_X_SM */ |
52401 | 587 |