Mercurial > hg > xemacs-beta
annotate src/redisplay-x.c @ 5887:6eca500211f4
Prototype for X509_check_host() has changed, detect this in configure.ac
ChangeLog addition:
2015-04-09 Aidan Kehoe <kehoea@parhasard.net>
* configure.ac:
If X509_check_host() is available, check the number of arguments
it takes. Don't use it if it takes any number of arguments other
than five. Also don't use it if <openssl/x509v3.h> does not
declare it, since if that is so there is no portable way to tell
how many arguments it should take, and so we would end up smashing
the stack.
* configure: Regenerate.
src/ChangeLog addition:
2015-04-09 Aidan Kehoe <kehoea@parhasard.net>
* tls.c:
#include <openssl/x509v3.h> for its prototype for
X509_check_host().
* tls.c (tls_open):
Pass the new fifth argument to X509_check_host().
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 09 Apr 2015 14:27:02 +0100 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
428 | 1 /* X output and frame manipulation routines. |
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
3 Copyright (C) 1994 Lucid, Inc. | |
4 Copyright (C) 1995 Sun Microsystems, Inc. | |
1318 | 5 Copyright (C) 2002, 2003 Ben Wing. |
428 | 6 |
7 This file is part of XEmacs. | |
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 | 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 | 13 |
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
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 | 21 |
22 /* Synched up with: Not in FSF. */ | |
23 | |
24 /* Author: Chuck Thompson */ | |
25 | |
26 /* Lots of work done by Ben Wing for Mule */ | |
27 | |
28 | |
29 /* Number of pixels below each line. */ | |
3094 | 30 int x_interline_space; /* #### this needs to be implemented, but per-font */ |
428 | 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 | 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 | 39 |
40 /***************************************************************************** | |
442 | 41 x_window_output_begin |
428 | 42 |
43 Perform any necessary initialization prior to an update. | |
44 ****************************************************************************/ | |
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 | 47 { |
48 } | |
49 | |
50 /***************************************************************************** | |
442 | 51 x_window_output_end |
428 | 52 |
53 Perform any necessary flushing of queues when an update has completed. | |
54 ****************************************************************************/ | |
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 | 57 { |
1204 | 58 if (!(check_if_pending_expose_event (WINDOW_XDEVICE (w)))) |
59 XFlush (DEVICE_X_DISPLAY (WINDOW_XDEVICE (w))); | |
428 | 60 } |
61 | |
62 /***************************************************************************** | |
63 x_bevel_area | |
64 | |
450 | 65 Draw shadows for the given area in the given face. |
428 | 66 ****************************************************************************/ |
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 | 71 { |
72 struct frame *f = XFRAME (w->frame); | |
73 struct device *d = XDEVICE (f->device); | |
74 | |
75 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); | |
76 Display *dpy = DEVICE_X_DISPLAY (d); | |
77 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f)); | |
78 Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel; | |
79 Lisp_Object tmp_pixel; | |
80 XColor tmp_color; | |
81 XGCValues gcv; | |
82 GC top_shadow_gc, bottom_shadow_gc, background_gc; | |
83 | |
84 int use_pixmap = 0; | |
85 int flip_gcs = 0; | |
86 unsigned long mask; | |
87 | |
88 assert (shadow_thickness >=0); | |
89 memset (&gcv, ~0, sizeof (XGCValues)); | |
90 | |
91 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex); | |
92 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); | |
93 | |
94 /* First, get the GC's. */ | |
95 top_shadow_pixel = tmp_color.pixel; | |
96 bottom_shadow_pixel = tmp_color.pixel; | |
97 background_pixel = tmp_color.pixel; | |
98 | |
99 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel, | |
100 background_pixel, ef->core.background_pixel); | |
101 | |
102 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex); | |
103 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); | |
104 gcv.background = tmp_color.pixel; | |
105 gcv.graphics_exposures = False; | |
106 mask = GCForeground | GCBackground | GCGraphicsExposures; | |
107 | |
108 /* If we can't distinguish one of the shadows (the color is the same as the | |
109 background), it's better to use a pixmap to generate a dithered gray. */ | |
110 if (top_shadow_pixel == background_pixel || | |
111 bottom_shadow_pixel == background_pixel) | |
112 use_pixmap = 1; | |
113 | |
114 if (use_pixmap) | |
115 { | |
116 if (DEVICE_X_GRAY_PIXMAP (d) == None) | |
117 { | |
118 DEVICE_X_GRAY_PIXMAP (d) = | |
119 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits, | |
120 gray_width, gray_height, 1, 0, 1); | |
121 } | |
122 | |
123 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex); | |
124 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); | |
125 gcv.foreground = tmp_color.pixel; | |
126 /* this is needed because the GC draws with a pixmap here */ | |
127 gcv.fill_style = FillOpaqueStippled; | |
128 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d); | |
129 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, | |
130 (mask | GCStipple | GCFillStyle)); | |
131 | |
132 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex); | |
133 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); | |
134 bottom_shadow_pixel = tmp_color.pixel; | |
135 | |
136 flip_gcs = (bottom_shadow_pixel == | |
137 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy))); | |
138 } | |
139 else | |
140 { | |
141 gcv.foreground = top_shadow_pixel; | |
142 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask); | |
143 } | |
144 | |
145 gcv.foreground = bottom_shadow_pixel; | |
146 bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask); | |
147 | |
148 if (use_pixmap && flip_gcs) | |
149 { | |
150 GC tmp_gc = bottom_shadow_gc; | |
151 bottom_shadow_gc = top_shadow_gc; | |
152 top_shadow_gc = tmp_gc; | |
153 } | |
154 | |
155 gcv.foreground = background_pixel; | |
156 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask); | |
157 | |
158 /* possibly revert the GC's This will give a depressed look to the | |
159 divider */ | |
160 if (style == EDGE_ETCHED_IN || style == EDGE_BEVEL_IN) | |
161 { | |
162 GC temp; | |
163 | |
164 temp = top_shadow_gc; | |
165 top_shadow_gc = bottom_shadow_gc; | |
166 bottom_shadow_gc = temp; | |
167 } | |
168 | |
169 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT) | |
170 shadow_thickness /= 2; | |
171 | |
172 /* Draw the shadows around the divider line */ | |
173 x_output_shadows (f, x, y, width, height, | |
174 top_shadow_gc, bottom_shadow_gc, | |
175 background_gc, shadow_thickness, edges); | |
176 | |
177 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT) | |
178 { | |
179 /* Draw the shadows around the divider line */ | |
180 x_output_shadows (f, x + shadow_thickness, y + shadow_thickness, | |
181 width - 2*shadow_thickness, height - 2*shadow_thickness, | |
182 bottom_shadow_gc, top_shadow_gc, | |
183 background_gc, shadow_thickness, edges); | |
184 } | |
185 } | |
186 | |
187 /***************************************************************************** | |
188 x_output_shadows | |
189 | |
190 Draw a shadow around the given area using the given GC's. It is the | |
191 callers responsibility to set the GC's appropriately. | |
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 | 194 x_output_shadows (struct frame *f, int x, int y, int width, int height, |
2286 | 195 GC top_shadow_gc, GC bottom_shadow_gc, |
196 GC UNUSED (background_gc), int shadow_thickness, int edges) | |
428 | 197 { |
198 struct device *d = XDEVICE (f->device); | |
199 | |
200 Display *dpy = DEVICE_X_DISPLAY (d); | |
201 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f)); | |
202 | |
203 XSegment top_shadow[20], bottom_shadow[20]; | |
204 int elt; | |
205 | |
206 if (shadow_thickness > 10) | |
207 shadow_thickness = 10; | |
208 else if (shadow_thickness < 0) | |
209 shadow_thickness = 0; | |
210 if (shadow_thickness > (width / 2)) | |
211 shadow_thickness = width / 2; | |
212 if (shadow_thickness > (height / 2)) | |
213 shadow_thickness = height / 2; | |
214 | |
215 for (elt = 0; elt < shadow_thickness; elt++) | |
216 { | |
217 int seg1 = elt; | |
218 int seg2 = (edges & EDGE_TOP) ? elt + shadow_thickness : elt; | |
219 int bot_seg2 = (edges & EDGE_BOTTOM) ? elt + shadow_thickness : elt; | |
220 | |
221 if (edges & EDGE_TOP) | |
222 { | |
223 top_shadow[seg1].x1 = x + elt; | |
224 top_shadow[seg1].x2 = x + width - elt - 1; | |
225 top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt; | |
226 } | |
227 if (edges & EDGE_LEFT) | |
228 { | |
229 top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt; | |
230 top_shadow[seg2].y1 = y + elt; | |
231 top_shadow[seg2].y2 = y + height - elt - 1; | |
232 } | |
233 if (edges & EDGE_BOTTOM) | |
234 { | |
235 bottom_shadow[seg1].x1 = x + elt; | |
236 bottom_shadow[seg1].x2 = x + width - elt - 1; | |
237 bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1; | |
238 } | |
239 if (edges & EDGE_RIGHT) | |
240 { | |
241 bottom_shadow[bot_seg2].x1 = bottom_shadow[bot_seg2].x2 = x + width - elt - 1; | |
242 bottom_shadow[bot_seg2].y1 = y + elt; | |
243 bottom_shadow[bot_seg2].y2 = y + height - elt - 1; | |
244 } | |
245 } | |
246 | |
247 XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow, | |
248 ((edges & EDGE_TOP) ? shadow_thickness : 0) | |
249 + ((edges & EDGE_LEFT) ? shadow_thickness : 0)); | |
250 XDrawSegments (dpy, x_win, bottom_shadow_gc, bottom_shadow, | |
251 ((edges & EDGE_BOTTOM) ? shadow_thickness : 0) | |
252 + ((edges & EDGE_RIGHT) ? shadow_thickness : 0)); | |
253 } | |
254 | |
255 /***************************************************************************** | |
256 x_generate_shadow_pixels | |
257 | |
258 Given three pixels (top shadow, bottom shadow, background) massage | |
259 the top and bottom shadow colors to guarantee that they differ. The | |
260 background pixels are not allowed to be modified. | |
261 | |
262 This function modifies its parameters. | |
263 | |
264 This code is modified from code blatantly stolen from lwlib/xlwmenu.c | |
265 ****************************************************************************/ | |
266 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ | |
267 ? ((unsigned long) (x)) : ((unsigned long) (y))) | |
268 | |
269 void | |
270 x_generate_shadow_pixels (struct frame *f, unsigned long *top_shadow, | |
271 unsigned long *bottom_shadow, | |
272 unsigned long background, | |
273 unsigned long core_background) | |
274 { | |
275 struct device *d = XDEVICE (f->device); | |
276 Display *dpy = DEVICE_X_DISPLAY (d); | |
277 Colormap cmap = DEVICE_X_COLORMAP (d); | |
278 Visual *visual = DEVICE_X_VISUAL (d); | |
279 | |
280 XColor topc, botc; | |
281 int top_frobbed = 0, bottom_frobbed = 0; | |
282 | |
283 /* If the top shadow is the same color as the background, try to | |
284 adjust it. */ | |
285 if (*top_shadow == background) | |
286 { | |
287 topc.pixel = background; | |
288 XQueryColor (dpy, cmap, &topc); | |
289 /* don't overflow/wrap! */ | |
290 topc.red = MINL (65535, (unsigned long) topc.red * 6 / 5); | |
291 topc.green = MINL (65535, (unsigned long) topc.green * 6 / 5); | |
292 topc.blue = MINL (65535, (unsigned long) topc.blue * 6 / 5); | |
3094 | 293 if (x_allocate_nearest_color (dpy, cmap, visual, &topc)) |
428 | 294 { |
295 *top_shadow = topc.pixel; | |
296 top_frobbed = 1; | |
297 } | |
298 } | |
299 | |
300 /* If the bottom shadow is the same color as the background, try to | |
301 adjust it. */ | |
302 if (*bottom_shadow == background) | |
303 { | |
304 botc.pixel = background; | |
305 XQueryColor (dpy, cmap, &botc); | |
306 botc.red = (unsigned short) ((unsigned long) botc.red * 3 / 5); | |
307 botc.green = (unsigned short) ((unsigned long) botc.green * 3 / 5); | |
308 botc.blue = (unsigned short) ((unsigned long) botc.blue * 3 / 5); | |
3094 | 309 if (x_allocate_nearest_color (dpy, cmap, visual, &botc)) |
428 | 310 { |
311 *bottom_shadow = botc.pixel; | |
312 bottom_frobbed = 1; | |
313 } | |
314 } | |
315 | |
316 /* If we had to adjust both shadows, then we have to do some | |
317 additional work. */ | |
318 if (top_frobbed && bottom_frobbed) | |
319 { | |
320 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3)); | |
321 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3)); | |
322 if (bot_avg > top_avg) | |
323 { | |
324 Pixel tmp = *top_shadow; | |
325 | |
326 *top_shadow = *bottom_shadow; | |
327 *bottom_shadow = tmp; | |
328 } | |
329 else if (topc.pixel == botc.pixel) | |
330 { | |
331 if (botc.pixel == background) | |
332 *top_shadow = core_background; | |
333 else | |
334 *bottom_shadow = background; | |
335 } | |
336 } | |
337 } | |
338 | |
339 | |
340 /* Make audible bell. */ | |
341 | |
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 | 344 { |
345 Display *display = DEVICE_X_DISPLAY (d); | |
346 | |
347 if (volume < 0) volume = 0; | |
348 else if (volume > 100) volume = 100; | |
349 if (pitch < 0 && duration < 0) | |
350 { | |
351 XBell (display, (volume * 2) - 100); | |
352 XFlush (display); | |
353 } | |
354 else | |
355 { | |
356 XKeyboardState state; | |
357 XKeyboardControl ctl; | |
358 XSync (display, 0); | |
359 /* #### grab server? */ | |
360 XGetKeyboardControl (display, &state); | |
361 | |
664 | 362 ctl.bell_pitch = (pitch >= 0 ? pitch : (int) state.bell_pitch); |
363 ctl.bell_duration = (duration >= 0 ? duration : (int) state.bell_duration); | |
428 | 364 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl); |
365 | |
366 XBell (display, (volume * 2) - 100); | |
367 | |
368 ctl.bell_pitch = state.bell_pitch; | |
369 ctl.bell_duration = state.bell_duration; | |
370 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl); | |
371 | |
372 /* #### ungrab server? */ | |
373 XSync (display, 0); | |
374 } | |
375 } |