home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / ibm / common / ibmQuery.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  1.9 KB  |  64 lines

  1. /*
  2.  * $XConsortium: ibmQuery.c,v 1.2 91/07/16 13:09:39 jap Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989,1990,1991
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * License 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 of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND 
  18.  * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
  19.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23.  * SOFTWARE.
  24.  *
  25. */
  26.  
  27. #include "X.h"
  28. #include "Xproto.h"
  29.  
  30. void
  31. ibmQueryBestSize(class, pwidth, pheight)
  32. register int class;
  33. register short *pwidth;
  34. register short *pheight;
  35. {
  36.     register unsigned width, test;
  37.  
  38.     switch(class)
  39.     {
  40.       case CursorShape:
  41.       *pwidth = 16;
  42.       *pheight = 16;
  43.       break;
  44.       case TileShape:
  45.       case StippleShape:
  46.       width = *pwidth;
  47.       if (width > 0) {
  48.       /* Return the closest power of two not less than what they gave me */
  49.           test = 0x80000000;
  50.           /* Find the highest 1 bit in the width given */
  51.           while(!(test & width))
  52.          test >>= 1;
  53.           /* If their number is greater than that, bump up to the next
  54.            *  power of two */
  55.           if((test - 1) & width)
  56.          test <<= 1;
  57.           *pwidth = test;
  58.       }
  59.       /* We don't care what height they use */
  60.       break;
  61.     }
  62.     return ;
  63. }
  64.