annotate src/balloon_help.c @ 611:38db05db9cb5

[xemacs-hg @ 2001-06-08 12:21:09 by ben] ------ gc-in-window-procedure fixes ------ alloc.c: Create "post-gc actions", to avoid those dreaded "GC during window procedure" problems. event-msw.c: Abort, clean and simple, when GC in window procedure. We want to flush these puppies out. glyphs-msw.c: Use a post-gc action when destroying subwindows. lisp.h: Declare register_post_gc_action(). scrollbar-msw.c: Use a post-gc action when unshowing scrollbar windows, if in gc. redisplay.c: Add comment about the utter evilness of what's going down here. ------ cygwin setitimer fixes ------ Makefile.in.in: Compile profile.c only when HAVE_SETITIMER. nt.c: Style fixes. nt.c: Move setitimer() emulation to win32.c, because Cygwin needs it too. profile.c: Make sure we don't compile if no setitimer(). Use qxe_setitimer() instead of just plain setitimer(). signal.c: Define qxe_setitimer() as an encapsulation around setitimer() -- call setitimer() directly unless Cygwin or MS Win, in which case we use our simulated version in win32.c. systime.h: Prototype mswindows_setitimer() and qxe_setitimer(). Long comment about "qxe" and the policy regarding encapsulation. win32.c: Move setitimer() emulation here, so Cygwin can use it. Rename a couple of functions and variables to be longer and more descriptive. In setitimer_helper_proc(), send the signal using either mswindows_raise() or (on Cygwin) kill(). If for some reason we are still getting lockups, we'll change the kill() to directly invoke the signal handlers. ------ windows shell fixes ------ callproc.c, ntproc.c: Comments about how these two files must die. callproc.c: On MS Windows, init shell-file-name from SHELL, then COMSPEC, not just COMSPEC. (more correct and closer to FSF.) Don't force a value for SHELL into the environment. (Comments added to explain why not.) nt.c: Don't shove a fabricated SHELL into the environment. See above. ------ misc fixes ------ glyphs-shared.c: Style correction. xemacs-faq.texi: Merge in the rest of Hrvoje's Windows FAQ. Redo section 7 to update current reality and add condensed versions of new changes for 21.1 and 21.4. (Not quite done for 21.4.) Lots more Windows updates. process.el: Need to quote a null argument, too. From Dan Holmsand. startup.el: startup.el: Call MS Windows init function. win32-native.el: Correct comments at top. Correctly handle passing arguments to Cygwin programs and to bash. Fix quoting of zero-length arguments (from Dan Holmsand). Set shell-command-switch based on shell-file-name, which in turn comes from env var SHELL.
author ben
date Fri, 08 Jun 2001 12:21:27 +0000
parents abe6d1db359e
children 943eaba38521
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * Balloon Help
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 * Version: 1.337 (Sun Apr 13 04:52:10 1997)
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 * Written by Douglas Keller <dkeller@vnet.ibm.com>
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 *
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 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include <assert.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include <X11/Xlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include <X11/Xutil.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include <X11/extensions/shape.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #include "xintrinsic.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 "balloon_help.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
47 #ifndef max
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #define max(x,y) (x>y?x:y)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #undef bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 #define bool int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 #define MARGIN_WIDTH 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #define POINTER_OFFSET 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #define BORDER_WIDTH 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #define BORDER_WIDTH_HALF 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #define CONE_HEIGHT 20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #define CONE_WIDTH 50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #define SHAPE_CONE_TOP (1<<0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #define SHAPE_CONE_LEFT (1<<1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #define SHAPE_CONE_TOP_LEFT (SHAPE_CONE_TOP | SHAPE_CONE_LEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #define SHAPE_CONE_TOP_RIGHT (SHAPE_CONE_TOP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #define SHAPE_CONE_BOTTOM_LEFT (SHAPE_CONE_LEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #define SHAPE_CONE_BOTTOM_RIGHT (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #define SHAPE_CONE_FREE (-1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 static Display* b_dpy;
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 XFontStruct* b_fontStruct;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 static GC b_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 static GC b_shineGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 static GC b_shadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 static Window b_win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 static bool b_winMapped;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 static Pixmap b_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static int b_maskWidth, b_maskHeight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 static GC b_maskGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
86 static const char* b_text;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 static int b_width, b_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 static XtIntervalId b_timer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 static unsigned long b_delay;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 static int b_screenWidth, b_screenHeight;
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_lastShape;
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 /*============================================================================
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 static GC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 create_gc (Display* dpy, Window win, unsigned long fg, unsigned long bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 XFontStruct* fontStruct)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 gcv.foreground = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 gcv.background = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 gcv.font = fontStruct->fid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 gcv.join_style = JoinMiter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 gcv.line_width = BORDER_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 mask = GCFont | GCBackground | GCForeground | GCJoinStyle | GCLineWidth;
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 return XCreateGC (dpy, win, mask, &gcv);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 destroy_gc (Display* dpy, GC gc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 if (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 XFreeGC (dpy, 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 }
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 static Window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 create_window (Display* dpy, unsigned long bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Window win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 XSetWindowAttributes attr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 unsigned long attr_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 attr_mask = CWOverrideRedirect | CWBackPixel | CWSaveUnder;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 attr.override_redirect = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 attr.background_pixel = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 attr.save_under = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 win =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 XCreateWindow (dpy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 DefaultRootWindow (dpy),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 0, 0, 1, 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 CopyFromParent, InputOutput, CopyFromParent,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 attr_mask, &attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 XSelectInput (dpy, win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 SubstructureRedirectMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 SubstructureNotifyMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 ExposureMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 EnterWindowMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 LeaveWindowMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 return win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 destroy_window (Display* dpy, Window win)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 if (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 XDestroyWindow (dpy, 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 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 get_pointer_xy (Display* dpy, int* x_return, int* y_return)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 int dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 unsigned int mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 Window dummy_win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 XQueryPointer (dpy, RootWindow(dpy, DefaultScreen(dpy)), &dummy_win, &dummy_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 x_return, y_return, &dummy, &dummy, &mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 create_pixmap_mask (int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 b_maskWidth = width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 b_maskHeight = height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 b_mask = XCreatePixmap (b_dpy, b_win, width, height, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 destroy_pixmap_mask(void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 XFreePixmap (b_dpy, b_mask);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 grow_pixmap_mask (int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if (width > b_maskWidth || height > b_maskHeight)
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 destroy_pixmap_mask ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 create_pixmap_mask (width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 }
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 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
217 text_extent (XFontStruct* fontStruct, const char* text, int len,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 int* width, int* height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 XCharStruct extent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 int dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 XTextExtents (fontStruct, text, len, &dummy, &dummy, &dummy, &extent);
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 *width = extent.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 *height = fontStruct->ascent + fontStruct->descent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
230 get_text_size (Display* dpy, XFontStruct* fontStruct, const char* text,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 int* max_width, int* max_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 int width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 int height;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
235 const char* start;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
236 const char* end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 *max_width = *max_height = 0;
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 start = text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 while ((end = strchr(start, '\n')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 text_extent (fontStruct, start, end - start, &width, &height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 *max_width = max (width, *max_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 *max_height += height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 start = end + 1;
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 text_extent (fontStruct, start, strlen (start), &width, &height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 *max_width = max (width, *max_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 *max_height += height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 /* Min width */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 *max_width = max (*max_width, CONE_WIDTH / 2 * 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 draw_text (Display* dpy, Window win, GC gc, XFontStruct* fontStruct,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
260 int x, int y, const char* text)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
262 const char* start;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
263 const char* end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 int font_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 y += fontStruct->ascent;
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 font_height = fontStruct->ascent + fontStruct->descent;
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 start = text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 while ((end = strchr(start, '\n')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 XDrawString (dpy, win, gc, x, y, start, end - start);
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 start = end + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 y += font_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 XDrawString (dpy, win, gc, x, y, start, strlen (start));
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
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 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
287 int screen_width, int screen_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 /* Can we use last_shape? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 if (((last_shape == SHAPE_CONE_TOP_LEFT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (x + width < screen_width) && (y + height < screen_height)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 ((last_shape == SHAPE_CONE_TOP_RIGHT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (x - width > 0) && (y + height < screen_height)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 ((last_shape == SHAPE_CONE_BOTTOM_LEFT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 (x + width < screen_width) && (y - height > 0)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 ((last_shape == SHAPE_CONE_BOTTOM_RIGHT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (x - width > 0) && (y - height > 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 return last_shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 /* Try to pick a shape that will not get changed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 e.g. if top left quadrant, top_left */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 return (x < screen_width / 2) ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (y < screen_height / 2 ? SHAPE_CONE_TOP_LEFT: SHAPE_CONE_BOTTOM_LEFT) :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (y < screen_height / 2 ? SHAPE_CONE_TOP_RIGHT: SHAPE_CONE_BOTTOM_RIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 make_mask (int shape, int x, int y, int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 XPoint cone[ 3 ];
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 grow_pixmap_mask (width, height);
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 /* Clear mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 XSetForeground (b_dpy, b_maskGC, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 XFillRectangle (b_dpy, b_mask, b_maskGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 0, 0, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 /* Enable text area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 XSetForeground (b_dpy, b_maskGC, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 XFillRectangle (b_dpy, b_mask, b_maskGC, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 shape & SHAPE_CONE_TOP ? CONE_HEIGHT : 0, width, height - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 /* Enable for cone area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 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
326 cone[0].y = (shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : height - CONE_HEIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 cone[1].x = (shape & SHAPE_CONE_LEFT) ? 0 : width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 cone[1].y = (shape & SHAPE_CONE_TOP) ? 0 : height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 cone[2].x = (shape & SHAPE_CONE_LEFT) ? CONE_WIDTH : width - CONE_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 cone[2].y = (shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : height - CONE_HEIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 XFillPolygon (b_dpy, b_mask, b_maskGC, cone, 3, Nonconvex, CoordModeOrigin);
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 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 show_help (XtPointer data, XtIntervalId* id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 int x, y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 int shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 XPoint border[ 3 ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 if (id == NULL || ((id && b_timer) && b_text))
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 b_timer = None;
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 /* size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 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
349 b_width += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 b_height += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH + CONE_HEIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 /* origin */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 get_pointer_xy (b_dpy, &x, &y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* guess at shape */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 shape = get_shape(b_lastShape, x, y, b_width, b_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 b_screenWidth, b_screenHeight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* make sure it is still ok with offset */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 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
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 b_lastShape = shape;
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 make_mask (shape, x, y, b_width, b_height);
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 XShapeCombineMask (b_dpy, b_win, ShapeBounding, 0, 0, b_mask, ShapeSet);
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 XMoveResizeWindow(b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (shape & SHAPE_CONE_LEFT) ? x : x - b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (shape & SHAPE_CONE_TOP) ? y : y - b_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 b_width, b_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 XClearWindow (b_dpy, b_win);
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 XMapRaised (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 b_winMapped = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 draw_text (b_dpy, b_win, b_gc, b_fontStruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 BORDER_WIDTH + MARGIN_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 BORDER_WIDTH + MARGIN_WIDTH + ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 b_text);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 /* 3d border */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 /* shine- top left */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 border[0].x = 0 + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 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
390 border[1].x = 0 + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 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
392 border[2].x = b_width - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 border[2].y = border[1].y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 XDrawLines (b_dpy, b_win, b_shineGC, border, 3, CoordModeOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 /* shadow- bottom right */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 border[0].x = 0 + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 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
399 border[1].x = b_width - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 border[1].y = border[0].y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 border[2].x = b_width - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 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
403 XDrawLines (b_dpy, b_win, b_shadowGC, border, 3, CoordModeOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 /* cone */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 if (SHAPE_CONE_TOP_LEFT == shape)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 CONE_WIDTH / 2 + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 CONE_HEIGHT,
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 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 CONE_WIDTH / 2 + BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 CONE_WIDTH - BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 else if (SHAPE_CONE_TOP_RIGHT == shape)
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 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 b_width - CONE_WIDTH + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 CONE_HEIGHT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 CONE_WIDTH / 2 - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 b_width - CONE_WIDTH / 2 - BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 b_width - CONE_WIDTH + BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 else if (SHAPE_CONE_BOTTOM_LEFT == shape)
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 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 CONE_WIDTH / 2 + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 b_height - CONE_HEIGHT - BORDER_WIDTH,
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 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 CONE_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 CONE_WIDTH / 2 + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 else if (SHAPE_CONE_BOTTOM_RIGHT == shape)
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 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 b_width - 1 - CONE_WIDTH + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 b_height - CONE_HEIGHT - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 CONE_WIDTH / 2 - BORDER_WIDTH - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 b_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 b_width - 1 - CONE_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 b_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 b_width - 1 - CONE_WIDTH / 2 - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 balloon_help_destroy (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 assert (b_dpy != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 b_dpy = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 destroy_window (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 destroy_gc (b_dpy, b_gc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 destroy_gc (b_dpy, b_shineGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 destroy_gc (b_dpy, b_shadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 destroy_pixmap_mask ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 destroy_gc (b_dpy, b_maskGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 if (b_timer) XtRemoveTimeOut (b_timer);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 balloon_help_create (Display* dpy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 Pixel fg, Pixel bg, Pixel shine, Pixel shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 XFontStruct* font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 if (b_dpy) balloon_help_destroy ();
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 b_dpy = dpy;
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_fontStruct = font;
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_win = create_window (dpy, bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 b_gc = create_gc (dpy, b_win, fg, bg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 b_shineGC = create_gc (dpy, b_win, shine, bg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 b_shadowGC = create_gc (dpy, b_win, shadow, bg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 create_pixmap_mask (1, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 b_maskGC = create_gc (dpy, b_mask, bg, fg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 b_winMapped = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 b_timer = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 b_delay = 500;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 b_screenWidth = DisplayWidth (b_dpy, DefaultScreen(b_dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 b_screenHeight = DisplayHeight (b_dpy, DefaultScreen(b_dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 b_lastShape = SHAPE_CONE_FREE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 balloon_help_set_delay (unsigned long milliseconds)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 b_delay = 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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
541 balloon_help_show (const char* text)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 assert (b_dpy != NULL);
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 /* We don't copy the text */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 b_text = text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 b_lastShape = SHAPE_CONE_FREE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 if (b_winMapped)
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 help is already being shown, don't delay just update */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 show_help (NULL, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 else
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 b_timer =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 XtAppAddTimeOut (XtDisplayToApplicationContext(b_dpy),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 b_delay, show_help, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 }
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 balloon_help_hide (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 assert (b_dpy != NULL);
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 b_text = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 XUnmapWindow (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 b_winMapped = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 if (b_timer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 XtRemoveTimeOut (b_timer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 b_timer = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 }
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 balloon_help_move_to_pointer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 assert (b_dpy != NULL);
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 if (b_winMapped)
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 int x, y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 int shape = b_lastShape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 get_pointer_xy (b_dpy, &x, &y);
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 x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 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
593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (shape == b_lastShape)
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 XMoveWindow (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 shape & SHAPE_CONE_LEFT ? x : x - b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 shape & SHAPE_CONE_TOP ? y : y - b_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 else
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 /* text would be off screen, rebuild with new shape */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 b_lastShape = SHAPE_CONE_FREE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 show_help (NULL, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 }