annotate src/balloon_help.c @ 134:34a5b81f86ba r20-2b1

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