WmRmWsFcn.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 International Business Machines Corp. *
  25. * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
  26. * (c) Copyright 1993, 1994 Novell, Inc. *
  27. */
  28. /************************************<+>*************************************
  29. ****************************************************************************
  30. **
  31. ** File: WmRmWsFcn.c
  32. **
  33. ** RCS: $XConsortium: WmRmWsFcn.c /main/5 1996/06/21 17:24:22 ageorge $
  34. ** Project: HP DT Workspace Manager
  35. **
  36. ** Description: Remove the Workspace functions on a client
  37. **
  38. ** (c) Copyright 1991, 1993, 1994 by Hewlett-Packard Company
  39. **
  40. ****************************************************************************
  41. ************************************<+>*************************************/
  42. #include <X11/Xlib.h>
  43. #include <X11/Xutil.h>
  44. #include <X11/Xatom.h>
  45. #include <Dt/Wsm.h>
  46. #include <Dt/WsmP.h>
  47. #include <Xm/AtomMgr.h>
  48. #include "DtSvcLock.h"
  49. /*************************************<->*************************************
  50. *
  51. * DtWsmRemoveWorkspaceFunctions (display, client)
  52. *
  53. *
  54. * Description:
  55. * -----------
  56. * Request the window manager to disallow workspace functions
  57. * for this client.
  58. *
  59. *
  60. * Inputs:
  61. * ------
  62. * display - display
  63. * root - root window of screen
  64. *
  65. * Returns:
  66. * --------
  67. * none
  68. *
  69. *
  70. * Comments:
  71. * ---------
  72. * Disables f.workspace_presence, f.remove, f.occupy_all for this
  73. * client.
  74. *
  75. *************************************<->***********************************/
  76. void
  77. DtWsmRemoveWorkspaceFunctions (Display *display, Window client)
  78. {
  79. DtWmHints vHints, *pHints;
  80. long functions;
  81. Boolean bSetHints = False;
  82. _DtSvcDisplayToAppContext(display);
  83. _DtSvcAppLock(app);
  84. if (_DtWsmGetDtWmHints (display, client, &pHints) != Success)
  85. {
  86. /*
  87. * There were no existing workspace hints, so we'll
  88. * just use our own variable
  89. */
  90. pHints = &vHints;
  91. pHints->flags = 0;
  92. }
  93. if (pHints->flags & DtWM_HINTS_FUNCTIONS)
  94. {
  95. functions = pHints->functions &
  96. (DtWM_FUNCTION_OCCUPY_WS | DtWM_FUNCTION_ALL);
  97. if (functions & DtWM_FUNCTION_ALL)
  98. {
  99. /*
  100. * The flags are a list of functions to remove. If
  101. * the workspace functions aren't on this list, make
  102. * sure that it's put there.
  103. */
  104. if (!(functions & DtWM_FUNCTION_OCCUPY_WS))
  105. {
  106. /* remove workspace functions */
  107. pHints->functions |= DtWM_FUNCTION_OCCUPY_WS;
  108. bSetHints = True;
  109. }
  110. }
  111. else
  112. {
  113. /*
  114. * The flags are a list of functions to add. If
  115. * the workspace functions are on the list, make
  116. * sure they get removed.
  117. */
  118. if (functions & DtWM_FUNCTION_OCCUPY_WS)
  119. {
  120. /* remove workspace functions */
  121. pHints->functions &= ~DtWM_FUNCTION_OCCUPY_WS;
  122. bSetHints = True;
  123. }
  124. }
  125. }
  126. else
  127. {
  128. /*
  129. * The hints didn't have workspace functions specified.
  130. * Set the flag and remove workspace functions.
  131. */
  132. pHints->flags |= DtWM_HINTS_FUNCTIONS;
  133. pHints->functions = DtWM_FUNCTION_OCCUPY_WS | DtWM_FUNCTION_ALL;
  134. bSetHints = True;
  135. }
  136. /*
  137. * If something needs to be changed, then change it.
  138. */
  139. if (bSetHints)
  140. _DtWsmSetDtWmHints (display, client, pHints);
  141. /*
  142. * If we read these hints off the window, then be sure to free
  143. * them.
  144. */
  145. if (pHints && (pHints != &vHints))
  146. {
  147. XFree ((char *)pHints);
  148. }
  149. _DtSvcAppUnlock(app);
  150. } /* END OF FUNCTION DtWsmRemoveWorkspaceFunctions */
  151. /*************************************<->*************************************
  152. *
  153. * DtWsmAddWorkspaceFunctions (display, client)
  154. *
  155. *
  156. * Description:
  157. * -----------
  158. * Request the window manager to allow workspace functions
  159. * for this client.
  160. *
  161. *
  162. * Inputs:
  163. * ------
  164. * display - display
  165. * root - root window of screen
  166. *
  167. * Returns:
  168. * --------
  169. * none
  170. *
  171. *
  172. * Comments:
  173. * ---------
  174. * Enables f.workspace_presence, f.remove, f.occupy_all for this
  175. * client.
  176. *
  177. *************************************<->***********************************/
  178. void
  179. DtWsmAddWorkspaceFunctions (Display *display, Window client)
  180. {
  181. DtWmHints vHints, *pHints;
  182. long functions;
  183. Boolean bSetHints = False;
  184. _DtSvcDisplayToAppContext(display);
  185. _DtSvcAppLock(app);
  186. if (_DtWsmGetDtWmHints (display, client, &pHints) != Success)
  187. {
  188. /*
  189. * There were no existing workspace hints, so we'll
  190. * just use our own variable
  191. */
  192. pHints = &vHints;
  193. pHints->flags = 0;
  194. }
  195. if (pHints->flags & DtWM_HINTS_FUNCTIONS)
  196. {
  197. functions = pHints->functions &
  198. (DtWM_FUNCTION_OCCUPY_WS | DtWM_FUNCTION_ALL);
  199. if (functions & DtWM_FUNCTION_ALL)
  200. {
  201. /*
  202. * The flags are a list of functions to remove. If
  203. * the workspace functions are on this list, make
  204. * sure that they're removed.
  205. */
  206. if (functions & DtWM_FUNCTION_OCCUPY_WS)
  207. {
  208. /* add workspace functions */
  209. pHints->functions &= ~DtWM_FUNCTION_OCCUPY_WS;
  210. bSetHints = True;
  211. }
  212. }
  213. else
  214. {
  215. /*
  216. * The flags are a list of functions to add. If
  217. * the workspace functions aren't on the list, make
  218. * sure they get added.
  219. */
  220. if (!(functions & DtWM_FUNCTION_OCCUPY_WS))
  221. {
  222. /* remove workspace functions */
  223. pHints->functions |= DtWM_FUNCTION_OCCUPY_WS;
  224. bSetHints = True;
  225. }
  226. }
  227. }
  228. else
  229. {
  230. /*
  231. * The hints didn't have workspace functions specified.
  232. * Set the flag and add workspace functions.
  233. */
  234. pHints->flags |= DtWM_HINTS_FUNCTIONS;
  235. pHints->functions = DtWM_FUNCTION_OCCUPY_WS;
  236. bSetHints = True;
  237. }
  238. /*
  239. * If something needs to be changed, then change it.
  240. */
  241. if (bSetHints)
  242. _DtWsmSetDtWmHints (display, client, pHints);
  243. /*
  244. * If we read these hints off the window, then be sure to free
  245. * them.
  246. */
  247. if (pHints && (pHints != &vHints))
  248. {
  249. XFree ((char *)pHints);
  250. }
  251. _DtSvcAppUnlock(app);
  252. } /* END OF FUNCTION DtWsmAddWorkspaceFunctions */