~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/twm/icons.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * 
 
3
Copyright 1989, 1998  The Open Group
 
4
 
 
5
Permission to use, copy, modify, distribute, and sell this software and its
 
6
documentation for any purpose is hereby granted without fee, provided that
 
7
the above copyright notice appear in all copies and that both that
 
8
copyright notice and this permission notice appear in supporting
 
9
documentation.
 
10
 
 
11
The above copyright notice and this permission notice shall be included in
 
12
all copies or substantial portions of the Software.
 
13
 
 
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
17
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
20
 
 
21
Except as contained in this notice, the name of The Open Group shall not be
 
22
used in advertising or otherwise to promote the sale, use or other dealings
 
23
in this Software without prior written authorization from The Open Group.
 
24
 * */
 
25
/* $XFree86: xc/programs/twm/icons.c,v 1.7 2002/12/10 22:29:54 tsi Exp $ */
 
26
 
 
27
/**********************************************************************
 
28
 *
 
29
 * $Xorg: icons.c,v 1.4 2001/02/09 02:05:36 xorgcvs Exp $
 
30
 *
 
31
 * Icon releated routines
 
32
 *
 
33
 * 10-Apr-89 Tom LaStrange        Initial Version.
 
34
 *
 
35
 **********************************************************************/
 
36
 
 
37
#include <stdio.h>
 
38
#include "twm.h"
 
39
#include "screen.h"
 
40
#include "icons.h"
 
41
#include "gram.h"
 
42
#include "parse.h"
 
43
#include "util.h"
 
44
 
 
45
#define iconWidth(w)    (Scr->IconBorderWidth * 2 + w->icon_w_width)
 
46
#define iconHeight(w)   (Scr->IconBorderWidth * 2 + w->icon_w_height)
 
47
 
 
48
static void splitEntry ( IconEntry *ie, int grav1, int grav2, int w, int h );
 
49
static IconEntry * FindIconEntry ( TwmWindow *tmp_win, IconRegion **irp );
 
50
static IconEntry * prevIconEntry ( IconEntry *ie, IconRegion *ir );
 
51
static void mergeEntries ( IconEntry *old, IconEntry *ie );
 
52
 
 
53
static void
 
54
splitEntry (ie, grav1, grav2, w, h)
 
55
    IconEntry   *ie;
 
56
    int         grav1, grav2;
 
57
    int         w, h;
 
58
{
 
59
    IconEntry   *new;
 
60
 
 
61
    switch (grav1) {
 
62
    case D_NORTH:
 
63
    case D_SOUTH:
 
64
        if (w != ie->w)
 
65
            splitEntry (ie, grav2, grav1, w, ie->h);
 
66
        if (h != ie->h) {
 
67
            new = (IconEntry *)malloc (sizeof (IconEntry));
 
68
            new->twm_win = 0;
 
69
            new->used = 0;
 
70
            new->next = ie->next;
 
71
            ie->next = new;
 
72
            new->x = ie->x;
 
73
            new->h = (ie->h - h);
 
74
            new->w = ie->w;
 
75
            ie->h = h;
 
76
            if (grav1 == D_SOUTH) {
 
77
                new->y = ie->y;
 
78
                ie->y = new->y + new->h;
 
79
            } else
 
80
                new->y = ie->y + ie->h;
 
81
        }
 
82
        break;
 
83
    case D_EAST:
 
84
    case D_WEST:
 
85
        if (h != ie->h)
 
86
            splitEntry (ie, grav2, grav1, ie->w, h);
 
87
        if (w != ie->w) {
 
88
            new = (IconEntry *)malloc (sizeof (IconEntry));
 
89
            new->twm_win = 0;
 
90
            new->used = 0;
 
91
            new->next = ie->next;
 
92
            ie->next = new;
 
93
            new->y = ie->y;
 
94
            new->w = (ie->w - w);
 
95
            new->h = ie->h;
 
96
            ie->w = w;
 
97
            if (grav1 == D_EAST) {
 
98
                new->x = ie->x;
 
99
                ie->x = new->x + new->w;
 
100
            } else
 
101
                new->x = ie->x + ie->w;
 
102
        }
 
103
        break;
 
104
    }
 
105
}
 
