|
|
1.1 root 1: /***********************************************************
2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
4:
5: All Rights Reserved
6:
7: Permission to use, copy, modify, and distribute this software and its
8: documentation for any purpose and without fee is hereby granted,
9: provided that the above copyright notice appear in all copies and that
10: both that copyright notice and this permission notice appear in
11: supporting documentation, and that the names of Digital or MIT not be
12: used in advertising or publicity pertaining to distribution of the
13: software without specific, written prior permission.
14:
15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21: SOFTWARE.
22:
23: ******************************************************************/
24: /* $Header: mfbcmap.c,v 1.13 87/09/04 14:19:49 toddb Exp $ */
25: #include "X.h"
26: #include "scrnintstr.h"
27: #include "colormapst.h"
28: #include "resource.h"
29:
30: extern int TellLostMap(), TellGainedMap();
31: /* A monochrome frame buffer is a static gray colormap with two entries.
32: * We have a "required list" of length 1. Because we can only support 1
33: * colormap, we never have to change it, but we may have to change the
34: * name we call it. If someone installs a new colormap, we know it must
35: * look just like the old one (because we've checked in dispatch that it was
36: * a valid colormap identifier, and all the colormap IDs for this device
37: * look the same). Nevertheless, we still have to uninstall the old colormap
38: * and install the new one. Similarly, if someone uninstalls a colormap,
39: * we have to install the default map, even though we know those two looked
40: * alike.
41: * The required list concept is pretty much irrelevant when you can only
42: * have one map installed at a time.
43: */
44: static ColormapPtr pInstalledMap = (ColormapPtr) None;
45: int
46: mfbListInstalledColormaps(pScreen, pmaps)
47: ScreenPtr pScreen;
48: Colormap *pmaps;
49: {
50: /* By the time we are processing requests, we can guarantee that there
51: * is always a colormap installed */
52: *pmaps = pInstalledMap->mid;
53: return (1);
54: }
55:
56:
57: void
58: mfbInstallColormap(pmap)
59: ColormapPtr pmap;
60: {
61: if(pmap != pInstalledMap)
62: {
63: /* Uninstall pInstalledMap. No hardware changes required, just
64: * notify all interested parties. */
65: if(pInstalledMap != (ColormapPtr)None)
66: WalkTree(pmap->pScreen, TellLostMap, &pInstalledMap->mid);
67: /* Install pmap */
68: pInstalledMap = pmap;
69: WalkTree(pmap->pScreen, TellGainedMap, &pmap->mid);
70:
71: }
72: }
73: void
74: mfbUninstallColormap(pmap)
75: ColormapPtr pmap;
76: {
77: if(pmap == pInstalledMap)
78: {
79: /* Uninstall pmap */
80: WalkTree(pmap->pScreen, TellLostMap, &pmap->mid);
81: /* Install default map */
82: pInstalledMap = (ColormapPtr) LookupID(pmap->pScreen->defColormap,
83: RT_COLORMAP, RC_CORE);
84: WalkTree(pmap->pScreen, TellGainedMap, &pInstalledMap->mid);
85: }
86:
87: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.