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 /* $TOG: WmGWsInfo.c /main/7 1997/11/13 14:03:00 bill $
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1992-1994,1996 Hewlett-Packard Company.
27 * (c) Copyright 1993,1994,1996 International Business Machines Corp.
28 * (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
29 * (c) Copyright 1993,1994,1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
34 /************************************<+>*************************************
35 ****************************************************************************
39 ** Project: DT Workspace Manager
41 ** Description: Get Dt Workspace Info
43 ****************************************************************************
44 ************************************<+>*************************************/
47 #include <X11/Xutil.h>
51 #include <Xm/AtomMgr.h>
52 #include <X11/Xatom.h>
53 #include "DtSvcLock.h"
55 /*************************************<->*************************************
57 * int DtWsmGetWorkspaceInfo (display, root, aWS, ppWsInfo)
62 * Get the contents of the _DT_WORKSPACE_INFO_<name> property
63 * for workspace <name>.
69 * root - root window of screen of interest
70 * aWS - atom for workspace
71 * ppWsInfo - ptr to WS info buffer ptr (to be returned)
75 * *ppWsInfo - returned ptr to WS Info. (free with XtFree).
80 * ptr to WorkspaceInfo should be freed by calling
81 * DtWsmFreeWorkspaceInfo.
83 *************************************<->***********************************/
85 DtWsmGetWorkspaceInfo(
89 DtWsmWorkspaceInfo **ppWsInfo)
94 DtWsmWorkspaceInfo *pWsInfo;
102 _DtSvcDisplayToAppContext(display);
106 * Construct atom name
108 pchName = (char *) XGetAtomName (display, aWS);
109 iLen = strlen(pchName) + strlen (_XA_DT_WORKSPACE_INFO) + 4;
111 pch = (char *) XtMalloc (iLen);
112 strcpy (pch, _XA_DT_WORKSPACE_INFO);
114 strcat (pch, pchName);
116 aProperty = XInternAtom (display, pch, FALSE);
118 XFree ((char *) pchName);
119 XtFree ((char *) pch);
123 * Get window where property is
125 if ((rcode=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
127 if ((rcode=XGetTextProperty(
131 aProperty))>=Success)
133 if (rcode=XmbTextPropertyToTextList (
139 pWsInfo = (DtWsmWorkspaceInfo *)
140 XtCalloc(1, sizeof(DtWsmWorkspaceInfo));
142 pWsInfo->workspace = aWS;
148 pWsInfo->pchTitle = (char *)
149 XtNewString ((String) ppchList[item]);
156 pWsInfo->colorSetId = atoi (ppchList[item]);
160 /* backdrop window (moved to end!) */
162 /* backdrop background */
165 pWsInfo->bg = (unsigned long)
166 strtol (ppchList[item], (char **) NULL, 0);
170 /* backdrop foreground */
173 pWsInfo->fg = (unsigned long)
174 strtol (ppchList[item], (char **) NULL, 0);
178 /* backdrop name (atom) */
181 pWsInfo->backdropName =
182 (Atom) strtol (ppchList[item], (char **) NULL, 0);
186 /* number of backdrop windows */
189 pWsInfo->numBackdropWindows =
190 (int) strtol (ppchList[item], (char **) NULL, 0);
194 /* list of backdrop windows */
195 if (pWsInfo->numBackdropWindows > 0 &&
196 (item + pWsInfo->numBackdropWindows) <= count)
199 XtMalloc (pWsInfo->numBackdropWindows *
201 for (i=0; i<pWsInfo->numBackdropWindows; i++)
204 strtol (ppchList[item], (char **) NULL, 0);
207 pWsInfo->backdropWindows = pWin;
211 /* Bogus backdrop windows info */
212 pWsInfo->numBackdropWindows = 0;
215 /* pass back ptr to filled in structure */
218 /* free the converted data */
219 XFreeStringList (ppchList);
223 /* conversion failed */
226 /* free the property data */
232 if (rcode >= Success) rcode=Success;
234 _DtSvcAppUnlock(app);
237 } /* END OF FUNCTION DtWsmGetWorkspaceInfo */
241 /*************************************<->*************************************
243 * void DtWsmFreeWorkspaceInfo (pWsInfo)
248 * Free a WorkspaceInfo buffer
253 * pWsInfo - ptr to WS info buffer
262 *************************************<->***********************************/
264 DtWsmFreeWorkspaceInfo(
265 DtWsmWorkspaceInfo *pWsInfo)
269 if (pWsInfo->pchTitle)
270 XtFree (pWsInfo->pchTitle);
271 if (pWsInfo->backdropWindows)
272 XtFree ((char *)pWsInfo->backdropWindows);
273 XtFree ((char *)pWsInfo);
276 } /* END OF FUNCTION DtWsmFreeWorkspaceInfo */