swpanel: Start with the first window when all are minimized
[wmaker-crm.git] / src / colormap.c
blobae7229b132c7c0bc6a8e15df210c8d3ffc6a7f7b
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
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.
27 #include "wconfig.h"
29 #include "WindowMaker.h"
30 #include <X11/Xatom.h>
31 #include "window.h"
33 #include "framewin.h"
34 void wColormapInstallForWindow(WScreen * scr, WWindow * wwin)
36 int i;
37 XWindowAttributes attributes;
38 int done = 0;
39 Window xwin = None;
41 if (wwin) {
42 xwin = wwin->client_win;
43 } else {
44 xwin = scr->root_win;
47 scr->cmap_window = wwin;
49 if (scr->root_colormap_install_count > 0) {
50 scr->original_cmap_window = wwin;
51 return;
54 /* install colormap for all windows of the client */
55 if (wwin && wwin->cmap_window_no > 0 && wwin->cmap_windows) {
56 for (i = wwin->cmap_window_no - 1; i >= 0; i--) {
57 Window w;
59 w = wwin->cmap_windows[i];
60 if (w == wwin->client_win)
61 done = 1;
63 XGetWindowAttributes(dpy, w, &attributes);
64 if (attributes.colormap == None)
65 attributes.colormap = scr->colormap;
67 if (scr->current_colormap != attributes.colormap) {
68 scr->current_colormap = attributes.colormap;
70 * ICCCM 2.0: some client requested permission
71 * to install colormaps by itself and we granted.
72 * So, we can't install any colormaps.
74 if (!scr->flags.colormap_stuff_blocked)
75 XInstallColormap(dpy, attributes.colormap);
80 if (!done) {
81 attributes.colormap = None;
82 if (xwin != None)
83 XGetWindowAttributes(dpy, xwin, &attributes);
84 if (attributes.colormap == None)
85 attributes.colormap = scr->colormap;
87 if (scr->current_colormap != attributes.colormap) {
88 scr->current_colormap = attributes.colormap;
89 if (!scr->flags.colormap_stuff_blocked)
90 XInstallColormap(dpy, attributes.colormap);
93 XSync(dpy, False);
96 void wColormapInstallRoot(WScreen * scr)
98 if (scr->root_colormap_install_count == 0) {
99 wColormapInstallForWindow(scr, NULL);
100 scr->original_cmap_window = scr->cmap_window;
102 scr->root_colormap_install_count++;
105 void wColormapUninstallRoot(WScreen * scr)
107 if (scr->root_colormap_install_count > 0)
108 scr->root_colormap_install_count--;
110 if (scr->root_colormap_install_count == 0) {
111 wColormapInstallForWindow(scr, scr->original_cmap_window);
112 scr->original_cmap_window = NULL;
116 void wColormapAllowClientInstallation(WScreen * scr, Bool starting)
118 scr->flags.colormap_stuff_blocked = starting;
120 * Client stopped managing the colormap stuff. Restore the colormap
121 * that would be installed if the client did not request colormap
122 * stuff.
124 if (!starting) {
125 XInstallColormap(dpy, scr->current_colormap);
126 XSync(dpy, False);