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

1.1     ! root        1: #ifndef lint
        !             2: static char *rcsid_Push_c = "$Header: Push.c,v 1.3 87/09/11 08:21:37 toddb 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 = "@(#)Push.c      3.8     1/24/86";
        !            42: #endif
        !            43: 
        !            44: #include "uwm.h"
        !            45: 
        !            46: #define PUSH_DOWN      1
        !            47: #define PUSH_UP                2
        !            48: #define PUSH_LEFT      3
        !            49: #define PUSH_RIGHT     4
        !            50: 
        !            51: extern Bool PushAll();
        !            52: 
        !            53: Bool PushDown(window, mask, button, x, y)
        !            54: Window window;                         /* Event window. */
        !            55: int mask;                              /* Button/key mask. */
        !            56: int button;                            /* Button event detail. */
        !            57: int x, y;                              /* Event mouse position. */
        !            58: {
        !            59:     return(PushAll(window, PUSH_DOWN));
        !            60: }
        !            61: 
        !            62: Bool PushUp(window, mask, button, x, y)
        !            63: Window window;                         /* Event window. */
        !            64: int mask;                              /* Button/key mask. */
        !            65: int button;                            /* Button event detail. */
        !            66: int x, y;                              /* Event mouse position. */
        !            67: {
        !            68:     return(PushAll(window, PUSH_UP));
        !            69: }
        !            70: 
        !            71: Bool PushLeft(window, mask, button, x, y)
        !            72: Window window;                         /* Event window. */
        !            73: int mask;                              /* Button/key mask. */
        !            74: int button;                            /* Button event detail. */
        !            75: int x, y;                              /* Event mouse position. */
        !            76: {
        !            77:     return(PushAll(window, PUSH_LEFT));
        !            78: }
        !            79: 
        !            80: Bool PushRight(window, mask, button, x, y)
        !            81: Window window;                         /* Event window. */
        !            82: int mask;                              /* Button/key mask. */
        !            83: int button;                            /* Button event detail. */
        !            84: int x, y;                              /* Event mouse position. */
        !            85: {
        !            86:     return(PushAll(window, PUSH_RIGHT));
        !            87: }
        !            88: 
        !            89: Bool PushAll(w, direction)
        !            90: Window w;
        !            91: int direction;
        !            92: {
        !            93:     XWindowAttributes winfo;                   /* Event window information. */
        !            94:     XWindowAttributes rinfo;                   /* Root window information. */
        !            95:     int xofs, yofs;                    /* Movement offsets. */
        !            96:     int x, y;                          /* New window position. */
        !            97: 
        !            98:     /*
        !            99:      * Do not try to move the root window.
        !           100:      */
        !           101:     if (w == RootWindow(dpy, scr))
        !           102:         return(FALSE);
        !           103: 
        !           104:     /*
        !           105:      * Gather info on the event window.
        !           106:      */
        !           107:     status = XGetWindowAttributes(dpy, w, &winfo);
        !           108:     if (status == FAILURE) return(FALSE);
        !           109: 
        !           110:     /*
        !           111:      * Calculate the movement offsets.
        !           112:      */
        !           113:     switch(direction) {
        !           114:     case PUSH_DOWN:
        !           115:         xofs = 0;
        !           116:         yofs = Push ? (winfo.height / Pushval) : Pushval;
        !           117:         break;
        !           118:     case PUSH_UP:
        !           119:         xofs = 0;
        !           120:         yofs = 0 - (Push ? (winfo.height / Pushval) : Pushval);
        !           121:         break;
        !           122:     case PUSH_LEFT:
        !           123:         xofs = 0 - (Push ? (winfo.width / Pushval) : Pushval);
        !           124:         yofs = 0;
        !           125:         break;
        !           126:     case PUSH_RIGHT:
        !           127:         xofs = Push ? (winfo.width / Pushval) : Pushval;
        !           128:         yofs = 0;
        !           129:         break;
        !           130:     }
        !           131: 
        !           132:     /*
        !           133:      * Calculate the new window position.
        !           134:      */
        !           135:     x = winfo.x + xofs;
        !           136:     y = winfo.y + yofs;
        !           137: 
        !           138:     /*
        !           139:      * Normalize the new window coordinates so we don't
        !           140:      * lose the window off the edge of the screen.
        !           141:      */
        !           142:     if (x < (0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1)))
        !           143:         x = 0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1);
        !           144:     if (y < (0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1)))
        !           145:         y = 0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1);
        !           146:     if (x > (ScreenWidth - CURSOR_WIDTH))
        !           147:         x = ScreenWidth - CURSOR_WIDTH;
        !           148:     if (y > (ScreenHeight - CURSOR_HEIGHT))
        !           149:         y = ScreenHeight - CURSOR_HEIGHT;
        !           150: 
        !           151:     /*
        !           152:      * Move the window into place.
        !           153:      */
        !           154:     XMoveWindow(dpy, w, x, y);
        !           155: 
        !           156:     return(FALSE);
        !           157: }

unix.superglobalmegacorp.com

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