421a4ea8a4ee2d82f135968c741fd8d836a45e30
[oweals/cde.git] / cde / lib / DtSvc / DtUtil1 / WmChBackD.c
1 /* $TOG: WmChBackD.c /main/7 1998/07/30 12:11:23 mgreess $
2  *
3  * (c) Copyright 1996 Digital Equipment Corporation.
4  * (c) Copyright 1991,1993,1994,1996 Hewlett-Packard Company.
5  * (c) Copyright 1993,1994,1996 International Business Machines Corp.
6  * (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
7  * (c) Copyright 1993,1994,1996 Novell, Inc. 
8  * (c) Copyright 1996 FUJITSU LIMITED.
9  * (c) Copyright 1996 Hitachi.
10  */
11
12 /************************************<+>*************************************
13  ****************************************************************************
14  **
15  **   File:     WmChBackD.c
16  **
17  **   Description: Request backdrop change of the workspace manager
18  **
19  ****************************************************************************
20  ************************************<+>*************************************/
21 #include <stdio.h>
22 #include <X11/Xlib.h>
23 #include <X11/Xutil.h>
24 #include <X11/Xatom.h>
25 #include <Dt/Wsm.h> 
26 #include <Dt/WsmP.h> 
27 #include <Xm/Xm.h>
28 #include <Xm/AtomMgr.h>
29
30
31 #define SYS_FILE_SEARCH_PATH "DTICONSEARCHPATH"
32     
33 \f
34 /*************************************<->*************************************
35  *
36  *  DtWsmChangeBackdrop (display, root, path, pixmap)
37  *
38  *
39  *  Description:
40  *  -----------
41  *  Request the CDE workspace manager to change the backdrop
42  *
43  *
44  *  Inputs:
45  *  ------
46  *  display     - display 
47  *  root        - root window of screen
48  *  path        - file path to bitmap file
49  *  pixmap      - pixmap id of backdrop pixmap
50  *
51  *  Returns:
52  *  --------
53  *  Success if request sent 
54  *
55  *  Comments:
56  *  ---------
57  *  public interface to _DtWsmChangeBackdrop()
58  *
59  *************************************<->***********************************/
60 int 
61 DtWsmChangeBackdrop (
62         Display *display, 
63         Window root, 
64         char *path, 
65         Pixmap pixmap)
66 {
67     return _DtWsmChangeBackdrop(display, root, path, pixmap);
68 }
69
70
71 /*************************************<->*************************************
72  *
73  *  _DtWsmChangeBackdrop (display, root, path, pixmap)
74  *
75  *
76  *  Description:
77  *  -----------
78  *  Request the CDE workspace manager to change the backdrop
79  *
80  *
81  *  Inputs:
82  *  ------
83  *  display     - display 
84  *  root        - root window of screen
85  *  path        - file path to bitmap file
86  *  pixmap      - pixmap id of backdrop pixmap
87  *
88  *  Returns:
89  *  --------
90  *  Success if request sent 
91  *
92  *  Comments:
93  *  ---------
94  * 
95  *************************************<->***********************************/
96 int 
97 _DtWsmChangeBackdrop (
98         Display *display, 
99         Window root, 
100         char *path, 
101         Pixmap pixmap)
102 {
103     int rval = BadAtom;
104     Window wmWindow;
105
106     if (!path)
107     {
108         rval = BadValue;
109     }
110     else
111     /*
112      * Get the workspace manager window
113      */
114     if ((rval=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
115     {
116         char *pch;
117         int len;
118       
119         /*
120          * Build up the NULL-terminated request string
121          */
122         len = strlen (DTWM_REQ_CHANGE_BACKDROP) + 1;
123         len += strlen (path) + 1;
124         len += 30;  /* fudge for ascii-ized pixmap id */
125
126         pch = (char *) XtMalloc (len * sizeof(char));
127
128         sprintf (pch, "%s %s %lx", DTWM_REQ_CHANGE_BACKDROP, path,
129                     pixmap);
130
131         /*
132          * Make the request by appending the string to 
133          * the _DT_WM_REQUEST property
134          */
135         rval = XChangeProperty (display, wmWindow, 
136             XmInternAtom(display, _XA_DT_WM_REQUEST, False),
137             XA_STRING, 8, PropModeAppend, 
138             (unsigned char *)pch, 
139             1+strlen(pch));
140
141     }
142
143     return (rval);
144
145 } /* END OF FUNCTION _DtWsmChangeBackdrop */
146
147