SetNrmHint.c revision 61b2299d
1/* $Xorg: SetNrmHint.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */ 2 3/*********************************************************** 4Copyright 1988 by Wyse Technology, Inc., San Jose, Ca, 5Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, 6 7 All Rights Reserved 8 9Permission to use, copy, modify, and distribute this software and its 10documentation for any purpose and without fee is hereby granted, 11provided that the above copyright notice appear in all copies and that 12both that copyright notice and this permission notice appear in 13supporting documentation, and that the name Digital not be 14used in advertising or publicity pertaining to distribution of the 15software without specific, written prior permission. 16 17DIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 18INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 19EVENT SHALL DIGITAL OR WYSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 20CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 21USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 22OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 23PERFORMANCE OF THIS SOFTWARE. 24 25******************************************************************/ 26/* 27 28Copyright 1987, 1988, 1998 The Open Group 29 30Permission to use, copy, modify, distribute, and sell this software and its 31documentation for any purpose is hereby granted without fee, provided that 32the above copyright notice appear in all copies and that both that 33copyright notice and this permission notice appear in supporting 34documentation. 35 36The above copyright notice and this permission notice shall be included 37in all copies or substantial portions of the Software. 38 39THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 40OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 41MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 43OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 44ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 45OTHER DEALINGS IN THE SOFTWARE. 46 47Except as contained in this notice, the name of The Open Group shall 48not be used in advertising or otherwise to promote the sale, use or 49other dealings in this Software without prior written authorization 50from The Open Group. 51 52*/ 53 54#ifdef HAVE_CONFIG_H 55#include <config.h> 56#endif 57#include <X11/Xlibint.h> 58#include <X11/Xutil.h> 59#include "Xatomtype.h" 60#include <X11/Xatom.h> 61#include <X11/Xos.h> 62 63void XSetWMSizeHints ( 64 Display *dpy, 65 Window w, 66 XSizeHints *hints, 67 Atom prop) 68{ 69 xPropSizeHints data; 70 71 memset(&data, 0, sizeof(data)); 72 data.flags = (hints->flags & 73 (USPosition|USSize|PPosition|PSize|PMinSize|PMaxSize| 74 PResizeInc|PAspect|PBaseSize|PWinGravity)); 75 76 /* 77 * The x, y, width, and height fields are obsolete; but, applications 78 * that want to work with old window managers might set them. 79 */ 80 if (hints->flags & (USPosition|PPosition)) { 81 data.x = hints->x; 82 data.y = hints->y; 83 } 84 if (hints->flags & (USSize|PSize)) { 85 data.width = hints->width; 86 data.height = hints->height; 87 } 88 89 if (hints->flags & PMinSize) { 90 data.minWidth = hints->min_width; 91 data.minHeight = hints->min_height; 92 } 93 if (hints->flags & PMaxSize) { 94 data.maxWidth = hints->max_width; 95 data.maxHeight = hints->max_height; 96 } 97 if (hints->flags & PResizeInc) { 98 data.widthInc = hints->width_inc; 99 data.heightInc = hints->height_inc; 100 } 101 if (hints->flags & PAspect) { 102 data.minAspectX = hints->min_aspect.x; 103 data.minAspectY = hints->min_aspect.y; 104 data.maxAspectX = hints->max_aspect.x; 105 data.maxAspectY = hints->max_aspect.y; 106 } 107 if (hints->flags & PBaseSize) { 108 data.baseWidth = hints->base_width; 109 data.baseHeight = hints->base_height; 110 } 111 if (hints->flags & PWinGravity) { 112 data.winGravity = hints->win_gravity; 113 } 114 115 XChangeProperty (dpy, w, prop, XA_WM_SIZE_HINTS, 32, 116 PropModeReplace, (unsigned char *) &data, 117 NumPropSizeElements); 118} 119 120 121void XSetWMNormalHints ( 122 Display *dpy, 123 Window w, 124 XSizeHints *hints) 125{ 126 XSetWMSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS); 127} 128 129