106
 
 
107
int
 
108
roundUp (int v, int multiple)
 
109
{
 
110
    return ((v + multiple - 1) / multiple) * multiple;
 
111
}
 
112
 
 
113
void
 
114
PlaceIcon(tmp_win, def_x, def_y, final_x, final_y)
 
115
    TwmWindow *tmp_win;
 
116
    int def_x, def_y;
 
117
    int *final_x, *final_y;
 
118
{
 
119
    IconRegion  *ir;
 
120
    IconEntry   *ie;
 
121
    int         w = 0, h = 0;
 
122
 
 
123
    ie = 0;
 
124
    for (ir = Scr->FirstRegion; ir; ir = ir->next) {
 
125
        w = roundUp (iconWidth (tmp_win), ir->stepx);
 
126
        h = roundUp (iconHeight (tmp_win), ir->stepy);
 
127
        for (ie = ir->entries; ie; ie=ie->next) {
 
128
            if (ie->used)
 
129
                continue;
 
130
            if (ie->w >= w && ie->h >= h)
 
131
                break;
 
132
        }
 
133
        if (ie)
 
134
            break;
 
135
    }
 
136
    if (ie) {
 
137
        splitEntry (ie, ir->grav1, ir->grav2, w, h);
 
138
        ie->used = 1;
 
139
        ie->twm_win = tmp_win;
 
140
        *final_x = ie->x + (ie->w - iconWidth (tmp_win)) / 2;
 
141
        *final_y = ie->y + (ie->h - iconHeight (tmp_win)) / 2;
 
142
    } else {
 
143
        *final_x = def_x;
 
144
        *final_y = def_y;
 
145
    }
 
146
    return;
 
147
}
 
148
 
 
149
static IconEntry *
 
150
FindIconEntry (tmp_win, irp)
 
151
    TwmWindow   *tmp_win;
 
152
    IconRegion  **irp;
 
153
{
 
154
    IconRegion  *ir;
 
155
    IconEntry   *ie;
 
156
 
 
157
    for (ir = Scr->FirstRegion; ir; ir = ir->next) {
 
158
        for (ie = ir->entries; ie; ie=ie->next)
 
159
            if (ie->twm_win == tmp_win) {
 
160
                if (irp)
 
161
                    *irp = ir;
 
162
                return ie;
 
163
            }
 
164
    }
 
165
    return 0;
 
166
}
 
167
 
 
168
void
 
169
IconUp (tmp_win)
 
170
    TwmWindow   *tmp_win;
 
171
{
 
172
    int         x, y;
 
173
    int         defx, defy;
 
174
    struct IconRegion *ir;
 
175
 
 
176
    /*
 
177
     * If the client specified a particular location, let's use it (this might
 
178
     * want to be an option at some point).  Otherwise, try to fit within the
 
179
     * icon region.
 
180
     */
 
181
    if (tmp_win->wmhints && (tmp_win->wmhints->flags & IconPositionHint))
 
182
      return;
 
183
 
 
184
    if (tmp_win->icon_moved) {
 
185
        if (!XGetGeometry (dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy,
 
186
                           &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth))
 
187
          return;
 
188
 
 
189
        x = defx + ((int) JunkWidth) / 2;
 
190
        y = defy + ((int) JunkHeight) / 2;
 
191
 
 
192
        for (ir = Scr->FirstRegion; ir; ir = ir->next) {
 
193
            if (x >= ir->x && x < (ir->x + ir->w) &&
 
194
                y >= ir->y && y < (ir->y + ir->h))
 
195
              break;
 
196
        }
 
197
        if (!ir) return;                /* outside icon regions, leave alone */
 
198
    }
 
199
 
 
200
    defx = -100;
 
201
    defy = -100;
 
202
    PlaceIcon(tmp_win, defx, defy, &x, &y);
 
203
    if (x != defx || y != defy) {
 
204
        XMoveWindow (dpy, tmp_win->icon_w, x, y);
 
205
        tmp_win->icon_moved = FALSE;    /* since we've restored it */
 
206
    }
 
207
}
 
