2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 /******************************************************************************
25 ******************************************************************************
28 ** RCS: $XConsortium: dispatch.c /main/4 1996/05/28 13:33:53 cde-hp $
32 ** (c) Copyright 1995, Hewlett-Packard Company, all rights reserved.
34 ******************************************************************************
35 *****************************************************************************/
37 #define DISPATCH_DOT_C
42 /******************************************************************************
44 * Dispatch PDM_MANAGER requests
46 * note: 'rec->pdm_exec_errorcode' is set to 0 (zero) and
47 * stays that way as long as no errors occur.
48 * Ultimately it gets set to either and error or
51 void dispatch_mgr( XEvent *report )
57 * Locate or create a client record for this request.
59 rec = find_rec( report->xselectionrequest.requestor );
62 * Setup the client record per the request.
64 mgr_initialize( report, rec );
66 if ( rec->pdm_exec_errorcode ) {
68 * Reply to requestor, but with bad news that
69 * basic initialization in prep to launch a
70 * pdm could not be completed.
72 mgr_launch_reply( rec );
79 * Locate the pdm to be launched.
83 if ( rec->pdm_exec_errorcode ) {
85 * Reply to requestor, but with bad news that
86 * selection of a pdm to launch could not be
89 mgr_launch_reply( rec );
98 mgr_launch_pdm( rec );
100 if ( rec->pdm_exec_errorcode ) {
102 * Reply to requestor, but with bad news that
103 * the pdm could not be launched.
105 mgr_launch_reply( rec );
112 * Set state flags indicating a pdm has been started, but
113 * defer the calling of 'mgr_launch_reply' until after the
114 * pdm itself tells us it is up and running.
116 * The pdm can generate stderr which we will trap, and can
117 * generate a SIGCLD which we will also trap and take
120 rec->pdm_exec_errorcode = g.pdm_start_ok;
121 rec->do_launch_reply = True;
122 /* sometime later someone else calls mgr_launch_reply( rec ) */
127 /******************************************************************************
129 * Dispatch MBOX and MAIL requests
131 void dispatch_mbox( XEvent *report )
133 XpPdmServiceRec *rec;
136 if (report->type == SelectionRequest) {
138 * Locate or create a client record for this request.
140 rec = find_rec( report->xselectionrequest.requestor );
142 mbox_initialize( report, rec );
148 else /* if (report->type == ClientMessage) */ {
150 * Locate (do not create) a client record for this request.
152 rec = find_rec_by_mbox_win( report->xclient.window );
154 mbox_receive( rec, report );
160 /******************************************************************************
162 * Dispatch TARGETS requests
164 void dispatch_targets( XEvent *report )
174 target_list = (Atom *) Xmalloc( sizeof(Atom) * target_count );
176 target_list[0] = g.pdm_targets;
177 target_list[1] = g.pdm_start;
178 target_list[2] = g.pdm_timestamp;
179 target_list[3] = g.pdm_mbox;
181 /* target_list[4] = g.pdm_multiple; */
183 XChangeProperty( report->xselectionrequest.display,
184 report->xselectionrequest.requestor,
185 report->xselectionrequest.property,
189 (unsigned char *) target_list,
192 reply.xselection.type = SelectionNotify;
193 reply.xselection.requestor = report->xselectionrequest.requestor;
194 reply.xselection.selection = report->xselectionrequest.selection;
195 reply.xselection.target = report->xselectionrequest.target;
196 reply.xselection.property = report->xselectionrequest.property;
197 reply.xselection.time = report->xselectionrequest.time;
199 status = XSendEvent( report->xselectionrequest.display,
200 report->xselectionrequest.requestor,
205 /******************************************************************************
207 * Dispatch MULTIPLE requests
209 void dispatch_multiple( XEvent *report )
214 /******************************************************************************
216 * Dispatch TIMESTAMP requests
218 void dispatch_timestamp( XEvent *report )
224 XChangeProperty( report->xselectionrequest.display,
225 report->xselectionrequest.requestor,
226 report->xselectionrequest.property,
230 (unsigned char *) &g.time,
233 reply.xselection.type = SelectionNotify;
234 reply.xselection.requestor = report->xselectionrequest.requestor;
235 reply.xselection.selection = report->xselectionrequest.selection;
236 reply.xselection.target = report->xselectionrequest.target;
237 reply.xselection.property = report->xselectionrequest.property;
238 reply.xselection.time = report->xselectionrequest.time;
240 status = XSendEvent( report->xselectionrequest.display,
241 report->xselectionrequest.requestor,
245 /******************************************************************************
247 * Dispatch unsupported selection requests
249 void dispatch_not_supported( XEvent *report )
254 reply.xselection.type = SelectionNotify;
255 reply.xselection.requestor = report->xselectionrequest.requestor;
256 reply.xselection.selection = report->xselectionrequest.selection;
257 reply.xselection.target = report->xselectionrequest.target;
258 reply.xselection.property = None;
259 reply.xselection.time = report->xselectionrequest.time;
261 status = XSendEvent( report->xselectionrequest.display,
262 report->xselectionrequest.requestor,