Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / DtUtil1 / WmRequest.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  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
25  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
26  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
27  * (c) Copyright 1993, 1994 Novell, Inc.                                *
28  */
29 /************************************<+>*************************************
30  ****************************************************************************
31  **
32  **   File:     WmRequest.c
33  **
34  **   RCS:      $XConsortium: WmRequest.c /main/4 1995/10/26 15:13:08 rswiston $
35  **   Project:  HP DT Workspace Manager
36  **
37  **   Description: Send a function request to the window manager
38  **
39  **   (c) Copyright 1992, 1993 by Hewlett-Packard Company
40  **
41  ****************************************************************************
42  ************************************<+>*************************************/
43 #include <stdio.h>
44 #include <X11/Xlib.h>
45 #include <X11/Xutil.h>
46 #include <X11/Xatom.h>
47 #include <Dt/Wsm.h> 
48 #include <Dt/WsmP.h> 
49 #include <Xm/Xm.h>
50 #include <Xm/AtomMgr.h>
51
52
53 \f
54 /*************************************<->*************************************
55  *
56  *  _DtWmRequestMultiple (display, root, char *pchRequest, int len)
57  *
58  *
59  *  Description:
60  *  -----------
61  *  Send one or more function requests to the window manager.
62  *
63  *
64  *  Inputs:
65  *  ------
66  *  display     - display 
67  *  root        - root window of screen 
68  *  pchRequest  - string request  (possibly multiple)
69  *                (usu. of form "f.<func> [<arg>]")
70  *  len         - length of request, counting terminating NULL
71  *
72  *  Returns:
73  *  --------
74  *  Success if request sent 
75  * 
76  *************************************<->***********************************/
77 Status 
78 _DtWmRequestMultiple (
79         Display *display, 
80         Window root, 
81         char *pchRequest,
82         int len)
83 {
84     Status rval = BadAtom;
85     Window wmWindow;
86
87     /*
88      * Get the workspace manager window
89      */
90     if ((rval=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
91     {
92       
93         /*
94          * Make the request by appending the request
95          * to the _DT_WM_REQUEST property
96          */
97
98         rval = XChangeProperty (display, wmWindow, 
99             XmInternAtom(display, _XA_DT_WM_REQUEST, False),
100             XA_STRING, 8, PropModeAppend, 
101             (unsigned char *)pchRequest, 
102             len);
103
104     }
105
106     return (rval);
107
108 } /* END OF FUNCTION _DtWmRequestMultiple */
109
110 #if 0
111 \f
112 /*************************************<->*************************************
113  *
114  *  DtWmRequest (display, root, char *pchRequest)
115  *
116  *
117  *  Description:
118  *  -----------
119  *  Send a function request to the window manager.
120  *
121  *
122  *  Inputs:
123  *  ------
124  *  display     - display 
125  *  root        - root window of screen 
126  *  pchRequest  - NULL terminated string request 
127  *                (usu. of form "f.<func> [<arg>]")
128  *
129  *  Returns:
130  *  --------
131  *  Success if request sent 
132  * 
133  *************************************<->***********************************/
134 Status 
135 DtWmRequest (Display *display, Window root, char *pchRequest)
136 {
137     return (_DtWmRequestMultiple (display, root, 
138                         pchRequest, 1+strlen(pchRequest)));
139
140 } /* END OF FUNCTION DtWmRequest */
141
142 #endif