Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / DtUtil1 / WmRestart.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 /* $XConsortium: WmRestart.c /main/5 1996/05/20 16:08:04 drk $
24  *
25  * (c) Copyright 1996 Digital Equipment Corporation.
26  * (c) Copyright 1991,1993,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.
32  */
33
34 /************************************<+>*************************************
35  ****************************************************************************
36  **
37  **   File:     WmRestart.c
38  **
39  **   Project:  HP DT Workspace Manager
40  **
41  **   Description: Request restart of the HP DT workspace manager
42  **
43  ****************************************************************************
44  ************************************<+>*************************************/
45 #include <stdio.h>
46 #include <X11/Xlib.h>
47 #include <X11/Xutil.h>
48 #include <X11/Xatom.h>
49 #include <Dt/Wsm.h> 
50 #include <Dt/WsmP.h> 
51 #include <Xm/Xm.h>
52 #include <Xm/AtomMgr.h>
53
54
55 \f
56 /*************************************<->*************************************
57  *
58  *  _DtWmRestart (display, root)
59  *
60  *
61  *  Description:
62  *  -----------
63  *  Request the window manager to restart
64  *
65  *
66  *  Inputs:
67  *  ------
68  *  display     - display 
69  *  root        - root window of screen 
70  *
71  *  Returns:
72  *  --------
73  *  Success if request sent 
74  * 
75  *************************************<->***********************************/
76 int 
77 _DtWmRestart (Display *display, Window root)
78 {
79     int rval = BadAtom;
80     Window wmWindow;
81
82     /*
83      * Get the workspace manager window
84      */
85     if ((rval=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
86     {
87       
88         /*
89          * Make the request by appending the restart request
90          * name to the _DT_WM_REQUEST property
91          */
92
93         rval = XChangeProperty (display, wmWindow, 
94             XmInternAtom(display, _XA_DT_WM_REQUEST, False),
95             XA_STRING, 8, PropModeAppend, 
96             (unsigned char *)DTWM_REQ_RESTART, 
97             1+strlen(DTWM_REQ_RESTART));
98
99         XFlush (display);       /* do it now */
100
101     }
102
103     return (rval);
104
105 } /* END OF FUNCTION _DtWmRestart */
106
107 \f
108 /*************************************<->*************************************
109  *
110  *  int _DtWmRestartNoConfirm (display, root)
111  *
112  *
113  *  Description:
114  *  -----------
115  *  Request the window manager to restart with no confirmation dialog
116  *
117  *
118  *  Inputs:
119  *  ------
120  *  display     - display 
121  *  root        - root window of screen 
122  *
123  *  Returns:
124  *  --------
125  *  Success if request sent 
126  * 
127  *************************************<->***********************************/
128 int
129 _DtWmRestartNoConfirm (Display *display, Window root)
130 {
131     int rval;
132     Window wmWindow;
133     char buffer[80];
134
135     /*
136      * Make the request by appending the restart request
137      * name to the _DT_WM_REQUEST property
138      */
139
140     strcpy (&buffer[0], DTWM_REQ_RESTART);
141     strcat (&buffer[0], " ");
142     strcat (&buffer[0], DTWM_REQP_NO_CONFIRM);
143
144     /*
145      * Get the workspace manager window
146      */
147     if ((rval=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
148     {
149         /*
150          * Make the request by appending the restart request
151          * name to the _DT_WM_REQUEST property
152          */
153
154         rval = XChangeProperty (display, wmWindow, 
155             XmInternAtom(display, _XA_DT_WM_REQUEST, False),
156             XA_STRING, 8, PropModeAppend, 
157             (unsigned char *)buffer, 
158             1+strlen(buffer));
159
160         XFlush (display);       /* do it now */
161     }
162
163     return (rval);
164
165 } /* END OF FUNCTION _DtWmRestartNoConfirm */
166