annotate src/balloon_help.c @ 155:43dd3413c7c7 r20-3b4

Import from CVS: tag r20-3b4
author cvs
date Mon, 13 Aug 2007 09:39:39 +0200
parents b980b6286996
children 6b37e6ddd302
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
1 /* Balloon Help
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
2 Copyright (c) 1997 Douglas Keller
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
3
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
4 This file is part of XEmacs.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
5
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
7 under the terms of the GNU General Public License as published by the
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
9 later version.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
10
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
14 for more details.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
15
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
16 You should have received a copy of the GNU General Public License
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
19 Boston, MA 02111-1307, USA. */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
20
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
21 /* Synched up with: Not in FSF. */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
22
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
23 /*
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
24 * Balloon Help
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
25 *
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
26 * Version: 1.337 (Sun Apr 13 04:52:10 1997)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
27 *
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
28 * Written by Douglas Keller <dkeller@vnet.ibm.com>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
29 *
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
30 *
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
31 */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
32
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
33 #include <string.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
34 #include <stdio.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
35 #include <stdlib.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
36 #include <assert.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
37
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
38 #include <X11/Xlib.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
39 #include <X11/Xutil.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
40 #include <X11/extensions/shape.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
41
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
42 #include <X11/Intrinsic.h>
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
43
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
44 #include "balloon_help.h"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
45
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 136
diff changeset
46 #include "config.h"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 136
diff changeset
47 #ifndef WINDOWSNT
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
48 #define max(x,y) (x>y?x:y)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 136
diff changeset
49 #endif
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
50
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
51 #undef bool
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
52 #define bool int
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
53
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
54 #define MARGIN_WIDTH 4
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
55 #define POINTER_OFFSET 8
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
56 #define BORDER_WIDTH 2
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
57 #define BORDER_WIDTH_HALF 1
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
58
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
59 #define CONE_HEIGHT 20
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
60 #define CONE_WIDTH 50
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
61
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
62 #define SHAPE_CONE_TOP (1<<0)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
63 #define SHAPE_CONE_LEFT (1<<1)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
64 #define SHAPE_CONE_TOP_LEFT (SHAPE_CONE_TOP | SHAPE_CONE_LEFT)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
65 #define SHAPE_CONE_TOP_RIGHT (SHAPE_CONE_TOP)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
66 #define SHAPE_CONE_BOTTOM_LEFT (SHAPE_CONE_LEFT)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
67 #define SHAPE_CONE_BOTTOM_RIGHT (0)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
68 #define SHAPE_CONE_FREE (-1)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
69
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
70
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
71 static Display* b_dpy;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
72
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
73 static XFontStruct* b_fontStruct;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
74 static GC b_gc;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
75
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
76 static GC b_shineGC;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
77 static GC b_shadowGC;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
78
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
79 static Window b_win;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
80 static bool b_winMapped;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
81
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
82 static Pixmap b_mask;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
83 static int b_maskWidth, b_maskHeight;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
84 static GC b_maskGC;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
85
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
86 static const char* b_text;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
87 static int b_width, b_height;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
88
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
89 static int b_lastX, b_lastY;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
90
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
91 static XtIntervalId b_timer;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
92 static unsigned long b_delay;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
93
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
94 static int b_screenWidth, b_screenHeight;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
95
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
96 static int b_lastShape;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
97
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
98 /*============================================================================
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
99
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
100 ============================================================================*/
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
101
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
102 static GC
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
103 create_gc (Display* dpy, Window win, unsigned long fg, unsigned long bg,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
104 XFontStruct* fontStruct)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
105 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
106 XGCValues gcv;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
107 unsigned long mask;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
108
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
109 gcv.foreground = fg;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
110 gcv.background = bg;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
111 gcv.font = fontStruct->fid;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
112 gcv.join_style = JoinMiter;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
113 gcv.line_width = BORDER_WIDTH;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
114
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
115 mask = GCFont | GCBackground | GCForeground | GCJoinStyle | GCLineWidth;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
116
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
117 return XCreateGC (dpy, win, mask, &gcv);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
118 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
119
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
120 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
121 destroy_gc (Display* dpy, GC gc)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
122 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
123 if (gc)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
124 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
125 XFreeGC (dpy, gc);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
126 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
127 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
128
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
129 /*============================================================================
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
130
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
131 ============================================================================*/
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
132
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
133 static Window
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
134 create_window (Display* dpy, unsigned long bg)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
135 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
136 Window win;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
137 XSetWindowAttributes attr;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
138 unsigned long attr_mask;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
139
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
140 attr_mask = CWOverrideRedirect | CWBackPixel | CWSaveUnder;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
141 attr.override_redirect = True;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
142 attr.background_pixel = bg;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
143 attr.save_under = True;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
144
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
145 win =
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
146 XCreateWindow (dpy,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
147 DefaultRootWindow (dpy),
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
148 0, 0, 1, 1,
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
149 0,
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
150 CopyFromParent, InputOutput, CopyFromParent,
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
151 attr_mask, &attr);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
152
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
153 XSelectInput (dpy, win,
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
154 SubstructureRedirectMask |
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
155 SubstructureNotifyMask |
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
156 ExposureMask |
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
157 EnterWindowMask |
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
158 LeaveWindowMask);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
159 return win;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
160 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
161
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
162 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
163 destroy_window (Display* dpy, Window win)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
164 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
165 if (win)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
166 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
167 XDestroyWindow (dpy, win);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
168 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
169 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
170
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
171 /*============================================================================
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
172
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
173 ============================================================================*/
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
174
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
175 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
176 get_pointer_xy (Display* dpy, int* x_return, int* y_return)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
177 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
178 int dummy;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
179 unsigned int mask;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
180 Window dummy_win;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
181
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
182 XQueryPointer (dpy, RootWindow(dpy, DefaultScreen(dpy)), &dummy_win, &dummy_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
183 x_return, y_return, &dummy, &dummy, &mask);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
184 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
185
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
186 /*============================================================================
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
187
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
188 ============================================================================*/
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
189
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
190 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
191 create_pixmap_mask (int width, int height)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
192 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
193 b_maskWidth = width;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
194 b_maskHeight = height;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
195 b_mask = XCreatePixmap (b_dpy, b_win, width, height, 1);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
196 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
197
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
198 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
199 destroy_pixmap_mask(void)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
200 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
201 XFreePixmap (b_dpy, b_mask);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
202 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
203
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
204 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
205 grow_pixmap_mask (int width, int height)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
206 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
207 if (width > b_maskWidth || height > b_maskHeight)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
208 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
209 destroy_pixmap_mask ();
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
210 create_pixmap_mask (width, height);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
211 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
212 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
213
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
214 /*============================================================================
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
215
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
216 ============================================================================*/
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
217
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
218 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
219 text_extent (XFontStruct* fontStruct, const char* text, int len,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
220 int* width, int* height)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
221 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
222 XCharStruct extent;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
223 int dummy;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
224
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
225 XTextExtents (fontStruct, text, len, &dummy, &dummy, &dummy, &extent);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
226
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
227 *width = extent.width;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
228 *height = fontStruct->ascent + fontStruct->descent;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
229 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
230
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
231 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
232 get_text_size (Display* dpy, XFontStruct* fontStruct, const char* text,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
233 int* max_width, int* max_height)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
234 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
235 int width;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
236 int height;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
237 const char* start;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
238 const char* end;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
239
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
240 *max_width = *max_height = 0;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
241
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
242 start = text;
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
243 while ((end = strchr(start, '\n')))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
244 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
245 text_extent (fontStruct, start, end - start, &width, &height);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
246 *max_width = max (width, *max_width);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
247 *max_height += height;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
248
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
249 start = end + 1;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
250 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
251 text_extent (fontStruct, start, strlen (start), &width, &height);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
252 *max_width = max (width, *max_width);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
253 *max_height += height;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
254
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
255 /* Min width */
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
256 *max_width = max (*max_width, CONE_WIDTH / 2 * 3);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
257
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
258 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
259
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
260 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
261 draw_text (Display* dpy, Window win, GC gc, XFontStruct* fontStruct,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
262 int x, int y, const char* text)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
263 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
264 const char* start;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
265 const char* end;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
266 int font_height;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
267
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
268 y += fontStruct->ascent;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
269
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
270 font_height = fontStruct->ascent + fontStruct->descent;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
271
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
272 start = text;
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
273 while ((end = strchr(start, '\n')))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
274 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
275 XDrawString (dpy, win, gc, x, y, start, end - start);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
276
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
277 start = end + 1;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
278 y += font_height;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
279 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
280 XDrawString (dpy, win, gc, x, y, start, strlen (start));
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
281 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
282
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
283 /*============================================================================
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
284
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
285 ============================================================================*/
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
286
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
287 static int
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
288 get_shape (int last_shape, int x, int y, int width, int height,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
289 int screen_width, int screen_height)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
290 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
291 /* Can we use last_shape */
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
292 if (SHAPE_CONE_TOP_LEFT == last_shape)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
293 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
294 if ((x + width < screen_width) && (y + height < screen_height))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
295 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
296 return last_shape;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
297 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
298 }
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
299 else if (SHAPE_CONE_TOP_RIGHT == last_shape)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
300 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
301 if ((x - width > 0) && (y + height < screen_height))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
302 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
303 return last_shape;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
304 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
305 }
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
306 else if (SHAPE_CONE_BOTTOM_LEFT == last_shape)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
307 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
308 if ((x + width < screen_width) && (y - height > 0))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
309 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
310 return last_shape;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
311 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
312 }
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
313 else if (SHAPE_CONE_BOTTOM_RIGHT == last_shape)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
314 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
315 if ((x - width > 0) && (y - height > 0))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
316 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
317 return last_shape;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
318 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
319 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
320
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
321 /* Try to pick a shape that will not get changed, ie if top left quadrant, top_left */
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
322 if (x < screen_width / 2)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
323 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
324 if (y < screen_height / 2)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
325 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
326 return SHAPE_CONE_TOP_LEFT;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
327 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
328 else
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
329 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
330 return SHAPE_CONE_BOTTOM_LEFT;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
331 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
332 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
333 else
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
334 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
335 if (y < screen_height / 2)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
336 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
337 return SHAPE_CONE_TOP_RIGHT;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
338 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
339 else
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
340 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
341 return SHAPE_CONE_BOTTOM_RIGHT;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
342 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
343 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
344
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
345 /* ### if width or height is greater than 1/2 the width or height then we might
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
346 run off the screen */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
347
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
348 abort ();
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
349
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
350 return 0;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
351 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
352
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
353 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
354 make_mask (int shape, int x, int y, int width, int height)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
355 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
356 XPoint cone[ 3 ];
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
357
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
358 grow_pixmap_mask (width, height);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
359
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
360 /* Clear mask */
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
361 XSetForeground (b_dpy, b_maskGC, 0);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
362 XFillRectangle (b_dpy, b_mask, b_maskGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
363 0, 0, width, height);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
364
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
365 /* Enable text area */
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
366 XSetForeground (b_dpy, b_maskGC, 1);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
367 XFillRectangle (b_dpy, b_mask, b_maskGC, 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
368 shape & SHAPE_CONE_TOP ? CONE_HEIGHT : 0, width, height - CONE_HEIGHT);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
369
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
370 /* Enable for cone area */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
371 cone[0].x = (shape & SHAPE_CONE_LEFT) ? CONE_WIDTH / 2 : width - (CONE_WIDTH / 2);
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
372 cone[0].y = (shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : height - CONE_HEIGHT;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
373 cone[1].x = (shape & SHAPE_CONE_LEFT) ? 0 : width;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
374 cone[1].y = (shape & SHAPE_CONE_TOP) ? 0 : height;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
375 cone[2].x = (shape & SHAPE_CONE_LEFT) ? CONE_WIDTH : width - CONE_WIDTH;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
376 cone[2].y = (shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : height - CONE_HEIGHT;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
377
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
378 XFillPolygon (b_dpy, b_mask, b_maskGC, cone, 3, Nonconvex, CoordModeOrigin);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
379
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
380 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
381
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
382 static void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
383 show_help (XtPointer data, XtIntervalId* id)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
384 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
385 int x, y;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
386 int shape;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
387 XPoint border[ 3 ];
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
388
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
389 if (id == NULL || (id && b_timer) && b_text)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
390 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
391 b_timer = None;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
392
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
393 /* size */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
394 get_text_size (b_dpy, b_fontStruct, b_text, &b_width, &b_height);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
395 b_width += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
396 b_height += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH + CONE_HEIGHT;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
397
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
398 /* origin */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
399 get_pointer_xy (b_dpy, &x, &y);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
400
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
401 /* guess at shape */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
402 shape = get_shape(b_lastShape, x, y, b_width, b_height,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
403 b_screenWidth, b_screenHeight);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
404
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
405 x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
406 y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
407
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
408 /* make sure it is still ok with offset */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
409 shape = get_shape (shape, x, y, b_width, b_height, b_screenWidth, b_screenHeight);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
410
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
411 b_lastX = x;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
412 b_lastY = y;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
413 b_lastShape = shape;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
414
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
415
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
416 make_mask (shape, x, y, b_width, b_height);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
417
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
418 XShapeCombineMask (b_dpy, b_win, ShapeBounding, 0, 0, b_mask, ShapeSet);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
419
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
420 XMoveResizeWindow(b_dpy, b_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
421 (shape & SHAPE_CONE_LEFT) ? x : x - b_width,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
422 (shape & SHAPE_CONE_TOP) ? y : y - b_height,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
423 b_width, b_height);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
424
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
425 XClearWindow (b_dpy, b_win);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
426
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
427 XMapRaised (b_dpy, b_win);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
428 b_winMapped = True;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
429
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
430 draw_text (b_dpy, b_win, b_gc, b_fontStruct,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
431 BORDER_WIDTH + MARGIN_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
432 BORDER_WIDTH + MARGIN_WIDTH + ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0),
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
433 b_text);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
434
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
435 /* 3d border */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
436 /* shine- top left */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
437 border[0].x = 0 + BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
438 border[0].y = ((shape & SHAPE_CONE_TOP) ? b_height : b_height - CONE_HEIGHT) - BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
439 border[1].x = 0 + BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
440 border[1].y = ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0) + BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
441 border[2].x = b_width - BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
442 border[2].y = border[1].y;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
443 XDrawLines (b_dpy, b_win, b_shineGC, border, 3, CoordModeOrigin);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
444
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
445 /* shadow- bottom right */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
446 border[0].x = 0 + BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
447 border[0].y = ((shape & SHAPE_CONE_TOP) ? b_height : b_height - CONE_HEIGHT) - BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
448 border[1].x = b_width - BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
449 border[1].y = border[0].y;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
450 border[2].x = b_width - BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
451 border[2].y = ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0) + BORDER_WIDTH_HALF;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
452 XDrawLines (b_dpy, b_win, b_shadowGC, border, 3, CoordModeOrigin);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
453
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
454 /* cone */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
455 if (SHAPE_CONE_TOP_LEFT == shape)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
456 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
457 XClearArea (b_dpy, b_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
458 CONE_WIDTH / 2 + BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
459 CONE_HEIGHT,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
460 CONE_WIDTH / 2 - BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
461 BORDER_WIDTH, False);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
462 XDrawLine (b_dpy, b_win, b_shadowGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
463 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
464 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
465 CONE_WIDTH / 2 + BORDER_WIDTH_HALF,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
466 CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
467 XDrawLine (b_dpy, b_win, b_shineGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
468 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
469 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
470 CONE_WIDTH - BORDER_WIDTH_HALF,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
471 CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
472 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
473 else if (SHAPE_CONE_TOP_RIGHT == shape)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
474 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
475 XClearArea (b_dpy, b_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
476 b_width - CONE_WIDTH + BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
477 CONE_HEIGHT,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
478 CONE_WIDTH / 2 - BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
479 BORDER_WIDTH, False);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
480 XDrawLine (b_dpy, b_win, b_shadowGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
481 b_width,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
482 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
483 b_width - CONE_WIDTH / 2 - BORDER_WIDTH_HALF,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
484 CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
485 XDrawLine (b_dpy, b_win, b_shineGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
486 b_width,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
487 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
488 b_width - CONE_WIDTH + BORDER_WIDTH_HALF,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
489 CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
490 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
491 else if (SHAPE_CONE_BOTTOM_LEFT == shape)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
492 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
493 XClearArea (b_dpy, b_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
494 CONE_WIDTH / 2 + BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
495 b_height - CONE_HEIGHT - BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
496 CONE_WIDTH / 2 - BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
497 BORDER_WIDTH, False);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
498 XDrawLine (b_dpy, b_win, b_shadowGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
499 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
500 b_height - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
501 CONE_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
502 b_height - 1 - CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
503 XDrawLine (b_dpy, b_win, b_shineGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
504 0,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
505 b_height - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
506 CONE_WIDTH / 2 + BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
507 b_height - 1 - CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
508 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
509 else if (SHAPE_CONE_BOTTOM_RIGHT == shape)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
510 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
511 XClearArea (b_dpy, b_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
512 b_width - 1 - CONE_WIDTH + BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
513 b_height - CONE_HEIGHT - BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
514 CONE_WIDTH / 2 - BORDER_WIDTH - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
515 BORDER_WIDTH, False);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
516 XDrawLine (b_dpy, b_win, b_shadowGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
517 b_width - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
518 b_height - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
519 b_width - 1 - CONE_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
520 b_height - 1 - CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
521 XDrawLine (b_dpy, b_win, b_shineGC,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
522 b_width - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
523 b_height - 1,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
524 b_width - 1 - CONE_WIDTH / 2 - BORDER_WIDTH,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
525 b_height - 1 - CONE_HEIGHT);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
526 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
527 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
528
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
529 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
530
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
531 /*============================================================================
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
532
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
533 ============================================================================*/
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
534
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
535 void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
536 balloon_help_create (Display* dpy,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
537 Pixel fg, Pixel bg, Pixel shine, Pixel shadow,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
538 XFontStruct* font)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
539 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
540 if (b_dpy) balloon_help_destroy ();
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
541
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
542 b_dpy = dpy;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
543
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
544 b_fontStruct = font;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
545
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
546 b_win = create_window (dpy, bg);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
547 b_gc = create_gc (dpy, b_win, fg, bg, b_fontStruct);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
548
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
549 b_shineGC = create_gc (dpy, b_win, shine, bg, b_fontStruct);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
550 b_shadowGC = create_gc (dpy, b_win, shadow, bg, b_fontStruct);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
551
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
552 create_pixmap_mask (1, 1);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
553 b_maskGC = create_gc (dpy, b_mask, bg, fg, b_fontStruct);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
554
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
555 b_winMapped = False;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
556 b_timer = None;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
557 b_delay = 500;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
558
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
559 b_screenWidth = DisplayWidth (b_dpy, DefaultScreen(b_dpy));
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
560 b_screenHeight = DisplayHeight (b_dpy, DefaultScreen(b_dpy));
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
561
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
562 b_lastShape = SHAPE_CONE_FREE;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
563 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
564
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
565 void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
566 balloon_help_destroy (void)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
567 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
568 assert (b_dpy != NULL);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
569 b_dpy = NULL;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
570
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
571 destroy_window (b_dpy, b_win);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
572 destroy_gc (b_dpy, b_gc);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
573
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
574 destroy_gc (b_dpy, b_shineGC);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
575 destroy_gc (b_dpy, b_shadowGC);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
576
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
577 destroy_pixmap_mask ();
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
578 destroy_gc (b_dpy, b_maskGC);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
579
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
580 if (b_timer) XtRemoveTimeOut (b_timer);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
581 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
582
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
583 void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
584 balloon_help_set_delay (unsigned long milliseconds)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
585 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
586 b_delay = milliseconds;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
587 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
588
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
589 void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
590 balloon_help_show (const char* text)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
591 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
592 assert (b_dpy != NULL);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
593
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
594 /* We don't copy the text */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
595 b_text = text;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
596 b_lastShape = SHAPE_CONE_FREE;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
597
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
598 if (b_winMapped)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
599 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
600 /* If help is already being shown, don't delay just update */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
601 show_help (NULL, NULL);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
602 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
603 else
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
604 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
605 b_timer =
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
606 XtAppAddTimeOut (XtDisplayToApplicationContext(b_dpy),
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
607 b_delay, show_help, NULL);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
608 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
609 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
610
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
611 void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
612 balloon_help_hide (void)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
613 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
614 assert (b_dpy != NULL);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
615
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
616 b_text = NULL;
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
617 XUnmapWindow (b_dpy, b_win);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
618 b_winMapped = False;
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
619 if (b_timer)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
620 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
621 XtRemoveTimeOut (b_timer);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
622 b_timer = None;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
623 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
624 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
625
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
626 void
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
627 balloon_help_move_to_pointer (void)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
628 {
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
629 assert (b_dpy != NULL);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
630
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
631 if (b_winMapped)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
632 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
633 int x, y;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
634 int shape = b_lastShape;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
635
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
636 get_pointer_xy (b_dpy, &x, &y);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
637
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
638 x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
639 y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
640
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
641 shape = get_shape (shape, x, y, b_width, b_height, b_screenWidth, b_screenHeight);
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
642
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
643 if (shape == b_lastShape)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
644 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
645 b_lastX = x;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
646 b_lastY = y;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
647
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
648 XMoveWindow (b_dpy, b_win,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
649 shape & SHAPE_CONE_LEFT ? x : x - b_width,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
650 shape & SHAPE_CONE_TOP ? y : y - b_height);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
651 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
652 else
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
653 {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
654 /* text would be off screen, rebuild with new shape */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
655 b_lastShape = SHAPE_CONE_FREE;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
656 show_help (NULL, NULL);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
657 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
658 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents:
diff changeset
659 }