1/*
2 * xutil.c --
3 *
4 *	This function contains generic X emulation routines.
5 *
6 * Copyright (c) 1995-1996 Sun Microsystems, Inc.
7 *
8 * See the file "license.terms" for information on usage and redistribution of
9 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 *
11 * RCS: @(#) $Id$
12 */
13
14#include <stdlib.h>
15#include <tk.h>
16
17#include <X11/Xutil.h>
18#include <X11/Xatom.h>
19
20/*
21 *----------------------------------------------------------------------
22 *
23 * XInternAtom --
24 *
25 *	This procedure simulates the XInternAtom function by calling Tk_Uid to
26 *	get a unique id for every atom. This is only a partial implementation,
27 *	since it doesn't work across applications.
28 *
29 * Results:
30 *	A new Atom.
31 *
32 * Side effects:
33 *	None.
34 *
35 *----------------------------------------------------------------------
36 */
37
38Atom
39XInternAtom(
40    Display *display,
41    _Xconst char *atom_name,
42    Bool only_if_exists)
43{
44    static Atom atom = XA_LAST_PREDEFINED;
45
46    display->request++;
47    return ++atom;
48}
49
50/*
51 *----------------------------------------------------------------------
52 *
53 * XGetVisualInfo --
54 *
55 *	Returns information about the specified visual.
56 *
57 * Results:
58 *	Returns a newly allocated XVisualInfo structure.
59 *
60 * Side effects:
61 *	Allocates storage.
62 *
63 *----------------------------------------------------------------------
64 */
65
66XVisualInfo *
67XGetVisualInfo(
68    Display *display,
69    long vinfo_mask,
70    XVisualInfo *vinfo_template,
71    int *nitems_return)
72{
73    XVisualInfo *info = (XVisualInfo *) ckalloc(sizeof(XVisualInfo));
74    info->visual = DefaultVisual(display, 0);
75    info->visualid = info->visual->visualid;
76    info->screen = 0;
77    info->depth = info->visual->bits_per_rgb;
78    info->class = info->visual->class;
79    info->colormap_size = info->visual->map_entries;
80    info->bits_per_rgb = info->visual->bits_per_rgb;
81    info->red_mask = info->visual->red_mask;
82    info->green_mask = info->visual->green_mask;
83    info->blue_mask = info->visual->blue_mask;
84
85    if (((vinfo_mask & VisualIDMask)
86	    && (vinfo_template->visualid != info->visualid))
87	    || ((vinfo_mask & VisualScreenMask)
88		    && (vinfo_template->screen != info->screen))
89	    || ((vinfo_mask & VisualDepthMask)
90		    && (vinfo_template->depth != info->depth))
91	    || ((vinfo_mask & VisualClassMask)
92		    && (vinfo_template->class != info->class))
93	    || ((vinfo_mask & VisualColormapSizeMask)
94		    && (vinfo_template->colormap_size != info->colormap_size))
95	    || ((vinfo_mask & VisualBitsPerRGBMask)
96		    && (vinfo_template->bits_per_rgb != info->bits_per_rgb))
97	    || ((vinfo_mask & VisualRedMaskMask)
98		    && (vinfo_template->red_mask != info->red_mask))
99	    || ((vinfo_mask & VisualGreenMaskMask)
100		    && (vinfo_template->green_mask != info->green_mask))
101	    || ((vinfo_mask & VisualBlueMaskMask)
102		    && (vinfo_template->blue_mask != info->blue_mask))
103	) {
104	ckfree((char *) info);
105	return NULL;
106    }
107
108    *nitems_return = 1;
109    return info;
110}
111
112/*
113 * Local Variables:
114 * mode: c
115 * c-basic-offset: 4
116 * fill-column: 78
117 * End:
118 */
119