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