208
 
 
209
static IconEntry *
 
210
prevIconEntry (ie, ir)
 
211
    IconEntry   *ie;
 
212
    IconRegion  *ir;
 
213
{
 
214
    IconEntry   *ip;
 
215
 
 
216
    if (ie == ir->entries)
 
217
        return 0;
 
218
    for (ip = ir->entries; ip->next != ie; ip=ip->next)
 
219
        ;
 
220
    return ip;
 
221
}
 
222
 
 
223
/* old is being freed; and is adjacent to ie.  Merge
 
224
 * regions together
 
225
 */
 
226
 
 
227
static void
 
228
mergeEntries (old, ie)
 
229
    IconEntry   *old, *ie;
 
230
{
 
231
    if (old->y == ie->y) {
 
232
        ie->w = old->w + ie->w;
 
233
        if (old->x < ie->x)
 
234
            ie->x = old->x;
 
235
    } else {
 
236
        ie->h = old->h + ie->h;
 
237
        if (old->y < ie->y)
 
238
            ie->y = old->y;
 
239
    }
 
240
}
 
241
 
 
242
void
 
243
IconDown (tmp_win)
 
244
    TwmWindow   *tmp_win;
 
245
{
 
246
    IconEntry   *ie, *ip, *in;
 
247
    IconRegion  *ir;
 
248
 
 
249
    ie = FindIconEntry (tmp_win, &ir);
 
250
    if (ie) {
 
251
        ie->twm_win = 0;
 
252
        ie->used = 0;
 
253
        ip = prevIconEntry (ie, ir);
 
254
        in = ie->next;
 
255
        for (;;) {
 
256
            if (ip && ip->used == 0 &&
 
257
               ((ip->x == ie->x && ip->w == ie->w) ||
 
258
                (ip->y == ie->y && ip->h == ie->h)))
 
259
            {
 
260
                ip->next = ie->next;
 
261
                mergeEntries (ie, ip);
 
262
                free ((char *) ie);
 
263
                ie = ip;
 
264
                ip = prevIconEntry (ip, ir);
 
265
            } else if (in && in->used == 0 &&
 
266
               ((in->x == ie->x && in->w == ie->w) ||
 
267
                (in->y == ie->y && in->h == ie->h)))
 
268
            {
 
269
                ie->next = in->next;
 
270
                mergeEntries (in, ie);
 
271
                free ((char *) in);
 
272
                in = ie->next;
 
273
            } else
 
274
                break;
 
275
        }
 
276
    }
 
277
}
 
278
 
 
279
void
 
280
AddIconRegion(geom, grav1, grav2, stepx, stepy)
 
281
char *geom;
 
282
int grav1, grav2;
 
283
int stepx, stepy;
 
284
{
 
285
    IconRegion *ir;
 
286
    int mask;
 
287
 
 
288
    ir = (IconRegion *)malloc(sizeof(IconRegion));
 
289
    ir->next = NULL;
 
290
    if (Scr->LastRegion)
 
291
        Scr->LastRegion->next = ir;
 
292
    Scr->LastRegion = ir;
 
293
    if (!Scr->FirstRegion)
 
294
        Scr->FirstRegion = ir;
 
295
 
 
296
    ir->entries = NULL;
 
297
    ir->grav1 = grav1;
 
298
    ir->grav2 = grav2;
 
299
    if (stepx <= 0)
 
300
        stepx = 1;
 
301
    if (stepy <= 0)
 
302
        stepy = 1;
 
303
    ir->stepx = stepx;
 
304
    ir->stepy = stepy;
 
305
    ir->x = ir->y = ir->w = ir->h = 0;
 
306
 
 
307
    mask = XParseGeometry(geom, &ir->x, &ir->y, (unsigned int *)&ir->w, (unsigned int *)&ir->h);
 
308
 
 
309
    if (mask & XNegative)
 
310
        ir->x += Scr->MyDisplayWidth - ir->w;
 
311
 
 
312
    if (mask & YNegative)
 
313
        ir->y += Scr->MyDisplayHeight - ir->h;
 
314
    ir->entries = (IconEntry *)malloc(sizeof(IconEntry));
 
315
    ir->entries->next = 0;
 
316
    ir->entries->x = ir->x;
 
317
    ir->entries->y = ir->y;
 
318
    ir->entries->w = ir->w;
 
319
    ir->entries->h = ir->h;
 
320
    ir->entries->twm_win = 0;
 
321
    ir->entries->used = 0;
 
322
}
 
