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
23 /* $XConsortium: SmProperty.c /main/7 1996/02/08 11:27:32 barstow $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
30 /*************************************<+>*************************************
31 *****************************************************************************
35 ** Project: HP DT Session Manager (dtsession)
39 ** This file contains routines that deal with the properties used by the
40 ** session manager to save and restore client information.
44 *******************************************************************
45 ** (c) Copyright Hewlett-Packard Company, 1990. All rights are
46 ** reserved. Copying or other reproduction of this program
47 ** except for archival purposes is prohibited without prior
48 ** written consent of Hewlett-Packard Company.
49 ********************************************************************
53 *****************************************************************************
54 *************************************<+>*************************************/
57 #include <X11/Intrinsic.h>
58 #include <X11/Xutil.h>
59 #include <X11/Xatom.h>
61 #include "SmProtocol.h"
65 /*************************************<->*************************************
67 * GetStandardProperties -
70 * Description: returns information about the specified window
75 * window = window for which we are getting properties
79 * argv = data returned from WM_COMMAND property (to restart client)
80 * argc = number of arguments returned from WM_COMMAND property
81 * clientMachine = which machine is client running on
82 * xsmpClient = True if the client is XSMP and False otherwise
83 * screen = window's screen number
87 * All X (except GetWMHints) were not available until R4 and therefore have
88 * R4 or greater dependencies.
90 * BEWARE OF THESE ROUTINES: The XGetWindowProperty routine returns 0 if
91 * it succeeds. These routines (which were derived from XGetWindowProperty
92 * return 0 if they FAIL.
94 *************************************<->***********************************/
95 Status GetStandardProperties(
98 int *argc, /* RETURNED */
99 char ***argv, /* RETURNED */
100 char **clientMachine, /* RETURNED */
101 Boolean *xsmpClient) /* RETURNED */
105 XTextProperty sessProp;
108 unsigned long bytesAfter;
109 unsigned long nitems;
110 unsigned char *data = NULL;
113 * If this client is participating in the XSMP, then don't save
114 * it as a proxy (pre-XSMP) client. However, do cache its
115 * screen number before returning.
117 if (XGetWindowProperty(smGD.display, window, XaSmClientId, 0L,
118 (long) BUFSIZ, False, XA_STRING, &actType,
119 &actFormat, &nitems, &bytesAfter, &data) == Success)
121 if (data && actType == XA_STRING)
123 ClientRecPtr pClient;
125 for (pClient = connectedList; pClient != NULL;
126 pClient = pClient->next) {
127 if (!strcmp ((char *) data, pClient->clientId)) {
128 pClient->screenNum = screen;
133 SM_FREE ((char *) data);
136 SM_FREE ((char *) data);
141 * Get WM_COMMAND property
143 if ((cc=XGetCommand(smGD.display,window,argv,argc))==0)
147 * If there is no argc or argv - don't bother going on. We're not
148 * going to save anything anyway
155 * Get WM_CLIENT_MACHINE property
157 if ((cc=XGetWMClientMachine(smGD.display,window,&sessProp))==0)
159 *clientMachine = NULL;
163 *clientMachine = (char *) sessProp.value;