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: WmGWsList.c /main/6 1996/06/21 17:24:26 ageorge $
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 List
43 ****************************************************************************
44 ************************************<+>*************************************/
47 #include <X11/Xutil.h>
51 #include <Xm/AtomMgr.h>
52 #include <X11/Xatom.h>
53 #include "DtSvcLock.h"
55 /*************************************<->*************************************
57 * int DtWsmGetWorkspaceList (display, root, ppWorkspaceList,
63 * Get the contents of the _DT_WORKSPACE_LIST property
69 * root - root window of screen of interest
70 * pNumWorkspaces - the number of workspaces returned
71 * ppWorkspaceList - pointer to a pointer to return
75 * *ppDtWmHints-points to the Workspace List
76 * (NOTE: This should be freed using XFree)
81 *************************************<->***********************************/
83 DtWsmGetWorkspaceList(
86 Atom **ppWorkspaceList,
91 unsigned long leftover, items, length, oldlength;
95 _DtSvcDisplayToAppContext(display);
99 if ((rcode=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
102 property = XmInternAtom(display, _XA_DT_WORKSPACE_LIST, False);
105 *ppWorkspaceList = NULL;
106 if ((rcode=XGetWindowProperty(
113 XA_ATOM, /* req_type */
116 &items, /* items returned */
118 (unsigned char **)ppWorkspaceList))==Success)
121 if (actualType != XA_ATOM)
123 /* wrong type, force failure */
125 if (actualType != None)
127 XFree ((char *)*ppWorkspaceList);
129 *ppWorkspaceList = NULL;
133 *pNumWorkspaces = (int) items;
138 _DtSvcAppUnlock(app);
141 } /* END OF FUNCTION DtWsmGetWorkspaceList */
143 /*************************************<->*************************************
145 * int DtWsmGetCurrentWorkspace (display, root, paWorkspace)
150 * Get the contents of the _DT_WORKSPACE_CURRENT property
156 * root - root window of screen of interest
157 * paWorkspace - pointer to a Atom of current workspace (returned)
161 * *paWorkspace - atom for current workspace (represents "name"
166 * The Atom is copied to the caller's space. Nothing needs to be
169 *************************************<->***********************************/
171 DtWsmGetCurrentWorkspace (
178 unsigned long leftover, items, length;
183 _DtSvcDisplayToAppContext(display);
186 if ((rcode=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
189 property = XmInternAtom(display, _XA_DT_WORKSPACE_CURRENT, False);
192 if ((rcode=XGetWindowProperty(
199 XA_ATOM, /* req_type */
202 &items, /* items returned */
204 (unsigned char **)&paTemp))==Success)
207 if (actualType != XA_ATOM)
209 /* wrong type, force failure */
211 if (actualType != None)
213 XFree ((char *)paTemp);
218 *paWorkspace = *paTemp;
219 XFree((char *) paTemp);
224 _DtSvcAppUnlock(app);
227 } /* END OF FUNCTION DtWsmGetCurrentWorkspace */