SetNrmHint.c revision 61b2299d
11ab64890Smrg/* $Xorg: SetNrmHint.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
21ab64890Smrg
31ab64890Smrg/***********************************************************
41ab64890SmrgCopyright 1988 by Wyse Technology, Inc., San Jose, Ca,
51ab64890SmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
61ab64890Smrg
71ab64890Smrg                        All Rights Reserved
81ab64890Smrg
91ab64890SmrgPermission to use, copy, modify, and distribute this software and its
101ab64890Smrgdocumentation for any purpose and without fee is hereby granted,
111ab64890Smrgprovided that the above copyright notice appear in all copies and that
121ab64890Smrgboth that copyright notice and this permission notice appear in
131ab64890Smrgsupporting documentation, and that the name Digital not be
141ab64890Smrgused in advertising or publicity pertaining to distribution of the
151ab64890Smrgsoftware without specific, written prior permission.
161ab64890Smrg
171ab64890SmrgDIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
181ab64890SmrgINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
191ab64890SmrgEVENT SHALL DIGITAL OR WYSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
201ab64890SmrgCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
211ab64890SmrgUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
221ab64890SmrgOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
231ab64890SmrgPERFORMANCE OF THIS SOFTWARE.
241ab64890Smrg
251ab64890Smrg******************************************************************/
261ab64890Smrg/*
271ab64890Smrg
281ab64890SmrgCopyright 1987, 1988, 1998  The Open Group
291ab64890Smrg
301ab64890SmrgPermission to use, copy, modify, distribute, and sell this software and its
311ab64890Smrgdocumentation for any purpose is hereby granted without fee, provided that
321ab64890Smrgthe above copyright notice appear in all copies and that both that
331ab64890Smrgcopyright notice and this permission notice appear in supporting
341ab64890Smrgdocumentation.
351ab64890Smrg
361ab64890SmrgThe above copyright notice and this permission notice shall be included
371ab64890Smrgin all copies or substantial portions of the Software.
381ab64890Smrg
391ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
401ab64890SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
411ab64890SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
421ab64890SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
431ab64890SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
441ab64890SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
451ab64890SmrgOTHER DEALINGS IN THE SOFTWARE.
461ab64890Smrg
471ab64890SmrgExcept as contained in this notice, the name of The Open Group shall
481ab64890Smrgnot be used in advertising or otherwise to promote the sale, use or
491ab64890Smrgother dealings in this Software without prior written authorization
501ab64890Smrgfrom The Open Group.
511ab64890Smrg
521ab64890Smrg*/
531ab64890Smrg
541ab64890Smrg#ifdef HAVE_CONFIG_H
551ab64890Smrg#include <config.h>
561ab64890Smrg#endif
571ab64890Smrg#include <X11/Xlibint.h>
581ab64890Smrg#include <X11/Xutil.h>
591ab64890Smrg#include "Xatomtype.h"
601ab64890Smrg#include <X11/Xatom.h>
611ab64890Smrg#include <X11/Xos.h>
621ab64890Smrg
631ab64890Smrgvoid XSetWMSizeHints (
641ab64890Smrg    Display *dpy,
651ab64890Smrg    Window w,
661ab64890Smrg    XSizeHints *hints,
671ab64890Smrg    Atom prop)
681ab64890Smrg{
691ab64890Smrg    xPropSizeHints data;
701ab64890Smrg
711ab64890Smrg    memset(&data, 0, sizeof(data));
7261b2299dSmrg    data.flags = (hints->flags &
731ab64890Smrg		  (USPosition|USSize|PPosition|PSize|PMinSize|PMaxSize|
741ab64890Smrg		   PResizeInc|PAspect|PBaseSize|PWinGravity));
751ab64890Smrg
761ab64890Smrg    /*
771ab64890Smrg     * The x, y, width, and height fields are obsolete; but, applications
781ab64890Smrg     * that want to work with old window managers might set them.
791ab64890Smrg     */
801ab64890Smrg    if (hints->flags & (USPosition|PPosition)) {
811ab64890Smrg	data.x = hints->x;
821ab64890Smrg	data.y = hints->y;
831ab64890Smrg    }
841ab64890Smrg    if (hints->flags & (USSize|PSize)) {
851ab64890Smrg	data.width = hints->width;
861ab64890Smrg	data.height = hints->height;
871ab64890Smrg    }
881ab64890Smrg
891ab64890Smrg    if (hints->flags & PMinSize) {
901ab64890Smrg	data.minWidth = hints->min_width;
911ab64890Smrg	data.minHeight = hints->min_height;
921ab64890Smrg    }
931ab64890Smrg    if (hints->flags & PMaxSize) {
941ab64890Smrg	data.maxWidth  = hints->max_width;
951ab64890Smrg	data.maxHeight = hints->max_height;
961ab64890Smrg    }
971ab64890Smrg    if (hints->flags & PResizeInc) {
981ab64890Smrg	data.widthInc = hints->width_inc;
991ab64890Smrg	data.heightInc = hints->height_inc;
1001ab64890Smrg    }
1011ab64890Smrg    if (hints->flags & PAspect) {
1021ab64890Smrg	data.minAspectX = hints->min_aspect.x;
1031ab64890Smrg	data.minAspectY = hints->min_aspect.y;
1041ab64890Smrg	data.maxAspectX = hints->max_aspect.x;
1051ab64890Smrg	data.maxAspectY = hints->max_aspect.y;
1061ab64890Smrg    }
1071ab64890Smrg    if (hints->flags & PBaseSize) {
1081ab64890Smrg	data.baseWidth = hints->base_width;
1091ab64890Smrg	data.baseHeight = hints->base_height;
1101ab64890Smrg    }
1111ab64890Smrg    if (hints->flags & PWinGravity) {
1121ab64890Smrg	data.winGravity = hints->win_gravity;
1131ab64890Smrg    }
11461b2299dSmrg
1151ab64890Smrg    XChangeProperty (dpy, w, prop, XA_WM_SIZE_HINTS, 32,
1161ab64890Smrg		     PropModeReplace, (unsigned char *) &data,
1171ab64890Smrg		     NumPropSizeElements);
1181ab64890Smrg}
1191ab64890Smrg
1201ab64890Smrg
1211ab64890Smrgvoid XSetWMNormalHints (
1221ab64890Smrg    Display *dpy,
1231ab64890Smrg    Window w,
1241ab64890Smrg    XSizeHints *hints)
1251ab64890Smrg{
1261ab64890Smrg    XSetWMSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS);
1271ab64890Smrg}
1281ab64890Smrg
129