1: #ifndef lint
   2: static char *rcsid_Move_c = "$Header: Move.c,v 10.3 86/02/01 16:23:17 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 = "@(#)Move.c	3.8	1/24/86";
  45: #endif
  46: 
  47: #include "uwm.h"
  48: 
  49: Bool Move(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 int prev_x;        /* Previous event window X location. */
  56:     register int prev_y;        /* Previous event window Y location. */
  57:     register WindowInfo window_info;    /* Event window information. */
  58:     int cur_x;              /* Current event window X location. */
  59:     int cur_y;              /* Current event window Y location. */
  60:     int ulx, uly;           /* Event window upper left X and Y. */
  61:     int lrx, lry;           /* Event window lower right X and Y. */
  62:     int init_ulx, init_uly;     /* Init window upper left X and Y. */
  63:     int init_lrx, init_lry;     /* Init window lower right X and Y. */
  64:     int num_vectors;            /* Number of vectors in box. */
  65:     Window sub_window;          /* Query mouse event sub-window. */
  66:     XButtonEvent button_event;      /* Button event packet. */
  67:     Vertex box[MAX_BOX_VECTORS];    /* Box vertex buffer. */
  68:     Vertex zap[MAX_ZAP_VECTORS];    /* Zap effect verted buffer. */
  69: 
  70:     /*
  71:      * Do not try to move the root window.
  72:      */
  73:     if (window == RootWindow)
  74:         return(FALSE);
  75: 
  76:     /*
  77:      * Change the cursor.
  78:      */
  79:     status = XGrabButton(RootWindow, ArrowCrossCursor, mask, EVENTMASK);
  80:     if (status == FAILURE)
  81:         Error("Move -> Unable to grab button and change cursor.");
  82: 
  83:     /*
  84:      * Clear the vector buffers.
  85:      */
  86:     bzero(box, sizeof(box));
  87:     if (Zap) bzero(zap, sizeof(zap));
  88: 
  89:     /*
  90:      * Gather info on the event window.
  91:      */
  92:     status = XQueryWindow(window, &window_info);
  93:     if (status == FAILURE) return(FALSE);
  94: 
  95:     /*
  96:      * Initialize movement variables.
  97:      */
  98:     init_ulx = ulx = window_info.x;
  99:     init_uly = uly = window_info.y;
 100:     init_lrx = lrx = window_info.x + window_info.width +
 101:                      (window_info.bdrwidth << 1) - 1;
 102:     init_lry = lry = window_info.y + window_info.height +
 103:                      (window_info.bdrwidth << 1) - 1;
 104: 
 105:     /*
 106:      * Store the box.
 107:      */
 108:     if (Grid)
 109:         num_vectors = StoreGridBox(box, ulx, uly, lrx, lry);
 110:     else num_vectors = StoreBox(box, ulx, uly, lrx, lry);
 111: 
 112:     /*
 113:      * Initialize the previous location variables.
 114:      */
 115:     prev_x = x;
 116:     prev_y = y;
 117: 
 118:     /*
 119:      * Freeze the server, if requested by the user.
 120:      * This results in a solid box instead of a flickering one.
 121:      */
 122:     if (Freeze) XGrabServer();
 123: 
 124:     /*
 125:      * Process any pending exposure events before drawing the box.
 126:      */
 127:     while (QLength() > 0) {
 128:         XPeekEvent(&button_event);
 129:         if (button_event.window == RootWindow)
 130:             break;
 131:         GetButton(&button_event);
 132:     }
 133: 
 134:     /*
 135:      * Now draw the box.
 136:      */
 137:     DrawBox();
 138:     Frozen = window;
 139: 
 140:     /*
 141:      * Main loop.
 142:      */
 143:     while (TRUE) {
 144: 
 145:         /*
 146: 	 * Check to see if we have a change in mouse button status.
 147: 	 * This is how we get out of this "while" loop.
 148: 	 */
 149:     if (XPending() && GetButton(&button_event)) {
 150:         /*
 151: 	     * Process the pending events, this sequence is the only
 152: 	     * way out of the loop and the routine.
 153: 	     */
 154: 
 155:             /*
 156:              * If we froze the server, then erase the last lines drawn.
 157:              */
 158:             if (Freeze) {
 159:                 DrawBox();
 160:                 Frozen = (Window)0;
 161:                 XUngrabServer();
 162:             }
 163: 
 164:         if ((button_event.type == ButtonReleased) &&
 165:         ((button_event.detail & ValueMask) == button)) {
 166: 
 167:         /*
 168: 		 * The button was released, so reset the cursor and
 169: 		 * move the window.
 170: 		 */
 171:                 Grab(mask);
 172: 
 173:         if (Zap) {
 174:                     num_vectors = StoreZap(zap,
 175:                                            init_ulx, init_uly,
 176:                                            init_lrx, init_lry,
 177:                                            ulx, uly,
 178:                                            lrx, lry);
 179:                     DrawZap();
 180:                     DrawZap();
 181:                 }
 182:         XMoveWindow(window, ulx, uly);
 183:         return(TRUE);
 184:         }
 185:         else {
 186: 
 187:         /*
 188: 		 * Some other button event occured, this aborts the
 189: 		 * current operation.
 190: 		 */
 191: 
 192:         /*
 193: 		 * Reset the cursor.
 194: 		 */
 195:                 Grab(mask);
 196:         return(TRUE);
 197:         }
 198:     }
 199: 
 200:         /*
 201:          * Take care of all the little things that have changed.
 202:          */
 203:         XUpdateMouse(RootWindow, &cur_x, &cur_y, &sub_window);
 204:         if ((cur_x != prev_x) || (cur_y != prev_y)) {
 205: 
 206:             /*
 207:              * If we've frozen the server, then erase the old box first!
 208:              */
 209:             if (Freeze)
 210:                 DrawBox();
 211: 
 212:             /*
 213:              * Box position has changed.
 214:              */
 215:             ulx += cur_x - prev_x;
 216:             uly += cur_y - prev_y;
 217:             lrx += cur_x - prev_x;
 218:             lry += cur_y - prev_y;
 219: 
 220:             /*
 221:              * Box needs to be restored.
 222:              */
 223:             if (Grid)
 224:                 num_vectors = StoreGridBox(box, ulx, uly, lrx, lry);
 225:             else num_vectors = StoreBox(box, ulx, uly, lrx, lry);
 226: 
 227: 
 228:             /*
 229:              * Draw the new box.
 230:              */
 231:             if (Freeze)
 232:                 DrawBox();
 233:         }
 234: 
 235:         /*
 236:     	 * Save old box position.
 237:     	 */
 238:         prev_x = cur_x;
 239:         prev_y = cur_y;
 240: 
 241:         /*
 242:          * If server is not frozen, then draw the "flicker" box.
 243:          */
 244:         if (!Freeze) {
 245:             DrawBox();
 246:             DrawBox();
 247:         }
 248:     }
 249: }

Defined functions

Move defined in line 49; used 1 times

Defined variables

rcsid_Move_c defined in line 2; never used
sccsid defined in line 44; never used
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1248
Valid CSS Valid XHTML 1.0 Strict