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 librararies 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: $TOG: setup.c /main/4 1997/06/18 17:33:23 samborn $
32 ** (c) Copyright 1995, Hewlett-Packard Company, all rights reserved.
34 ******************************************************************************
35 *****************************************************************************/
42 /*********************************************************************
44 * Setup PDM_MANAGER selection and TYPE atoms
46 Bool _PdmMgrSetup( Display *sel_display, Window sel_window, Bool security_flag )
48 enum { XA_PDM_START, XA_PDM_REPLY, XA_TARGETS, XA_TIMESTAMP,
49 XA_MULTIPLE, XA_PDM_START_OK, XA_PDM_START_VXAUTH,
50 XA_PDM_START_PXAUTH, XA_PDM_START_ERROR, XA_PDM_EXIT_OK,
51 XA_PDM_EXIT_CANCEL, XA_PDM_EXIT_VXAUTH, XA_PDM_EXIT_PXAUTH,
52 XA_PDM_EXIT_ERROR, XA_PDM_MBOX, XA_PDM_MAIL, NUM_ATOMS };
53 static char *atom_names[] = {
54 "PDM_START", "PDM_REPLY", "TARGETS", "TIMESTAMP",
55 "MULTIPLE", "PDM_START_OK", "PDM_START_VXAUTH",
56 "PDM_START_PXAUTH", "PDM_START_ERROR", "PDM_EXIT_OK",
57 "PDM_EXIT_CANCEL", "PDM_EXIT_VXAUTH", "PDM_EXIT_PXAUTH",
58 "PDM_EXIT_ERROR", "PDM_MBOX", "PDM_MAIL" };
61 Atom atoms[XtNumber(atom_names)];
64 * Create PDM_MANAGER atoms.
66 XInternAtoms( sel_display, atom_names, XtNumber(atom_names), False, atoms );
68 g.pdm_selection = XInternAtom( sel_display, g.alt_selection, False );
69 g.pdm_start = atoms[XA_PDM_START];
70 g.pdm_reply = atoms[XA_PDM_REPLY];
71 g.pdm_targets = atoms[XA_TARGETS];
72 g.pdm_timestamp = atoms[XA_TIMESTAMP];
73 g.pdm_multiple = atoms[XA_MULTIPLE];
75 g.pdm_start_ok = atoms[XA_PDM_START_OK];
76 g.pdm_start_vxauth = atoms[XA_PDM_START_VXAUTH];
77 g.pdm_start_pxauth = atoms[XA_PDM_START_PXAUTH];
78 g.pdm_start_error = atoms[XA_PDM_START_ERROR];
80 g.pdm_exit_ok = atoms[XA_PDM_EXIT_OK];
81 g.pdm_exit_cancel = atoms[XA_PDM_EXIT_CANCEL];
82 g.pdm_exit_vxauth = atoms[XA_PDM_EXIT_VXAUTH];
83 g.pdm_exit_pxauth = atoms[XA_PDM_EXIT_PXAUTH];
84 g.pdm_exit_error = atoms[XA_PDM_EXIT_ERROR];
87 g.pdm_mbox = atoms[XA_PDM_MBOX];
88 g.pdm_mail = atoms[XA_PDM_MAIL];
91 g.pdm_mbox = (Atom) 0;
92 g.pdm_mail = (Atom) 0;
95 if ( XGetSelectionOwner(sel_display, g.pdm_selection) != None ) {
97 * Someone else already owns the selection.
99 return( /* cannot become owner */ False );
103 * Claim ownership of the selection.
106 while ((XGetSelectionOwner(sel_display, g.pdm_selection)!=sel_window)) {
108 return( /* cannot become owner */ False );
110 XSetSelectionOwner( sel_display, g.pdm_selection, sel_window,
114 return( /* became owner */ True );