Annotation of 43BSDTahoe/new/X/uwm/MoveOpaque.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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