annotate src/redisplay-x.c @ 5940:c608d4b0b75e cygwin64 tip

rescue lost branch from 64bit.backup
author Henry Thompson <ht@markup.co.uk>
date Thu, 16 Dec 2021 18:48:58 +0000
parents 308d34e9f07d
children
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 /* X output and frame manipulation routines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1994 Lucid, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1204
diff changeset
5 Copyright (C) 2002, 2003 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4908
diff changeset
9 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4908
diff changeset
11 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4908
diff changeset
12 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 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
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4908
diff changeset
20 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
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 /* Author: Chuck Thompson */
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 /* Lots of work done by Ben Wing for Mule */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 /* Number of pixels below each line. */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
30 int x_interline_space; /* #### this needs to be implemented, but per-font */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
4882
eab9498ecc0e merge most of rest of redisplay-x.c and redisplay-gtk.c into redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4881
diff changeset
32 #define THIS_IS_X
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
33 #include "redisplay-xlike-inc.c"
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
34
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
35 static void x_output_shadows (struct frame *f, int x, int y, int width,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
36 int height, GC top_shadow_gc,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
37 GC bottom_shadow_gc, GC background_gc,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
38 int shadow_thickness, int edges);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 /*****************************************************************************
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
41 x_window_output_begin
428
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 Perform any necessary initialization prior to an update.
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 static void
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
46 XLIKE_window_output_begin (struct window *UNUSED (w))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /*****************************************************************************
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51 x_window_output_end
428
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 Perform any necessary flushing of queues when an update has completed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 static void
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
56 XLIKE_window_output_end (struct window *w)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
58 if (!(check_if_pending_expose_event (WINDOW_XDEVICE (w))))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
59 XFlush (DEVICE_X_DISPLAY (WINDOW_XDEVICE (w)));
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 x_bevel_area
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 448
diff changeset
65 Draw shadows for the given area in the given face.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 static void
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
68 XLIKE_bevel_area (struct window *w, face_index findex,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
69 int x, int y, int width, int height,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
70 int shadow_thickness, int edges, enum edge_style style)
428
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 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 struct device *d = XDEVICE (f->device);
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 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 XColor tmp_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 GC top_shadow_gc, bottom_shadow_gc, background_gc;
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 int use_pixmap = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 int flip_gcs = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 assert (shadow_thickness >=0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 memset (&gcv, ~0, sizeof (XGCValues));
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 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
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 /* First, get the GC's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 top_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 bottom_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 background_pixel = tmp_color.pixel;
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 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 background_pixel, ef->core.background_pixel);
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 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 gcv.background = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 /* If we can't distinguish one of the shadows (the color is the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 background), it's better to use a pixmap to generate a dithered gray. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 if (top_shadow_pixel == background_pixel ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 bottom_shadow_pixel == background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 use_pixmap = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 if (use_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 if (DEVICE_X_GRAY_PIXMAP (d) == None)
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 DEVICE_X_GRAY_PIXMAP (d) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 gray_width, gray_height, 1, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 }
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 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 gcv.foreground = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 /* this is needed because the GC draws with a pixmap here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (mask | GCStipple | GCFillStyle));
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 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 bottom_shadow_pixel = tmp_color.pixel;
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 flip_gcs = (bottom_shadow_pixel ==
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 gcv.foreground = top_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 }
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 gcv.foreground = bottom_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 if (use_pixmap && flip_gcs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 GC tmp_gc = bottom_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 bottom_shadow_gc = top_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 top_shadow_gc = tmp_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 gcv.foreground = background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 /* possibly revert the GC's This will give a depressed look to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 divider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 if (style == EDGE_ETCHED_IN || style == EDGE_BEVEL_IN)
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 GC temp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 temp = top_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 top_shadow_gc = bottom_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 bottom_shadow_gc = temp;
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 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 shadow_thickness /= 2;
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 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 x_output_shadows (f, x, y, width, height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 top_shadow_gc, bottom_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 background_gc, shadow_thickness, edges);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 x_output_shadows (f, x + shadow_thickness, y + shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 width - 2*shadow_thickness, height - 2*shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 bottom_shadow_gc, top_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 background_gc, shadow_thickness, edges);
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 x_output_shadows
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 Draw a shadow around the given area using the given GC's. It is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 callers responsibility to set the GC's appropriately.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 ****************************************************************************/
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
193 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 x_output_shadows (struct frame *f, int x, int y, int width, int height,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
195 GC top_shadow_gc, GC bottom_shadow_gc,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
196 GC UNUSED (background_gc), int shadow_thickness, int edges)
428
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 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
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 XSegment top_shadow[20], bottom_shadow[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 int elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 if (shadow_thickness > 10)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 shadow_thickness = 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 else if (shadow_thickness < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 shadow_thickness = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 if (shadow_thickness > (width / 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 shadow_thickness = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 if (shadow_thickness > (height / 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 shadow_thickness = height / 2;
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 for (elt = 0; elt < shadow_thickness; elt++)
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 int seg1 = elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 int seg2 = (edges & EDGE_TOP) ? elt + shadow_thickness : elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 int bot_seg2 = (edges & EDGE_BOTTOM) ? elt + shadow_thickness : elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 if (edges & EDGE_TOP)
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 top_shadow[seg1].x1 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 top_shadow[seg1].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt;
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 if (edges & EDGE_LEFT)
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 top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 top_shadow[seg2].y1 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 top_shadow[seg2].y2 = y + height - elt - 1;
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 if (edges & EDGE_BOTTOM)
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 bottom_shadow[seg1].x1 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 bottom_shadow[seg1].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 if (edges & EDGE_RIGHT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 bottom_shadow[bot_seg2].x1 = bottom_shadow[bot_seg2].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 bottom_shadow[bot_seg2].y1 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 bottom_shadow[bot_seg2].y2 = y + height - elt - 1;
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 }
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 XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 ((edges & EDGE_TOP) ? shadow_thickness : 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 + ((edges & EDGE_LEFT) ? shadow_thickness : 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 XDrawSegments (dpy, x_win, bottom_shadow_gc, bottom_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 ((edges & EDGE_BOTTOM) ? shadow_thickness : 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 + ((edges & EDGE_RIGHT) ? shadow_thickness : 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 }
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 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 x_generate_shadow_pixels
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 Given three pixels (top shadow, bottom shadow, background) massage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 the top and bottom shadow colors to guarantee that they differ. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 background pixels are not allowed to be modified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 This function modifies its parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 This code is modified from code blatantly stolen from lwlib/xlwmenu.c
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 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 ? ((unsigned long) (x)) : ((unsigned long) (y)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 x_generate_shadow_pixels (struct frame *f, unsigned long *top_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 unsigned long *bottom_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 unsigned long background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 unsigned long core_background)
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 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 Colormap cmap = DEVICE_X_COLORMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 Visual *visual = DEVICE_X_VISUAL (d);
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 XColor topc, botc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 int top_frobbed = 0, bottom_frobbed = 0;
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 /* If the top shadow is the same color as the background, try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 adjust it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 if (*top_shadow == background)
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 topc.pixel = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 XQueryColor (dpy, cmap, &topc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 /* don't overflow/wrap! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 topc.red = MINL (65535, (unsigned long) topc.red * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 topc.green = MINL (65535, (unsigned long) topc.green * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 topc.blue = MINL (65535, (unsigned long) topc.blue * 6 / 5);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
293 if (x_allocate_nearest_color (dpy, cmap, visual, &topc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 *top_shadow = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 top_frobbed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 }
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 /* If the bottom shadow is the same color as the background, try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 adjust it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 if (*bottom_shadow == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 botc.pixel = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 XQueryColor (dpy, cmap, &botc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 botc.red = (unsigned short) ((unsigned long) botc.red * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 botc.green = (unsigned short) ((unsigned long) botc.green * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 botc.blue = (unsigned short) ((unsigned long) botc.blue * 3 / 5);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
309 if (x_allocate_nearest_color (dpy, cmap, visual, &botc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 *bottom_shadow = botc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 bottom_frobbed = 1;
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 }
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 /* If we had to adjust both shadows, then we have to do some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 additional work. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 if (top_frobbed && bottom_frobbed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 if (bot_avg > top_avg)
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 Pixel tmp = *top_shadow;
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 *top_shadow = *bottom_shadow;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 *bottom_shadow = tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 else if (topc.pixel == botc.pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 if (botc.pixel == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 *top_shadow = core_background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 *bottom_shadow = background;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 /* Make audible bell. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 static void
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4882
diff changeset
343 XLIKE_ring_bell (struct device *d, int volume, int pitch, int duration)
428
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 Display *display = DEVICE_X_DISPLAY (d);
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 if (volume < 0) volume = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 else if (volume > 100) volume = 100;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 if (pitch < 0 && duration < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 XBell (display, (volume * 2) - 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 XFlush (display);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 XKeyboardState state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 XKeyboardControl ctl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 XSync (display, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 /* #### grab server? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 XGetKeyboardControl (display, &state);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
664
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 647
diff changeset
362 ctl.bell_pitch = (pitch >= 0 ? pitch : (int) state.bell_pitch);
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 647
diff changeset
363 ctl.bell_duration = (duration >= 0 ? duration : (int) state.bell_duration);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 XBell (display, (volume * 2) - 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 ctl.bell_pitch = state.bell_pitch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 ctl.bell_duration = state.bell_duration;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 /* #### ungrab server? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 XSync (display, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 }