2
0

GetVWmHint.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /* $XConsortium: GetVWmHint.c /main/5 1996/05/20 16:07:19 drk $
  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: GetVwmHint.c
  37. **
  38. ** Project: DT Workspace Manager
  39. **
  40. ** Description: Get Dt Window manager hints
  41. **
  42. ****************************************************************************
  43. ************************************<+>*************************************/
  44. #include <stdio.h>
  45. #include <X11/Xlib.h>
  46. #include <X11/Xutil.h>
  47. #include <Dt/Wsm.h>
  48. #include <Dt/WsmP.h>
  49. #include <Xm/Xm.h>
  50. #include <Xm/AtomMgr.h>
  51. /*************************************<->*************************************
  52. *
  53. * int _DtWsmGetDtWmHints (display, window, ppDtWmHints)
  54. *
  55. *
  56. * Description:
  57. * -----------
  58. * Get the contents of the _DT_WM_HINTS property on a window
  59. *
  60. *
  61. * Inputs:
  62. * ------
  63. * display - display
  64. * window - window to get hints from
  65. * ppDtWmHints- pointer to a pointer to return
  66. *
  67. * Outputs:
  68. * --------
  69. * *ppDtWmHints-points to the DtWmHints structure retrieved from
  70. * the window (NOTE: This should be freed using XFree)
  71. *
  72. * Comments:
  73. * ---------
  74. *
  75. *************************************<->***********************************/
  76. int
  77. _DtWsmGetDtWmHints(
  78. Display *display,
  79. Window window,
  80. DtWmHints **ppDtWmHints)
  81. {
  82. Atom actualType;
  83. int actualFormat;
  84. unsigned long leftover, items, length;
  85. int rcode;
  86. Atom property;
  87. property = XmInternAtom(display, _XA_DT_WM_HINTS, False);
  88. length = sizeof (DtWmHints) / sizeof (long);
  89. *ppDtWmHints = NULL;
  90. if ((rcode=XGetWindowProperty(
  91. display,
  92. window,
  93. property,
  94. 0L, /* offset */
  95. length,
  96. False, /* delete */
  97. property, /* req_type */
  98. &actualType,
  99. &actualFormat,
  100. &items, /* items returned */
  101. &leftover,
  102. (unsigned char **)ppDtWmHints))==Success)
  103. {
  104. if ((actualType != property) || (items < length))
  105. {
  106. /* wrong type, force failure */
  107. rcode = BadValue;
  108. if (actualType != None)
  109. {
  110. XFree ((char *)*ppDtWmHints);
  111. }
  112. *ppDtWmHints = NULL;
  113. }
  114. }
  115. return(rcode);
  116. } /* END OF FUNCTION _DtWsmGetDtWmHints */