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