Home | History | Annotate | Line # | Download | only in src
      1 
      2 /***********************************************************
      3 Copyright 1988 by Wyse Technology, Inc., San Jose, Ca,
      4 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
      5 
      6                         All Rights Reserved
      7 
      8 Permission to use, copy, modify, and distribute this software and its
      9 documentation for any purpose and without fee is hereby granted,
     10 provided that the above copyright notice appear in all copies and that
     11 both that copyright notice and this permission notice appear in
     12 supporting documentation, and that the name Digital not be
     13 used in advertising or publicity pertaining to distribution of the
     14 software without specific, written prior permission.
     15 
     16 DIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     17 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     18 EVENT SHALL DIGITAL OR WYSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     19 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
     20 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
     21 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     22 PERFORMANCE OF THIS SOFTWARE.
     23 
     24 ******************************************************************/
     25 /*
     26 
     27 Copyright 1987, 1988, 1998  The Open Group
     28 
     29 Permission to use, copy, modify, distribute, and sell this software and its
     30 documentation for any purpose is hereby granted without fee, provided that
     31 the above copyright notice appear in all copies and that both that
     32 copyright notice and this permission notice appear in supporting
     33 documentation.
     34 
     35 The above copyright notice and this permission notice shall be included
     36 in all copies or substantial portions of the Software.
     37 
     38 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     39 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     40 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     41 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
     42 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     43 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     44 OTHER DEALINGS IN THE SOFTWARE.
     45 
     46 Except as contained in this notice, the name of The Open Group shall
     47 not be used in advertising or otherwise to promote the sale, use or
     48 other dealings in this Software without prior written authorization
     49 from 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 
     62 void 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 
    120 void XSetWMNormalHints (
    121     Display *dpy,
    122     Window w,
    123     XSizeHints *hints)
    124 {
    125     XSetWMSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS);
    126 }
    127 
    128