1: #ifndef lint
   2: static char *rcsid_MoveOpaque_c = "$Header: MoveOpaque.c,v 10.3 86/02/01 16:23:22 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 = "@(#)MoveOpaque.c	1.7	1/24/86";
  45: #endif
  46: 
  47: #include "uwm.h"
  48: 
  49: Bool MoveOpaque(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:     int prev_x, prev_y;         /* Previous mouse location. */
  56:     int cur_x, cur_y;           /* Current mouse location. */
  57:     int win_x, win_y;           /* Current window location. */
  58:     WindowInfo window_info;     /* Event window information. */
  59:     Window sub_window;          /* Query mouse event sub-window. */
  60:     XButtonEvent button_event;      /* Button event packet. */
  61: 
  62:     /*
  63:      * Do not try to move the root window.
  64:      */
  65:     if (window == RootWindow)
  66:         return(FALSE);
  67: 
  68:     /*
  69:      * Change the cursor.
  70:      */
  71:     status = XGrabButton(RootWindow, ArrowCrossCursor, mask, EVENTMASK);
  72:     if (status == FAILURE)
  73:         Error("MoveOpaque -> Unable to grab button and change cursor.");
  74: 
  75:     /*
  76:      * Gather info on the event window.
  77:      */
  78:     status = XQueryWindow(window, &window_info);
  79:     if (status == FAILURE) return(FALSE);
  80: 
  81:     /*
  82:      * Initialize movement variables.
  83:      */
  84:     prev_x = cur_x = x;
  85:     prev_y = cur_y = y;
  86:     win_x = window_info.x;
  87:     win_y = window_info.y;
  88: 
  89:     /*
  90:      * Main loop.
  91:      */
  92:     while (TRUE) {
  93: 
  94:         /*
  95: 	 * Check to see if we have a change in mouse button status.
  96: 	 * This is how we get out of this "while" loop.
  97: 	 */
  98:     if (XPending() && GetButton(&button_event)) {
  99: 
 100:         /*
 101: 	     * If the button event was something other than the
 102:              * release of the original button pressed, then move the
 103:              * window back to where it was originally.
 104: 	     */
 105:             if ((button_event.type != ButtonReleased) ||
 106:                 ((button_event.detail & ValueMask) != button))
 107:                 XMoveWindow(window, window_info.x, window_info.y);
 108: 
 109:             /*
 110:              * Reset the cursor and return.
 111:              */
 112:             Grab(mask);
 113:             return(TRUE);
 114:     }
 115: 
 116:         /*
 117:          * Take care of all the little things that have changed;
 118:          * i.e., move the window, if necessary.
 119:          */
 120:         XUpdateMouse(RootWindow, &cur_x, &cur_y, &sub_window);
 121:         if ((cur_x != prev_x) || (cur_y != prev_y)) {
 122:             win_x += (cur_x - prev_x);
 123:             win_y += (cur_y - prev_y);
 124:             XMoveWindow(window, win_x, win_y);
 125:             prev_x = cur_x;
 126:             prev_y = cur_y;
 127:         }
 128:     }
 129: }

Defined functions

MoveOpaque defined in line 49; used 1 times

Defined variables

rcsid_MoveOpaque_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: 1008
Valid CSS Valid XHTML 1.0 Strict