testing new loginfo script
[wmaker-crm.git] / src / colormap.c
blob0dba281282b04ac3529283026af09b2a82927841
1 /* colormap.c - colormap handling code
2 *
3 * Window Maker window manager
4 *
5 * Copyright (c) 1998 Alfredo K. Kojima
6 *
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,
24 * USA.
28 #include "wconfig.h"
30 #include "WindowMaker.h"
31 #include <X11/Xatom.h>
32 #include "window.h"
35 #include "framewin.h"
36 void
37 wColormapInstallForWindow(WScreen *scr, WWindow *wwin)
39 int i;
40 XWindowAttributes attributes;
41 int done = 0;
42 Window xwin = None;
45 if (wwin) {
46 xwin = wwin->client_win;
47 } else {
48 xwin = scr->root_win;
51 scr->cmap_window = wwin;
53 if (scr->root_colormap_install_count > 0) {
54 scr->original_cmap_window = wwin;
55 return;
58 /* install colormap for all windows of the client */
59 if (wwin && wwin->cmap_window_no > 0 && wwin->cmap_windows) {
60 for (i = wwin->cmap_window_no - 1; i >= 0; i--) {
61 Window w;
63 w = wwin->cmap_windows[i];
64 if (w == wwin->client_win)
65 done = 1;
67 XGetWindowAttributes(dpy, w, &attributes);
68 if (attributes.colormap == None)
69 attributes.colormap = scr->colormap;
71 if (scr->current_colormap != attributes.colormap) {
72 scr->current_colormap = attributes.colormap;
74 * ICCCM 2.0: some client requested permission
75 * to install colormaps by itself and we granted.
76 * So, we can't install any colormaps.
78 if (!scr->flags.colormap_stuff_blocked)
79 XInstallColormap(dpy, attributes.colormap);
84 if (!done) {
85 attributes.colormap = None;
86 if (xwin != None)
87 XGetWindowAttributes(dpy, xwin, &attributes);
88 if (attributes.colormap == None)
89 attributes.colormap = scr->colormap;
91 if (scr->current_colormap != attributes.colormap) {
92 scr->current_colormap = attributes.colormap;
93 if (!scr->flags.colormap_stuff_blocked)
94 XInstallColormap(dpy, attributes.colormap);
97 XSync(dpy, False);
101 void
102 wColormapInstallRoot(WScreen *scr)
104 if (scr->root_colormap_install_count == 0) {
105 wColormapInstallForWindow(scr, NULL);
106 scr->original_cmap_window = scr->cmap_window;
108 scr->root_colormap_install_count++;
112 void
113 wColormapUninstallRoot(WScreen *scr)
115 if (scr->root_colormap_install_count > 0)
116 scr->root_colormap_install_count--;
118 if (scr->root_colormap_install_count == 0) {
119 wColormapInstallForWindow(scr, scr->original_cmap_window);
120 scr->original_cmap_window = NULL;
125 void
126 wColormapAllowClientInstallation(WScreen *scr, Bool starting)
128 scr->flags.colormap_stuff_blocked = starting;
130 * Client stopped managing the colormap stuff. Restore the colormap
131 * that would be installed if the client did not request colormap
132 * stuff.
134 if (!starting) {
135 XInstallColormap(dpy, scr->current_colormap);
136 XSync(dpy, False);