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