PageRenderTime 30ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/nx-3.5.0/nx-X11/lib/X11/GetNrmHint.c

#
C | 128 lines | 66 code | 10 blank | 52 comment | 9 complexity | f092ba3e45a5baf3ef88b605aad543a7 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0
  1. /* $Xorg: GetNrmHint.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
  2. /***********************************************************
  3. Copyright 1988 by Wyse Technology, Inc., San Jose, Ca,
  4. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  5. All Rights Reserved
  6. Permission to use, copy, modify, and distribute this software and its
  7. documentation for any purpose and without fee is hereby granted,
  8. provided that the above copyright notice appear in all copies and that
  9. both that copyright notice and this permission notice appear in
  10. supporting documentation, and that the name Digital not be
  11. used in advertising or publicity pertaining to distribution of the
  12. software without specific, written prior permission.
  13. DIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  14. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  15. EVENT SHALL DIGITAL OR WYSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  16. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  17. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  18. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. PERFORMANCE OF THIS SOFTWARE.
  20. ******************************************************************/
  21. /*
  22. Copyright 1987, 1988, 1998 The Open Group
  23. Permission to use, copy, modify, distribute, and sell this software and its
  24. documentation for any purpose is hereby granted without fee, provided that
  25. the above copyright notice appear in all copies and that both that
  26. copyright notice and this permission notice appear in supporting
  27. documentation.
  28. The above copyright notice and this permission notice shall be included
  29. in all copies or substantial portions of the Software.
  30. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  31. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  32. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  33. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
  34. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  35. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  36. OTHER DEALINGS IN THE SOFTWARE.
  37. Except as contained in this notice, the name of The Open Group shall
  38. not be used in advertising or otherwise to promote the sale, use or
  39. other dealings in this Software without prior written authorization
  40. from The Open Group.
  41. */
  42. #ifdef HAVE_CONFIG_H
  43. #include <config.h>
  44. #endif
  45. #include <X11/Xlibint.h>
  46. #include <X11/Xatom.h>
  47. #include "Xatomtype.h"
  48. #include <X11/Xutil.h>
  49. #include <stdio.h>
  50. Status XGetWMSizeHints (dpy, w, hints, supplied, property)
  51. Display *dpy;
  52. Window w;
  53. XSizeHints *hints;
  54. long *supplied;
  55. Atom property;
  56. {
  57. xPropSizeHints *prop = NULL;
  58. Atom actual_type;
  59. int actual_format;
  60. unsigned long leftover;
  61. unsigned long nitems;
  62. if (XGetWindowProperty (dpy, w, property, 0L,
  63. (long)NumPropSizeElements,
  64. False, XA_WM_SIZE_HINTS, &actual_type,
  65. &actual_format, &nitems, &leftover,
  66. (unsigned char **)&prop)
  67. != Success)
  68. return False;
  69. if ((actual_type != XA_WM_SIZE_HINTS) ||
  70. (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
  71. if (prop != NULL) Xfree ((char *)prop);
  72. return False;
  73. }
  74. hints->flags = prop->flags;
  75. /* XSizeHints misdeclares these as int instead of long */
  76. hints->x = cvtINT32toInt (prop->x);
  77. hints->y = cvtINT32toInt (prop->y);
  78. hints->width = cvtINT32toInt (prop->width);
  79. hints->height = cvtINT32toInt (prop->height);
  80. hints->min_width = cvtINT32toInt (prop->minWidth);
  81. hints->min_height = cvtINT32toInt (prop->minHeight);
  82. hints->max_width = cvtINT32toInt (prop->maxWidth);
  83. hints->max_height = cvtINT32toInt (prop->maxHeight);
  84. hints->width_inc = cvtINT32toInt (prop->widthInc);
  85. hints->height_inc = cvtINT32toInt (prop->heightInc);
  86. hints->min_aspect.x = cvtINT32toInt (prop->minAspectX);
  87. hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
  88. hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
  89. hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
  90. *supplied = (USPosition | USSize | PAllHints);
  91. if (nitems >= NumPropSizeElements) {
  92. hints->base_width= cvtINT32toInt (prop->baseWidth);
  93. hints->base_height= cvtINT32toInt (prop->baseHeight);
  94. hints->win_gravity= cvtINT32toInt (prop->winGravity);
  95. *supplied |= (PBaseSize | PWinGravity);
  96. }
  97. hints->flags &= (*supplied); /* get rid of unwanted bits */
  98. Xfree((char *)prop);
  99. return True;
  100. }
  101. Status XGetWMNormalHints (dpy, w, hints, supplied)
  102. Display *dpy;
  103. Window w;
  104. XSizeHints *hints;
  105. long *supplied;
  106. {
  107. return (XGetWMSizeHints (dpy, w, hints, supplied, XA_WM_NORMAL_HINTS));
  108. }