WmChBackD.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 libraries 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. /* $TOG: WmChBackD.c /main/7 1998/07/30 12:11:23 mgreess $
  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. ** File: WmChBackD.c
  37. **
  38. ** Description: Request backdrop change of the workspace manager
  39. **
  40. ****************************************************************************
  41. ************************************<+>*************************************/
  42. #include <stdio.h>
  43. #include <X11/Xlib.h>
  44. #include <X11/Xutil.h>
  45. #include <X11/Xatom.h>
  46. #include <Dt/Wsm.h>
  47. #include <Dt/WsmP.h>
  48. #include <Xm/Xm.h>
  49. #include <Xm/AtomMgr.h>
  50. #define SYS_FILE_SEARCH_PATH "DTICONSEARCHPATH"
  51. /*************************************<->*************************************
  52. *
  53. * DtWsmChangeBackdrop (display, root, path, pixmap)
  54. *
  55. *
  56. * Description:
  57. * -----------
  58. * Request the CDE workspace manager to change the backdrop
  59. *
  60. *
  61. * Inputs:
  62. * ------
  63. * display - display
  64. * root - root window of screen
  65. * path - file path to bitmap file
  66. * pixmap - pixmap id of backdrop pixmap
  67. *
  68. * Returns:
  69. * --------
  70. * Success if request sent
  71. *
  72. * Comments:
  73. * ---------
  74. * public interface to _DtWsmChangeBackdrop()
  75. *
  76. *************************************<->***********************************/
  77. int
  78. DtWsmChangeBackdrop (
  79. Display *display,
  80. Window root,
  81. char *path,
  82. Pixmap pixmap)
  83. {
  84. return _DtWsmChangeBackdrop(display, root, path, pixmap);
  85. }
  86. /*************************************<->*************************************
  87. *
  88. * _DtWsmChangeBackdrop (display, root, path, pixmap)
  89. *
  90. *
  91. * Description:
  92. * -----------
  93. * Request the CDE workspace manager to change the backdrop
  94. *
  95. *
  96. * Inputs:
  97. * ------
  98. * display - display
  99. * root - root window of screen
  100. * path - file path to bitmap file
  101. * pixmap - pixmap id of backdrop pixmap
  102. *
  103. * Returns:
  104. * --------
  105. * Success if request sent
  106. *
  107. * Comments:
  108. * ---------
  109. *
  110. *************************************<->***********************************/
  111. int
  112. _DtWsmChangeBackdrop (
  113. Display *display,
  114. Window root,
  115. char *path,
  116. Pixmap pixmap)
  117. {
  118. int rval = BadAtom;
  119. Window wmWindow;
  120. if (!path)
  121. {
  122. rval = BadValue;
  123. }
  124. else
  125. /*
  126. * Get the workspace manager window
  127. */
  128. if ((rval=_DtGetMwmWindow (display, root, &wmWindow)) == Success)
  129. {
  130. char *pch;
  131. int len;
  132. /*
  133. * Build up the NULL-terminated request string
  134. */
  135. len = strlen (DTWM_REQ_CHANGE_BACKDROP) + 1;
  136. len += strlen (path) + 1;
  137. len += 30; /* fudge for ascii-ized pixmap id */
  138. pch = (char *) XtMalloc (len * sizeof(char));
  139. sprintf (pch, "%s %s %lx", DTWM_REQ_CHANGE_BACKDROP, path,
  140. pixmap);
  141. /*
  142. * Make the request by appending the string to
  143. * the _DT_WM_REQUEST property
  144. */
  145. rval = XChangeProperty (display, wmWindow,
  146. XmInternAtom(display, _XA_DT_WM_REQUEST, False),
  147. XA_STRING, 8, PropModeAppend,
  148. (unsigned char *)pch,
  149. 1+strlen(pch));
  150. }
  151. return (rval);
  152. } /* END OF FUNCTION _DtWsmChangeBackdrop */