1 /* colormap.c - colormap handling code
3 * Window Maker window manager
5 * Copyright (c) 1998-2003 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 along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "WindowMaker.h"
29 #include <X11/Xatom.h>
33 void wColormapInstallForWindow(WScreen
* scr
, WWindow
* wwin
)
36 XWindowAttributes attributes
;
41 xwin
= wwin
->client_win
;
46 scr
->cmap_window
= wwin
;
48 if (scr
->root_colormap_install_count
> 0) {
49 scr
->original_cmap_window
= wwin
;
53 /* install colormap for all windows of the client */
54 if (wwin
&& wwin
->cmap_window_no
> 0 && wwin
->cmap_windows
) {
55 for (i
= wwin
->cmap_window_no
- 1; i
>= 0; i
--) {
58 w
= wwin
->cmap_windows
[i
];
59 if (w
== wwin
->client_win
)
62 XGetWindowAttributes(dpy
, w
, &attributes
);
63 if (attributes
.colormap
== None
)
64 attributes
.colormap
= scr
->colormap
;
66 if (scr
->current_colormap
!= attributes
.colormap
) {
67 scr
->current_colormap
= attributes
.colormap
;
69 * ICCCM 2.0: some client requested permission
70 * to install colormaps by itself and we granted.
71 * So, we can't install any colormaps.
73 if (!scr
->flags
.colormap_stuff_blocked
)
74 XInstallColormap(dpy
, attributes
.colormap
);
80 attributes
.colormap
= None
;
82 XGetWindowAttributes(dpy
, xwin
, &attributes
);
83 if (attributes
.colormap
== None
)
84 attributes
.colormap
= scr
->colormap
;
86 if (scr
->current_colormap
!= attributes
.colormap
) {
87 scr
->current_colormap
= attributes
.colormap
;
88 if (!scr
->flags
.colormap_stuff_blocked
)
89 XInstallColormap(dpy
, attributes
.colormap
);
95 void wColormapAllowClientInstallation(WScreen
* scr
, Bool starting
)
97 scr
->flags
.colormap_stuff_blocked
= starting
;
99 * Client stopped managing the colormap stuff. Restore the colormap
100 * that would be installed if the client did not request colormap
104 XInstallColormap(dpy
, scr
->current_colormap
);