323
 
 
324
#ifdef comment
 
325
void
 
326
FreeIconEntries (ir)
 
327
    IconRegion  *ir;
 
328
{
 
329
    IconEntry   *ie, *tmp;
 
330
 
 
331
    for (ie = ir->entries; ie; ie=tmp)
 
332
    {
 
333
        tmp = ie->next;
 
334
        free ((char *) ie);
 
335
    }
 
336
}
 
337
 
 
338
void
 
339
FreeIconRegions()
 
340
{
 
341
    IconRegion *ir, *tmp;
 
342
 
 
343
    for (ir = Scr->FirstRegion; ir != NULL;)
 
344
    {
 
345
        tmp = ir;
 
346
        FreeIconEntries (ir);
 
347
        ir = ir->next;
 
348
        free((char *) tmp);
 
349
    }
 
350
    Scr->FirstRegion = NULL;
 
351
    Scr->LastRegion = NULL;
 
352
}
 
353
#endif
 
354
 
 
355
void
 
356
CreateIconWindow(tmp_win, def_x, def_y)
 
357
    TwmWindow *tmp_win;
 
358
    int def_x, def_y;
 
359
{
 
360
    unsigned long event_mask;
 
361
    unsigned long valuemask;            /* mask for create windows */
 
362
    XSetWindowAttributes attributes;    /* attributes for create windows */
 
363
    Pixmap pm = None;                   /* tmp pixmap variable */
 
364
    int final_x, final_y;
 
365
    int x;
 
366
 
 
367
 
 
368
    FB(tmp_win->iconc.fore, tmp_win->iconc.back);
 
369
 
 
370
    tmp_win->forced = FALSE;
 
371
    tmp_win->icon_not_ours = FALSE;
 
372
 
 
373
    /* now go through the steps to get an icon window,  if ForceIcon is 
 
374
     * set, then no matter what else is defined, the bitmap from the
 
375
     * .twmrc file is used
 
376
     */
 
377
    if (Scr->ForceIcon)
 
378
    {
 
379
        char *icon_name;
 
380
        Pixmap bm;
 
381
 
 
382
        icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
 
383
        if (icon_name == NULL)
 
384
            icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
 
385
                                   &tmp_win->class);
 
386
 
 
387
        bm = None;
 
388
        if (icon_name != NULL)
 
389
        {
 
390
            if ((bm = (Pixmap)LookInNameList(Scr->Icons, icon_name)) == None)
 
391
            {
 
392
                if ((bm = GetBitmap (icon_name)) != None)
 
393
                    AddToList(&Scr->Icons, icon_name, (char *)bm);
 
394
            }
 
395
        }
 
396
 
 
397
        if (bm != None)
 
398
        {
 
399
            XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
 
400
                (unsigned int *) &tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height,
 
401
                &JunkBW, &JunkDepth);
 
402
 
 
403
            pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
 
404
                tmp_win->icon_height, Scr->d_depth);
 
405
 
 
406
            /* the copy plane works on color ! */
 
407
            XCopyPlane(dpy, bm, pm, Scr->NormalGC,
 
408
                0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
 
409
 
 
410
            tmp_win->forced = TRUE;
 
411
        }
 
412
    }
 
