57 |
|
|
58 |
extern Lisp_Object Vuser_login_name; |
extern Lisp_Object Vuser_login_name; |
59 |
|
|
60 |
/* This is the event used when save_session occurs */ |
/* This is the event used when SAVE_SESSION_EVENT occurs. */ |
61 |
|
|
62 |
static struct input_event emacs_event; |
static struct input_event emacs_event; |
63 |
|
|
64 |
/* The descriptor that we use to check for data from the session manager. */ |
/* The descriptor that we use to check for data from the session manager. */ |
65 |
|
|
66 |
static int ice_fd = -1; |
static int ice_fd = -1; |
67 |
|
|
68 |
/* A flag that says if we are in shutdown interactions or not. */ |
/* A flag that says if we are in shutdown interactions or not. */ |
69 |
|
|
70 |
static int doing_interact = False; |
static int doing_interact = False; |
71 |
|
|
98 |
open to a session manager, just return 0. |
open to a session manager, just return 0. |
99 |
Otherwise returns the number of events stored in buffer BUFP, |
Otherwise returns the number of events stored in buffer BUFP, |
100 |
which can hold up to *NUMCHARS characters. At most one event is |
which can hold up to *NUMCHARS characters. At most one event is |
101 |
stored, an save_session_event. */ |
stored, an SAVE_SESSION_EVENT. */ |
102 |
int |
int |
103 |
x_session_check_input (bufp, numchars) |
x_session_check_input (bufp, numchars) |
104 |
struct input_event *bufp; |
struct input_event *bufp; |
117 |
|
|
118 |
/* Reset this so wo can check kind after callbacks have been called by |
/* Reset this so wo can check kind after callbacks have been called by |
119 |
IceProcessMessages. The smc_interact_CB sets the kind to |
IceProcessMessages. The smc_interact_CB sets the kind to |
120 |
save_session_event, but we don't know beforehand if that callback |
SAVE_SESSION_EVENT, but we don't know beforehand if that callback |
121 |
will be called. */ |
will be called. */ |
122 |
emacs_event.kind = no_event; |
emacs_event.kind = NO_EVENT; |
123 |
|
|
124 |
if (select (ice_fd+1, &read_fds, |
if (select (ice_fd+1, &read_fds, |
125 |
(SELECT_TYPE *)0, (SELECT_TYPE *)0, &tmout) < 0) |
(SELECT_TYPE *)0, (SELECT_TYPE *)0, &tmout) < 0) |
135 |
|
|
136 |
|
|
137 |
/* Check if smc_interact_CB was called and we shall generate a |
/* Check if smc_interact_CB was called and we shall generate a |
138 |
save_session event. */ |
SAVE_SESSION_EVENT. */ |
139 |
if (*numchars > 0 && emacs_event.kind != no_event) |
if (*numchars > 0 && emacs_event.kind != NO_EVENT) |
140 |
{ |
{ |
141 |
bcopy (&emacs_event, bufp, sizeof (struct input_event)); |
bcopy (&emacs_event, bufp, sizeof (struct input_event)); |
142 |
bufp++; |
bufp++; |
156 |
} |
} |
157 |
|
|
158 |
/* This is called when the session manager says it is OK to interact with the |
/* This is called when the session manager says it is OK to interact with the |
159 |
user. Here we set the kind to save_session so an event is generated. |
user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated. |
160 |
Then lisp code can interact with the user. */ |
Then lisp code can interact with the user. */ |
161 |
static void |
static void |
162 |
smc_interact_CB (smcConn, clientData) |
smc_interact_CB (smcConn, clientData) |
164 |
SmPointer clientData; |
SmPointer clientData; |
165 |
{ |
{ |
166 |
doing_interact = True; |
doing_interact = True; |
167 |
emacs_event.kind = save_session_event; |
emacs_event.kind = SAVE_SESSION_EVENT; |
168 |
} |
} |
169 |
|
|
170 |
/* This is called when the session manager tells us to save ourself. |
/* This is called when the session manager tells us to save ourself. |