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