413
 
 
414
    /* if the pixmap is still NULL, we didn't get one from the above code,
 
415
     * that could mean that ForceIcon was not set, or that the window
 
416
     * was not in the Icons list, now check the WM hints for an icon
 
417
     */
 
418
    if (pm == None && tmp_win->wmhints &&
 
419
        tmp_win->wmhints->flags & IconPixmapHint)
 
420
    {
 
421
    
 
422
        XGetGeometry(dpy,   tmp_win->wmhints->icon_pixmap,
 
423
             &JunkRoot, &JunkX, &JunkY,
 
424
             (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height, &JunkBW, &JunkDepth);
 
425
 
 
426
        pm = XCreatePixmap(dpy, Scr->Root,
 
427
                           tmp_win->icon_width, tmp_win->icon_height,
 
428
                           Scr->d_depth);
 
429
 
 
430
        XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, pm, Scr->NormalGC,
 
431
            0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
 
432
    }
 
433
 
 
434
    /* if we still haven't got an icon, let's look in the Icon list 
 
435
     * if ForceIcon is not set
 
436
     */
 
437
    if (pm == None && !Scr->ForceIcon)
 
438
    {
 
439
        char *icon_name;
 
440
        Pixmap bm;
 
441
 
 
442
        icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
 
443
        if (icon_name == NULL)
 
444
            icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
 
445
                                   &tmp_win->class);
 
446
 
 
447
        bm = None;
 
448
        if (icon_name != NULL)
 
449
        {
 
450
            if ((bm = (Pixmap)LookInNameList(Scr->Icons, icon_name)) == None)
 
451
            {
 
452
                if ((bm = GetBitmap (icon_name)) != None)
 
453
                    AddToList(&Scr->Icons, icon_name, (char *)bm);
 
454
            }
 
455
        }
 
456
 
 
457
        if (bm != None)
 
458
        {
 
459
            XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
 
460
                (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height,
 
461
                &JunkBW, &JunkDepth);
 
462
 
 
463
            pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
 
464
                tmp_win->icon_height, Scr->d_depth);
 
465
 
 
466
            /* the copy plane works on color ! */
 
467
            XCopyPlane(dpy, bm, pm, Scr->NormalGC,
 
468
                0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
 
469
        }
 
470
    }
 
471
 
 
472
    /* if we still don't have an icon, assign the UnknownIcon */
 
473
 
 
474
    if (pm == None && Scr->UnknownPm != None)
 
475
    {
 
476
        tmp_win->icon_width = Scr->UnknownWidth;
 
477
        tmp_win->icon_height = Scr->UnknownHeight;
 
478
 
 
479
        pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
 
480
            tmp_win->icon_height, Scr->d_depth);
 
481
 
 
482
        /* the copy plane works on color ! */
 
483
        XCopyPlane(dpy, Scr->UnknownPm, pm, Scr->NormalGC,
 
484
            0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
 
485
    }
 
486
 
 
487
    if (pm == None)
 
488
    {
 
489
        tmp_win->icon_height = 0;
 
490
        tmp_win->icon_width = 0;
 
491
        valuemask = 0;
 
492
    }
 
493
    else
 
494
    {
 
495
        valuemask = CWBackPixmap;
 
496
        attributes.background_pixmap = pm;
 
497
    }
 
498
 
 
499
    tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
 
500
        tmp_win->icon_name, strlen(tmp_win->icon_name));
 
501
 
 
502
    tmp_win->icon_w_width += 6;
 
503
    if (tmp_win->icon_w_width < tmp_win->icon_width)
 
504
    {
 
505
        tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2;
 
506
        tmp_win->icon_x += 3;
 
507
        tmp_win->icon_w_width = tmp_win->icon_width;
 
508
    }
 
509
    else
 
510
    {
 
511
        tmp_win->icon_x = 3;
 
512
    }
 
513
    tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height;
 
514
    tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4;
 
515
 
 
516
    event_mask = 0;
 
517
    if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)
 
