Small fix for wmaker nightly build script 2
[wmaker-crm.git] / src / client.c
blob962e70399accc061d79704f1d015526cade7feb0
1 /*
2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
21 #include "wconfig.h"
23 #include <X11/Xlib.h>
24 #include <X11/Xutil.h>
25 #include <X11/Xatom.h>
26 #ifdef SHAPE
27 #include <X11/extensions/shape.h>
28 #endif
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
34 #include "WindowMaker.h"
35 #include "wcore.h"
36 #include "framewin.h"
37 #include "window.h"
38 #include "properties.h"
39 #include "actions.h"
40 #include "icon.h"
41 #include "client.h"
42 #include "funcs.h"
43 #include "stacking.h"
44 #include "appicon.h"
45 #include "appmenu.h"
46 #include "wmspec.h"
48 /****** Global Variables ******/
50 /* contexts */
51 extern XContext wWinContext;
53 extern Atom _XA_WM_STATE;
54 extern Atom _XA_WM_PROTOCOLS;
55 extern Atom _XA_WM_COLORMAP_WINDOWS;
57 extern Atom _XA_WINDOWMAKER_MENU;
59 extern Atom _XA_GNUSTEP_WM_ATTR;
60 extern Atom _XA_GNUSTEP_WM_RESIZEBAR;
62 #ifdef SHAPE
63 extern Bool wShapeSupported;
64 #endif
67 *--------------------------------------------------------------------
68 * wClientRestore--
69 * Reparent the window back to the root window.
71 *--------------------------------------------------------------------
73 void wClientRestore(WWindow * wwin)
75 #if 0
76 int gx, gy;
78 wClientGetGravityOffsets(wwin, &gx, &gy);
79 /* set the positio of the frame on screen */
80 wwin->frame_x -= gx * FRAME_BORDER_WIDTH;
81 wwin->frame_y -= gy * FRAME_BORDER_WIDTH;
82 /* if gravity is to the south, account for the border sizes */
83 if (gy > 0)
84 wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width);
85 #endif
86 XSetWindowBorderWidth(dpy, wwin->client_win, wwin->old_border_width);
87 XReparentWindow(dpy, wwin->client_win, wwin->screen_ptr->root_win, wwin->frame_x, wwin->frame_y);
89 /* don't let the window get iconified after restart */
91 if (wwin->flags.shaded)
92 wClientSetState(wwin, NormalState, None);
97 *----------------------------------------------------------------------
98 * wClientSetState--
99 * Set the state of the client window to one of the window
100 * states defined in ICCCM (Iconic, Withdrawn, Normal)
102 * Side effects:
103 * The WM_STATE property of the window is updated as well as the
104 * WWindow.state variable.
105 *----------------------------------------------------------------------
107 void wClientSetState(WWindow * wwin, int state, Window icon_win)
109 CARD32 data[2];
111 wwin->state = state;
113 data[0] = (unsigned long)state;
114 data[1] = (unsigned long)icon_win;
116 XChangeProperty(dpy, wwin->client_win, _XA_WM_STATE, _XA_WM_STATE, 32,
117 PropModeReplace, (unsigned char *)data, 2);
120 void wClientGetGravityOffsets(WWindow * wwin, int *ofs_x, int *ofs_y)
122 switch (wwin->normal_hints->win_gravity) {
123 case ForgetGravity:
124 case CenterGravity:
125 case StaticGravity:
126 *ofs_x = 0;
127 *ofs_y = 0;
128 break;
129 case NorthWestGravity:
130 *ofs_x = -1;
131 *ofs_y = -1;
132 break;
133 case NorthGravity:
134 *ofs_x = 0;
135 *ofs_y = -1;
136 break;
137 case NorthEastGravity:
138 *ofs_x = 1;
139 *ofs_y = -1;
140 break;
141 case WestGravity:
142 *ofs_x = -1;
143 *ofs_y = 0;
144 break;
145 case EastGravity:
146 *ofs_x = 1;
147 *ofs_y = 0;
148 break;
149 case SouthWestGravity:
150 *ofs_x = -1;
151 *ofs_y = 1;
152 break;
153 case SouthGravity:
154 *ofs_x = 0;
155 *ofs_y = 1;
156 break;
157 case SouthEastGravity:
158 *ofs_x = 1;
159 *ofs_y = 1;
160 break;
164 void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
166 XWindowChanges xwc;
167 int nx, ny, nwidth, nheight;
168 int ofs_x, ofs_y;
170 /* printf("configure event: %d %d %d %d\n", xcre->x, xcre->y, xcre->width, xcre->height); */
172 if (wwin == NULL) {
174 * configure a window that was not mapped by us
176 xwc.x = xcre->x;
177 xwc.y = xcre->y;
178 xwc.width = xcre->width;
179 xwc.height = xcre->height;
180 xwc.border_width = xcre->border_width;
181 xwc.stack_mode = xcre->detail;
182 xwc.sibling = xcre->above;
183 XConfigureWindow(dpy, xcre->window, xcre->value_mask, &xwc);
184 return;
186 #ifdef SHAPE
187 if (wShapeSupported) {
188 int junk;
189 unsigned int ujunk;
190 int b_shaped;
192 XShapeSelectInput(dpy, wwin->client_win, ShapeNotifyMask);
193 XShapeQueryExtents(dpy, wwin->client_win, &b_shaped, &junk, &junk,
194 &ujunk, &ujunk, &junk, &junk, &junk, &ujunk, &ujunk);
195 wwin->flags.shaped = b_shaped;
197 #endif
198 if (xcre->value_mask & CWStackMode) {
199 WObjDescriptor *desc;
200 WWindow *sibling;
202 if ((xcre->value_mask & CWSibling) &&
203 (XFindContext(dpy, xcre->above, wWinContext, (XPointer *) & desc) == XCSUCCESS)
204 && (desc->parent_type == WCLASS_WINDOW)) {
205 sibling = desc->parent;
206 xwc.sibling = sibling->frame->core->window;
207 } else {
208 xwc.sibling = xcre->above;
210 xwc.stack_mode = xcre->detail;
211 XConfigureWindow(dpy, wwin->frame->core->window,
212 xcre->value_mask & (CWSibling | CWStackMode), &xwc);
213 /* fix stacking order */
214 RemakeStackList(wwin->screen_ptr);
217 wClientGetGravityOffsets(wwin, &ofs_x, &ofs_y);
219 if (xcre->value_mask & CWBorderWidth) {
220 wwin->old_border_width = xcre->border_width;
223 if (!wwin->flags.shaded) {
224 /* If the window is shaded, wrong height will be set for the window */
225 if (xcre->value_mask & CWX) {
226 nx = xcre->x;
227 /* Subtracting the border makes the window shift by 1 pixel -Dan */
228 /*if (HAS_BORDER(wwin)) {
229 nx -= FRAME_BORDER_WIDTH;
230 } */
231 } else {
232 nx = wwin->frame_x;
235 if (xcre->value_mask & CWY) {
236 ny = xcre->y - ((ofs_y < 0) ? 0 : wwin->frame->top_width);
237 /* Subtracting the border makes the window shift by 1 pixel -Dan */
238 /*if (HAS_BORDER(wwin)) {
239 ny -= FRAME_BORDER_WIDTH;
240 } */
241 } else {
242 ny = wwin->frame_y;
245 if (xcre->value_mask & CWWidth)
246 nwidth = xcre->width;
247 else
248 nwidth = wwin->frame->core->width;
250 if (xcre->value_mask & CWHeight)
251 nheight = xcre->height;
252 else
253 nheight = wwin->frame->core->height - wwin->frame->top_width - wwin->frame->bottom_width;
255 if (nwidth != wwin->old_geometry.width)
256 wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_MAXIMUS);
257 if (nheight != wwin->old_geometry.height)
258 wwin->flags.maximized &= ~(MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS);
260 wWindowConfigure(wwin, nx, ny, nwidth, nheight);
261 wwin->old_geometry.x = nx;
262 wwin->old_geometry.y = ny;
263 wwin->old_geometry.width = nwidth;
264 wwin->old_geometry.height = nheight;
268 void wClientSendProtocol(WWindow * wwin, Atom protocol, Time time)
270 XEvent event;
272 event.xclient.type = ClientMessage;
273 event.xclient.message_type = _XA_WM_PROTOCOLS;
274 event.xclient.format = 32;
275 event.xclient.display = dpy;
276 event.xclient.window = wwin->client_win;
277 event.xclient.data.l[0] = protocol;
278 event.xclient.data.l[1] = time;
279 event.xclient.data.l[2] = 0;
280 event.xclient.data.l[3] = 0;
281 XSendEvent(dpy, wwin->client_win, False, NoEventMask, &event);
282 XSync(dpy, False);
285 void wClientKill(WWindow * wwin)
287 XKillClient(dpy, wwin->client_win);
289 XFlush(dpy);
293 *----------------------------------------------------------------------
294 * wClientCheckProperty--
295 * Handles PropertyNotify'es, verifying which property was
296 * changed and updating internal state according to that, like redrawing
297 * the icon title when it is changed.
299 * Side effects:
300 * Depends on the changed property.
302 * TODO: _GNUSTEP_WM_ATTR
303 *----------------------------------------------------------------------
305 void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event)
307 XWindowAttributes attribs;
308 XWMHints *new_hints;
309 int i, g1, g2;
310 char *tmp = NULL;
312 switch (event->atom) {
313 case XA_WM_NAME:
314 if (!wwin->flags.net_has_title) {
315 /* window title was changed */
316 if (!wFetchName(dpy, wwin->client_win, &tmp)) {
317 wWindowUpdateName(wwin, NULL);
318 } else {
319 wWindowUpdateName(wwin, tmp);
321 if (tmp)
322 XFree(tmp);
324 break;
326 case XA_WM_ICON_NAME:
327 if (!wwin->flags.net_has_icon_title) {
328 if (!wwin->icon)
329 break;
330 else {
331 char *new_title;
333 /* icon title was changed */
334 wGetIconName(dpy, wwin->client_win, &new_title);
335 wIconChangeTitle(wwin->icon, new_title);
338 break;
340 case XA_WM_COMMAND:
341 if (wwin->main_window != None) {
342 WApplication *wapp = wApplicationOf(wwin->main_window);
343 char *command;
345 if (!wapp || !wapp->app_icon || wapp->app_icon->docked)
346 break;
348 command = GetCommandForWindow(wwin->main_window);
349 if (command) {
350 if (wapp->app_icon->command)
351 wfree(wapp->app_icon->command);
352 wapp->app_icon->command = command;
355 break;
357 case XA_WM_HINTS:
358 /* WM_HINTS */
360 new_hints = XGetWMHints(dpy, wwin->client_win);
362 /* group leader update
364 * This means that the window is setting the leader after
365 * it was mapped, changing leaders or removing the leader.
367 * Valid state transitions are:
369 * _1 __2
370 * / \ / \
371 * v | v |
372 * (GC) (GC')
373 * / ^ / ^
374 * 3| |4 5| |6
375 * | | | |
376 * v / v /
377 * (G'C) (G'C')
379 * Where G is the window_group hint, C is CLIENT_LEADER property
380 * and ' indicates the hint is unset.
382 * 1,2 - change group leader to new value of window_group
383 * 3 - change leader to value of CLIENT_LEADER
384 * 4 - change leader to value of window_group
385 * 5 - destroy application
386 * 6 - create application
388 if (new_hints && (new_hints->flags & WindowGroupHint)
389 && new_hints->window_group != None) {
390 g2 = 1;
391 } else {
392 g2 = 0;
394 if (wwin->wm_hints && (wwin->wm_hints->flags & WindowGroupHint)
395 && wwin->wm_hints->window_group != None) {
396 g1 = 1;
397 } else {
398 g1 = 0;
401 if (wwin->client_leader) {
402 if (g1 && g2 && wwin->wm_hints->window_group != new_hints->window_group) {
403 i = 1;
404 } else if (g1 && !g2) {
405 i = 3;
406 } else if (!g1 && g2) {
407 i = 4;
408 } else {
409 i = 0;
411 } else {
412 if (g1 && g2 && wwin->wm_hints->window_group != new_hints->window_group) {
413 i = 2;
414 } else if (g1 && !g2) {
415 i = 5;
416 } else if (!g1 && g2) {
417 i = 6;
418 } else {
419 i = 0;
423 /* Handling this may require more work. -Dan */
424 if (wwin->fake_group != NULL) {
425 i = 7;
428 if (wwin->wm_hints)
429 XFree(wwin->wm_hints);
431 wwin->wm_hints = new_hints;
433 /* do action according to state transition */
434 switch (i) {
435 /* 3 - change leader to value of CLIENT_LEADER */
436 case 3:
437 wApplicationDestroy(wApplicationOf(wwin->main_window));
438 wwin->main_window = wwin->client_leader;
439 wwin->group_id = None;
440 wApplicationCreate(wwin);
441 break;
443 /* 1,2,4 - change leader to new value of window_group */
444 case 1:
445 case 2:
446 case 4:
447 wApplicationDestroy(wApplicationOf(wwin->main_window));
448 wwin->main_window = new_hints->window_group;
449 wwin->group_id = wwin->main_window;
450 wApplicationCreate(wwin);
451 break;
453 /* 5 - destroy application */
454 case 5:
455 wApplicationDestroy(wApplicationOf(wwin->main_window));
456 wwin->main_window = None;
457 wwin->group_id = None;
458 break;
460 /* 6 - create application */
461 case 6:
462 wwin->main_window = new_hints->window_group;
463 wwin->group_id = wwin->main_window;
464 wApplicationCreate(wwin);
465 break;
466 /* 7 - we have a fake window group id, so just ignore anything else */
467 case 7:
468 break;
470 #ifdef DEBUG
471 if (i) {
472 printf("window leader update caused state transition %i\n", i);
474 #endif
476 if (wwin->wm_hints) {
477 /* update icon */
478 if ((wwin->wm_hints->flags & IconPixmapHint)
479 || (wwin->wm_hints->flags & IconWindowHint)) {
480 WApplication *wapp;
482 if (wwin->flags.miniaturized && wwin->icon) {
483 wIconUpdate(wwin->icon);
485 wapp = wApplicationOf(wwin->main_window);
486 if (wapp && wapp->app_icon) {
487 wIconUpdate(wapp->app_icon->icon);
491 if (wwin->wm_hints->flags & UrgencyHint)
492 wwin->flags.urgent = 1;
493 else
494 wwin->flags.urgent = 0;
495 /*} else if (wwin->fake_group!=NULL) {
496 wwin->group_id = wwin->fake_group->leader; */
497 } else {
498 wwin->group_id = None;
500 break;
502 case XA_WM_NORMAL_HINTS:
503 /* normal (geometry) hints */
505 int foo;
506 unsigned bar;
508 XGetWindowAttributes(dpy, wwin->client_win, &attribs);
509 wClientGetNormalHints(wwin, &attribs, False, &foo, &foo, &bar, &bar);
510 /* TODO: should we check for consistency of the current
511 * size against the new geometry hints? */
513 break;
515 case XA_WM_TRANSIENT_FOR:
517 Window new_owner;
518 WWindow *owner;
520 if (!XGetTransientForHint(dpy, wwin->client_win, &new_owner)) {
521 new_owner = None;
522 } else {
523 if (new_owner == 0 || new_owner == wwin->client_win) {
524 new_owner = wwin->screen_ptr->root_win;
527 if (new_owner != wwin->transient_for) {
528 owner = wWindowFor(wwin->transient_for);
529 if (owner) {
530 if (owner->flags.semi_focused) {
531 owner->flags.semi_focused = 0;
532 if ((owner->flags.mapped || owner->flags.shaded)
533 && owner->frame)
534 wFrameWindowPaint(owner->frame);
537 owner = wWindowFor(new_owner);
538 if (owner) {
539 if (!owner->flags.semi_focused) {
540 owner->flags.semi_focused = 1;
541 if ((owner->flags.mapped || owner->flags.shaded)
542 && owner->frame)
543 wFrameWindowPaint(owner->frame);
546 wwin->transient_for = new_owner;
547 if (new_owner == None) {
548 if (WFLAGP(wwin, no_miniaturizable)) {
549 WSETUFLAG(wwin, no_miniaturizable, 0);
550 WSETUFLAG(wwin, no_miniaturize_button, 0);
551 if (wwin->frame)
552 wWindowConfigureBorders(wwin);
554 } else if (!WFLAGP(wwin, no_miniaturizable)) {
555 WSETUFLAG(wwin, no_miniaturizable, 1);
556 WSETUFLAG(wwin, no_miniaturize_button, 1);
557 if (wwin->frame)
558 wWindowConfigureBorders(wwin);
562 break;
564 default:
565 if (event->atom == _XA_WM_PROTOCOLS) {
567 PropGetProtocols(wwin->client_win, &wwin->protocols);
569 WSETUFLAG(wwin, kill_close, !wwin->protocols.DELETE_WINDOW);
571 if (wwin->frame)
572 wWindowUpdateButtonImages(wwin);
574 } else if (event->atom == _XA_WM_COLORMAP_WINDOWS) {
576 GetColormapWindows(wwin);
577 wColormapInstallForWindow(wwin->screen_ptr, wwin);
579 } else if (event->atom == _XA_WINDOWMAKER_MENU) {
580 WApplication *wapp;
582 wapp = wApplicationOf(wwin->main_window);
583 if (wapp) {
584 if (wapp->menu) {
585 /* update menu */
586 /* TODO: remake appmenu update */
587 wAppMenuDestroy(wapp->menu);
589 if (wwin->fake_group) {
590 extern WPreferences wPreferences;
591 WScreen *scr = wwin->screen_ptr;
592 WWindow *foo = scr->focused_window;
593 WFakeGroupLeader *fPtr = wwin->fake_group;
595 wApplicationDestroy(wapp);
596 while (foo) {
597 if (foo->fake_group && foo->fake_group == fPtr) {
598 WSETUFLAG(foo, shared_appicon, 0);
599 foo->fake_group = NULL;
600 if (foo->group_id != None)
601 foo->main_window = foo->group_id;
602 else if (foo->client_leader != None)
603 foo->main_window = foo->client_leader;
604 else if (WFLAGP(foo, emulate_appicon))
605 foo->main_window = foo->client_win;
606 else
607 foo->main_window = None;
608 if (foo->main_window) {
609 wapp = wApplicationCreate(foo);
612 foo = foo->prev;
615 if (fPtr->leader != None)
616 XDestroyWindow(dpy, fPtr->leader);
617 fPtr->retainCount = 0;
618 fPtr->leader = None;
619 fPtr->origLeader = None;
621 wapp = wApplicationOf(wwin->main_window);
622 if (wapp) {
623 wapp->menu = wAppMenuGet(scr, wwin->main_window);
625 if (wPreferences.auto_arrange_icons) {
626 wArrangeIcons(wwin->screen_ptr, True);
628 } else {
629 wapp->menu = wAppMenuGet(wwin->screen_ptr, wwin->main_window);
631 /* make the appmenu be mapped */
632 wSetFocusTo(wwin->screen_ptr, NULL);
633 wSetFocusTo(wwin->screen_ptr, wwin->screen_ptr->focused_window);
635 } else if (event->atom == _XA_GNUSTEP_WM_ATTR) {
636 GNUstepWMAttributes *attr;
638 PropGetGNUstepWMAttr(wwin->client_win, &attr);
640 wWindowUpdateGNUstepAttr(wwin, attr);
642 XFree(attr);
643 } else {
644 wNETWMCheckClientHintChange(wwin, event);
650 *----------------------------------------------------------------------
651 * wClientGetNormalHints--
652 * Get size (normal) hints and a default geometry for the client
653 * window. The hints are also checked for inconsistency. If geometry is
654 * True, the returned data will account for client specified initial
655 * geometry.
657 * Side effects:
658 * normal_hints is filled with valid data.
659 *----------------------------------------------------------------------
661 void
662 wClientGetNormalHints(WWindow * wwin, XWindowAttributes * wattribs, Bool geometry,
663 int *x, int *y, unsigned *width, unsigned *height)
665 int pre_icccm = 0; /* not used */
667 /* find a position for the window */
668 if (!wwin->normal_hints)
669 wwin->normal_hints = XAllocSizeHints();
671 if (!PropGetNormalHints(wwin->client_win, wwin->normal_hints, &pre_icccm)) {
672 wwin->normal_hints->flags = 0;
674 *x = wattribs->x;
675 *y = wattribs->y;
677 *width = wattribs->width;
678 *height = wattribs->height;
680 if (!(wwin->normal_hints->flags & PWinGravity)) {
681 wwin->normal_hints->win_gravity = NorthWestGravity;
683 if (!(wwin->normal_hints->flags & PMinSize)) {
684 wwin->normal_hints->min_width = MIN_WINDOW_SIZE;
685 wwin->normal_hints->min_height = MIN_WINDOW_SIZE;
687 if (!(wwin->normal_hints->flags & PBaseSize)) {
688 wwin->normal_hints->base_width = 0;
689 wwin->normal_hints->base_height = 0;
691 if (!(wwin->normal_hints->flags & PMaxSize)) {
692 wwin->normal_hints->max_width = wwin->screen_ptr->scr_width * 2;
693 wwin->normal_hints->max_height = wwin->screen_ptr->scr_height * 2;
696 /* some buggy apps set weird hints.. */
697 if (wwin->normal_hints->min_width <= 0)
698 wwin->normal_hints->min_width = MIN_WINDOW_SIZE;
700 if (wwin->normal_hints->min_height <= 0)
701 wwin->normal_hints->min_height = MIN_WINDOW_SIZE;
703 if (wwin->normal_hints->max_width < wwin->normal_hints->min_width)
704 wwin->normal_hints->max_width = wwin->normal_hints->min_width;
706 if (wwin->normal_hints->max_height < wwin->normal_hints->min_height)
707 wwin->normal_hints->max_height = wwin->normal_hints->min_height;
709 if (!(wwin->normal_hints->flags & PResizeInc)) {
710 wwin->normal_hints->width_inc = 1;
711 wwin->normal_hints->height_inc = 1;
712 } else {
713 if (wwin->normal_hints->width_inc <= 0)
714 wwin->normal_hints->width_inc = 1;
715 if (wwin->normal_hints->height_inc <= 0)
716 wwin->normal_hints->height_inc = 1;
719 if (wwin->normal_hints->flags & PAspect) {
720 if (wwin->normal_hints->min_aspect.x < 1)
721 wwin->normal_hints->min_aspect.x = 1;
722 if (wwin->normal_hints->min_aspect.y < 1)
723 wwin->normal_hints->min_aspect.y = 1;
725 if (wwin->normal_hints->max_aspect.x < 1)
726 wwin->normal_hints->max_aspect.x = 1;
727 if (wwin->normal_hints->max_aspect.y < 1)
728 wwin->normal_hints->max_aspect.y = 1;
731 if (wwin->normal_hints->min_height > wwin->normal_hints->max_height) {
732 wwin->normal_hints->min_height = wwin->normal_hints->max_height;
734 if (wwin->normal_hints->min_width > wwin->normal_hints->max_width) {
735 wwin->normal_hints->min_width = wwin->normal_hints->max_width;
737 #ifdef IGNORE_PPOSITION
738 wwin->normal_hints->flags &= ~PPosition;
739 #endif
741 if (pre_icccm && !wwin->screen_ptr->flags.startup && geometry) {
742 if (wwin->normal_hints->flags & (USPosition | PPosition)) {
743 *x = wwin->normal_hints->x;
744 *y = wwin->normal_hints->y;
746 if (wwin->normal_hints->flags & (USSize | PSize)) {
747 *width = wwin->normal_hints->width;
748 *height = wwin->normal_hints->height;
753 void GetColormapWindows(WWindow * wwin)
755 #ifndef NO_CRASHES
756 if (wwin->cmap_windows) {
757 XFree(wwin->cmap_windows);
760 wwin->cmap_windows = NULL;
761 wwin->cmap_window_no = 0;
763 if (!XGetWMColormapWindows(dpy, wwin->client_win, &(wwin->cmap_windows), &(wwin->cmap_window_no))
764 || !wwin->cmap_windows) {
765 wwin->cmap_window_no = 0;
766 wwin->cmap_windows = NULL;
768 #endif