|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid_Iconify_c = "$Header: Iconify.c,v 10.4 86/02/01 16:22:58 tony Rel $"; ! 3: #endif lint ! 4: ! 5: /************************************************************************ ! 6: * * ! 7: * Copyright (c) 1986 by * ! 8: * Digital Equipment Corporation, Maynard, MA * ! 9: * All Rights Reserved. * ! 10: * * ! 11: * Permission to use, copy, modify, and distribute this software * ! 12: * and its documentation is hereby granted only to licensees of * ! 13: * The Regents of the University of California pursuant to their * ! 14: * license agreement for the Berkeley Software Distribution * ! 15: * provided that the following appears on all copies. * ! 16: * * ! 17: * "LICENSED FROM DIGITAL EQUIPMENT CORPORATION * ! 18: * COPYRIGHT (C) 1986 * ! 19: * DIGITAL EQUIPMENT CORPORATION * ! 20: * MAYNARD, MA * ! 21: * ALL RIGHTS RESERVED. * ! 22: * * ! 23: * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT * ! 24: * NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL * ! 25: * EQUIPMENT CORPORATION. DIGITAL MAKES NO REPRESENTATIONS * ! 26: * ABOUT SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. IT IS * ! 27: * SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. * ! 28: * * ! 29: * IF THE UNIVERSITY OF CALIFORNIA OR ITS LICENSEES MODIFY * ! 30: * THE SOFTWARE IN A MANNER CREATING DERIVATIVE COPYRIGHT * ! 31: * RIGHTS APPROPRIATE COPYRIGHT LEGENDS MAY BE PLACED ON THE * ! 32: * DERIVATIVE WORK IN ADDITION TO THAT SET FORTH ABOVE." * ! 33: * * ! 34: ************************************************************************/ ! 35: ! 36: ! 37: /* ! 38: * MODIFICATION HISTORY ! 39: * ! 40: * 000 -- M. Gancarz, DEC Ultrix Engineering Group ! 41: */ ! 42: ! 43: #ifndef lint ! 44: static char *sccsid = "@(#)Iconify.c 3.9 1/29/86"; ! 45: #endif ! 46: ! 47: #include "uwm.h" ! 48: ! 49: Bool Iconify(window, mask, button, x, y) ! 50: Window window; /* Event window. */ ! 51: int mask; /* Button/key mask. */ ! 52: short button; /* Button event detail. */ ! 53: int x, y; /* Event mouse position. */ ! 54: { ! 55: register WindowInfo window_info; /* Event window info. */ ! 56: register WindowInfo assoc_info; /* Associated window info. */ ! 57: char *name; /* Event window name. */ ! 58: int mse_x, mse_y; /* Mouse X and Y coordinates. */ ! 59: int icon_x, icon_y; /* Icon U. L. X and Y coordinates. */ ! 60: int icon_w, icon_h; /* Icon width and height. */ ! 61: int icon_bdr; /* Icon border width. */ ! 62: int num_vectors; /* Number of vectors in zap buffer. */ ! 63: Window assoc; /* Associated window. */ ! 64: Window sub_win; /* Mouse position sub-window. */ ! 65: XButtonEvent button_event; /* Button event packet. */ ! 66: Vertex zap[MAX_ZAP_VECTORS]; /* Zap effect vertex buffer. */ ! 67: Bool iconifying; /* Are we iconifying? */ ! 68: ! 69: /* ! 70: * Do not try to iconify the root window. ! 71: */ ! 72: if (window == RootWindow) ! 73: return(FALSE); ! 74: ! 75: /* ! 76: * Clear the vector buffer. ! 77: */ ! 78: if (Zap) bzero(zap, sizeof(zap)); ! 79: ! 80: /* ! 81: * Get the mouse cursor position in case we must put a new ! 82: * icon there. ! 83: */ ! 84: XQueryMouse(RootWindow, &mse_x, &mse_y, &sub_win); ! 85: ! 86: /* ! 87: * Get info on the event window. ! 88: */ ! 89: status = XQueryWindow(window, &window_info); ! 90: if (status == FAILURE) return(FALSE); ! 91: ! 92: /* ! 93: * If the event window is an icon, de-iconify it and return. ! 94: */ ! 95: if (window_info.type == IsIcon) { ! 96: ! 97: assoc = window_info.assoc_wind; ! 98: ! 99: /* ! 100: * Gather info about the assoc window. ! 101: */ ! 102: status = XQueryWindow(assoc, &assoc_info); ! 103: if (status == FAILURE) return(FALSE); ! 104: ! 105: /* ! 106: * Store the zap vector buffer. ! 107: */ ! 108: if (Zap) { ! 109: num_vectors = StoreZap( ! 110: zap, ! 111: assoc_info.x - 1, ! 112: assoc_info.y - 1, ! 113: assoc_info.x + assoc_info.width + ! 114: (assoc_info.bdrwidth << 1), ! 115: assoc_info.y + assoc_info.height + ! 116: (assoc_info.bdrwidth << 1), ! 117: window_info.x - 1, ! 118: window_info.y - 1, ! 119: window_info.x + window_info.width + ! 120: (window_info.bdrwidth << 1), ! 121: window_info.y + window_info.height + ! 122: (window_info.bdrwidth << 1)); ! 123: } ! 124: ! 125: /* ! 126: * Map the window and synchronize. ! 127: */ ! 128: XMapWindow(assoc); ! 129: ! 130: if (Zap) { ! 131: /* ! 132: * Draw the zap lines. ! 133: */ ! 134: DrawZap(); ! 135: } ! 136: ! 137: /* ! 138: * Unmap the icon window. ! 139: */ ! 140: XUnmapWindow(window); ! 141: ! 142: return(FALSE); ! 143: } ! 144: else { ! 145: /* ! 146: * If event window doesn't already have an icon window, ! 147: * make one for it. ! 148: */ ! 149: if (window_info.assoc_wind == 0) { ! 150: ! 151: /* ! 152: * Set the icon border width. ! 153: */ ! 154: icon_bdr = IBorderWidth; ! 155: ! 156: /* ! 157: * Determine the size of the icon window. ! 158: */ ! 159: status = XFetchName(window, &name); ! 160: if (status == FAILURE) return(FALSE); ! 161: icon_h = IFontInfo.height + (VIconPad << 1); ! 162: icon_w = XQueryWidth(name, IFont); ! 163: if (icon_w == 0) ! 164: icon_w = icon_h; ! 165: else icon_w += (HIconPad << 1); ! 166: ! 167: /* ! 168: * Determine the coordinates of the icon window; ! 169: * normalize so that we don't lose the icon off the ! 170: * edge of the screen. ! 171: */ ! 172: icon_x = mse_x - (icon_w >> 1) + 1; ! 173: if (icon_x < 0) icon_x = 0; ! 174: icon_y = mse_y - (icon_h >> 1) + 1; ! 175: if (icon_y < 0) icon_y = 0; ! 176: if ((icon_x - 1 + icon_w + (icon_bdr << 1)) > ScreenWidth) { ! 177: icon_x = ScreenWidth - icon_w - (icon_bdr << 1) + 1; ! 178: } ! 179: if ((icon_y - 1 + icon_h + (icon_bdr << 1)) > ScreenHeight) { ! 180: icon_y = ScreenHeight - icon_h - (icon_bdr << 1) + 1; ! 181: } ! 182: ! 183: ! 184: /* ! 185: * Create the icon window. ! 186: */ ! 187: assoc = XCreateWindow( ! 188: RootWindow, ! 189: icon_x, icon_y, ! 190: icon_w, icon_h, ! 191: icon_bdr, ! 192: IBorder, IBackground ! 193: ); ! 194: if (assoc == FAILURE) return(FALSE); ! 195: ! 196: /* ! 197: * Use the text cursor whenever the mouse is in the icon window. ! 198: */ ! 199: XDefineCursor(assoc, TextCursor); ! 200: ! 201: /* ! 202: * Select "key pressed", "window exposure" and "unmap window" ! 203: * events for the icon window. ! 204: */ ! 205: XSelectInput(assoc, (KeyPressed | ExposeWindow | UnmapWindow)); ! 206: ! 207: /* ! 208: * Set the event window's icon window to be the new icon window. ! 209: */ ! 210: XSetIconWindow(window, assoc); ! 211: } ! 212: else { ! 213: /* ! 214: * If we already have an icon window all we have to do is ! 215: * map it. ! 216: */ ! 217: assoc = window_info.assoc_wind; ! 218: status = XQueryWindow(assoc, &assoc_info); ! 219: if (status == FAILURE) return(FALSE); ! 220: icon_x = assoc_info.x; ! 221: icon_y = assoc_info.y; ! 222: icon_w = assoc_info.width; ! 223: icon_h = assoc_info.height; ! 224: } ! 225: ! 226: if (Zap) { ! 227: /* ! 228: * Store the zap effect vectors. ! 229: */ ! 230: num_vectors = StoreZap( ! 231: zap, ! 232: window_info.x - 1, ! 233: window_info.y - 1, ! 234: window_info.x + window_info.width + (window_info.bdrwidth << 1), ! 235: window_info.y + window_info.height + (window_info.bdrwidth << 1), ! 236: icon_x - 1, ! 237: icon_y - 1, ! 238: icon_x + icon_w + (icon_bdr << 1), ! 239: icon_y + icon_h + (icon_bdr << 1) ! 240: ); ! 241: } ! 242: ! 243: /* ! 244: * Map the icon window. ! 245: */ ! 246: XMapWindow(assoc); ! 247: ! 248: if (Zap) { ! 249: /* ! 250: * Draw zap lines from the window to its icon. ! 251: */ ! 252: DrawZap(); ! 253: DrawZap(); ! 254: } ! 255: ! 256: /* ! 257: * Unmap the event window. ! 258: */ ! 259: XUnmapWindow(window); ! 260: } ! 261: return(FALSE); ! 262: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.