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