annotate src/balloon_help.c @ 1279:cd0abfdb9e9d

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