Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Managers / WorkspaceMgr.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  * $XConsortium: WorkspaceMgr.cc /main/1 1996/08/13 14:15:55 cde-hal $
25  *
26  * Copyright (c) 1992 HaL Computer Systems, Inc.  All rights reserved.
27  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28  * States.  Use of a copyright notice is precautionary only and does not
29  * imply publication or disclosure.
30  * 
31  * This software contains confidential information and trade secrets of HaL
32  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
33  * without the prior express written permission of HaL Computer Systems, Inc.
34  * 
35  *                         RESTRICTED RIGHTS LEGEND
36  * Use, duplication, or disclosure by the Government is subject to
37  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38  * Technical Data and Computer Software clause at DFARS 252.227-7013.
39  *                        HaL Computer Systems, Inc.
40  *                  1315 Dell Avenue, Campbell, CA  95008
41  * 
42  */
43
44 #define C_WindowSystem
45 #define L_Other
46
47 #define C_WorkspaceMgr
48 #define L_Managers
49
50 #include "Prelude.h"
51
52 LONG_LIVED_CC( WorkspaceMgr, workspace );
53
54 #include <Xm/XmAll.h>
55 #include <Dt/Wsm.h>
56
57
58 WorkspaceMgr::WorkspaceMgr()
59 {
60     Atom  wsc ;
61
62     current( &wsc ) ;
63     f_target = wsc ;
64
65     DtWsmAddCurrentWorkspaceCallback( window_system().toplevel(),
66                   (DtWsmWsChangeProc) PrimaryWorkspace_cb, this );
67 }
68
69
70 WorkspaceMgr::~WorkspaceMgr()
71 {
72     // XtFree( f_target ) ;
73 }
74
75
76 Status
77 WorkspaceMgr::current( Atom *wscur_ap )
78 {
79     Display *display = XtDisplay(window_system().toplevel()) ;
80     return DtWsmGetCurrentWorkspace( display,
81                                      XDefaultRootWindow(display),
82                                      wscur_ap ) ;
83 }
84
85
86 Status
87 WorkspaceMgr::current( Widget w,
88                        Atom   wst_a )
89 {
90     return DtWsmSetCurrentWorkspace( w, wst_a ) ;
91 }
92
93
94 Status
95 WorkspaceMgr::get( Window w,
96                    Atom **wslp,
97                    unsigned long *wsnum )
98 {
99     Display *display = XtDisplay(window_system().toplevel()) ;
100     return DtWsmGetWorkspacesOccupied( display, w, wslp, wsnum );
101 }
102
103
104 void
105 WorkspaceMgr::put( Window w,
106                    Atom *wslp,
107                    int  wsnum )
108 {
109     Display *display = XtDisplay(window_system().toplevel()) ;
110     DtWsmSetWorkspacesOccupied( display, w, wslp, wsnum );
111 }
112
113
114 void
115 WorkspaceMgr::target( Atom wst_a )
116 {
117     f_target = wst_a ;
118 }
119
120
121 // void
122 // WorkspaceMgr::target( Window w )
123 // {
124 // }
125
126
127 void
128 WorkspaceMgr::PrimaryWorkspace_cb( Widget w,
129                                    Atom aWorkspace,
130                                    XtPointer client_data )
131 {
132     ((WorkspaceMgr*)client_data)->f_actual = aWorkspace ;
133 }
134
135