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