Annotation of researchv9/X11/src/X.V11R1/clients/uwm/MoveOpaque.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char *rcsid_MoveOpaque_c = "$Header: MoveOpaque.c,v 1.8 87/08/25 11:26:34 swick Exp $";
        !             3: #endif lint
        !             4: 
        !             5: #include <X11/copyright.h>
        !             6: 
        !             7: /*
        !             8:  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
        !             9:  *
        !            10:  *                         All Rights Reserved
        !            11:  *
        !            12:  * Permission to use, copy, modify, and distribute this software and its
        !            13:  * documentation for any purpose and without fee is hereby granted,
        !            14:  * provided that the above copyright notice appear in all copies and that
        !            15:  * both that copyright notice and this permission notice appear in
        !            16:  * supporting documentation, and that the name of Digital Equipment
        !            17:  * Corporation not be used in advertising or publicity pertaining to
        !            18:  * distribution of the software without specific, written prior permission.
        !            19:  *
        !            20:  *
        !            21:  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
        !            22:  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
        !            23:  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
        !            24:  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
        !            25:  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
        !            26:  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
        !            27:  * SOFTWARE.
        !            28:  */
        !            29: 
        !            30: 
        !            31: 
        !            32: /*
        !            33:  * MODIFICATION HISTORY
        !            34:  *
        !            35:  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
        !            36:  * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
        !            37:     Western Software Lab. Convert to X11.
        !            38:  */
        !            39: 
        !            40: #ifndef lint
        !            41: static char *sccsid = "@(#)MoveOpaque.c        1.7     1/24/86";
        !            42: #endif
        !            43: 
        !            44: #include "uwm.h"
        !            45: 
        !            46: Bool MoveOpaque(window, mask, button, x, y)
        !            47: Window window;                         /* Event window. */
        !            48: int mask;                              /* Button/key mask. */
        !            49: int button;                            /* Button event detail. */
        !            50: int x, y;                              /* Event mouse position. */
        !            51: {
        !            52:     int prev_x, prev_y;                        /* Previous mouse location. */
        !            53:     int cur_x, cur_y;                  /* Current mouse location. */
        !            54:     int win_x, win_y;                  /* Current window location. */
        !            55:     int root_x;                                /* Root window X location. */
        !            56:     int root_y;                                /* Root window Y location. */
        !            57:     int ptrmask;                       /* state of ptr when queried */
        !            58:     XWindowAttributes window_info;     /* Event window information. */
        !            59:     Window sub_window;                 /* Query mouse event sub-window. */
        !            60:     Window root;                       /* Query mouse event root. */
        !            61:     XEvent button_event;               /* Button event packet. */
        !            62: 
        !            63:     /*
        !            64:      * Do not try to move the root window.
        !            65:      */
        !            66:     if (window == RootWindow(dpy, scr))
        !            67:         return(FALSE);
        !            68: 
        !            69:     /*
        !            70:      * Change the cursor.
        !            71:      */
        !            72:     XChangeActivePointerGrab(dpy, EVENTMASK, ArrowCrossCursor, CurrentTime);
        !            73: 
        !            74:     /*
        !            75:      * Gather info on the event window.
        !            76:      */
        !            77:     status = XGetWindowAttributes(dpy, window, &window_info);
        !            78:     if (status == FAILURE) return(FALSE);
        !            79: 
        !            80:     /*
        !            81:      * Initialize movement variables.
        !            82:      */
        !            83:     prev_x = cur_x = x;
        !            84:     prev_y = cur_y = y;
        !            85:     win_x = window_info.x;
        !            86:     win_y = window_info.y;
        !            87: 
        !            88:     /*
        !            89:      * Main loop.
        !            90:      */
        !            91:     while (TRUE) {
        !            92: 
        !            93:        /*
        !            94:         * Check to see if we have a change in mouse button status.
        !            95:         * This is how we get out of this "while" loop.
        !            96:         */
        !            97:        if (XCheckMaskEvent(dpy,
        !            98:                            ButtonPressMask|ButtonReleaseMask,
        !            99:                            &button_event)) {
        !           100: 
        !           101:            /*
        !           102:             * If the button event was something other than the
        !           103:              * release of the original button pressed, then move the
        !           104:              * window back to where it was originally.
        !           105:             */
        !           106:             if ((button_event.type != ButtonRelease) ||
        !           107:                 (((XButtonReleasedEvent *)&button_event)->button != button)) {
        !           108:                 ResetCursor(button);
        !           109:                XMoveWindow(dpy, window, window_info.x, window_info.y);
        !           110:            }
        !           111: 
        !           112:             return(TRUE);
        !           113:        }
        !           114: 
        !           115:         /*
        !           116:          * Take care of all the little things that have changed; 
        !           117:          * i.e., move the window, if necessary.
        !           118:          */
        !           119:         XQueryPointer(dpy, RootWindow(dpy, scr), 
        !           120:                &root, &sub_window, &root_x, &root_y, &cur_x, &cur_y, 
        !           121:                &ptrmask);
        !           122:         if ((cur_x != prev_x) || (cur_y != prev_y)) {
        !           123:             win_x += (cur_x - prev_x);
        !           124:             win_y += (cur_y - prev_y);
        !           125:             XMoveWindow(dpy, window, win_x, win_y);
        !           126:            prev_x = cur_x;
        !           127:            prev_y = cur_y;
        !           128:        }
        !           129:     }
        !           130: }

unix.superglobalmegacorp.com

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