diff options
author | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
commit | 3562e78743202e43aec8727005182a2558117eca (patch) | |
tree | 8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /libX11/src/VisUtil.c | |
download | vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2 vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip |
Checked in the following released items:
xkeyboard-config-1.4.tar.gz
ttf-bitstream-vera-1.10.tar.gz
font-alias-1.0.1.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sony-misc-1.0.0.tar.gz
font-schumacher-misc-1.0.0.tar.gz
font-mutt-misc-1.0.0.tar.gz
font-misc-misc-1.0.0.tar.gz
font-misc-meltho-1.0.0.tar.gz
font-micro-misc-1.0.0.tar.gz
font-jis-misc-1.0.0.tar.gz
font-isas-misc-1.0.0.tar.gz
font-dec-misc-1.0.0.tar.gz
font-daewoo-misc-1.0.0.tar.gz
font-cursor-misc-1.0.0.tar.gz
font-arabic-misc-1.0.0.tar.gz
font-winitzki-cyrillic-1.0.0.tar.gz
font-misc-cyrillic-1.0.0.tar.gz
font-cronyx-cyrillic-1.0.0.tar.gz
font-screen-cyrillic-1.0.1.tar.gz
font-xfree86-type1-1.0.1.tar.gz
font-adobe-utopia-type1-1.0.1.tar.gz
font-ibm-type1-1.0.0.tar.gz
font-bitstream-type1-1.0.0.tar.gz
font-bitstream-speedo-1.0.0.tar.gz
font-bh-ttf-1.0.0.tar.gz
font-bh-type1-1.0.0.tar.gz
font-bitstream-100dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz
font-bh-100dpi-1.0.0.tar.gz
font-adobe-utopia-100dpi-1.0.1.tar.gz
font-adobe-100dpi-1.0.0.tar.gz
font-util-1.0.1.tar.gz
font-bitstream-75dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz
font-adobe-utopia-75dpi-1.0.1.tar.gz
font-bh-75dpi-1.0.0.tar.gz
bdftopcf-1.0.1.tar.gz
font-adobe-75dpi-1.0.0.tar.gz
mkfontscale-1.0.6.tar.gz
openssl-0.9.8k.tar.gz
bigreqsproto-1.0.2.tar.gz
xtrans-1.2.2.tar.gz
resourceproto-1.0.2.tar.gz
inputproto-1.4.4.tar.gz
compositeproto-0.4.tar.gz
damageproto-1.1.0.tar.gz
zlib-1.2.3.tar.gz
xkbcomp-1.0.5.tar.gz
freetype-2.3.9.tar.gz
pthreads-w32-2-8-0-release.tar.gz
pixman-0.12.0.tar.gz
kbproto-1.0.3.tar.gz
evieext-1.0.2.tar.gz
fixesproto-4.0.tar.gz
recordproto-1.13.2.tar.gz
randrproto-1.2.2.tar.gz
scrnsaverproto-1.1.0.tar.gz
renderproto-0.9.3.tar.gz
xcmiscproto-1.1.2.tar.gz
fontsproto-2.0.2.tar.gz
xextproto-7.0.3.tar.gz
xproto-7.0.14.tar.gz
libXdmcp-1.0.2.tar.gz
libxkbfile-1.0.5.tar.gz
libfontenc-1.0.4.tar.gz
libXfont-1.3.4.tar.gz
libX11-1.1.5.tar.gz
libXau-1.0.4.tar.gz
libxcb-1.1.tar.gz
xorg-server-1.5.3.tar.gz
Diffstat (limited to 'libX11/src/VisUtil.c')
-rw-r--r-- | libX11/src/VisUtil.c | 255 |
1 files changed, 255 insertions, 0 deletions
diff --git a/libX11/src/VisUtil.c b/libX11/src/VisUtil.c new file mode 100644 index 000000000..53320cad0 --- /dev/null +++ b/libX11/src/VisUtil.c @@ -0,0 +1,255 @@ +/* $Xorg: VisUtil.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */ +/* + +Copyright 1986, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "Xlibint.h" +#include "Xutil.h" +#include <stdio.h> +/* + * This procedure returns a list of visual information structures + * that match the specified attributes given in the visual information + * template. + * + * If no visuals exist that match the specified attributes, a NULL is + * returned. + * + * The choices for visual_info_mask are: + * + * VisualNoMask + * VisualIDMask + * VisualScreenMask + * VisualDepthMask + * VisualClassMask + * VisualRedMaskMask + * VisualGreenMaskMask + * VisualBlueMaskMask + * VisualColormapSizeMask + * VisualBitsPerRGBMask + * VisualAllMask + */ + +XVisualInfo *XGetVisualInfo( + Display *dpy, + register long visual_info_mask, + register XVisualInfo *visual_info_template, + int *nitems) /* RETURN */ +{ + + register Visual *vp; + register Depth *dp; + Screen *sp; + int ii,screen_s,screen_e,total,count; + register XVisualInfo *vip,*vip_base; + + /* NOTE: NO HIGH PERFORMING CODE TO BE FOUND HERE */ + + LockDisplay(dpy); + + /* ALLOCATE THE ORIGINAL BUFFER; REALLOCED LATER IF OVERFLOW OCCURS; + FREED AT END IF NO VISUALS ARE FOUND */ + + count = 0; + total = 10; + if (! (vip_base = vip = (XVisualInfo *) + Xmalloc((unsigned) (sizeof(XVisualInfo) * total)))) { + UnlockDisplay(dpy); + return (XVisualInfo *) NULL; + } + + /* DETERMINE IF WE DO ALL SCREENS OR ONLY ONE */ + + screen_s = 0; + screen_e = dpy->nscreens; + if (visual_info_mask & VisualScreenMask) + { + screen_s = visual_info_template->screen; + if (screen_s < 0 || screen_s >= screen_e) + screen_e = screen_s; + else + screen_e = screen_s + 1; + } + + /* LOOP THROUGH SCREENS */ + + for (ii=screen_s; ii<screen_e; ii++) + { + sp = (Screen *)(&dpy->screens[ii]); + + /* LOOP THROUGH DEPTHS */ + + for (dp=sp->depths; dp < (sp->depths + sp->ndepths); dp++) + { + if ((visual_info_mask & VisualDepthMask) && + (dp->depth != visual_info_template->depth)) continue; + + /* LOOP THROUGH VISUALS */ + + if (dp->visuals) { + for (vp=dp->visuals; vp<(dp->visuals + dp->nvisuals); vp++) { + if ((visual_info_mask & VisualIDMask) && + (vp->visualid != visual_info_template->visualid)) continue; + if ((visual_info_mask & VisualClassMask) && + (vp->class != visual_info_template->class)) continue; + if ((visual_info_mask & VisualRedMaskMask) && + (vp->red_mask != visual_info_template->red_mask)) continue; + if ((visual_info_mask & VisualGreenMaskMask) && + (vp->green_mask != visual_info_template->green_mask)) continue; + if ((visual_info_mask & VisualBlueMaskMask) && + (vp->blue_mask != visual_info_template->blue_mask)) continue; + if ((visual_info_mask & VisualColormapSizeMask) && + (vp->map_entries != visual_info_template->colormap_size)) continue; + if ((visual_info_mask & VisualBitsPerRGBMask) && + (vp->bits_per_rgb != visual_info_template->bits_per_rgb)) continue; + + /* YEA!!! WE FOUND A GOOD ONE */ + + if (count+1 > total) + { + XVisualInfo *old_vip_base = vip_base; + total += 10; + if (! (vip_base = (XVisualInfo *) + Xrealloc((char *) vip_base, + (unsigned) (sizeof(XVisualInfo) * total)))) { + Xfree((char *) old_vip_base); + UnlockDisplay(dpy); + return (XVisualInfo *) NULL; + } + vip = &vip_base[count]; + } + + count++; + + vip->visual = _XVIDtoVisual(dpy, vp->visualid); + vip->visualid = vp->visualid; + vip->screen = ii; + vip->depth = dp->depth; + vip->class = vp->class; + vip->red_mask = vp->red_mask; + vip->green_mask = vp->green_mask; + vip->blue_mask = vp->blue_mask; + vip->colormap_size = vp->map_entries; + vip->bits_per_rgb = vp->bits_per_rgb; + + vip++; + + } /* END OF LOOP ON VISUALS */ + } /* END OF IF THERE ARE ANY VISUALS AT THIS DEPTH */ + + } /* END OF LOOP ON DEPTHS */ + + } /* END OF LOOP ON SCREENS */ + + UnlockDisplay(dpy); + + if (count) + { + *nitems = count; + return vip_base; + } + + Xfree((char *) vip_base); + *nitems = 0; + return NULL; +} + + +/* + * This procedure will return the visual information for a visual + * that matches the specified depth and class for a screen. Since + * multiple visuals may exist that match the specified depth and + * class, which visual chosen is undefined. + * + * If a visual is found, True is returned as the function value, + * otherwise False is returned. + */ + +Status XMatchVisualInfo( + Display *dpy, + int screen, + int depth, + int class, + XVisualInfo *visual_info) /* RETURNED */ +{ + + Visual *vp; + Depth *dp; + Screen *sp; + int ii,jj; + + if (screen < 0 || screen >= dpy->nscreens) + return False; + + LockDisplay(dpy); + + sp = (Screen *)(&dpy->screens[screen]); + + dp = sp->depths; + + for (ii=0; ii < sp->ndepths; ii++) + { + + /* LOOK THROUGH DEPTHS FOR THE WANTED DEPTH */ + + if (dp->depth == depth) + { + vp = dp->visuals; + + /* LOOK THROUGH VISUALS FOR THE WANTED CLASS */ + + /* if nvisuals == 0 then vp will be NULL */ + for (jj=0; jj<dp->nvisuals; jj++) + { + if (vp->class == class) + { + visual_info->visual = _XVIDtoVisual(dpy, vp->visualid); + visual_info->visualid = vp->visualid; + visual_info->screen = screen; + visual_info->depth = depth; + visual_info->class = vp->class; + visual_info->red_mask = vp->red_mask; + visual_info->green_mask = vp->green_mask; + visual_info->blue_mask = vp->blue_mask; + visual_info->colormap_size = vp->map_entries; + visual_info->bits_per_rgb = vp->bits_per_rgb; + UnlockDisplay(dpy); + return True; + } + vp++; + } + } + + dp++; + + } + + UnlockDisplay(dpy); + + return False; + +} |