1 /* colormap.c - colormap handling code
3 * Window Maker window manager
5 * Copyright (c) 1998 Alfredo K. Kojima
7 * This code slightly based on fvwm code,
8 * Copyright (c) Rob Nation and others
9 * but completely rewritten.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30 #include "WindowMaker.h"
31 #include <X11/Xatom.h>
37 wColormapInstallForWindow(WScreen
*scr
, WWindow
*wwin
)
40 XWindowAttributes attributes
;
45 xwin
= wwin
->client_win
;
50 scr
->cmap_window
= wwin
;
52 if (scr
->root_colormap_install_count
> 0) {
53 scr
->original_cmap_window
= wwin
;
57 /* install colormap for all windows of the client */
58 if (wwin
&& wwin
->cmap_window_no
> 0) {
59 for (i
= wwin
->cmap_window_no
- 1; i
>= 0; i
--) {
62 w
= wwin
->cmap_windows
[i
];
63 if (w
== wwin
->client_win
)
66 XGetWindowAttributes(dpy
, w
, &attributes
);
67 if (attributes
.colormap
== None
)
68 attributes
.colormap
= scr
->colormap
;
70 if (scr
->current_colormap
!= attributes
.colormap
) {
71 scr
->current_colormap
= attributes
.colormap
;
72 XInstallColormap(dpy
, attributes
.colormap
);
78 XGetWindowAttributes(dpy
, xwin
, &attributes
);
79 if (attributes
.colormap
== None
)
80 attributes
.colormap
= scr
->colormap
;
82 if (scr
->current_colormap
!= attributes
.colormap
) {
83 scr
->current_colormap
= attributes
.colormap
;
84 XInstallColormap(dpy
, attributes
.colormap
);
91 wColormapInstallRoot(WScreen
*scr
)
93 if (scr
->root_colormap_install_count
== 0) {
94 wColormapInstallForWindow(scr
, NULL
);
95 scr
->original_cmap_window
= scr
->cmap_window
;
97 scr
->root_colormap_install_count
++;
102 wColormapUninstallRoot(WScreen
*scr
)
104 if (scr
->root_colormap_install_count
> 0)
105 scr
->root_colormap_install_count
--;
107 if (scr
->root_colormap_install_count
== 0) {
108 wColormapInstallForWindow(scr
, scr
->original_cmap_window
);
109 scr
->original_cmap_window
= NULL
;