home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / common / ibmQuery.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  3KB  |  84 lines

  1. /*
  2.  * $Id: ibmQuery.c,v 1.1 1991/09/20 18:24:03 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989
  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 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 AND FITNESS, IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25. /***********************************************************
  26. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  27. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  28.  
  29.                         All Rights Reserved
  30.  
  31. Permission to use, copy, modify, and distribute this software and its
  32. documentation for any purpose and without fee is hereby granted,
  33. provided that the above copyright notice appear in all copies and that
  34. both that copyright notice and this permission notice appear in
  35. supporting documentation, and that the names of Digital or MIT not be
  36. used in advertising or publicity pertaining to distribution of the
  37. software without specific, written prior permission.
  38.  
  39. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  40. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  41. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  42. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  43. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  44. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  45. SOFTWARE.
  46.  
  47. ******************************************************************/
  48.  
  49. #include "X.h"
  50.  
  51. void
  52. ibmQueryBestSize( class, pwidth, pheight )
  53. register int class ;
  54. register short *pwidth ;
  55. register short *pheight ;
  56. {
  57.     register unsigned width, test ;
  58.  
  59.     switch ( class ) {
  60.       case CursorShape:
  61.       *pwidth = 16 ;
  62.       *pheight = 16 ;
  63.       break ;
  64.       case TileShape:
  65.       case StippleShape:
  66.       width = *pwidth ;
  67.       if ( width > 0 ) {
  68.       /* Return the closes power of two not less than what they gave me */
  69.           test = 0x80000000 ;
  70.           /* Find the highest 1 bit in the width given */
  71.           while ( !( test & width ) )
  72.          test >>= 1 ;
  73.           /* If their number is greater than that, bump up to the next
  74.            *  power of two */
  75.           if ( ( test - 1 ) & width )
  76.          test <<= 1 ;
  77.           *pwidth = test ;
  78.       }
  79.       /* We don't care what height they use */
  80.       break ;
  81.     }
  82.     return ;
  83. }
  84.