2 .\" To print: troff -ms flash.txt
8 =======================================================================
9 || Colormap Compaction - A Technique for Reducing Colormap Flashing ||
10 =======================================================================
16 In some situations, it is beneficial to \fIcompact\fP the \fBxnews\fP default
17 colormap. This often leads to reduced \fIcolormap flashing\fP. Colormap
18 flashing occurs when colors in two different software colormaps conflict
19 with each other. Since only one software colormap can be loaded into the
20 hardware at a time, for a given pixel value you will see the color
21 which is in one colormap or the other. Which color you see depends
22 on the window into which you assign the \fIcolormap focus\fP. Typically,
23 the focus is assigned to a window by moving the pointer into it.
25 This material applies only to color devices which have a single
26 hardware color LUT, such as GX. It does not apply to monochrome screens.
27 The technique describe herein may be used on a device which
28 provides multiple hardware color LUTs, such as GS or GT, but it
29 is less valuable in this configuration, because the benefit will
30 probably not be as pronounced as it can be on a single hardware
34 \fBB. An Example of Colormap Flashing\fP
36 Let us suppose we have two windows, window A and window B.
37 Window A is attached to software colormap A; window B is attached to
38 software colormap B. When you move the pointer into window A, colormap A
39 will be loaded into the hardware colormap. Likewise, when you move
40 the pointer into window B, colormap B will be loaded.
42 Let's say the pixel value 5 is drawn somewhere on the screen. Let's also
43 suppose that the color value for pixel 5 in colormap A is Red and
44 the color value for pixel 5 in colormap B is Blue. When the pointer is
45 in window A, all pixels of value 5 will be displayed as Red, no matter where
46 they are on the screen. When the pointer is in window B, these same pixels
47 will be displayed as Blue.
49 In OpenWindows, a software colormap will only displace the other in places where they
50 each have allocated colors. In places where no colors
51 have been allocated, the contents of the hardware will remain set to the previous values.
52 Thus, the colors of two software colormaps can exist harmoniously together in the
53 hardware colormap only if their allocated colormap entries do not intersect.
55 (Readers familiar with Sunview should note that this style of colormap management
56 is very different than the named colormap segment scheme used by Sunview.)
58 Moving the pointer rapidly back and forth between windows A and B causes
59 the pixels with value 5 on the screen to blink between Red and Blue.
60 This is why this effect is called colormap \fIflashing\fP.
62 The rest of this discussion will assume a basic level of familiarity
63 with X11 colormap concepts. Users should refer to O'Reilley Volume 1
64 Chapter 7 "Color" for more information.
67 \fBC. Why Does Colormap Flashing Happen?\fP
69 The previous section discussed the effects and symptoms of colormap
70 flashing. But the fundamental question remains: what causes the
71 colors in the two colormaps to coincide and conflict?
73 For the purposes of the following discussion, pixel 0 is called the
74 \fIlow end\fP of the colormap and pixel 255 is called the \fIhigh end\fP.
76 Because, for a typical device, a maximum of 256 distinct colors can be displayed
77 on a screen at once, colors are a very scarce resource. The X11R4 standard provides
78 some mechanisms for sharing colors between client programs, thus
79 reducing the chance of colormap flashing. For example, two different
80 applications may share the same pixel value, and therefore the same color,
81 in a single colormap. Usually, a client program has to explicitly try
82 to share colors with other clients. Some situations in which such
83 attempts break down are:
86 \(bu All of the clients which are running collectively demand more
87 than 256 distinct colors.
89 \(bu One or more clients make no attempt at all to share colors
90 with other applications.
92 \(bu One or more clients use read-write (modifiable) colors, which
96 There are several techniques X11 client programmers can use to share
97 colors. Most of them entail the implementation of additional code
98 in the program. What we seek to present in this document,
99 is a generic technique that any OpenWindows user can take advantage of,
100 regardless of whether a particular program contains explicit code
101 which tries to reduce colormap flashing.
103 Client programs ask the xnews server to grant them pixels to use by telling
104 the server what colors they desire. The server figures out where to
105 put the colors in the colormap and then tells the clients which pixels
106 have been assigned to them. This process is called \fIcolor allocation\fP.
107 Unless client programs do something out of the ordinary, color allocations
108 tend to gravitate toward the low end of a colormap. This is because the
109 server always gives a client the lowest unused pixel when allocating a
112 The default colormap is a colormap which all clients know about and
113 can use. By default, when a window is created, the default colormap is
114 attached it. If a client allocates a color in a colormap and indicates it to be
115 \fIshareable\fP, other clients allocating the same color value are
116 able to share these colors. More sharing of colors means less color
117 conflicts and less colormap flashing. The default colormap, therefore,
118 is the preferred colormap to use if you want to share colors. Sometimes
119 a program cannot use the default colormap and must allocate its
120 colors in an alternate colormap. This increases the chances of flashing
121 between the colors in these two different colormaps. Sometimes a program wants
122 to use the default colormap, but cannot because it is full. The program is then
123 forced to use an alternate colormap. This, again, increases the chance of flashing.
125 To summarize, client applications would like to use the default colormap if
126 possible, but sometimes they need to or are forced to use an alternate
127 colormap. The only way to prevent colormap flashing between two separate
128 colormaps is to make them disjoint--to ensure their color allocations not
132 \fBC. Types of Colormap Flashing\fP
134 Some kinds of colormap flashing are worse than others. For example,
135 an MCAD application which flashes against a spreadsheet program
136 is unpleasant, but since the flashing is usually confined to specific
137 window areas, it can often be tolerated as a reality of limited
138 hardware. However, if the same MCAD application flashes against
139 the root window background or the frame border colors, the effect
140 is usually very pronounced. This is very disconcerting and
141 disorienting for the user.
143 It is specifically this latter type of colormap flashing that the
144 colormap compaction attempts to solve. Other techniques for dealing
145 with the former type of flashing exist, but they usually require
146 programming changes and, therefore, are not something the end-user
147 can typically take advantage of without having specially-modified software.
148 We will therefore not deal further with this \fIwindow-to-window\fP type of
149 colormap flashing. What we
150 will proceed to address is the problem of the flashing of windows against
151 a group of colors called the \fIworkspace colors\fP.
153 The workspace colors are colors which are in some way important
154 or pervasive in a user's workspace. They may be colors which
155 cover a large area on the screen or they may be colors appear
156 in frequently used applications. Some examples of applications
157 which might utilize workspace colors are:
160 \(bu A window manager (e.g \fBolwm\fP), for the root background, window borders, and menus.
162 \(bu A toolkit (e.g. XView), for window decorations and controls.
164 \(bu A root image loader (e.g. \fBxsetroot\fP), for the root background image.
166 \(bu An oft-used application (e.g. \fBfilemgr\fP).
169 Which colors should be designated as workspace colors is left
170 up to the user. The only criteria for a workspace color is that it
171 be a read-only (sharable) color and that it be allocated in the default
172 colormap of a screen.
174 To summarize, the workspace colors are the colors the user has deemed
175 to be important and with which he or she would prefer not to have
176 any colormap flashing.
181 \fIColormap compaction\fP takes advantage of the identification
182 of the colors of special applications and the low-end clustering effect of
183 typical applications. It takes advantage of these
184 by shoving the workspace colors up to the top of the colormap.
185 In this position, there is a reduced chance of the colors flashing
186 flashing with other applications.
188 It is important that it be easy to identify the workspace colors.
189 Detailed knowledge of how X11 colormaps work should not be required.
190 Nor should any programming ability be required. Lastly, we
191 don't want to rely on the availability of specially adapted programs;
192 the technique should work with any arbitrary program which conforms
193 to the X11 standard protocol.
195 All of these considerations lead us to the method which is described
196 in the following section.
199 \fBE. Instructions\fP
201 The preceding material has been presented to give you a overall sense
202 what the problem is and the general method of solution. This section
203 will show you how to apply this method in the OpenWindows environment.
205 In a nutshell, to reduce or prevent colormap flashing, you need to run the
206 \fBxnews\fP server, perform some configuration steps, and then exit the server.
207 The next time you run the server, the workspace colors you designate
208 will be put up at the high end of the default colormap.
210 For additional details on this process, refer to \fBcmap_compact\fP(1).
216 \(bu Your \fL~/.xinitrc\fP file should invoke a version of
217 \fLopenwin-sys\fP that has the following as its first line:
229 The \fLopenwin-sys\fP shipped with OpenWindows 3.0 contains this
230 line. If you use some other file, be sure to add this line.
231 The process should never be backgrounded.
234 \(bu Edit your \fL~/.openwin-menu\fP file and insert the following lines into the \fIUtilities\fP menu
235 after the "Save Workspace" menu entry:
243 "Save" DEFAULT $OPENWINHOME/bin/cmap_compact save
244 "Discard" $OPENWINHOME/bin/cmap_compact discard
252 If you do not have your own customized menu file, start with a copy
253 of \fL$OPENWINHOME/lib/openwin-menu\fP placed in your home directory, renamed
254 to \fL.openwin-menu.\fP
262 1. Run the server with the \fBopenwin\fP(1) script. Be sure at this
263 time to configure the server for all of the screens you want to
264 compact colors for. \fBopenwin\fP will (typically) execute
265 \fI~/.openwin-init\fP, which will in turn bring up your initial
269 2. If you use a program which loads a root background image (such as
270 \fBxsetroot\fP(1)), make sure you run this program. Do this for
274 3. Use the \fIWorkspace Properties\fP sheet to select your desired
275 window border and/or root window background colors. This property
276 is available by selecting the \fIProperties\fP entry of the
277 root menu. Do this for every screen.
280 4. Choose the applications whose colors you want to designate as
281 workspace colors. You do this by either quitting undesired
282 applications which are on the screen or by running desired
283 applications which are not yet on the screen. Do this for
287 5. At this point, the only colors which are in the default colormap
288 should belong to the displayed programs. Go into the
289 \fIUtilities\fP submenu of the root menu of any screen and select the
290 \fISave Colors\fP entry. All sharable (read-only)
291 colors in the default colormaps for all screens will be recorded and stored in
292 the file \fI~/.owcolors\fP. Note: private (read-write) colors used
293 by any of these applications will be ignored and will not
297 6. Exit the window system.
300 7. Reenter the window system by rerunning \fIopenwin\fP.
303 When you reenter the window system, the colors that have
304 been stored in \fI~/.owcolors\fP are placed at the high
305 end of the default colormap. Since this is done before
306 any of the other applications are started, when these
307 applications are finally started, they will find the colors
308 they want waiting for them at the high end and will use
311 Note: If you decide to change any of the workspace colors, you should
312 repeat steps 3-7. Otherwise, you may end up with more colormap
315 If, at any time, you wish to undo the effects of the colormap
316 compaction, select the \fIDiscard\fP entry of the \fISave Colors\fP
319 As a side-effect of colormap compaction, the NeWS color cube in the
320 StaticColor colormap gets shifted downward. The cube is shifted down by
321 the number of workspace colors you have saved (actually, the number
322 of colors for the screen with the most colors). This is done to avoid
323 flashing between NeWS windows and the workspace colors. Note: the base
324 of the color cube is never shifted lower than pixel 0.
326 The black and white pixels which are pre-allocated in the default colormap
327 by the server are shifted up to the high end of the colormap.
329 In addition, XGL (version 2.0 and greater) will recognize that
330 colormap compaction has been turned on and will adjust its
331 color cube accordingly. XGL usually allocates its color cube
332 at the high end of its colormap by default. When colormap
333 compaction is turned on, XGL will allocate its color cube at
334 the low end of the colormap.
337 \fBF. What if Colormap Flashing isn't Reduced?\fP
339 Colormap compaction is a heuristic technique: it is not always effective
340 in reducing colormap flashing and, in some situations, may actually
341 increase colormap flashing. The result of using colormap compaction
342 is highly dependent on the applications you use and the way that you
343 have configured color on your desktop.
345 Here are some example situations in which colormap compaction does
350 \(bu If you are running a program which allocates
351 its colors at the high end of a non-default colormap on purpose,
352 this program will end up flashing more with the workspace colors.
355 \(bu If you select a large amount of workspace colors, the
356 NeWS color cube may be shifted down enough to start
357 flashing more with X11 applications allocating their
358 colors at the low end. This may increase colormap flashing
359 between X11 and NeWS applications.
362 In general, the amount of colormap flashing reduction or
363 increase afforded by colormap compaction is highly dependent
364 on the set of applications you run in your environment.
365 For many environments, colormap compaction will be useful.
366 But there are some environments for which it is not.
367 The best policy is to give it a try and see if it helps.
368 If it does not help, turn it off by selecting discard on
369 the "Save Colors" menu.
371 Some other things to be aware of:
375 \(bu Colormap compaction has no effect for screens which
376 have the StaticColor colormap as the default (i.e. for
377 screens which have a device modifier of \fIstaticvis\fP).
380 \(bu You should discard the saved workspace colors and
381 reconfigure whenever you change the device modifiers
382 (\fLstaticvis\fP, \fLgrayvis\fP or \fLdefdepth\fP) used on
383 the server command line.
386 \(bu You should discard the saved colors and reconfigure whenever
387 you remove a screen from your configuration.
390 \(bu Colormap compaction does not preclude other means of
391 inter-application color sharing which programmers may
392 want to use. For example, X11 \fIStandard Colormap
393 properties\fP can be used to promote sharing among imaging
394 applications that use lots of colors. Application developers can
395 use these properties in conjunction with colormap
396 compaction to achieve even less colormap flashing.
402 Compacting the default colormap is the process of selecting certain application
403 colors you would prefer not to flash and saving these
404 colors into a file. When the window system is reentered, these colors
405 will end up at the high end of the default colormap, a preferred position
406 which often decreases colormap flashing.
408 This process may not always make sense for your situation. Depending on the
409 applications you run, it may or may not help, but it probably will. You
410 must also make sure you keep the configuration up-to-date to continue
411 to derive the maximum benefits. If, after trying colormap compaction, colormap
412 flashing on your desktop is not reduced, colormap compaction should be turned back off.