|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid_Move_c = "$Header: Move.c,v 10.4 86/11/19 16:24:03 jg Rel $"; ! 3: #endif lint ! 4: ! 5: /* ! 6: * COPYRIGHT 1985, 1986 ! 7: * DIGITAL EQUIPMENT CORPORATION ! 8: * MAYNARD, MASSACHUSETTS ! 9: * ALL RIGHTS RESERVED. ! 10: * ! 11: * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND ! 12: * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION. ! 13: * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITIBILITY OF THIS SOFTWARE FOR ! 14: * ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ! 15: * ! 16: * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS, ! 17: * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT ! 18: * SET FORTH ABOVE. ! 19: * ! 20: * ! 21: * Permission to use, copy, modify, and distribute this software and its ! 22: * documentation for any purpose and without fee is hereby granted, provided ! 23: * that the above copyright notice appear in all copies and that both that ! 24: * copyright notice and this permission notice appear in supporting documentation, ! 25: * and that the name of Digital Equipment Corporation not be used in advertising ! 26: * or publicity pertaining to distribution of the software without specific, ! 27: * written prior permission. ! 28: * ! 29: */ ! 30: ! 31: ! 32: /* ! 33: * MODIFICATION HISTORY ! 34: * ! 35: * 000 -- M. Gancarz, DEC Ultrix Engineering Group ! 36: */ ! 37: ! 38: #ifndef lint ! 39: static char *sccsid = "@(#)Move.c 3.8 1/24/86"; ! 40: #endif ! 41: ! 42: #include "uwm.h" ! 43: ! 44: Bool Move(window, mask, button, x, y) ! 45: Window window; /* Event window. */ ! 46: int mask; /* Button/key mask. */ ! 47: short button; /* Button event detail. */ ! 48: int x, y; /* Event mouse position. */ ! 49: { ! 50: register int prev_x; /* Previous event window X location. */ ! 51: register int prev_y; /* Previous event window Y location. */ ! 52: register WindowInfo window_info; /* Event window information. */ ! 53: int cur_x; /* Current event window X location. */ ! 54: int cur_y; /* Current event window Y location. */ ! 55: int ulx, uly; /* Event window upper left X and Y. */ ! 56: int lrx, lry; /* Event window lower right X and Y. */ ! 57: int init_ulx, init_uly; /* Init window upper left X and Y. */ ! 58: int init_lrx, init_lry; /* Init window lower right X and Y. */ ! 59: int num_vectors; /* Number of vectors in box. */ ! 60: Window sub_window; /* Query mouse event sub-window. */ ! 61: XButtonEvent button_event; /* Button event packet. */ ! 62: Vertex box[MAX_BOX_VECTORS]; /* Box vertex buffer. */ ! 63: Vertex zap[MAX_ZAP_VECTORS]; /* Zap effect verted buffer. */ ! 64: ! 65: /* ! 66: * Do not try to move the root window. ! 67: */ ! 68: if (window == RootWindow) ! 69: return(FALSE); ! 70: ! 71: /* ! 72: * Change the cursor. ! 73: */ ! 74: status = XGrabButton(RootWindow, ArrowCrossCursor, mask, EVENTMASK); ! 75: if (status == FAILURE) ! 76: Error("Move -> Unable to grab button and change cursor."); ! 77: ! 78: /* ! 79: * Clear the vector buffers. ! 80: */ ! 81: bzero(box, sizeof(box)); ! 82: if (Zap) bzero(zap, sizeof(zap)); ! 83: ! 84: /* ! 85: * Gather info on the event window. ! 86: */ ! 87: status = XQueryWindow(window, &window_info); ! 88: if (status == FAILURE) return(FALSE); ! 89: ! 90: /* ! 91: * Initialize movement variables. ! 92: */ ! 93: init_ulx = ulx = window_info.x; ! 94: init_uly = uly = window_info.y; ! 95: init_lrx = lrx = window_info.x + window_info.width + ! 96: (window_info.bdrwidth << 1) - 1; ! 97: init_lry = lry = window_info.y + window_info.height + ! 98: (window_info.bdrwidth << 1) - 1; ! 99: ! 100: /* ! 101: * Store the box. ! 102: */ ! 103: if (Grid) ! 104: num_vectors = StoreGridBox(box, ulx, uly, lrx, lry); ! 105: else num_vectors = StoreBox(box, ulx, uly, lrx, lry); ! 106: ! 107: /* ! 108: * Initialize the previous location variables. ! 109: */ ! 110: prev_x = x; ! 111: prev_y = y; ! 112: ! 113: /* ! 114: * Freeze the server, if requested by the user. ! 115: * This results in a solid box instead of a flickering one. ! 116: */ ! 117: if (Freeze) XGrabServer(); ! 118: ! 119: /* ! 120: * Process any pending exposure events before drawing the box. ! 121: */ ! 122: while (QLength() > 0) { ! 123: XPeekEvent(&button_event); ! 124: if (button_event.window == RootWindow) ! 125: break; ! 126: GetButton(&button_event); ! 127: } ! 128: ! 129: /* ! 130: * Now draw the box. ! 131: */ ! 132: DrawBox(); ! 133: Frozen = window; ! 134: ! 135: /* ! 136: * Main loop. ! 137: */ ! 138: while (TRUE) { ! 139: ! 140: /* ! 141: * Check to see if we have a change in mouse button status. ! 142: * This is how we get out of this "while" loop. ! 143: */ ! 144: if (XPending() && GetButton(&button_event)) { ! 145: /* ! 146: * Process the pending events, this sequence is the only ! 147: * way out of the loop and the routine. ! 148: */ ! 149: ! 150: /* ! 151: * If we froze the server, then erase the last lines drawn. ! 152: */ ! 153: if (Freeze) { ! 154: DrawBox(); ! 155: Frozen = (Window)0; ! 156: XUngrabServer(); ! 157: } ! 158: ! 159: if ((button_event.type == ButtonReleased) && ! 160: ((button_event.detail & ValueMask) == button)) { ! 161: ! 162: /* ! 163: * The button was released, so reset the cursor and ! 164: * move the window. ! 165: */ ! 166: Grab(mask); ! 167: ! 168: if (Zap) { ! 169: num_vectors = StoreZap(zap, ! 170: init_ulx, init_uly, ! 171: init_lrx, init_lry, ! 172: ulx, uly, ! 173: lrx, lry); ! 174: DrawZap(); ! 175: DrawZap(); ! 176: } ! 177: XMoveWindow(window, ulx, uly); ! 178: return(TRUE); ! 179: } ! 180: else { ! 181: ! 182: /* ! 183: * Some other button event occured, this aborts the ! 184: * current operation. ! 185: */ ! 186: ! 187: /* ! 188: * Reset the cursor. ! 189: */ ! 190: Grab(mask); ! 191: return(TRUE); ! 192: } ! 193: } ! 194: ! 195: /* ! 196: * Take care of all the little things that have changed. ! 197: */ ! 198: XUpdateMouse(RootWindow, &cur_x, &cur_y, &sub_window); ! 199: if ((cur_x != prev_x) || (cur_y != prev_y)) { ! 200: ! 201: /* ! 202: * If we've frozen the server, then erase the old box first! ! 203: */ ! 204: if (Freeze) ! 205: DrawBox(); ! 206: ! 207: /* ! 208: * Box position has changed. ! 209: */ ! 210: ulx += cur_x - prev_x; ! 211: uly += cur_y - prev_y; ! 212: lrx += cur_x - prev_x; ! 213: lry += cur_y - prev_y; ! 214: ! 215: /* ! 216: * Box needs to be restored. ! 217: */ ! 218: if (Grid) ! 219: num_vectors = StoreGridBox(box, ulx, uly, lrx, lry); ! 220: else num_vectors = StoreBox(box, ulx, uly, lrx, lry); ! 221: ! 222: ! 223: /* ! 224: * Draw the new box. ! 225: */ ! 226: if (Freeze) ! 227: DrawBox(); ! 228: } ! 229: ! 230: /* ! 231: * Save old box position. ! 232: */ ! 233: prev_x = cur_x; ! 234: prev_y = cur_y; ! 235: ! 236: /* ! 237: * If server is not frozen, then draw the "flicker" box. ! 238: */ ! 239: if (!Freeze) { ! 240: DrawBox(); ! 241: DrawBox(); ! 242: } ! 243: } ! 244: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.