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