518
    {
 
519
        tmp_win->icon_w = tmp_win->wmhints->icon_window;
 
520
        if (tmp_win->forced ||
 
521
            XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY,
 
522
                     (unsigned int *)&tmp_win->icon_w_width, (unsigned int *)&tmp_win->icon_w_height,
 
523
                     &JunkBW, &JunkDepth) == 0)
 
524
        {
 
525
            tmp_win->icon_w = None;
 
526
            tmp_win->wmhints->flags &= ~IconWindowHint;
 
527
        }
 
528
        else
 
529
        {
 
530
            tmp_win->icon_not_ours = TRUE;
 
531
            event_mask = EnterWindowMask | LeaveWindowMask;
 
532
        }
 
533
    }
 
534
    else
 
535
    {
 
536
        tmp_win->icon_w = None;
 
537
    }
 
538
 
 
539
    if (tmp_win->icon_w == None)
 
540
    {
 
541
        tmp_win->icon_w = XCreateSimpleWindow(dpy, Scr->Root,
 
542
            0,0,
 
543
            tmp_win->icon_w_width, tmp_win->icon_w_height,
 
544
            Scr->IconBorderWidth, tmp_win->icon_border, tmp_win->iconc.back);
 
545
        event_mask = ExposureMask;
 
546
    }
 
547
 
 
548
    XSelectInput (dpy, tmp_win->icon_w,
 
549
                  KeyPressMask | ButtonPressMask | ButtonReleaseMask |
 
550
                  event_mask);
 
551
 
 
552
    tmp_win->icon_bm_w = None;
 
553
    if (pm != None &&
 
554
        (! (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)))
 
555
    {
 
556
        int y;
 
557
 
 
558
        y = 0;
 
559
        if (tmp_win->icon_w_width == tmp_win->icon_width)
 
560
            x = 0;
 
561
        else
 
562
            x = (tmp_win->icon_w_width - tmp_win->icon_width)/2;
 
563
 
 
564
        tmp_win->icon_bm_w = XCreateWindow (dpy, tmp_win->icon_w, x, y,
 
565
                                            (unsigned int)tmp_win->icon_width,
 
566
                                            (unsigned int)tmp_win->icon_height,
 
567
                                            (unsigned int) 0, Scr->d_depth,
 
568
                                            (unsigned int) CopyFromParent,
 
569
                                            Scr->d_visual, valuemask,
 
570
                                            &attributes);
 
571
    }
 
572
 
 
573
    /* I need to figure out where to put the icon window now, because 
 
574
     * getting here means that I am going to make the icon visible
 
575
     */
 
576
    if (tmp_win->wmhints &&
 
577
        tmp_win->wmhints->flags & IconPositionHint)
 
578
    {
 
579
        final_x = tmp_win->wmhints->icon_x;
 
580
        final_y = tmp_win->wmhints->icon_y;
 
581
    }
 
582
    else
 
583
    {
 
584
        PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y);
 
585
    }
 
586
 
 
587
    if (final_x > Scr->MyDisplayWidth)
 
588
        final_x = Scr->MyDisplayWidth - tmp_win->icon_w_width -
 
589
            (2 * Scr->IconBorderWidth);
 
590
 
 
591
    if (final_y > Scr->MyDisplayHeight)
 
592
        final_y = Scr->MyDisplayHeight - tmp_win->icon_height -
 
593
            Scr->IconFont.height - 4 - (2 * Scr->IconBorderWidth);
 
594
 
 
595
    XMoveWindow(dpy, tmp_win->icon_w, final_x, final_y);
 
596
    tmp_win->iconified = TRUE;
 
597
 
 
598
    XMapSubwindows(dpy, tmp_win->icon_w);
 
599
    XSaveContext(dpy, tmp_win->icon_w, TwmContext, (caddr_t)tmp_win);
 
600
    XSaveContext(dpy, tmp_win->icon_w, ScreenContext, (caddr_t)Scr);
 
601
    XDefineCursor(dpy, tmp_win->icon_w, Scr->IconCursor);
 
602
    if (pm) XFreePixmap (dpy, pm);
 
603
    return;
 
604
}