WmBackWin.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. /*
  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: WmBackWin.c
  33. **
  34. ** RCS: $XConsortium: WmBackWin.c /main/4 1995/10/26 15:12:20 rswiston $
  35. ** Project: DT Workspace Manager
  36. **
  37. ** Description: Identify backdrop windows
  38. **
  39. ** (c) Copyright 1993 by Hewlett-Packard Company
  40. **
  41. ****************************************************************************
  42. ************************************<+>*************************************/
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45. #include <X11/Xlib.h>
  46. #include <X11/Xutil.h>
  47. #include <Dt/Wsm.h>
  48. #include <Xm/Xm.h>
  49. #include <Xm/AtomMgr.h>
  50. /******** Public Function Declarations ********/
  51. extern Window DtWsmGetCurrentBackdropWindow(
  52. Display *display,
  53. Window root);
  54. extern Boolean _DtWsmIsBackdropWindow(
  55. Display *display,
  56. int screen_num,
  57. Window window );
  58. /******** End Public Function Declarations ********/
  59. /*************************************<->*************************************
  60. *
  61. * Window DtWsmGetCurrentBackdropWindow (display, root)
  62. *
  63. *
  64. * Description:
  65. * -----------
  66. * Returns the window used for the backdrop for the current workspace
  67. *
  68. *
  69. * Inputs:
  70. * ------
  71. * display - display
  72. * root - root window
  73. *
  74. * Return - window used for current workspace
  75. * None if no backdrop window or error
  76. *
  77. * Comments:
  78. * --------
  79. *
  80. *
  81. *************************************<->***********************************/
  82. Window
  83. DtWsmGetCurrentBackdropWindow(
  84. Display *display ,
  85. Window root )
  86. {
  87. Window wReturn = None;
  88. Atom aWS;
  89. DtWsmWorkspaceInfo *pWsInfo;
  90. Status status;
  91. status = DtWsmGetCurrentWorkspace (display, root, &aWS);
  92. if (status == Success)
  93. {
  94. status = DtWsmGetWorkspaceInfo(display, root, aWS, &pWsInfo);
  95. if (status == Success)
  96. {
  97. if (pWsInfo->numBackdropWindows > 0)
  98. {
  99. /* copy backdrop window (there should be at most one) */
  100. wReturn = pWsInfo->backdropWindows[0];
  101. }
  102. DtWsmFreeWorkspaceInfo (pWsInfo);
  103. }
  104. }
  105. return (wReturn);
  106. } /* END OF FUNCTION DtWsmGetCurrentBackdropWindow */
  107. /*************************************<->*************************************
  108. *
  109. * Boolean _DtWsmIsBackdropWindow (display, screen_num, window)
  110. *
  111. *
  112. * Description:
  113. * -----------
  114. * Returns true if the window passed in is a backdrop window.
  115. *
  116. *
  117. * Inputs:
  118. * ------
  119. * display - display
  120. * screen_num - number of screen we're interested in
  121. * window - window we want to test
  122. *
  123. * Outputs:
  124. * -------
  125. * Return - True if window is a backdrop window
  126. * False otherwise.
  127. *
  128. * Comments:
  129. * --------
  130. *
  131. *************************************<->***********************************/
  132. Boolean
  133. _DtWsmIsBackdropWindow(
  134. Display *display,
  135. int screen_num,
  136. Window window )
  137. {
  138. Boolean rval = False;
  139. Status status;
  140. Atom *pWorkspaceList;
  141. int ix, iw, numWorkspaces;
  142. DtWsmWorkspaceInfo *pWsInfo;
  143. Window root;
  144. root = XRootWindow (display, screen_num);
  145. status = DtWsmGetWorkspaceList (display, root,
  146. &pWorkspaceList, &numWorkspaces);
  147. if ((status == Success) &&
  148. (numWorkspaces > 0) &&
  149. (pWsInfo = (DtWsmWorkspaceInfo *)
  150. malloc (numWorkspaces * sizeof(DtWsmWorkspaceInfo))))
  151. {
  152. for (ix=0;
  153. (!rval) && (ix < numWorkspaces) && (status == Success);
  154. ix++)
  155. {
  156. status = DtWsmGetWorkspaceInfo (display,
  157. root,
  158. pWorkspaceList[ix],
  159. &pWsInfo);
  160. if (status == Success)
  161. {
  162. for (iw = 0; iw < pWsInfo->numBackdropWindows; iw++)
  163. {
  164. if (pWsInfo->backdropWindows[iw] == window)
  165. {
  166. rval = True;
  167. }
  168. }
  169. DtWsmFreeWorkspaceInfo(pWsInfo);
  170. }
  171. }
  172. XFree ((char *)pWorkspaceList);
  173. }
  174. return (rval);
  175. } /* END OF FUNCTION _DtWsmIsBackdropWindow */