|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1989, 1998 The Open Group
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit Service |
2b1f13 |
the above copyright notice appear in all copies and that both that
|
|
Packit Service |
2b1f13 |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
2b1f13 |
documentation.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
2b1f13 |
all copies or substantial portions of the Software.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
2b1f13 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
2b1f13 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit Service |
2b1f13 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit Service |
2b1f13 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
2b1f13 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit Service |
2b1f13 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit Service |
2b1f13 |
in this Software without prior written authorization from The Open Group.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
2b1f13 |
#include <config.h>
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#include <stdio.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xlib.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xatom.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xutil.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/StdCmap.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
static XVisualInfo *getDeepestVisual(int, XVisualInfo*, int);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* To create all of the appropriate standard colormaps for every visual of
|
|
Packit Service |
2b1f13 |
* every screen on a given display, use XmuAllStandardColormaps.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Define and retain as permanent resources all standard colormaps which are
|
|
Packit Service |
2b1f13 |
* meaningful for the visuals of each screen of the display. Return 0 on
|
|
Packit Service |
2b1f13 |
* failure, non-zero on success. If the property of any standard colormap
|
|
Packit Service |
2b1f13 |
* is already defined, redefine it.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* This interface is intended to be used by window managers or a client
|
|
Packit Service |
2b1f13 |
* upon start-up of a session.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* The standard colormaps of a screen are defined by properties associated
|
|
Packit Service |
2b1f13 |
* with the screen's root window. Each screen has exactly one root window.
|
|
Packit Service |
2b1f13 |
* The property names of standard colormaps are predefined, and each property
|
|
Packit Service |
2b1f13 |
* name may describe at most one colormap.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* The standard colormaps are
|
|
Packit Service |
2b1f13 |
* RGB_BEST_MAP
|
|
Packit Service |
2b1f13 |
* RGB_RED_MAP
|
|
Packit Service |
2b1f13 |
* RGB_GREEN_MAP
|
|
Packit Service |
2b1f13 |
* RGB_BLUE_MAP
|
|
Packit Service |
2b1f13 |
* RGB_DEFAULT_MAP
|
|
Packit Service |
2b1f13 |
* RGB_GRAY_MAP
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Therefore a screen may have at most 6 standard colormap properties defined.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* A standard colormap is associated with a particular visual of the screen.
|
|
Packit Service |
2b1f13 |
* A screen may have multiple visuals defined, including visuals of the same
|
|
Packit Service |
2b1f13 |
* class at different depths. Note that a visual id might be repeated for
|
|
Packit Service |
2b1f13 |
* more than one depth, so the visual id and the depth of a visual identify
|
|
Packit Service |
2b1f13 |
* the visual. The characteristics of the visual will determine which
|
|
Packit Service |
2b1f13 |
* standard colormaps are meaningful under that visual, and will determine
|
|
Packit Service |
2b1f13 |
* how the standard colormap is defined. Because a standard colormap is
|
|
Packit Service |
2b1f13 |
* associated with a specific visual, there must be a method of determining
|
|
Packit Service |
2b1f13 |
* which visuals take precedence in defining standard colormaps.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* The method used here is: for the visual of greatest depth, define all
|
|
Packit Service |
2b1f13 |
* standard colormaps meaningful to that visual class, according to this
|
|
Packit Service |
2b1f13 |
* order of (descending) precedence:
|
|
Packit Service |
2b1f13 |
* 1. DirectColor
|
|
Packit Service |
2b1f13 |
* 2. PseudoColor
|
|
Packit Service |
2b1f13 |
* 3. TrueColor and GrayScale
|
|
Packit Service |
2b1f13 |
* 4. StaticColor and StaticGray
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Allows partial success by screenful. For example, if a map on screen 1
|
|
Packit Service |
2b1f13 |
* fails, the maps on screen 0, created earlier, will remain. However,
|
|
Packit Service |
2b1f13 |
* none on screen 1 will remain. If a map on 0 fails, none will remain.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* See the comments under XmuVisualStandardColormaps() for notes on which
|
|
Packit Service |
2b1f13 |
* standard colormaps are meaningful under these classes of visuals.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Status
|
|
Packit Service |
2b1f13 |
XmuAllStandardColormaps(Display *dpy)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
int nvisuals, scr;
|
|
Packit Service |
2b1f13 |
Status status;
|
|
Packit Service |
2b1f13 |
long vinfo_mask;
|
|
Packit Service |
2b1f13 |
XVisualInfo template, *vinfo, *v1, *v2;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
status = 0;
|
|
Packit Service |
2b1f13 |
/* for each screen, determine all visuals of this server */
|
|
Packit Service |
2b1f13 |
for (scr=0; scr < ScreenCount(dpy); scr++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
template.screen = scr;
|
|
Packit Service |
2b1f13 |
vinfo_mask = VisualScreenMask;
|
|
Packit Service |
2b1f13 |
vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
|
|
Packit Service |
2b1f13 |
if (vinfo == NULL) /* unexpected: a screen with no visuals */
|
|
Packit Service |
2b1f13 |
continue;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
|
|
Packit Service |
2b1f13 |
v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (v2 &&
|
|
Packit Service |
2b1f13 |
(!v1 || (v2->colormap_size >=
|
|
Packit Service |
2b1f13 |
((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
|
|
Packit Service |
2b1f13 |
status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
|
|
Packit Service |
2b1f13 |
(unsigned) v2->depth, 1, 1);
|
|
Packit Service |
2b1f13 |
else if (v1)
|
|
Packit Service |
2b1f13 |
status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
|
|
Packit Service |
2b1f13 |
(unsigned) v1->depth, 1, 1);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
else {
|
|
Packit Service |
2b1f13 |
if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL)
|
|
Packit Service |
2b1f13 |
|| ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) !=
|
|
Packit Service |
2b1f13 |
NULL))
|
|
Packit Service |
2b1f13 |
status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
|
|
Packit Service |
2b1f13 |
(unsigned) v1->depth, 1, 1);
|
|
Packit Service |
2b1f13 |
if (status &&
|
|
Packit Service |
2b1f13 |
(((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL)
|
|
Packit Service |
2b1f13 |
|| ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) !=
|
|
Packit Service |
2b1f13 |
NULL)))
|
|
Packit Service |
2b1f13 |
status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
|
|
Packit Service |
2b1f13 |
(unsigned) v1->depth, 1, 1);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
XFree ((char *) vinfo);
|
|
Packit Service |
2b1f13 |
if (!status) break;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
return status;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
static XVisualInfo *
|
|
Packit Service |
2b1f13 |
getDeepestVisual(int visual_class, XVisualInfo *vinfo, int nvisuals)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
register int i;
|
|
Packit Service |
2b1f13 |
register int maxdepth = 0;
|
|
Packit Service |
2b1f13 |
XVisualInfo *v = NULL;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i=0; i < nvisuals; i++, vinfo++)
|
|
Packit Service |
2b1f13 |
if (vinfo->class == visual_class && vinfo->depth > maxdepth)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
maxdepth = vinfo->depth;
|
|
Packit Service |
2b1f13 |
v = vinfo;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
return(v);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|