Fix Maximize/Unmaximize in window menu
[wmaker-crm.git] / src / colormap.c
blob3a8906ae1c5e32c92c8be087862458cd39449574
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.
26 #include "wconfig.h"
28 #include "WindowMaker.h"
29 #include <X11/Xatom.h>
30 #include "window.h"
32 #include "framewin.h"
33 void wColormapInstallForWindow(WScreen * scr, WWindow * wwin)
35 int i;
36 XWindowAttributes attributes;
37 int done = 0;
38 Window xwin = None;
40 if (wwin) {
41 xwin = wwin->client_win;
42 } else {
43 xwin = scr->root_win;
46 scr->cmap_window = wwin;
48 if (scr->root_colormap_install_count > 0) {
49 scr->original_cmap_window = wwin;
50 return;
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--) {
56 Window w;
58 w = wwin->cmap_windows[i];
59 if (w == wwin->client_win)
60 done = 1;
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);
79 if (!done) {
80 attributes.colormap = None;
81 if (xwin != 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);
92 XSync(dpy, False);
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
101 * stuff.
103 if (!starting) {
104 XInstallColormap(dpy, scr->current_colormap);
105 XSync(dpy, False);