Annotation of researchv9/X11/src/X.V11R1/clients/uwm/Iconify.c, revision 1.1.1.1

1.1       root        1: /* $Header: Iconify.c,v 1.1 87/09/11 08:21:28 toddb Exp $ */
                      2: #include <X11/copyright.h>
                      3: 
                      4: /*
                      5:  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
                      6:  *
                      7:  *                         All Rights Reserved
                      8:  *
                      9:  * Permission to use, copy, modify, and distribute this software and its
                     10:  * documentation for any purpose and without fee is hereby granted,
                     11:  * provided that the above copyright notice appear in all copies and that
                     12:  * both that copyright notice and this permission notice appear in
                     13:  * supporting documentation, and that the name of Digital Equipment
                     14:  * Corporation not be used in advertising or publicity pertaining to
                     15:  * distribution of the software without specific, written prior permission.
                     16:  *
                     17:  *
                     18:  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
                     19:  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
                     20:  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
                     21:  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
                     22:  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
                     23:  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                     24:  * SOFTWARE.
                     25:  */
                     26: 
                     27: 
                     28:  
                     29: /*
                     30:  * MODIFICATION HISTORY
                     31:  *
                     32:  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
                     33:  * 001 -- R. Kittell, DEC Storage A/D May 20, 1986
                     34:  *  Add optional warp of mouse to the upper right corner on de-iconify,
                     35:  *  and to the icon center on iconify.
                     36:  * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
                     37:  *  Western Software Lab. Port to X11.
                     38:  */
                     39:  
                     40: #ifndef lint
                     41: static char *sccsid = "%W%     %G%";
                     42: #endif
                     43:  
                     44: #include "uwm.h"
                     45:  
                     46: Bool Iconify(window, mask, button, x, y)
                     47: Window window;                          /* Event window. */
                     48: int mask;                               /* Button/key mask. */
                     49: int button;                             /* Button event detail. */
                     50: int x, y;                               /* Event mouse position. */
                     51: {
                     52:     XWindowAttributes window_info;     /* Event window info. */
                     53:     XWindowAttributes assoc_info;      /* Associated window info. */
                     54:     int mse_x, mse_y;                  /* Mouse X and Y coordinates. */
                     55:     int sub_win_x, sub_win_y;          /* relative Mouse coordinates. */
                     56:     int icon_x, icon_y;                        /* Icon U. L. X and Y coordinates. */
                     57:     int icon_w, icon_h;                        /* Icon width and height. */
                     58:     int icon_bdr;                      /* Icon border width. */
                     59:     int num_vectors;                   /* Number of vectors in zap buffer. */
                     60:     int mmask;                         /* Mouse state */
                     61:     Window root;                       /* Mouse root window. */
                     62:     Window assoc;                      /* Associated window. */
                     63:     Window sub_win;                    /* Mouse position sub-window. */
                     64:     XSegment zap[MAX_ZAP_VECTORS];     /* Zap effect vertex buffer. */
                     65:     Bool iconifying;                   /* Are we iconifying? */
                     66:  
                     67:     /*
                     68:      * Do not try to iconify the root window.
                     69:      */
                     70:     if (window == RootWindow(dpy, scr))
                     71:         return(FALSE);
                     72:  
                     73:     /*
                     74:      * Clear the vector buffer.
                     75:      */
                     76:     if (Zap) bzero(zap, sizeof(zap));
                     77:  
                     78:     /*
                     79:      * Get the mouse cursor position in case we must put a new
                     80:      * icon there.
                     81:      */
                     82:     XQueryPointer(dpy, RootWindow(dpy, scr), &root, &sub_win, 
                     83:        &mse_x, &mse_y, &sub_win_x, &sub_win_y, &mmask);
                     84:  
                     85:     /*
                     86:      * Gather info about the window.
                     87:      */
                     88:     status = XGetWindowAttributes(dpy, window, &window_info);
                     89:     if (status == FAILURE) return(FALSE);
                     90:  
                     91:     /*
                     92:      * If the event window is an icon, de-iconify it and return.
                     93:      */
                     94:     if (IsIcon(window, mse_x, mse_y, TRUE, &assoc)) {
                     95:  
                     96:  
                     97:         /*
                     98:          * Gather info about the assoc window.
                     99:          */
                    100:         status = XGetWindowAttributes(dpy, assoc, &assoc_info);
                    101:         if (status == FAILURE) return(FALSE);
                    102:  
                    103:         /*
                    104:          * Store the zap vector buffer.
                    105:          */
                    106:         if (Zap) {
                    107:                 num_vectors = StoreZap(
                    108:                     zap,
                    109:                     assoc_info.x - 1,
                    110:                     assoc_info.y - 1,
                    111:                     assoc_info.x + assoc_info.width +
                    112:                         (assoc_info.border_width << 1),
                    113:                     assoc_info.y + assoc_info.height +
                    114:                         (assoc_info.border_width << 1),
                    115:                     window_info.x - 1,
                    116:                     window_info.y - 1,
                    117:                     window_info.x + window_info.width +
                    118:                         (window_info.border_width << 1),
                    119:                     window_info.y + window_info.height +
                    120:                         (window_info.border_width << 1));
                    121:         }
                    122:  
                    123:         /*
                    124:          * Map the window and synchronize.
                    125:          */
                    126:         XMapRaised(dpy, assoc);
                    127:        XRemoveFromSaveSet(dpy, assoc);
                    128:  
                    129:             if (Zap) {
                    130:                 /*
                    131:                  * Draw the zap lines.
                    132:                  */
                    133:                 DrawZap();
                    134:             }
                    135:  
                    136:         /*
                    137:          * Unmap the icon window.
                    138:          */
                    139:         XUnmapWindow(dpy, window);
                    140:  
                    141:        /*
                    142:         * Optionally warp the mouse to the upper right corner of the
                    143:          *  window.
                    144:          */
                    145:         if (WarpOnDeIconify) {
                    146:            status = XGetWindowAttributes (dpy, assoc, &assoc_info);
                    147:             if (status == FAILURE) return(FALSE);
                    148:            status = XWarpPointer (dpy, None, assoc, 
                    149:                                 0, 0, 0, 0,
                    150:                                 assoc_info.width >= 7 ?
                    151:                                  assoc_info.width - 7 : assoc_info.width / 2,
                    152:                                  assoc_info.height >= 10 ? 10 :
                    153:                                  assoc_info.height / 2);
                    154:             if (status == FAILURE) return(FALSE);
                    155:        }
                    156:     }
                    157:     else {
                    158:         /*
                    159:          * We have an icon window; all we have to do is
                    160:          * map it.
                    161:          */
                    162:         status = XGetWindowAttributes(dpy, assoc, &assoc_info);
                    163:         if (status == FAILURE) return(FALSE);
                    164:         icon_x = assoc_info.x;
                    165:         icon_y = assoc_info.y;
                    166:         icon_w = assoc_info.width;
                    167:         icon_h = assoc_info.height;
                    168:        icon_bdr = assoc_info.border_width;
                    169:  
                    170:         if (Zap) {
                    171:         /*
                    172:          * Store the zap effect vectors.
                    173:          */
                    174:         num_vectors = StoreZap(
                    175:             zap,
                    176:             window_info.x - 1,
                    177:             window_info.y - 1,
                    178:             window_info.x + window_info.width + (window_info.border_width << 1),
                    179:             window_info.y + window_info.height + (window_info.border_width << 1),
                    180:             icon_x - 1,
                    181:             icon_y - 1,
                    182:             icon_x + icon_w + (icon_bdr << 1),
                    183:             icon_y + icon_h + (icon_bdr << 1)
                    184:         );
                    185:         }
                    186:  
                    187:         /*
                    188:          * Map the icon window.
                    189:          */
                    190:         XMapWindow(dpy, assoc);
                    191:  
                    192:         if (Zap) {
                    193:         /*
                    194:          * Draw zap lines from the window to its icon.
                    195:          */
                    196:             DrawZap();
                    197:             DrawZap();
                    198:         }
                    199:  
                    200:         /*
                    201:          * Unmap the event window.
                    202:          */
                    203:        XAddToSaveSet(dpy, window);
                    204:         XUnmapWindow(dpy, window);
                    205:  
                    206:        /*
                    207:         * Optionally warp the mouse to the icon center.
                    208:          */
                    209:         if (WarpOnIconify) {
                    210:             status = XGetWindowAttributes(dpy, assoc, &assoc_info);
                    211:             if (status == FAILURE) return(FALSE);
                    212:            status = XWarpPointer (dpy, None, assoc, 
                    213:                                 0, 0, 0, 0,
                    214:                                 assoc_info.width / 2, assoc_info.height / 2);
                    215:             if (status == FAILURE) return(FALSE);
                    216:        }
                    217:  
                    218:     }
                    219:     return(FALSE);
                    220: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.