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.
|
793
|
5 Copyright (C) 2002 Ben Wing.
|
428
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
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
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 /* Author: Chuck Thompson */
|
|
27
|
|
28 /* Lots of work done by Ben Wing for Mule */
|
|
29
|
|
30 #include <config.h>
|
|
31 #include "lisp.h"
|
|
32
|
|
33 #include "buffer.h"
|
|
34 #include "debug.h"
|
872
|
35 #include "device-impl.h"
|
428
|
36 #include "faces.h"
|
800
|
37 #include "file-coding.h"
|
872
|
38 #include "frame-impl.h"
|
428
|
39 #include "gutter.h"
|
|
40 #include "redisplay.h"
|
|
41 #include "sysdep.h"
|
|
42 #include "window.h"
|
800
|
43
|
|
44 #ifdef MULE
|
|
45 #include "mule-ccl.h"
|
|
46 #endif
|
|
47
|
872
|
48 #include "console-x-impl.h"
|
800
|
49 #include "glyphs-x.h"
|
872
|
50 #include "objects-x-impl.h"
|
800
|
51 #include "xgccache.h"
|
|
52
|
|
53 #include "EmacsFrame.h"
|
|
54 #include "EmacsFrameP.h"
|
428
|
55
|
|
56 #include "sysproc.h" /* for select() */
|
|
57
|
800
|
58 #include <X11/bitmaps/gray>
|
428
|
59
|
|
60 /* Number of pixels below each line. */
|
|
61 int x_interline_space; /* #### implement me */
|
|
62
|
|
63 #define EOL_CURSOR_WIDTH 5
|
|
64
|
|
65 static void x_output_vertical_divider (struct window *w, int clear);
|
|
66 static void x_output_blank (struct window *w, struct display_line *dl,
|
|
67 struct rune *rb, int start_pixpos,
|
|
68 int cursor_start, int cursor_width);
|
|
69 static void x_output_hline (struct window *w, struct display_line *dl,
|
|
70 struct rune *rb);
|
|
71 static void x_redraw_exposed_window (struct window *w, int x, int y,
|
|
72 int width, int height);
|
|
73 static void x_redraw_exposed_windows (Lisp_Object window, int x, int y,
|
|
74 int width, int height);
|
|
75 static void x_output_eol_cursor (struct window *w, struct display_line *dl,
|
|
76 int xpos, face_index findex);
|
|
77 static void x_clear_frame (struct frame *f);
|
|
78 static void x_clear_frame_windows (Lisp_Object window);
|
|
79
|
|
80
|
|
81 /* Note: We do not use the Xmb*() functions and XFontSets.
|
|
82 Those functions are generally losing for a number of reasons:
|
|
83
|
|
84 1) They only support one locale (e.g. you could display
|
|
85 Japanese and ASCII text, but not mixed Japanese/Chinese
|
|
86 text). You could maybe call setlocale() frequently
|
|
87 to try to deal with this, but that would generally
|
|
88 fail because an XFontSet is tied to one locale and
|
|
89 won't have the other character sets in it.
|
|
90 2) Not all (or even very many) OS's support the useful
|
|
91 locales. For example, as far as I know SunOS and
|
|
92 Solaris only support the Japanese locale if you get the
|
|
93 special Asian-language version of the OS. Yuck yuck
|
|
94 yuck. Linux doesn't support the Japanese locale at
|
|
95 all.
|
|
96 3) The locale support in X only exists in R5, not in R4.
|
|
97 (Not sure how big of a problem this is: how many
|
|
98 people are using R4?)
|
|
99 4) Who knows if the multi-byte text format (which is locale-
|
|
100 specific) is even the same for the same locale on
|
|
101 different OS's? It's not even documented anywhere that
|
|
102 I can find what the multi-byte text format for the
|
|
103 Japanese locale under SunOS and Solaris is, but I assume
|
|
104 it's EUC.
|
|
105 */
|
|
106
|
|
107 struct textual_run
|
|
108 {
|
|
109 Lisp_Object charset;
|
|
110 unsigned char *ptr;
|
|
111 int len;
|
|
112 int dimension;
|
|
113 };
|
|
114
|
|
115 /* Separate out the text in DYN into a series of textual runs of a
|
|
116 particular charset. Also convert the characters as necessary into
|
|
117 the format needed by XDrawImageString(), XDrawImageString16(), et
|
|
118 al. (This means converting to one or two byte format, possibly
|
|
119 tweaking the high bits, and possibly running a CCL program.) You
|
|
120 must pre-allocate the space used and pass it in. (This is done so
|
851
|
121 you can ALLOCA () the space.) You need to allocate (2 * len) bytes
|
428
|
122 of TEXT_STORAGE and (len * sizeof (struct textual_run)) bytes of
|
|
123 RUN_STORAGE, where LEN is the length of the dynarr.
|
|
124
|
|
125 Returns the number of runs actually used. */
|
|
126
|
|
127 static int
|
|
128 separate_textual_runs (unsigned char *text_storage,
|
|
129 struct textual_run *run_storage,
|
867
|
130 const Ichar *str, Charcount len)
|
428
|
131 {
|
|
132 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
|
|
133 possible valid charset when
|
|
134 MULE is not defined */
|
|
135 int runs_so_far = 0;
|
|
136 int i;
|
|
137 #ifdef MULE
|
|
138 struct ccl_program char_converter;
|
|
139 int need_ccl_conversion = 0;
|
|
140 #endif
|
|
141
|
|
142 for (i = 0; i < len; i++)
|
|
143 {
|
867
|
144 Ichar ch = str[i];
|
428
|
145 Lisp_Object charset;
|
|
146 int byte1, byte2;
|
|
147 int dimension;
|
|
148 int graphic;
|
|
149
|
867
|
150 BREAKUP_ICHAR (ch, charset, byte1, byte2);
|
428
|
151 dimension = XCHARSET_DIMENSION (charset);
|
|
152 graphic = XCHARSET_GRAPHIC (charset);
|
|
153
|
|
154 if (!EQ (charset, prev_charset))
|
|
155 {
|
|
156 run_storage[runs_so_far].ptr = text_storage;
|
|
157 run_storage[runs_so_far].charset = charset;
|
|
158 run_storage[runs_so_far].dimension = dimension;
|
|
159
|
|
160 if (runs_so_far)
|
|
161 {
|
|
162 run_storage[runs_so_far - 1].len =
|
|
163 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
164 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
165 run_storage[runs_so_far - 1].len >>= 1;
|
|
166 }
|
|
167 runs_so_far++;
|
|
168 prev_charset = charset;
|
|
169 #ifdef MULE
|
|
170 {
|
|
171 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
|
444
|
172 if ((!NILP (ccl_prog))
|
|
173 && (setup_ccl_program (&char_converter, ccl_prog) >= 0))
|
|
174 need_ccl_conversion = 1;
|
428
|
175 }
|
|
176 #endif
|
|
177 }
|
|
178
|
|
179 if (graphic == 0)
|
|
180 {
|
|
181 byte1 &= 0x7F;
|
|
182 byte2 &= 0x7F;
|
|
183 }
|
|
184 else if (graphic == 1)
|
|
185 {
|
|
186 byte1 |= 0x80;
|
|
187 byte2 |= 0x80;
|
|
188 }
|
|
189 #ifdef MULE
|
|
190 if (need_ccl_conversion)
|
|
191 {
|
|
192 char_converter.reg[0] = XCHARSET_ID (charset);
|
|
193 char_converter.reg[1] = byte1;
|
|
194 char_converter.reg[2] = byte2;
|
|
195 ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
|
|
196 byte1 = char_converter.reg[1];
|
|
197 byte2 = char_converter.reg[2];
|
|
198 }
|
|
199 #endif
|
|
200 *text_storage++ = (unsigned char) byte1;
|
|
201 if (dimension == 2)
|
|
202 *text_storage++ = (unsigned char) byte2;
|
|
203 }
|
|
204
|
|
205 if (runs_so_far)
|
|
206 {
|
|
207 run_storage[runs_so_far - 1].len =
|
|
208 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
209 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
210 run_storage[runs_so_far - 1].len >>= 1;
|
|
211 }
|
|
212
|
|
213 return runs_so_far;
|
|
214 }
|
|
215
|
|
216 /****************************************************************************/
|
|
217 /* */
|
|
218 /* X output routines */
|
|
219 /* */
|
|
220 /****************************************************************************/
|
|
221
|
|
222 static int
|
|
223 x_text_width_single_run (struct face_cachel *cachel, struct textual_run *run)
|
|
224 {
|
|
225 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
|
440
|
226 Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
|
428
|
227 if (!fi->proportional_p)
|
|
228 return fi->width * run->len;
|
|
229 else
|
|
230 {
|
|
231 if (run->dimension == 2)
|
|
232 return XTextWidth16 (FONT_INSTANCE_X_FONT (fi),
|
|
233 (XChar2b *) run->ptr, run->len);
|
|
234 else
|
|
235 return XTextWidth (FONT_INSTANCE_X_FONT (fi),
|
|
236 (char *) run->ptr, run->len);
|
|
237 }
|
|
238 }
|
|
239
|
|
240 /*
|
|
241 x_text_width
|
|
242
|
|
243 Given a string and a face, return the string's length in pixels when
|
|
244 displayed in the font associated with the face.
|
|
245 */
|
|
246
|
|
247 static int
|
867
|
248 x_text_width (struct frame *f, struct face_cachel *cachel, const Ichar *str,
|
428
|
249 Charcount len)
|
|
250 {
|
|
251 int width_so_far = 0;
|
851
|
252 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
|
428
|
253 struct textual_run *runs = alloca_array (struct textual_run, len);
|
|
254 int nruns;
|
|
255 int i;
|
|
256
|
|
257 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
258
|
|
259 for (i = 0; i < nruns; i++)
|
|
260 width_so_far += x_text_width_single_run (cachel, runs + i);
|
|
261
|
|
262 return width_so_far;
|
|
263 }
|
|
264
|
|
265 /*****************************************************************************
|
|
266 x_divider_height
|
|
267
|
|
268 Return the height of the horizontal divider. This is a function because
|
|
269 divider_height is a device method.
|
|
270
|
|
271 #### If we add etched horizontal divider lines this will have to get
|
|
272 smarter.
|
|
273 ****************************************************************************/
|
|
274 static int
|
|
275 x_divider_height (void)
|
|
276 {
|
|
277 return 1;
|
|
278 }
|
|
279
|
|
280 /*****************************************************************************
|
|
281 x_eol_cursor_width
|
|
282
|
|
283 Return the width of the end-of-line cursor. This is a function
|
|
284 because eol_cursor_width is a device method.
|
|
285 ****************************************************************************/
|
|
286 static int
|
|
287 x_eol_cursor_width (void)
|
|
288 {
|
|
289 return EOL_CURSOR_WIDTH;
|
|
290 }
|
|
291
|
|
292 /*****************************************************************************
|
442
|
293 x_window_output_begin
|
428
|
294
|
|
295 Perform any necessary initialization prior to an update.
|
|
296 ****************************************************************************/
|
|
297 static void
|
442
|
298 x_window_output_begin (struct window *w)
|
428
|
299 {
|
|
300 }
|
|
301
|
|
302 /*****************************************************************************
|
442
|
303 x_window_output_end
|
428
|
304
|
|
305 Perform any necessary flushing of queues when an update has completed.
|
|
306 ****************************************************************************/
|
|
307 static void
|
442
|
308 x_window_output_end (struct window *w)
|
428
|
309 {
|
442
|
310 XFlush (DEVICE_X_DISPLAY (WINDOW_XDEVICE (w)));
|
428
|
311 }
|
|
312
|
|
313 /*****************************************************************************
|
|
314 x_output_display_block
|
|
315
|
|
316 Given a display line, a block number for that start line, output all
|
|
317 runes between start and end in the specified display block.
|
|
318 ****************************************************************************/
|
|
319 static void
|
|
320 x_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
321 int start, int end, int start_pixpos, int cursor_start,
|
|
322 int cursor_width, int cursor_height)
|
|
323 {
|
|
324 struct frame *f = XFRAME (w->frame);
|
867
|
325 Ichar_dynarr *buf = Dynarr_new (Ichar);
|
428
|
326 Lisp_Object window;
|
|
327
|
|
328 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
329 rune_dynarr *rba = db->runes;
|
|
330 struct rune *rb;
|
|
331
|
|
332 int elt = start;
|
|
333 face_index findex;
|
|
334 int xpos, width = 0;
|
|
335 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
336 MULE is not defined */
|
|
337
|
793
|
338 window = wrap_window (w);
|
428
|
339 rb = Dynarr_atp (rba, start);
|
|
340
|
|
341 if (!rb)
|
|
342 /* Nothing to do so don't do anything. */
|
|
343 return;
|
|
344
|
|
345 findex = rb->findex;
|
|
346 xpos = rb->xpos;
|
|
347 if (rb->type == RUNE_CHAR)
|
867
|
348 charset = ichar_charset (rb->object.chr.ch);
|
428
|
349
|
|
350 if (end < 0)
|
|
351 end = Dynarr_length (rba);
|
|
352 Dynarr_reset (buf);
|
|
353
|
|
354 while (elt < end)
|
|
355 {
|
|
356 rb = Dynarr_atp (rba, elt);
|
|
357
|
|
358 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
359 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
867
|
360 && EQ (charset, ichar_charset (rb->object.chr.ch)))
|
428
|
361 {
|
|
362 Dynarr_add (buf, rb->object.chr.ch);
|
|
363 width += rb->width;
|
|
364 elt++;
|
|
365 }
|
|
366 else
|
|
367 {
|
|
368 if (Dynarr_length (buf))
|
|
369 {
|
|
370 x_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
371 findex, 0, cursor_start, cursor_width,
|
|
372 cursor_height);
|
|
373 xpos = rb->xpos;
|
|
374 width = 0;
|
|
375 }
|
|
376 Dynarr_reset (buf);
|
|
377 width = 0;
|
|
378
|
|
379 if (rb->type == RUNE_CHAR)
|
|
380 {
|
|
381 findex = rb->findex;
|
|
382 xpos = rb->xpos;
|
867
|
383 charset = ichar_charset (rb->object.chr.ch);
|
428
|
384
|
|
385 if (rb->cursor_type == CURSOR_ON)
|
|
386 {
|
|
387 if (rb->object.chr.ch == '\n')
|
|
388 {
|
|
389 x_output_eol_cursor (w, dl, xpos, findex);
|
|
390 }
|
|
391 else
|
|
392 {
|
|
393 Dynarr_add (buf, rb->object.chr.ch);
|
|
394 x_output_string (w, dl, buf, xpos, 0, start_pixpos,
|
|
395 rb->width, findex, 1,
|
|
396 cursor_start, cursor_width,
|
|
397 cursor_height);
|
|
398 Dynarr_reset (buf);
|
|
399 }
|
|
400
|
|
401 xpos += rb->width;
|
|
402 elt++;
|
|
403 }
|
|
404 else if (rb->object.chr.ch == '\n')
|
|
405 {
|
|
406 /* Clear in case a cursor was formerly here. */
|
440
|
407 redisplay_clear_region (window, findex, xpos,
|
428
|
408 DISPLAY_LINE_YPOS (dl),
|
440
|
409 rb->width,
|
428
|
410 DISPLAY_LINE_HEIGHT (dl));
|
|
411 elt++;
|
|
412 }
|
|
413 }
|
|
414 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
415 {
|
|
416 if (rb->type == RUNE_BLANK)
|
|
417 x_output_blank (w, dl, rb, start_pixpos, cursor_start,
|
|
418 cursor_width);
|
|
419 else
|
|
420 {
|
|
421 /* #### Our flagging of when we need to redraw the
|
|
422 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
423 by the modeline at the moment it is a good bet
|
|
424 that if it gets redrawn then we should also
|
|
425 redraw the shadows. This won't be true forever.
|
|
426 We borrow the shadow_thickness_changed flag for
|
|
427 now. */
|
|
428 w->shadow_thickness_changed = 1;
|
|
429 x_output_hline (w, dl, rb);
|
|
430 }
|
|
431
|
|
432 elt++;
|
|
433 if (elt < end)
|
|
434 {
|
|
435 rb = Dynarr_atp (rba, elt);
|
|
436
|
|
437 findex = rb->findex;
|
|
438 xpos = rb->xpos;
|
|
439 }
|
|
440 }
|
|
441 else if (rb->type == RUNE_DGLYPH)
|
|
442 {
|
|
443 Lisp_Object instance;
|
|
444 struct display_box dbox;
|
|
445 struct display_glyph_area dga;
|
819
|
446
|
428
|
447 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
|
819
|
448 rb->object.dglyph.yoffset, start_pixpos,
|
|
449 rb->width, &dbox, &dga);
|
428
|
450
|
793
|
451 window = wrap_window (w);
|
428
|
452 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
793
|
453 window, ERROR_ME_DEBUG_WARN, 1);
|
428
|
454 findex = rb->findex;
|
|
455
|
|
456 if (IMAGE_INSTANCEP (instance))
|
442
|
457 {
|
|
458 switch (XIMAGE_INSTANCE_TYPE (instance))
|
428
|
459 {
|
442
|
460 case IMAGE_MONO_PIXMAP:
|
|
461 case IMAGE_COLOR_PIXMAP:
|
|
462 redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
|
|
463 cursor_start, cursor_width,
|
|
464 cursor_height, 0);
|
|
465 break;
|
428
|
466
|
442
|
467 case IMAGE_WIDGET:
|
|
468 if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance),
|
|
469 Qlayout))
|
|
470 {
|
|
471 redisplay_output_layout (window, instance, &dbox, &dga, findex,
|
|
472 cursor_start, cursor_width,
|
|
473 cursor_height);
|
|
474 break;
|
|
475 }
|
|
476 case IMAGE_SUBWINDOW:
|
|
477 redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
|
|
478 cursor_start, cursor_width,
|
|
479 cursor_height);
|
|
480 break;
|
428
|
481
|
442
|
482 case IMAGE_NOTHING:
|
|
483 /* nothing is as nothing does */
|
|
484 break;
|
428
|
485
|
442
|
486 case IMAGE_TEXT:
|
|
487 case IMAGE_POINTER:
|
|
488 default:
|
|
489 abort ();
|
|
490 }
|
|
491 IMAGE_INSTANCE_OPTIMIZE_OUTPUT
|
|
492 (XIMAGE_INSTANCE (instance)) = 0;
|
|
493 }
|
428
|
494
|
|
495 xpos += rb->width;
|
|
496 elt++;
|
|
497 }
|
|
498 else
|
|
499 abort ();
|
|
500 }
|
|
501 }
|
|
502
|
|
503 if (Dynarr_length (buf))
|
|
504 x_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex,
|
|
505 0, cursor_start, cursor_width, cursor_height);
|
|
506
|
|
507 /* #### This is really conditionalized well for optimized
|
|
508 performance. */
|
|
509 if (dl->modeline
|
|
510 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
511 && (f->clear
|
|
512 || f->windows_structure_changed
|
|
513 || w->shadow_thickness_changed))
|
|
514 bevel_modeline (w, dl);
|
|
515
|
|
516 Dynarr_free (buf);
|
|
517 }
|
|
518
|
|
519 /*****************************************************************************
|
|
520 x_bevel_area
|
|
521
|
450
|
522 Draw shadows for the given area in the given face.
|
428
|
523 ****************************************************************************/
|
|
524 static void
|
|
525 x_bevel_area (struct window *w, face_index findex,
|
|
526 int x, int y, int width, int height,
|
|
527 int shadow_thickness, int edges, enum edge_style style)
|
|
528 {
|
|
529 struct frame *f = XFRAME (w->frame);
|
|
530 struct device *d = XDEVICE (f->device);
|
|
531
|
|
532 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
|
|
533 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
534 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
535 Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel;
|
|
536 Lisp_Object tmp_pixel;
|
|
537 XColor tmp_color;
|
|
538 XGCValues gcv;
|
|
539 GC top_shadow_gc, bottom_shadow_gc, background_gc;
|
|
540
|
|
541 int use_pixmap = 0;
|
|
542 int flip_gcs = 0;
|
|
543 unsigned long mask;
|
|
544
|
|
545 assert (shadow_thickness >=0);
|
|
546 memset (&gcv, ~0, sizeof (XGCValues));
|
|
547
|
|
548 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
549 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
550
|
|
551 /* First, get the GC's. */
|
|
552 top_shadow_pixel = tmp_color.pixel;
|
|
553 bottom_shadow_pixel = tmp_color.pixel;
|
|
554 background_pixel = tmp_color.pixel;
|
|
555
|
|
556 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
|
|
557 background_pixel, ef->core.background_pixel);
|
|
558
|
|
559 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
560 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
561 gcv.background = tmp_color.pixel;
|
|
562 gcv.graphics_exposures = False;
|
|
563 mask = GCForeground | GCBackground | GCGraphicsExposures;
|
|
564
|
|
565 /* If we can't distinguish one of the shadows (the color is the same as the
|
|
566 background), it's better to use a pixmap to generate a dithered gray. */
|
|
567 if (top_shadow_pixel == background_pixel ||
|
|
568 bottom_shadow_pixel == background_pixel)
|
|
569 use_pixmap = 1;
|
|
570
|
|
571 if (use_pixmap)
|
|
572 {
|
|
573 if (DEVICE_X_GRAY_PIXMAP (d) == None)
|
|
574 {
|
|
575 DEVICE_X_GRAY_PIXMAP (d) =
|
|
576 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits,
|
|
577 gray_width, gray_height, 1, 0, 1);
|
|
578 }
|
|
579
|
|
580 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
581 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
582 gcv.foreground = tmp_color.pixel;
|
|
583 /* this is needed because the GC draws with a pixmap here */
|
|
584 gcv.fill_style = FillOpaqueStippled;
|
|
585 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
|
|
586 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
|
|
587 (mask | GCStipple | GCFillStyle));
|
|
588
|
|
589 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
590 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
591 bottom_shadow_pixel = tmp_color.pixel;
|
|
592
|
|
593 flip_gcs = (bottom_shadow_pixel ==
|
|
594 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy)));
|
|
595 }
|
|
596 else
|
|
597 {
|
|
598 gcv.foreground = top_shadow_pixel;
|
|
599 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
|
|
600 }
|
|
601
|
|
602 gcv.foreground = bottom_shadow_pixel;
|
|
603 bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
|
|
604
|
|
605 if (use_pixmap && flip_gcs)
|
|
606 {
|
|
607 GC tmp_gc = bottom_shadow_gc;
|
|
608 bottom_shadow_gc = top_shadow_gc;
|
|
609 top_shadow_gc = tmp_gc;
|
|
610 }
|
|
611
|
|
612 gcv.foreground = background_pixel;
|
|
613 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
|
|
614
|
|
615 /* possibly revert the GC's This will give a depressed look to the
|
|
616 divider */
|
|
617 if (style == EDGE_ETCHED_IN || style == EDGE_BEVEL_IN)
|
|
618 {
|
|
619 GC temp;
|
|
620
|
|
621 temp = top_shadow_gc;
|
|
622 top_shadow_gc = bottom_shadow_gc;
|
|
623 bottom_shadow_gc = temp;
|
|
624 }
|
|
625
|
|
626 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
|
|
627 shadow_thickness /= 2;
|
|
628
|
|
629 /* Draw the shadows around the divider line */
|
|
630 x_output_shadows (f, x, y, width, height,
|
|
631 top_shadow_gc, bottom_shadow_gc,
|
|
632 background_gc, shadow_thickness, edges);
|
|
633
|
|
634 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
|
|
635 {
|
|
636 /* Draw the shadows around the divider line */
|
|
637 x_output_shadows (f, x + shadow_thickness, y + shadow_thickness,
|
|
638 width - 2*shadow_thickness, height - 2*shadow_thickness,
|
|
639 bottom_shadow_gc, top_shadow_gc,
|
|
640 background_gc, shadow_thickness, edges);
|
|
641 }
|
|
642 }
|
|
643
|
|
644 /*****************************************************************************
|
|
645 x_get_gc
|
|
646
|
|
647 Given a number of parameters return a GC with those properties.
|
|
648 ****************************************************************************/
|
|
649 static GC
|
|
650 x_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
|
|
651 Lisp_Object bg_pmap, Lisp_Object lwidth)
|
|
652 {
|
|
653 XGCValues gcv;
|
|
654 unsigned long mask;
|
|
655
|
|
656 memset (&gcv, ~0, sizeof (XGCValues));
|
|
657 gcv.graphics_exposures = False;
|
|
658 /* Make absolutely sure that we don't pick up a clipping region in
|
|
659 the GC returned by this function. */
|
|
660 gcv.clip_mask = None;
|
|
661 gcv.clip_x_origin = 0;
|
|
662 gcv.clip_y_origin = 0;
|
|
663 gcv.fill_style = FillSolid;
|
|
664 mask = GCGraphicsExposures | GCClipMask | GCClipXOrigin | GCClipYOrigin;
|
|
665 mask |= GCFillStyle;
|
|
666
|
|
667 if (!NILP (font))
|
|
668 {
|
|
669 gcv.font = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))->fid;
|
|
670 mask |= GCFont;
|
|
671 }
|
|
672
|
|
673 /* evil kludge! */
|
|
674 if (!NILP (fg) && !COLOR_INSTANCEP (fg) && !INTP (fg))
|
|
675 {
|
|
676 /* #### I fixed once case where this was getting it. It was a
|
|
677 bad macro expansion (compiler bug). */
|
442
|
678 stderr_out ("Help! x_get_gc got a bogus fg value! fg = ");
|
428
|
679 debug_print (fg);
|
|
680 fg = Qnil;
|
|
681 }
|
|
682
|
|
683 if (!NILP (fg))
|
|
684 {
|
|
685 if (COLOR_INSTANCEP (fg))
|
|
686 gcv.foreground = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (fg)).pixel;
|
|
687 else
|
|
688 gcv.foreground = XINT (fg);
|
|
689 mask |= GCForeground;
|
|
690 }
|
|
691
|
|
692 if (!NILP (bg))
|
|
693 {
|
|
694 if (COLOR_INSTANCEP (bg))
|
|
695 gcv.background = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (bg)).pixel;
|
|
696 else
|
|
697 gcv.background = XINT (bg);
|
|
698 mask |= GCBackground;
|
|
699 }
|
|
700
|
|
701 /* This special case comes from a request to draw text with a face which has
|
|
702 the dim property. We'll use a stippled foreground GC. */
|
|
703 if (EQ (bg_pmap, Qdim))
|
|
704 {
|
|
705 assert (DEVICE_X_GRAY_PIXMAP (d) != None);
|
|
706
|
|
707 gcv.fill_style = FillStippled;
|
|
708 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
|
|
709 mask |= (GCFillStyle | GCStipple);
|
|
710 }
|
|
711 else if (IMAGE_INSTANCEP (bg_pmap)
|
|
712 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
713 {
|
|
714 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
|
|
715 {
|
|
716 gcv.fill_style = FillOpaqueStippled;
|
|
717 gcv.stipple = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
|
|
718 mask |= (GCStipple | GCFillStyle);
|
|
719 }
|
|
720 else
|
|
721 {
|
|
722 gcv.fill_style = FillTiled;
|
|
723 gcv.tile = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
|
|
724 mask |= (GCTile | GCFillStyle);
|
|
725 }
|
|
726 }
|
|
727
|
|
728 if (!NILP (lwidth))
|
|
729 {
|
|
730 gcv.line_width = XINT (lwidth);
|
|
731 mask |= GCLineWidth;
|
|
732 }
|
|
733
|
|
734 return gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
|
|
735 }
|
|
736
|
|
737 /*****************************************************************************
|
|
738 x_output_string
|
|
739
|
|
740 Given a string and a starting position, output that string in the
|
|
741 given face. If cursor is true, draw a cursor around the string.
|
|
742 Correctly handles multiple charsets in the string.
|
|
743
|
|
744 The meaning of the parameters is something like this:
|
|
745
|
|
746 W Window that the text is to be displayed in.
|
|
747 DL Display line that this text is on. The values in the
|
|
748 structure are used to determine the vertical position and
|
|
749 clipping range of the text.
|
867
|
750 BUF Dynamic array of Ichars specifying what is actually to be
|
428
|
751 drawn.
|
|
752 XPOS X position in pixels where the text should start being drawn.
|
|
753 XOFFSET Number of pixels to be chopped off the left side of the
|
|
754 text. The effect is as if the text were shifted to the
|
|
755 left this many pixels and clipped at XPOS.
|
|
756 CLIP_START Clip everything left of this X position.
|
|
757 WIDTH Clip everything right of XPOS + WIDTH.
|
|
758 FINDEX Index for the face cache element describing how to display
|
|
759 the text.
|
|
760 CURSOR #### I don't understand this. There's something
|
|
761 strange and overcomplexified with this variable.
|
|
762 Chuck, explain please?
|
|
763 CURSOR_START Starting X position of cursor.
|
|
764 CURSOR_WIDTH Width of cursor in pixels.
|
|
765 CURSOR_HEIGHT Height of cursor in pixels.
|
|
766
|
|
767 Starting Y position of cursor is the top of the text line.
|
|
768 The cursor is drawn sometimes whether or not CURSOR is set. ???
|
|
769 ****************************************************************************/
|
|
770 void
|
|
771 x_output_string (struct window *w, struct display_line *dl,
|
867
|
772 Ichar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
428
|
773 int width, face_index findex, int cursor,
|
|
774 int cursor_start, int cursor_width, int cursor_height)
|
|
775 {
|
|
776 /* General variables */
|
|
777 struct frame *f = XFRAME (w->frame);
|
|
778 struct device *d = XDEVICE (f->device);
|
|
779 Lisp_Object device;
|
|
780 Lisp_Object window;
|
|
781 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
782 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
783
|
|
784 int clip_end;
|
|
785
|
|
786 /* Cursor-related variables */
|
|
787 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
788 int cursor_clip;
|
|
789 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
790 WINDOW_BUFFER (w));
|
|
791 struct face_cachel *cursor_cachel = 0;
|
|
792
|
|
793 /* Text-related variables */
|
|
794 Lisp_Object bg_pmap;
|
|
795 GC bgc, gc;
|
|
796 int height;
|
|
797 int len = Dynarr_length (buf);
|
851
|
798 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
|
428
|
799 struct textual_run *runs = alloca_array (struct textual_run, len);
|
|
800 int nruns;
|
|
801 int i;
|
|
802 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
803
|
793
|
804 device = wrap_device (d);
|
|
805 window = wrap_window (w);
|
428
|
806
|
|
807 if (width < 0)
|
|
808 width = x_text_width (f, cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
809 height = DISPLAY_LINE_HEIGHT (dl);
|
|
810
|
|
811 /* Regularize the variables passed in. */
|
|
812
|
|
813 if (clip_start < xpos)
|
|
814 clip_start = xpos;
|
|
815 clip_end = xpos + width;
|
|
816 if (clip_start >= clip_end)
|
|
817 /* It's all clipped out. */
|
|
818 return;
|
|
819
|
|
820 xpos -= xoffset;
|
|
821
|
|
822 /* make sure the area we are about to display is subwindow free. */
|
|
823 redisplay_unmap_subwindows_maybe (f, clip_start, DISPLAY_LINE_YPOS (dl),
|
|
824 clip_end - clip_start, DISPLAY_LINE_HEIGHT (dl));
|
|
825
|
|
826 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
|
|
827 Dynarr_length (buf));
|
|
828
|
|
829 cursor_clip = (cursor_start >= clip_start &&
|
|
830 cursor_start < clip_end);
|
|
831
|
|
832 /* This cursor code is really a mess. */
|
|
833 if (!NILP (w->text_cursor_visible_p)
|
|
834 && (cursor
|
|
835 || cursor_clip
|
|
836 || (cursor_width
|
|
837 && (cursor_start + cursor_width >= clip_start)
|
|
838 && !NILP (bar_cursor_value))))
|
|
839 {
|
|
840 /* These have to be in separate statements in order to avoid a
|
|
841 compiler bug. */
|
|
842 face_index sucks = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
843 cursor_cachel = WINDOW_FACE_CACHEL (w, sucks);
|
|
844
|
|
845 /* We have to reset this since any call to WINDOW_FACE_CACHEL
|
|
846 may cause the cache to resize and any pointers to it to
|
|
847 become invalid. */
|
|
848 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
849 }
|
|
850
|
|
851 #ifdef HAVE_XIM
|
|
852 if (cursor && focus && (cursor_start == clip_start) && cursor_height)
|
|
853 XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2);
|
|
854 #endif /* HAVE_XIM */
|
|
855
|
|
856 bg_pmap = cachel->background_pixmap;
|
|
857 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
858 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
859 bg_pmap = Qnil;
|
|
860
|
|
861 if ((cursor && focus && NILP (bar_cursor_value)
|
|
862 && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
|
|
863 bgc = 0;
|
|
864 else
|
|
865 bgc = x_get_gc (d, Qnil, cachel->foreground, cachel->background,
|
|
866 bg_pmap, Qnil);
|
|
867
|
|
868 if (bgc)
|
|
869 XFillRectangle (dpy, x_win, bgc, clip_start,
|
|
870 DISPLAY_LINE_YPOS (dl), clip_end - clip_start,
|
|
871 height);
|
|
872
|
|
873 for (i = 0; i < nruns; i++)
|
|
874 {
|
|
875 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
440
|
876 Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
428
|
877 int this_width;
|
|
878 int need_clipping;
|
|
879
|
|
880 if (EQ (font, Vthe_null_font_instance))
|
|
881 continue;
|
|
882
|
|
883 this_width = x_text_width_single_run (cachel, runs + i);
|
|
884 need_clipping = (dl->clip || clip_start > xpos ||
|
|
885 clip_end < xpos + this_width);
|
|
886
|
|
887 /* XDrawImageString only clears the area equal to the height of
|
|
888 the given font. It is possible that a font is being displayed
|
|
889 on a line taller than it is, so this would cause us to fail to
|
|
890 clear some areas. */
|
|
891 if ((int) fi->height < (int) (height + dl->clip + dl->top_clip))
|
|
892 {
|
|
893 int clear_start = max (xpos, clip_start);
|
|
894 int clear_end = min (xpos + this_width, clip_end);
|
|
895
|
|
896 if (cursor)
|
|
897 {
|
|
898 int ypos1_line, ypos1_string, ypos2_line, ypos2_string;
|
|
899
|
|
900 ypos1_string = dl->ypos - fi->ascent;
|
|
901 ypos2_string = dl->ypos + fi->descent;
|
|
902 ypos1_line = DISPLAY_LINE_YPOS (dl);
|
|
903 ypos2_line = ypos1_line + DISPLAY_LINE_HEIGHT (dl);
|
|
904
|
|
905 /* Make sure we don't clear below the real bottom of the
|
|
906 line. */
|
|
907 if (ypos1_string > ypos2_line)
|
|
908 ypos1_string = ypos2_line;
|
|
909 if (ypos2_string > ypos2_line)
|
|
910 ypos2_string = ypos2_line;
|
|
911
|
|
912 if (ypos1_line < ypos1_string)
|
|
913 {
|
|
914 redisplay_clear_region (window, findex, clear_start, ypos1_line,
|
|
915 clear_end - clear_start,
|
|
916 ypos1_string - ypos1_line);
|
|
917 }
|
|
918
|
|
919 if (ypos2_line > ypos2_string)
|
|
920 {
|
|
921 redisplay_clear_region (window, findex, clear_start, ypos2_string,
|
|
922 clear_end - clear_start,
|
|
923 ypos2_line - ypos2_string);
|
|
924 }
|
|
925 }
|
|
926 else
|
|
927 {
|
|
928 redisplay_clear_region (window, findex, clear_start,
|
|
929 DISPLAY_LINE_YPOS (dl), clear_end - clear_start,
|
|
930 height);
|
|
931 }
|
|
932 }
|
|
933
|
|
934 if (cursor && cursor_cachel && focus && NILP (bar_cursor_value))
|
|
935 gc = x_get_gc (d, font, cursor_cachel->foreground,
|
|
936 cursor_cachel->background, Qnil, Qnil);
|
|
937 else if (cachel->dim)
|
|
938 {
|
|
939 /* Ensure the gray bitmap exists */
|
|
940 if (DEVICE_X_GRAY_PIXMAP (d) == None)
|
|
941 DEVICE_X_GRAY_PIXMAP (d) =
|
|
942 XCreateBitmapFromData (dpy, x_win, (char *)gray_bits,
|
|
943 gray_width, gray_height);
|
|
944
|
|
945 /* Request a GC with the gray stipple pixmap to draw dimmed text */
|
|
946 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
|
|
947 Qdim, Qnil);
|
|
948 }
|
|
949 else
|
|
950 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
|
|
951 Qnil, Qnil);
|
|
952
|
|
953 if (need_clipping)
|
|
954 {
|
|
955 XRectangle clip_box[1];
|
|
956
|
|
957 clip_box[0].x = 0;
|
|
958 clip_box[0].y = 0;
|
|
959 clip_box[0].width = clip_end - clip_start;
|
|
960 clip_box[0].height = height;
|
|
961
|
|
962 XSetClipRectangles (dpy, gc, clip_start, DISPLAY_LINE_YPOS (dl),
|
|
963 clip_box, 1, Unsorted);
|
|
964 }
|
|
965
|
|
966 if (runs[i].dimension == 1)
|
|
967 (bgc ? XDrawString : XDrawImageString) (dpy, x_win, gc, xpos,
|
|
968 dl->ypos, (char *) runs[i].ptr,
|
|
969 runs[i].len);
|
|
970 else
|
|
971 (bgc ? XDrawString16 : XDrawImageString16) (dpy, x_win, gc, xpos,
|
|
972 dl->ypos,
|
|
973 (XChar2b *) runs[i].ptr,
|
|
974 runs[i].len);
|
|
975
|
|
976 /* We draw underlines in the same color as the text. */
|
|
977 if (cachel->underline)
|
|
978 {
|
647
|
979 int upos, uthick;
|
|
980 unsigned long upos_ext, uthick_ext;
|
428
|
981 XFontStruct *xfont;
|
|
982
|
|
983 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font));
|
647
|
984 if (!XGetFontProperty (xfont, XA_UNDERLINE_POSITION, &upos_ext))
|
428
|
985 upos = dl->descent / 2;
|
647
|
986 else
|
|
987 upos = (int) upos_ext;
|
|
988 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick_ext))
|
428
|
989 uthick = 1;
|
647
|
990 else
|
|
991 uthick = (int) uthick_ext;
|
428
|
992
|
|
993 if (dl->ypos + upos < dl->ypos + dl->descent - dl->clip)
|
|
994 {
|
|
995 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip)
|
|
996 uthick = dl->descent - dl->clip - upos;
|
|
997
|
|
998 if (uthick == 1)
|
|
999 {
|
|
1000 XDrawLine (dpy, x_win, gc, xpos, dl->ypos + upos,
|
|
1001 xpos + this_width, dl->ypos + upos);
|
|
1002 }
|
|
1003 else if (uthick > 1)
|
|
1004 {
|
|
1005 XFillRectangle (dpy, x_win, gc, xpos,
|
|
1006 dl->ypos + upos, this_width, uthick);
|
|
1007 }
|
|
1008 }
|
|
1009 }
|
|
1010
|
647
|
1011 if (cachel->strikethru)
|
|
1012 {
|
|
1013 int ascent, descent, upos, uthick;
|
|
1014 unsigned long ascent_ext, descent_ext, uthick_ext;
|
|
1015 XFontStruct *xfont;
|
428
|
1016
|
647
|
1017 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font));
|
|
1018
|
|
1019 if (!XGetFontProperty (xfont, XA_STRIKEOUT_ASCENT, &ascent_ext))
|
|
1020 ascent = xfont->ascent;
|
|
1021 else
|
|
1022 ascent = (int) ascent_ext;
|
|
1023 if (!XGetFontProperty (xfont, XA_STRIKEOUT_DESCENT, &descent_ext))
|
|
1024 descent = xfont->descent;
|
|
1025 else
|
|
1026 descent = (int) descent_ext;
|
|
1027 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick_ext))
|
|
1028 uthick = 1;
|
|
1029 else
|
|
1030 uthick = (int) uthick_ext;
|
428
|
1031
|
647
|
1032 upos = ascent - ((ascent + descent) / 2) + 1;
|
428
|
1033
|
647
|
1034 /* Generally, upos will be positive (above the baseline),so
|
|
1035 subtract */
|
|
1036 if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip)
|
|
1037 {
|
|
1038 if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip)
|
|
1039 uthick = dl->descent - dl->clip + upos;
|
|
1040
|
|
1041 if (uthick == 1)
|
428
|
1042 XDrawLine (dpy, x_win, gc, xpos, dl->ypos - upos,
|
|
1043 xpos + this_width, dl->ypos - upos);
|
647
|
1044 else if (uthick > 1)
|
428
|
1045 XFillRectangle (dpy, x_win, gc, xpos, dl->ypos + upos,
|
|
1046 this_width, uthick);
|
647
|
1047 }
|
|
1048 }
|
428
|
1049
|
|
1050 /* Restore the GC */
|
|
1051 if (need_clipping)
|
|
1052 {
|
|
1053 XSetClipMask (dpy, gc, None);
|
|
1054 XSetClipOrigin (dpy, gc, 0, 0);
|
|
1055 }
|
|
1056
|
|
1057 /* If we are actually superimposing the cursor then redraw with just
|
|
1058 the appropriate section highlighted. */
|
|
1059 if (cursor_clip && !cursor && focus && cursor_cachel)
|
|
1060 {
|
|
1061 GC cgc;
|
|
1062 XRectangle clip_box[1];
|
|
1063
|
|
1064 cgc = x_get_gc (d, font, cursor_cachel->foreground,
|
|
1065 cursor_cachel->background, Qnil, Qnil);
|
|
1066
|
|
1067 clip_box[0].x = 0;
|
|
1068 clip_box[0].y = 0;
|
|
1069 clip_box[0].width = cursor_width;
|
|
1070 clip_box[0].height = height;
|
|
1071
|
|
1072 XSetClipRectangles (dpy, cgc, cursor_start, DISPLAY_LINE_YPOS (dl),
|
|
1073 clip_box, 1, Unsorted);
|
|
1074
|
|
1075 if (runs[i].dimension == 1)
|
|
1076 XDrawImageString (dpy, x_win, cgc, xpos, dl->ypos,
|
|
1077 (char *) runs[i].ptr, runs[i].len);
|
|
1078 else
|
|
1079 XDrawImageString16 (dpy, x_win, cgc, xpos, dl->ypos,
|
|
1080 (XChar2b *) runs[i].ptr, runs[i].len);
|
|
1081
|
|
1082 XSetClipMask (dpy, cgc, None);
|
|
1083 XSetClipOrigin (dpy, cgc, 0, 0);
|
|
1084 }
|
|
1085
|
|
1086 xpos += this_width;
|
|
1087 }
|
|
1088
|
|
1089 /* Draw the non-focus box or bar-cursor as needed. */
|
|
1090 /* Can't this logic be simplified? */
|
|
1091 if (cursor_cachel
|
|
1092 && ((cursor && !focus && NILP (bar_cursor_value))
|
|
1093 || (cursor_width
|
|
1094 && (cursor_start + cursor_width >= clip_start)
|
|
1095 && !NILP (bar_cursor_value))))
|
|
1096 {
|
|
1097 int tmp_height, tmp_y;
|
|
1098 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1099 int need_clipping = (cursor_start < clip_start
|
|
1100 || clip_end < cursor_start + cursor_width);
|
|
1101
|
|
1102 /* #### This value is correct (as far as I know) because
|
|
1103 all of the times we need to draw this cursor, we will
|
|
1104 be called with exactly one character, so we know we
|
|
1105 can always use runs[0].
|
|
1106
|
|
1107 This is bogus as all hell, however. The cursor handling in
|
|
1108 this function is way bogus and desperately needs to be
|
|
1109 cleaned up. (In particular, the drawing of the cursor should
|
|
1110 really really be separated out of this function. This may be
|
|
1111 a bit tricky now because this function itself does way too
|
|
1112 much stuff, a lot of which needs to be moved into
|
|
1113 redisplay.c) This is the only way to be able to easily add
|
|
1114 new cursor types or (e.g.) make the bar cursor be able to
|
|
1115 span two characters instead of overlaying just one. */
|
|
1116 int bogusly_obtained_ascent_value =
|
|
1117 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent;
|
|
1118
|
|
1119 if (!NILP (bar_cursor_value))
|
|
1120 {
|
|
1121 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1122 make_int (bar_width));
|
|
1123 }
|
|
1124 else
|
|
1125 {
|
|
1126 gc = x_get_gc (d, Qnil, cursor_cachel->background,
|
|
1127 Qnil, Qnil, Qnil);
|
|
1128 }
|
|
1129
|
|
1130 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
|
|
1131 tmp_height = cursor_height;
|
|
1132 if (tmp_y + tmp_height > (int) (DISPLAY_LINE_YPOS(dl) + height))
|
|
1133 {
|
|
1134 tmp_y = DISPLAY_LINE_YPOS (dl) + height - tmp_height;
|
|
1135 if (tmp_y < (int) DISPLAY_LINE_YPOS (dl))
|
|
1136 tmp_y = DISPLAY_LINE_YPOS (dl);
|
|
1137 tmp_height = DISPLAY_LINE_YPOS (dl) + height - tmp_y;
|
|
1138 }
|
|
1139
|
|
1140 if (need_clipping)
|
|
1141 {
|
|
1142 XRectangle clip_box[1];
|
|
1143 clip_box[0].x = 0;
|
|
1144 clip_box[0].y = 0;
|
|
1145 clip_box[0].width = clip_end - clip_start;
|
|
1146 clip_box[0].height = tmp_height;
|
|
1147 XSetClipRectangles (dpy, gc, clip_start, tmp_y,
|
|
1148 clip_box, 1, Unsorted);
|
|
1149 }
|
|
1150
|
|
1151 if (!focus && NILP (bar_cursor_value))
|
|
1152 {
|
|
1153 XDrawRectangle (dpy, x_win, gc, cursor_start, tmp_y,
|
|
1154 cursor_width - 1, tmp_height - 1);
|
|
1155 }
|
|
1156 else if (focus && !NILP (bar_cursor_value))
|
|
1157 {
|
|
1158 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1, tmp_y,
|
|
1159 cursor_start + bar_width - 1, tmp_y + tmp_height - 1);
|
|
1160 }
|
|
1161
|
|
1162 /* Restore the GC */
|
|
1163 if (need_clipping)
|
|
1164 {
|
|
1165 XSetClipMask (dpy, gc, None);
|
|
1166 XSetClipOrigin (dpy, gc, 0, 0);
|
|
1167 }
|
|
1168 }
|
|
1169 }
|
|
1170
|
|
1171 void
|
440
|
1172 x_output_x_pixmap (struct frame *f, Lisp_Image_Instance *p, int x,
|
428
|
1173 int y, int xoffset, int yoffset,
|
440
|
1174 int width, int height, unsigned long fg, unsigned long bg,
|
428
|
1175 GC override_gc)
|
|
1176 {
|
|
1177 struct device *d = XDEVICE (f->device);
|
|
1178 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1179 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1180
|
|
1181 GC gc;
|
|
1182 XGCValues gcv;
|
|
1183 unsigned long pixmap_mask;
|
|
1184
|
|
1185 if (!override_gc)
|
|
1186 {
|
|
1187 memset (&gcv, ~0, sizeof (XGCValues));
|
|
1188 gcv.graphics_exposures = False;
|
|
1189 gcv.foreground = fg;
|
|
1190 gcv.background = bg;
|
|
1191 pixmap_mask = GCForeground | GCBackground | GCGraphicsExposures;
|
|
1192
|
|
1193 if (IMAGE_INSTANCE_X_MASK (p))
|
|
1194 {
|
|
1195 gcv.function = GXcopy;
|
|
1196 gcv.clip_mask = IMAGE_INSTANCE_X_MASK (p);
|
|
1197 gcv.clip_x_origin = x - xoffset;
|
|
1198 gcv.clip_y_origin = y - yoffset;
|
|
1199 pixmap_mask |= (GCFunction | GCClipMask | GCClipXOrigin |
|
|
1200 GCClipYOrigin);
|
|
1201 /* Can't set a clip rectangle because we already have a mask.
|
|
1202 Is it possible to get an equivalent effect by changing the
|
|
1203 args to XCopyArea below rather than messing with a clip box?
|
|
1204 - dkindred@cs.cmu.edu
|
|
1205 Yes. We don't clip at all now - andy@xemacs.org
|
|
1206 */
|
|
1207 }
|
|
1208
|
|
1209 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, pixmap_mask);
|
|
1210 }
|
|
1211 else
|
|
1212 {
|
|
1213 gc = override_gc;
|
|
1214 /* override_gc might have a mask already--we don't want to nuke it.
|
|
1215 Maybe we can insist that override_gc have no mask, or use
|
|
1216 one of the suggestions above. */
|
|
1217 }
|
|
1218
|
|
1219 /* depth of 0 means it's a bitmap, not a pixmap, and we should use
|
|
1220 XCopyPlane (1 = current foreground color, 0 = background) instead
|
|
1221 of XCopyArea, which means that the bits in the pixmap are actual
|
|
1222 pixel values, instead of symbolic of fg/bg. */
|
|
1223 if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0)
|
|
1224 {
|
440
|
1225 XCopyArea (dpy,
|
|
1226 IMAGE_INSTANCE_X_PIXMAP_SLICE
|
428
|
1227 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset,
|
|
1228 yoffset, width,
|
|
1229 height, x, y);
|
|
1230 }
|
|
1231 else
|
|
1232 {
|
440
|
1233 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE
|
428
|
1234 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc,
|
|
1235 xoffset, yoffset, width, height, x, y, 1L);
|
|
1236 }
|
|
1237 }
|
|
1238
|
|
1239 static void
|
|
1240 x_output_pixmap (struct window *w, Lisp_Object image_instance,
|
|
1241 struct display_box *db, struct display_glyph_area *dga,
|
|
1242 face_index findex, int cursor_start, int cursor_width,
|
|
1243 int cursor_height, int bg_pixmap)
|
|
1244 {
|
|
1245 struct frame *f = XFRAME (w->frame);
|
|
1246 struct device *d = XDEVICE (f->device);
|
440
|
1247 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
428
|
1248
|
|
1249 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1250 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
440
|
1251
|
428
|
1252 /* Output the pixmap. */
|
|
1253 {
|
|
1254 Lisp_Object tmp_pixel;
|
|
1255 XColor tmp_bcolor, tmp_fcolor;
|
|
1256
|
|
1257 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1258 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1259 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1260 tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1261
|
|
1262 x_output_x_pixmap (f, p, db->xpos, db->ypos,
|
|
1263 dga->xoffset, dga->yoffset,
|
|
1264 dga->width, dga->height,
|
|
1265 tmp_fcolor.pixel, tmp_bcolor.pixel, 0);
|
|
1266 }
|
|
1267
|
|
1268 /* Draw a cursor over top of the pixmap. */
|
|
1269 if (cursor_width && cursor_height && (cursor_start >= db->xpos)
|
|
1270 && !NILP (w->text_cursor_visible_p)
|
|
1271 && (cursor_start < db->xpos + dga->width))
|
|
1272 {
|
|
1273 GC gc;
|
|
1274 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1275 struct face_cachel *cursor_cachel =
|
|
1276 WINDOW_FACE_CACHEL (w,
|
|
1277 get_builtin_face_cache_index
|
|
1278 (w, Vtext_cursor_face));
|
|
1279
|
|
1280 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1281
|
|
1282 if (cursor_width > db->xpos + dga->width - cursor_start)
|
|
1283 cursor_width = db->xpos + dga->width - cursor_start;
|
|
1284
|
|
1285 if (focus)
|
|
1286 {
|
|
1287 XFillRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
|
|
1288 cursor_height);
|
|
1289 }
|
|
1290 else
|
|
1291 {
|
|
1292 XDrawRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
|
|
1293 cursor_height);
|
|
1294 }
|
|
1295 }
|
|
1296 }
|
|
1297
|
|
1298 /*****************************************************************************
|
|
1299 x_output_vertical_divider
|
|
1300
|
|
1301 Draw a vertical divider down the right side of the given window.
|
|
1302 ****************************************************************************/
|
|
1303 static void
|
|
1304 x_output_vertical_divider (struct window *w, int clear)
|
|
1305 {
|
|
1306 struct frame *f = XFRAME (w->frame);
|
|
1307 struct device *d = XDEVICE (f->device);
|
|
1308
|
|
1309 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1310 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1311 Lisp_Object tmp_pixel;
|
|
1312 XColor tmp_color;
|
|
1313 XGCValues gcv;
|
|
1314 GC background_gc;
|
|
1315 enum edge_style style;
|
|
1316
|
|
1317 unsigned long mask;
|
|
1318 int x, y1, y2, width, shadow_thickness, spacing, line_width;
|
647
|
1319 face_index div_face =
|
|
1320 get_builtin_face_cache_index (w, Vvertical_divider_face);
|
428
|
1321
|
|
1322 width = window_divider_width (w);
|
|
1323 shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
|
|
1324 spacing = XINT (w->vertical_divider_spacing);
|
|
1325 line_width = XINT (w->vertical_divider_line_width);
|
|
1326 x = WINDOW_RIGHT (w) - width;
|
442
|
1327 y1 = WINDOW_TOP (w);
|
|
1328 y2 = WINDOW_BOTTOM (w);
|
428
|
1329
|
|
1330 memset (&gcv, ~0, sizeof (XGCValues));
|
|
1331
|
|
1332 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
|
|
1333 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1334
|
|
1335 /* First, get the GC's. */
|
|
1336 gcv.background = tmp_color.pixel;
|
|
1337 gcv.foreground = tmp_color.pixel;
|
|
1338 gcv.graphics_exposures = False;
|
|
1339 mask = GCForeground | GCBackground | GCGraphicsExposures;
|
|
1340 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
|
|
1341
|
|
1342 /* Clear the divider area first. This needs to be done when a
|
|
1343 window split occurs. */
|
|
1344 if (clear)
|
|
1345 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False);
|
|
1346
|
|
1347 /* Draw the divider line. */
|
|
1348 XFillRectangle (dpy, x_win, background_gc,
|
|
1349 x + spacing + shadow_thickness, y1,
|
|
1350 line_width, y2 - y1);
|
|
1351
|
|
1352 if (shadow_thickness < 0)
|
|
1353 {
|
|
1354 shadow_thickness = -shadow_thickness;
|
|
1355 style = EDGE_BEVEL_IN;
|
|
1356 }
|
|
1357 else
|
|
1358 {
|
|
1359 style = EDGE_BEVEL_OUT;
|
|
1360 }
|
|
1361
|
|
1362 /* Draw the shadows around the divider line */
|
|
1363 x_bevel_area (w, div_face, x + spacing, y1,
|
|
1364 width - 2 * spacing, y2 - y1,
|
|
1365 shadow_thickness, EDGE_ALL, style);
|
|
1366 }
|
|
1367
|
|
1368 /*****************************************************************************
|
|
1369 x_output_blank
|
|
1370
|
|
1371 Output a blank by clearing the area it covers in the foreground color
|
|
1372 of its face.
|
|
1373 ****************************************************************************/
|
|
1374 static void
|
|
1375 x_output_blank (struct window *w, struct display_line *dl, struct rune *rb,
|
|
1376 int start_pixpos, int cursor_start, int cursor_width)
|
|
1377 {
|
|
1378 struct frame *f = XFRAME (w->frame);
|
|
1379 struct device *d = XDEVICE (f->device);
|
|
1380
|
|
1381 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1382 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1383 GC gc;
|
|
1384 struct face_cachel *cursor_cachel =
|
|
1385 WINDOW_FACE_CACHEL (w,
|
|
1386 get_builtin_face_cache_index
|
|
1387 (w, Vtext_cursor_face));
|
|
1388 Lisp_Object bg_pmap;
|
|
1389 Lisp_Object buffer = WINDOW_BUFFER (w);
|
|
1390 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
1391 buffer);
|
|
1392
|
|
1393 int x = rb->xpos;
|
|
1394 int y = DISPLAY_LINE_YPOS (dl);
|
|
1395 int width = rb->width;
|
|
1396 int height = DISPLAY_LINE_HEIGHT (dl);
|
|
1397
|
|
1398 /* Unmap all subwindows in the area we are going to blank. */
|
|
1399 redisplay_unmap_subwindows_maybe (f, x, y, width, height);
|
|
1400
|
|
1401 if (start_pixpos > x)
|
|
1402 {
|
|
1403 if (start_pixpos >= (x + width))
|
|
1404 return;
|
|
1405 else
|
|
1406 {
|
|
1407 width -= (start_pixpos - x);
|
|
1408 x = start_pixpos;
|
|
1409 }
|
|
1410 }
|
|
1411
|
|
1412 bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
|
|
1413 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
1414 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
1415 bg_pmap = Qnil;
|
|
1416
|
|
1417 if (NILP (bg_pmap))
|
|
1418 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
|
|
1419 Qnil, Qnil, Qnil);
|
|
1420 else
|
|
1421 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
|
|
1422 WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
|
|
1423 Qnil);
|
|
1424
|
|
1425 XFillRectangle (dpy, x_win, gc, x, y, width, height);
|
|
1426
|
|
1427 /* If this rune is marked as having the cursor, then it is actually
|
|
1428 representing a tab. */
|
|
1429 if (!NILP (w->text_cursor_visible_p)
|
|
1430 && (rb->cursor_type == CURSOR_ON
|
|
1431 || (cursor_width
|
|
1432 && (cursor_start + cursor_width > x)
|
|
1433 && cursor_start < (x + width))))
|
|
1434 {
|
|
1435 int cursor_height, cursor_y;
|
|
1436 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
440
|
1437 Lisp_Font_Instance *fi;
|
428
|
1438
|
|
1439 fi = XFONT_INSTANCE (FACE_CACHEL_FONT
|
|
1440 (WINDOW_FACE_CACHEL (w, rb->findex),
|
|
1441 Vcharset_ascii));
|
|
1442
|
|
1443 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1444
|
|
1445 cursor_y = dl->ypos - fi->ascent;
|
|
1446 cursor_height = fi->height;
|
|
1447 if (cursor_y + cursor_height > y + height)
|
|
1448 cursor_height = y + height - cursor_y;
|
|
1449
|
|
1450 if (focus)
|
|
1451 {
|
|
1452 if (NILP (bar_cursor_value))
|
|
1453 {
|
|
1454 XFillRectangle (dpy, x_win, gc, cursor_start, cursor_y,
|
|
1455 fi->width, cursor_height);
|
|
1456 }
|
|
1457 else
|
|
1458 {
|
|
1459 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1460
|
|
1461 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1462 make_int (bar_width));
|
|
1463 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1,
|
|
1464 cursor_y, cursor_start + bar_width - 1,
|
|
1465 cursor_y + cursor_height - 1);
|
|
1466 }
|
|
1467 }
|
|
1468 else if (NILP (bar_cursor_value))
|
|
1469 {
|
|
1470 XDrawRectangle (dpy, x_win, gc, cursor_start, cursor_y,
|
|
1471 fi->width - 1, cursor_height - 1);
|
|
1472 }
|
|
1473 }
|
|
1474 }
|
|
1475
|
|
1476 /*****************************************************************************
|
|
1477 x_output_hline
|
|
1478
|
|
1479 Output a horizontal line in the foreground of its face.
|
|
1480 ****************************************************************************/
|
|
1481 static void
|
|
1482 x_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
|
|
1483 {
|
|
1484 struct frame *f = XFRAME (w->frame);
|
|
1485 struct device *d = XDEVICE (f->device);
|
|
1486
|
|
1487 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1488 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1489 GC gc;
|
|
1490
|
|
1491 int x = rb->xpos;
|
|
1492 int width = rb->width;
|
|
1493 int height = DISPLAY_LINE_HEIGHT (dl);
|
|
1494 int ypos1, ypos2, ypos3, ypos4;
|
|
1495
|
|
1496 ypos1 = DISPLAY_LINE_YPOS (dl);
|
|
1497 ypos2 = ypos1 + rb->object.hline.yoffset;
|
|
1498 ypos3 = ypos2 + rb->object.hline.thickness;
|
|
1499 ypos4 = dl->ypos + dl->descent - dl->clip;
|
|
1500
|
|
1501 /* First clear the area not covered by the line. */
|
|
1502 if (height - rb->object.hline.thickness > 0)
|
|
1503 {
|
|
1504 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
|
|
1505 Qnil, Qnil, Qnil);
|
|
1506
|
|
1507 if (ypos2 - ypos1 > 0)
|
|
1508 XFillRectangle (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
|
|
1509 if (ypos4 - ypos3 > 0)
|
|
1510 XFillRectangle (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
|
|
1511 }
|
|
1512
|
|
1513 /* Now draw the line. */
|
|
1514 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
|
|
1515 Qnil, Qnil, Qnil);
|
|
1516
|
|
1517 if (ypos2 < ypos1)
|
|
1518 ypos2 = ypos1;
|
|
1519 if (ypos3 > ypos4)
|
|
1520 ypos3 = ypos4;
|
|
1521
|
|
1522 if (ypos3 - ypos2 > 0)
|
|
1523 XFillRectangle (dpy, x_win, gc, x, ypos2, width, ypos3 - ypos2);
|
|
1524 }
|
|
1525
|
|
1526 /*****************************************************************************
|
|
1527 x_output_shadows
|
|
1528
|
|
1529 Draw a shadow around the given area using the given GC's. It is the
|
|
1530 callers responsibility to set the GC's appropriately.
|
|
1531 ****************************************************************************/
|
|
1532 void
|
|
1533 x_output_shadows (struct frame *f, int x, int y, int width, int height,
|
|
1534 GC top_shadow_gc, GC bottom_shadow_gc, GC background_gc,
|
|
1535 int shadow_thickness, int edges)
|
|
1536 {
|
|
1537 struct device *d = XDEVICE (f->device);
|
|
1538
|
|
1539 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1540 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1541
|
|
1542 XSegment top_shadow[20], bottom_shadow[20];
|
|
1543 int elt;
|
|
1544
|
|
1545 if (shadow_thickness > 10)
|
|
1546 shadow_thickness = 10;
|
|
1547 else if (shadow_thickness < 0)
|
|
1548 shadow_thickness = 0;
|
|
1549 if (shadow_thickness > (width / 2))
|
|
1550 shadow_thickness = width / 2;
|
|
1551 if (shadow_thickness > (height / 2))
|
|
1552 shadow_thickness = height / 2;
|
|
1553
|
|
1554 for (elt = 0; elt < shadow_thickness; elt++)
|
|
1555 {
|
|
1556 int seg1 = elt;
|
|
1557 int seg2 = (edges & EDGE_TOP) ? elt + shadow_thickness : elt;
|
|
1558 int bot_seg2 = (edges & EDGE_BOTTOM) ? elt + shadow_thickness : elt;
|
|
1559
|
|
1560 if (edges & EDGE_TOP)
|
|
1561 {
|
|
1562 top_shadow[seg1].x1 = x + elt;
|
|
1563 top_shadow[seg1].x2 = x + width - elt - 1;
|
|
1564 top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt;
|
|
1565 }
|
|
1566 if (edges & EDGE_LEFT)
|
|
1567 {
|
|
1568 top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt;
|
|
1569 top_shadow[seg2].y1 = y + elt;
|
|
1570 top_shadow[seg2].y2 = y + height - elt - 1;
|
|
1571 }
|
|
1572 if (edges & EDGE_BOTTOM)
|
|
1573 {
|
|
1574 bottom_shadow[seg1].x1 = x + elt;
|
|
1575 bottom_shadow[seg1].x2 = x + width - elt - 1;
|
|
1576 bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1;
|
|
1577 }
|
|
1578 if (edges & EDGE_RIGHT)
|
|
1579 {
|
|
1580 bottom_shadow[bot_seg2].x1 = bottom_shadow[bot_seg2].x2 = x + width - elt - 1;
|
|
1581 bottom_shadow[bot_seg2].y1 = y + elt;
|
|
1582 bottom_shadow[bot_seg2].y2 = y + height - elt - 1;
|
|
1583 }
|
|
1584 }
|
|
1585
|
|
1586 XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow,
|
|
1587 ((edges & EDGE_TOP) ? shadow_thickness : 0)
|
|
1588 + ((edges & EDGE_LEFT) ? shadow_thickness : 0));
|
|
1589 XDrawSegments (dpy, x_win, bottom_shadow_gc, bottom_shadow,
|
|
1590 ((edges & EDGE_BOTTOM) ? shadow_thickness : 0)
|
|
1591 + ((edges & EDGE_RIGHT) ? shadow_thickness : 0));
|
|
1592 }
|
|
1593
|
|
1594 /*****************************************************************************
|
|
1595 x_generate_shadow_pixels
|
|
1596
|
|
1597 Given three pixels (top shadow, bottom shadow, background) massage
|
|
1598 the top and bottom shadow colors to guarantee that they differ. The
|
|
1599 background pixels are not allowed to be modified.
|
|
1600
|
|
1601 This function modifies its parameters.
|
|
1602
|
|
1603 This code is modified from code blatantly stolen from lwlib/xlwmenu.c
|
|
1604 ****************************************************************************/
|
|
1605 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
|
|
1606 ? ((unsigned long) (x)) : ((unsigned long) (y)))
|
|
1607
|
|
1608 void
|
|
1609 x_generate_shadow_pixels (struct frame *f, unsigned long *top_shadow,
|
|
1610 unsigned long *bottom_shadow,
|
|
1611 unsigned long background,
|
|
1612 unsigned long core_background)
|
|
1613 {
|
|
1614 struct device *d = XDEVICE (f->device);
|
|
1615 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1616 Colormap cmap = DEVICE_X_COLORMAP (d);
|
|
1617 Visual *visual = DEVICE_X_VISUAL (d);
|
|
1618
|
|
1619 XColor topc, botc;
|
|
1620 int top_frobbed = 0, bottom_frobbed = 0;
|
|
1621
|
|
1622 /* If the top shadow is the same color as the background, try to
|
|
1623 adjust it. */
|
|
1624 if (*top_shadow == background)
|
|
1625 {
|
|
1626 topc.pixel = background;
|
|
1627 XQueryColor (dpy, cmap, &topc);
|
|
1628 /* don't overflow/wrap! */
|
|
1629 topc.red = MINL (65535, (unsigned long) topc.red * 6 / 5);
|
|
1630 topc.green = MINL (65535, (unsigned long) topc.green * 6 / 5);
|
|
1631 topc.blue = MINL (65535, (unsigned long) topc.blue * 6 / 5);
|
|
1632 if (allocate_nearest_color (dpy, cmap, visual, &topc))
|
|
1633 {
|
|
1634 *top_shadow = topc.pixel;
|
|
1635 top_frobbed = 1;
|
|
1636 }
|
|
1637 }
|
|
1638
|
|
1639 /* If the bottom shadow is the same color as the background, try to
|
|
1640 adjust it. */
|
|
1641 if (*bottom_shadow == background)
|
|
1642 {
|
|
1643 botc.pixel = background;
|
|
1644 XQueryColor (dpy, cmap, &botc);
|
|
1645 botc.red = (unsigned short) ((unsigned long) botc.red * 3 / 5);
|
|
1646 botc.green = (unsigned short) ((unsigned long) botc.green * 3 / 5);
|
|
1647 botc.blue = (unsigned short) ((unsigned long) botc.blue * 3 / 5);
|
|
1648 if (allocate_nearest_color (dpy, cmap, visual, &botc))
|
|
1649 {
|
|
1650 *bottom_shadow = botc.pixel;
|
|
1651 bottom_frobbed = 1;
|
|
1652 }
|
|
1653 }
|
|
1654
|
|
1655 /* If we had to adjust both shadows, then we have to do some
|
|
1656 additional work. */
|
|
1657 if (top_frobbed && bottom_frobbed)
|
|
1658 {
|
|
1659 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
|
|
1660 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
|
|
1661 if (bot_avg > top_avg)
|
|
1662 {
|
|
1663 Pixel tmp = *top_shadow;
|
|
1664
|
|
1665 *top_shadow = *bottom_shadow;
|
|
1666 *bottom_shadow = tmp;
|
|
1667 }
|
|
1668 else if (topc.pixel == botc.pixel)
|
|
1669 {
|
|
1670 if (botc.pixel == background)
|
|
1671 *top_shadow = core_background;
|
|
1672 else
|
|
1673 *bottom_shadow = background;
|
|
1674 }
|
|
1675 }
|
|
1676 }
|
|
1677
|
|
1678 /*****************************************************************************
|
|
1679 x_redraw_exposed_window
|
|
1680
|
|
1681 Given a bounding box for an area that needs to be redrawn, determine
|
|
1682 what parts of what lines are contained within and re-output their
|
|
1683 contents.
|
|
1684 ****************************************************************************/
|
|
1685 static void
|
|
1686 x_redraw_exposed_window (struct window *w, int x, int y, int width, int height)
|
|
1687 {
|
|
1688 struct frame *f = XFRAME (w->frame);
|
|
1689 int line;
|
|
1690 int start_x, start_y, end_x, end_y;
|
|
1691 int orig_windows_structure_changed;
|
|
1692
|
|
1693 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
1694
|
|
1695 if (!NILP (w->vchild))
|
|
1696 {
|
|
1697 x_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
1698 return;
|
|
1699 }
|
|
1700 else if (!NILP (w->hchild))
|
|
1701 {
|
|
1702 x_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
1703 return;
|
|
1704 }
|
|
1705
|
|
1706 /* If the window doesn't intersect the exposed region, we're done here. */
|
|
1707 if (x >= WINDOW_RIGHT (w) || (x + width) <= WINDOW_LEFT (w)
|
|
1708 || y >= WINDOW_BOTTOM (w) || (y + height) <= WINDOW_TOP (w))
|
|
1709 {
|
|
1710 return;
|
|
1711 }
|
|
1712 else
|
|
1713 {
|
|
1714 start_x = max (WINDOW_LEFT (w), x);
|
|
1715 end_x = min (WINDOW_RIGHT (w), (x + width));
|
|
1716 start_y = max (WINDOW_TOP (w), y);
|
|
1717 end_y = min (WINDOW_BOTTOM (w), y + height);
|
|
1718
|
|
1719 /* We do this to make sure that the 3D modelines get redrawn if
|
|
1720 they are in the exposed region. */
|
|
1721 orig_windows_structure_changed = f->windows_structure_changed;
|
|
1722 f->windows_structure_changed = 1;
|
|
1723 }
|
|
1724
|
448
|
1725 redisplay_clear_top_of_window (w);
|
428
|
1726 if (window_needs_vertical_divider (w))
|
|
1727 {
|
|
1728 x_output_vertical_divider (w, 0);
|
|
1729 }
|
|
1730
|
|
1731 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
1732 {
|
|
1733 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
1734 int top_y = cdl->ypos - cdl->ascent;
|
|
1735 int bottom_y = cdl->ypos + cdl->descent;
|
|
1736
|
|
1737 if (bottom_y >= start_y)
|
|
1738 {
|
|
1739 if (top_y > end_y)
|
|
1740 {
|
|
1741 if (line == 0)
|
|
1742 continue;
|
|
1743 else
|
|
1744 break;
|
|
1745 }
|
|
1746 else
|
|
1747 {
|
|
1748 output_display_line (w, 0, cdla, line, start_x, end_x);
|
|
1749 }
|
|
1750 }
|
|
1751 }
|
|
1752
|
|
1753 f->windows_structure_changed = orig_windows_structure_changed;
|
|
1754
|
|
1755 /* If there have never been any face cache_elements created, then this
|
|
1756 expose event doesn't actually have anything to do. */
|
|
1757 if (Dynarr_largest (w->face_cachels))
|
|
1758 redisplay_clear_bottom_of_window (w, cdla, start_y, end_y);
|
|
1759 }
|
|
1760
|
|
1761 /*****************************************************************************
|
|
1762 x_redraw_exposed_windows
|
|
1763
|
|
1764 For each window beneath the given window in the window hierarchy,
|
|
1765 ensure that it is redrawn if necessary after an Expose event.
|
|
1766 ****************************************************************************/
|
|
1767 static void
|
|
1768 x_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
1769 int height)
|
|
1770 {
|
|
1771 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
1772 x_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
1773 }
|
|
1774
|
|
1775 /*****************************************************************************
|
|
1776 x_redraw_exposed_area
|
|
1777
|
|
1778 For each window on the given frame, ensure that any area in the
|
|
1779 Exposed area is redrawn.
|
|
1780 ****************************************************************************/
|
|
1781 void
|
|
1782 x_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
|
|
1783 {
|
|
1784 /* If any window on the frame has had its face cache reset then the
|
|
1785 redisplay structures are effectively invalid. If we attempt to
|
|
1786 use them we'll blow up. We mark the frame as changed to ensure
|
|
1787 that redisplay will do a full update. This probably isn't
|
|
1788 necessary but it can't hurt. */
|
|
1789
|
|
1790 #ifdef HAVE_TOOLBARS
|
|
1791 /* #### We would rather put these off as well but there is currently
|
|
1792 no combination of flags which will force an unchanged toolbar to
|
|
1793 redraw anyhow. */
|
|
1794 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
|
|
1795 #endif
|
|
1796 redraw_exposed_gutters (f, x, y, width, height);
|
|
1797
|
|
1798 if (!f->window_face_cache_reset)
|
|
1799 {
|
|
1800 x_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
1801
|
|
1802 XFlush (DEVICE_X_DISPLAY (XDEVICE (f->device)));
|
|
1803 }
|
|
1804 else
|
|
1805 MARK_FRAME_CHANGED (f);
|
|
1806 }
|
|
1807
|
|
1808 /****************************************************************************
|
|
1809 x_clear_region
|
|
1810
|
|
1811 Clear the area in the box defined by the given parameters using the
|
|
1812 given face.
|
|
1813 ****************************************************************************/
|
|
1814 static void
|
|
1815 x_clear_region (Lisp_Object locale, struct device* d, struct frame* f, face_index findex,
|
|
1816 int x, int y,
|
|
1817 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
|
|
1818 Lisp_Object background_pixmap)
|
|
1819 {
|
|
1820 Display *dpy;
|
|
1821 Window x_win;
|
|
1822 GC gc = NULL;
|
|
1823
|
|
1824 dpy = DEVICE_X_DISPLAY (d);
|
|
1825 x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1826
|
|
1827 if (!UNBOUNDP (background_pixmap))
|
|
1828 {
|
|
1829 gc = x_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
|
|
1830 }
|
|
1831
|
|
1832 if (gc)
|
|
1833 XFillRectangle (dpy, x_win, gc, x, y, width, height);
|
|
1834 else
|
|
1835 XClearArea (dpy, x_win, x, y, width, height, False);
|
|
1836 }
|
|
1837
|
|
1838 /*****************************************************************************
|
|
1839 x_output_eol_cursor
|
|
1840
|
|
1841 Draw a cursor at the end of a line. The end-of-line cursor is
|
|
1842 narrower than the normal cursor.
|
|
1843 ****************************************************************************/
|
|
1844 static void
|
|
1845 x_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
|
|
1846 face_index findex)
|
|
1847 {
|
|
1848 struct frame *f = XFRAME (w->frame);
|
|
1849 struct device *d = XDEVICE (f->device);
|
|
1850 Lisp_Object window;
|
|
1851
|
|
1852 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1853 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1854 GC gc;
|
|
1855 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
1856 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt);
|
|
1857
|
|
1858 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1859 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
1860 WINDOW_BUFFER (w));
|
|
1861
|
|
1862 int x = xpos;
|
|
1863 int y = DISPLAY_LINE_YPOS (dl);
|
|
1864 int width = EOL_CURSOR_WIDTH;
|
|
1865 int height = DISPLAY_LINE_HEIGHT (dl);
|
|
1866 int cursor_height, cursor_y;
|
|
1867 int defheight, defascent;
|
|
1868
|
793
|
1869 window = wrap_window (w);
|
428
|
1870 redisplay_clear_region (window, findex, x, y, width, height);
|
|
1871
|
|
1872 if (NILP (w->text_cursor_visible_p))
|
|
1873 return;
|
|
1874
|
|
1875 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1876
|
|
1877 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
|
|
1878
|
|
1879 /* make sure the cursor is entirely contained between y and y+height */
|
|
1880 cursor_height = min (defheight, height);
|
|
1881 cursor_y = max (y, min (y + height - cursor_height,
|
|
1882 dl->ypos - defascent));
|
|
1883
|
|
1884 if (focus)
|
|
1885 {
|
|
1886 #ifdef HAVE_XIM
|
|
1887 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);
|
|
1888 #endif /* HAVE_XIM */
|
|
1889
|
|
1890 if (NILP (bar_cursor_value))
|
|
1891 {
|
|
1892 XFillRectangle (dpy, x_win, gc, x, cursor_y, width, cursor_height);
|
|
1893 }
|
|
1894 else
|
|
1895 {
|
|
1896 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1897
|
|
1898 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1899 make_int (bar_width));
|
|
1900 XDrawLine (dpy, x_win, gc, x + bar_width - 1, cursor_y,
|
|
1901 x + bar_width - 1, cursor_y + cursor_height - 1);
|
|
1902 }
|
|
1903 }
|
|
1904 else if (NILP (bar_cursor_value))
|
|
1905 {
|
|
1906 XDrawRectangle (dpy, x_win, gc, x, cursor_y, width - 1,
|
|
1907 cursor_height - 1);
|
|
1908 }
|
|
1909 }
|
|
1910
|
|
1911 static void
|
|
1912 x_clear_frame_window (Lisp_Object window)
|
|
1913 {
|
|
1914 struct window *w = XWINDOW (window);
|
|
1915
|
|
1916 if (!NILP (w->vchild))
|
|
1917 {
|
|
1918 x_clear_frame_windows (w->vchild);
|
|
1919 return;
|
|
1920 }
|
|
1921
|
|
1922 if (!NILP (w->hchild))
|
|
1923 {
|
|
1924 x_clear_frame_windows (w->hchild);
|
|
1925 return;
|
|
1926 }
|
|
1927
|
440
|
1928 redisplay_clear_to_window_end (w, WINDOW_TEXT_TOP (w),
|
428
|
1929 WINDOW_TEXT_BOTTOM (w));
|
|
1930 }
|
|
1931
|
|
1932 static void
|
|
1933 x_clear_frame_windows (Lisp_Object window)
|
|
1934 {
|
|
1935 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
1936 x_clear_frame_window (window);
|
|
1937 }
|
|
1938
|
|
1939 static void
|
|
1940 x_clear_frame (struct frame *f)
|
|
1941 {
|
|
1942 struct device *d = XDEVICE (f->device);
|
|
1943 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1944 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
1945 int x, y, width, height;
|
|
1946 Lisp_Object frame;
|
|
1947
|
|
1948 x = FRAME_LEFT_BORDER_START (f);
|
|
1949 width = (FRAME_PIXWIDTH (f) - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
|
|
1950 FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -
|
|
1951 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) -
|
|
1952 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f));
|
|
1953 /* #### This adjustment by 1 should be being done in the macros.
|
|
1954 There is some small differences between when the menubar is on
|
|
1955 and off that we still need to deal with. */
|
|
1956 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
1957 height = (FRAME_PIXHEIGHT (f) - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
|
|
1958 FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -
|
|
1959 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) -
|
|
1960 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f)) + 1;
|
|
1961
|
|
1962 XClearArea (dpy, x_win, x, y, width, height, False);
|
|
1963
|
793
|
1964 frame = wrap_frame (f);
|
428
|
1965
|
|
1966 if (!UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vdefault_face, frame))
|
|
1967 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vleft_margin_face, frame))
|
|
1968 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vright_margin_face, frame)))
|
|
1969 {
|
|
1970 x_clear_frame_windows (f->root_window);
|
|
1971 }
|
|
1972
|
|
1973 XFlush (DEVICE_X_DISPLAY (d));
|
|
1974 }
|
|
1975
|
|
1976 /* briefly swap the foreground and background colors.
|
|
1977 */
|
|
1978
|
|
1979 static int
|
|
1980 x_flash (struct device *d)
|
|
1981 {
|
|
1982 Display *dpy;
|
|
1983 Window win;
|
|
1984 XGCValues gcv;
|
|
1985 GC gc;
|
|
1986 XColor tmp_fcolor, tmp_bcolor;
|
|
1987 Lisp_Object tmp_pixel, frame;
|
|
1988 struct frame *f = device_selected_frame (d);
|
|
1989 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
|
|
1990 Widget shell = FRAME_X_SHELL_WIDGET (f);
|
442
|
1991 int flash_height;
|
428
|
1992
|
793
|
1993 frame = wrap_frame (f);
|
428
|
1994
|
|
1995 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
|
|
1996 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1997 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
|
|
1998 tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1999
|
|
2000 dpy = XtDisplay (shell);
|
|
2001 win = XtWindow (FRAME_X_TEXT_WIDGET (f));
|
|
2002 memset (&gcv, ~0, sizeof (XGCValues)); /* initialize all slots to ~0 */
|
|
2003 gcv.foreground = (tmp_fcolor.pixel ^ tmp_bcolor.pixel);
|
|
2004 gcv.function = GXxor;
|
|
2005 gcv.graphics_exposures = False;
|
|
2006 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (XDEVICE (f->device)), &gcv,
|
|
2007 (GCForeground | GCFunction | GCGraphicsExposures));
|
442
|
2008 default_face_height_and_width (frame, &flash_height, 0);
|
|
2009
|
|
2010 /* If window is tall, flash top and bottom line. */
|
|
2011 if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
|
|
2012 {
|
|
2013 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
|
|
2014 w->pixel_width, flash_height);
|
|
2015 XFillRectangle (dpy, win, gc, w->pixel_left,
|
|
2016 w->pixel_top + w->pixel_height - flash_height,
|
|
2017 w->pixel_width, flash_height);
|
|
2018 }
|
|
2019 else
|
|
2020 /* If it is short, flash it all. */
|
|
2021 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
|
|
2022 w->pixel_width, w->pixel_height);
|
|
2023
|
428
|
2024 XSync (dpy, False);
|
|
2025
|
|
2026 #ifdef HAVE_SELECT
|
|
2027 {
|
|
2028 int usecs = 100000;
|
|
2029 struct timeval tv;
|
|
2030 tv.tv_sec = usecs / 1000000L;
|
|
2031 tv.tv_usec = usecs % 1000000L;
|
|
2032 /* I'm sure someone is going to complain about this... */
|
|
2033 select (0, 0, 0, 0, &tv);
|
|
2034 }
|
|
2035 #else
|
|
2036 #ifdef HAVE_POLL
|
|
2037 poll (0, 0, 100);
|
|
2038 #else /* !HAVE_POLL */
|
|
2039 bite me
|
|
2040 #endif /* HAVE_POLL */
|
|
2041 #endif /* HAVE_SELECT */
|
|
2042
|
442
|
2043 /* If window is tall, flash top and bottom line. */
|
|
2044 if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
|
|
2045 {
|
|
2046 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
|
|
2047 w->pixel_width, flash_height);
|
|
2048 XFillRectangle (dpy, win, gc, w->pixel_left,
|
|
2049 w->pixel_top + w->pixel_height - flash_height,
|
|
2050 w->pixel_width, flash_height);
|
|
2051 }
|
|
2052 else
|
|
2053 /* If it is short, flash it all. */
|
|
2054 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
|
|
2055 w->pixel_width, w->pixel_height);
|
|
2056
|
428
|
2057 XSync (dpy, False);
|
|
2058
|
|
2059 return 1;
|
|
2060 }
|
|
2061
|
|
2062 /* Make audible bell. */
|
|
2063
|
|
2064 static void
|
|
2065 x_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
2066 {
|
|
2067 Display *display = DEVICE_X_DISPLAY (d);
|
|
2068
|
|
2069 if (volume < 0) volume = 0;
|
|
2070 else if (volume > 100) volume = 100;
|
|
2071 if (pitch < 0 && duration < 0)
|
|
2072 {
|
|
2073 XBell (display, (volume * 2) - 100);
|
|
2074 XFlush (display);
|
|
2075 }
|
|
2076 else
|
|
2077 {
|
|
2078 XKeyboardState state;
|
|
2079 XKeyboardControl ctl;
|
|
2080 XSync (display, 0);
|
|
2081 /* #### grab server? */
|
|
2082 XGetKeyboardControl (display, &state);
|
|
2083
|
664
|
2084 ctl.bell_pitch = (pitch >= 0 ? pitch : (int) state.bell_pitch);
|
|
2085 ctl.bell_duration = (duration >= 0 ? duration : (int) state.bell_duration);
|
428
|
2086 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
|
|
2087
|
|
2088 XBell (display, (volume * 2) - 100);
|
|
2089
|
|
2090 ctl.bell_pitch = state.bell_pitch;
|
|
2091 ctl.bell_duration = state.bell_duration;
|
|
2092 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
|
|
2093
|
|
2094 /* #### ungrab server? */
|
|
2095 XSync (display, 0);
|
|
2096 }
|
|
2097 }
|
|
2098
|
|
2099
|
|
2100 /************************************************************************/
|
|
2101 /* initialization */
|
|
2102 /************************************************************************/
|
|
2103
|
|
2104 void
|
|
2105 console_type_create_redisplay_x (void)
|
|
2106 {
|
|
2107 /* redisplay methods */
|
|
2108 CONSOLE_HAS_METHOD (x, text_width);
|
|
2109 CONSOLE_HAS_METHOD (x, output_display_block);
|
|
2110 CONSOLE_HAS_METHOD (x, divider_height);
|
|
2111 CONSOLE_HAS_METHOD (x, eol_cursor_width);
|
|
2112 CONSOLE_HAS_METHOD (x, output_vertical_divider);
|
|
2113 CONSOLE_HAS_METHOD (x, clear_region);
|
|
2114 CONSOLE_HAS_METHOD (x, clear_frame);
|
442
|
2115 CONSOLE_HAS_METHOD (x, window_output_begin);
|
|
2116 CONSOLE_HAS_METHOD (x, window_output_end);
|
428
|
2117 CONSOLE_HAS_METHOD (x, flash);
|
|
2118 CONSOLE_HAS_METHOD (x, ring_bell);
|
|
2119 CONSOLE_HAS_METHOD (x, bevel_area);
|
|
2120 CONSOLE_HAS_METHOD (x, output_string);
|
|
2121 CONSOLE_HAS_METHOD (x, output_pixmap);
|
|
2122 }
|