GetEmbed.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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: GetEmbed.c
  33. **
  34. ** RCS: $XConsortium: GetEmbed.c /main/5 1996/05/20 16:09:08 drk $
  35. ** Project: DT Workspace Manager
  36. **
  37. ** Description: Get workspace embedded clients property.
  38. **
  39. ** (c) Copyright 1990, 1993 by Hewlett-Packard Company
  40. **
  41. ****************************************************************************
  42. ************************************<+>*************************************/
  43. #include <stdio.h>
  44. #include <X11/Xlib.h>
  45. #include <X11/Xutil.h>
  46. #include <Dt/Wsm.h>
  47. #include <Dt/WsmP.h>
  48. #include <Xm/Xm.h>
  49. #include <Xm/AtomMgr.h>
  50. /*************************************<->*************************************
  51. *
  52. * int _DtGetEmbeddedClients (display, root, ppEmbeddedClients,
  53. * pNumEmbeddedClients)
  54. *
  55. *
  56. * Description:
  57. * -----------
  58. * Get the contents of the _DT_WORKSPACE_EMBEDDED_CLIENTS property
  59. * from a root window. This is a array of top-level windows that are
  60. * embedded in the front panel of the window manager. They would
  61. * not be picked up ordinarily by a session manager in a normal
  62. * search for top-level windows because they are reparented to
  63. * the front panel which itself is a top-level window.
  64. *
  65. *
  66. * Inputs:
  67. * ------
  68. * display - display
  69. * root - root window to get info from
  70. * ppEmbeddedClients - pointer to a pointer (to be returned)
  71. * pNumEmbeddedClients - pointer to a number (to be returned)
  72. *
  73. * Outputs:
  74. * -------
  75. * *ppEmbeddedClients - pointer to a array of window IDs (top-level
  76. * windows for embedded clients)
  77. * (NOTE: This should be freed using XFree)
  78. * *pNumEmbeddedClients- number of window IDs in array
  79. * Return - Success if property fetched ok.
  80. * Failure returns are from XGetWindowProperty
  81. *
  82. * Comments:
  83. * --------
  84. * Use XFree to free the returned data.
  85. *
  86. *************************************<->***********************************/
  87. int
  88. _DtGetEmbeddedClients(
  89. Display *display,
  90. Window root,
  91. Atom **ppEmbeddedClients,
  92. unsigned long *pNumEmbeddedClients )
  93. {
  94. Atom actualType;
  95. int actualFormat;
  96. unsigned long leftover;
  97. int rcode;
  98. Atom property;
  99. *ppEmbeddedClients = NULL;
  100. property = XmInternAtom (display,
  101. _XA_DT_WORKSPACE_EMBEDDED_CLIENTS, False);
  102. if ((rcode=XGetWindowProperty(display,
  103. root,
  104. property,
  105. 0L,
  106. (long)BUFSIZ,
  107. False,
  108. property,
  109. &actualType,
  110. &actualFormat,
  111. pNumEmbeddedClients,
  112. &leftover,
  113. (unsigned char **)ppEmbeddedClients))==Success)
  114. {
  115. if (actualType != property)
  116. {
  117. /* wrong type, force failure */
  118. *pNumEmbeddedClients = 0;
  119. rcode = BadValue;
  120. if (actualType != None)
  121. {
  122. XFree ((char *) *ppEmbeddedClients);
  123. }
  124. }
  125. }
  126. return(rcode);
  127. }