714
|
1 /* GTK output and frame manipulation routines.
|
462
|
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.
|
462
|
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 /* Gtk flavor by William Perry */
|
|
28
|
|
29 /* Lots of work done by Ben Wing for Mule */
|
|
30
|
|
31 #include <config.h>
|
|
32 #include "lisp.h"
|
|
33
|
|
34 #include "buffer.h"
|
|
35 #include "debug.h"
|
872
|
36 #include "device-impl.h"
|
462
|
37 #include "faces.h"
|
872
|
38 #include "file-coding.h"
|
|
39 #include "frame-impl.h"
|
462
|
40 #include "gutter.h"
|
|
41 #include "redisplay.h"
|
|
42 #include "sysdep.h"
|
|
43 #include "window.h"
|
872
|
44
|
|
45 #include "console-gtk-impl.h"
|
|
46 #include "gccache-gtk.h"
|
|
47 #include "glyphs-gtk.h"
|
|
48 #include "objects-gtk-impl.h"
|
462
|
49
|
|
50 #include "sysproc.h" /* for select() */
|
|
51
|
|
52 #ifdef MULE
|
|
53 #include "mule-ccl.h"
|
|
54 #endif
|
|
55
|
|
56 #define CONST const
|
|
57
|
|
58 #define EOL_CURSOR_WIDTH 5
|
|
59
|
714
|
60 static void gtk_output_pixmap (struct window *w,
|
|
61 Lisp_Object image_instance,
|
|
62 struct display_box *db,
|
|
63 struct display_glyph_area *dga,
|
|
64 face_index findex,
|
|
65 int cursor_start,
|
|
66 int cursor_width,
|
|
67 int cursor_height,
|
|
68 int bgpixmap);
|
462
|
69 static void gtk_output_vertical_divider (struct window *w, int clear);
|
|
70 static void gtk_output_blank (struct window *w, struct display_line *dl,
|
|
71 struct rune *rb, int start_pixpos,
|
|
72 int cursor_start, int cursor_width);
|
714
|
73 static void gtk_output_horizontal_line (struct window *w,
|
|
74 struct display_line *dl,
|
|
75 struct rune *rb);
|
462
|
76 static void gtk_clear_region (Lisp_Object locale, struct device* d, struct frame* f,
|
|
77 face_index findex, int x, int y,
|
|
78 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
|
|
79 Lisp_Object background_pixmap);
|
|
80 static void gtk_output_eol_cursor (struct window *w, struct display_line *dl,
|
|
81 int xpos, face_index findex);
|
|
82 static void gtk_clear_frame (struct frame *f);
|
|
83 static void gtk_clear_frame_windows (Lisp_Object window);
|
|
84 static void gtk_bevel_modeline (struct window *w, struct display_line *dl);
|
|
85
|
|
86 #if 0
|
|
87 static void __describe_gc (GdkGC *);
|
|
88 #endif
|
|
89
|
|
90 struct textual_run
|
|
91 {
|
|
92 Lisp_Object charset;
|
|
93 unsigned char *ptr;
|
|
94 int len;
|
|
95 int dimension;
|
|
96 };
|
|
97
|
|
98 /* Separate out the text in DYN into a series of textual runs of a
|
|
99 particular charset. Also convert the characters as necessary into
|
|
100 the format needed by XDrawImageString(), XDrawImageString16(), et
|
|
101 al. (This means converting to one or two byte format, possibly
|
|
102 tweaking the high bits, and possibly running a CCL program.) You
|
|
103 must pre-allocate the space used and pass it in. (This is done so
|
851
|
104 you can ALLOCA () the space.) You need to allocate (2 * len) bytes
|
462
|
105 of TEXT_STORAGE and (len * sizeof (struct textual_run)) bytes of
|
|
106 RUN_STORAGE, where LEN is the length of the dynarr.
|
|
107
|
|
108 Returns the number of runs actually used. */
|
|
109
|
|
110 static int
|
|
111 separate_textual_runs (unsigned char *text_storage,
|
|
112 struct textual_run *run_storage,
|
867
|
113 CONST Ichar *str, Charcount len)
|
462
|
114 {
|
|
115 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
|
|
116 possible valid charset when
|
|
117 MULE is not defined */
|
|
118 int runs_so_far = 0;
|
|
119 int i;
|
|
120 #ifdef MULE
|
|
121 struct ccl_program char_converter;
|
|
122 int need_ccl_conversion = 0;
|
|
123 #endif
|
|
124
|
|
125 for (i = 0; i < len; i++)
|
|
126 {
|
867
|
127 Ichar ch = str[i];
|
462
|
128 Lisp_Object charset;
|
|
129 int byte1, byte2;
|
|
130 int dimension;
|
|
131 int graphic;
|
|
132
|
867
|
133 BREAKUP_ICHAR (ch, charset, byte1, byte2);
|
462
|
134 dimension = XCHARSET_DIMENSION (charset);
|
|
135 graphic = XCHARSET_GRAPHIC (charset);
|
|
136
|
|
137 if (!EQ (charset, prev_charset))
|
|
138 {
|
|
139 run_storage[runs_so_far].ptr = text_storage;
|
|
140 run_storage[runs_so_far].charset = charset;
|
|
141 run_storage[runs_so_far].dimension = dimension;
|
|
142
|
|
143 if (runs_so_far)
|
|
144 {
|
|
145 run_storage[runs_so_far - 1].len =
|
|
146 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
147 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
148 run_storage[runs_so_far - 1].len >>= 1;
|
|
149 }
|
|
150 runs_so_far++;
|
|
151 prev_charset = charset;
|
|
152 #ifdef MULE
|
|
153 {
|
|
154 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
|
|
155 need_ccl_conversion = !NILP (ccl_prog);
|
|
156 if (need_ccl_conversion)
|
|
157 setup_ccl_program (&char_converter, ccl_prog);
|
|
158 }
|
|
159 #endif
|
|
160 }
|
|
161
|
|
162 if (graphic == 0)
|
|
163 {
|
|
164 byte1 &= 0x7F;
|
|
165 byte2 &= 0x7F;
|
|
166 }
|
|
167 else if (graphic == 1)
|
|
168 {
|
|
169 byte1 |= 0x80;
|
|
170 byte2 |= 0x80;
|
|
171 }
|
|
172 #ifdef MULE
|
|
173 if (need_ccl_conversion)
|
|
174 {
|
|
175 char_converter.reg[0] = XCHARSET_ID (charset);
|
|
176 char_converter.reg[1] = byte1;
|
|
177 char_converter.reg[2] = byte2;
|
|
178 ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
|
|
179 byte1 = char_converter.reg[1];
|
|
180 byte2 = char_converter.reg[2];
|
|
181 }
|
|
182 #endif
|
|
183 *text_storage++ = (unsigned char) byte1;
|
|
184 if (dimension == 2)
|
|
185 *text_storage++ = (unsigned char) byte2;
|
|
186 }
|
|
187
|
|
188 if (runs_so_far)
|
|
189 {
|
|
190 run_storage[runs_so_far - 1].len =
|
|
191 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
192 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
193 run_storage[runs_so_far - 1].len >>= 1;
|
|
194 }
|
|
195
|
|
196 return runs_so_far;
|
|
197 }
|
|
198
|
|
199 /****************************************************************************/
|
|
200 /* */
|
|
201 /* Gtk output routines */
|
|
202 /* */
|
|
203 /****************************************************************************/
|
|
204
|
|
205 static int
|
|
206 gtk_text_width_single_run (struct face_cachel *cachel, struct textual_run *run)
|
|
207 {
|
|
208 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
|
|
209 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
|
|
210
|
|
211 if (!fi->proportional_p)
|
|
212 {
|
|
213 return fi->width * run->len;
|
|
214 }
|
|
215 else
|
|
216 {
|
|
217 if (run->dimension == 2)
|
|
218 {
|
|
219 stderr_out ("Measuring wide characters\n");
|
|
220 return gdk_text_width_wc (FONT_INSTANCE_GTK_FONT (fi),
|
|
221 (GdkWChar *) run->ptr, run->len);
|
|
222 }
|
|
223 else
|
|
224 {
|
|
225 return gdk_text_width (FONT_INSTANCE_GTK_FONT (fi),
|
|
226 (char *) run->ptr, run->len);
|
|
227 }
|
|
228 }
|
|
229 }
|
|
230
|
|
231 /*
|
|
232 gtk_text_width
|
|
233
|
|
234 Given a string and a face, return the string's length in pixels when
|
|
235 displayed in the font associated with the face.
|
|
236 */
|
|
237
|
|
238 static int
|
2286
|
239 gtk_text_width (struct frame *UNUSED (f), struct face_cachel *cachel,
|
|
240 CONST Ichar *str, Charcount len)
|
462
|
241 {
|
2367
|
242 /* !!#### */
|
462
|
243 int width_so_far = 0;
|
851
|
244 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
|
462
|
245 struct textual_run *runs = alloca_array (struct textual_run, len);
|
|
246 int nruns;
|
|
247 int i;
|
|
248
|
|
249 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
250
|
|
251 for (i = 0; i < nruns; i++)
|
|
252 width_so_far += gtk_text_width_single_run (cachel, runs + i);
|
|
253
|
|
254 return width_so_far;
|
|
255 }
|
|
256
|
|
257 /*****************************************************************************
|
|
258 gtk_divider_height
|
|
259
|
|
260 Return the height of the horizontal divider. This is a function because
|
|
261 divider_height is a device method.
|
|
262
|
|
263 #### If we add etched horizontal divider lines this will have to get
|
|
264 smarter.
|
|
265 ****************************************************************************/
|
|
266 static int
|
|
267 gtk_divider_height (void)
|
|
268 {
|
|
269 return 2;
|
|
270 }
|
|
271
|
|
272 /*****************************************************************************
|
|
273 gtk_eol_cursor_width
|
|
274
|
|
275 Return the width of the end-of-line cursor. This is a function
|
|
276 because eol_cursor_width is a device method.
|
|
277 ****************************************************************************/
|
|
278 static int
|
|
279 gtk_eol_cursor_width (void)
|
|
280 {
|
|
281 return EOL_CURSOR_WIDTH;
|
|
282 }
|
|
283
|
|
284 /*****************************************************************************
|
|
285 gtk_output_display_block
|
|
286
|
|
287 Given a display line, a block number for that start line, output all
|
|
288 runes between start and end in the specified display block.
|
|
289 ****************************************************************************/
|
|
290 static void
|
|
291 gtk_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
292 int start, int end, int start_pixpos, int cursor_start,
|
|
293 int cursor_width, int cursor_height)
|
|
294 {
|
|
295 struct frame *f = XFRAME (w->frame);
|
3479
|
296 Ichar_dynarr *buf;
|
462
|
297 Lisp_Object window;
|
|
298
|
|
299 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
300 rune_dynarr *rba = db->runes;
|
|
301 struct rune *rb;
|
|
302
|
|
303 int elt = start;
|
|
304 face_index findex;
|
|
305 int xpos, width;
|
|
306 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
307 MULE is not defined */
|
|
308
|
793
|
309 window = wrap_window (w);
|
462
|
310 rb = Dynarr_atp (rba, start);
|
|
311
|
|
312 if (!rb)
|
|
313 {
|
|
314 /* Nothing to do so don't do anything. */
|
|
315 return;
|
|
316 }
|
|
317 else
|
|
318 {
|
|
319 findex = rb->findex;
|
|
320 xpos = rb->xpos;
|
|
321 width = 0;
|
|
322 if (rb->type == RUNE_CHAR)
|
867
|
323 charset = ichar_charset (rb->object.chr.ch);
|
462
|
324 }
|
|
325
|
|
326 if (end < 0)
|
|
327 end = Dynarr_length (rba);
|
3479
|
328 buf = Dynarr_new (Ichar);
|
462
|
329
|
|
330 while (elt < end)
|
|
331 {
|
|
332 rb = Dynarr_atp (rba, elt);
|
|
333
|
|
334 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
335 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
867
|
336 && EQ (charset, ichar_charset (rb->object.chr.ch)))
|
462
|
337 {
|
|
338 Dynarr_add (buf, rb->object.chr.ch);
|
|
339 width += rb->width;
|
|
340 elt++;
|
|
341 }
|
|
342 else
|
|
343 {
|
|
344 if (Dynarr_length (buf))
|
|
345 {
|
|
346 gtk_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
347 findex, 0, cursor_start, cursor_width,
|
|
348 cursor_height);
|
|
349 xpos = rb->xpos;
|
|
350 width = 0;
|
|
351 }
|
|
352 Dynarr_reset (buf);
|
|
353 width = 0;
|
|
354
|
|
355 if (rb->type == RUNE_CHAR)
|
|
356 {
|
|
357 findex = rb->findex;
|
|
358 xpos = rb->xpos;
|
867
|
359 charset = ichar_charset (rb->object.chr.ch);
|
462
|
360
|
|
361 if (rb->cursor_type == CURSOR_ON)
|
|
362 {
|
|
363 if (rb->object.chr.ch == '\n')
|
|
364 {
|
|
365 gtk_output_eol_cursor (w, dl, xpos, findex);
|
|
366 }
|
|
367 else
|
|
368 {
|
|
369 Dynarr_add (buf, rb->object.chr.ch);
|
|
370 gtk_output_string (w, dl, buf, xpos, 0, start_pixpos,
|
|
371 rb->width, findex, 1,
|
|
372 cursor_start, cursor_width,
|
|
373 cursor_height);
|
|
374 Dynarr_reset (buf);
|
|
375 }
|
|
376
|
|
377 xpos += rb->width;
|
|
378 elt++;
|
|
379 }
|
|
380 else if (rb->object.chr.ch == '\n')
|
|
381 {
|
|
382 /* Clear in case a cursor was formerly here. */
|
|
383 int height = dl->ascent + dl->descent - dl->clip;
|
|
384
|
|
385 redisplay_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
|
|
386 rb->width, height);
|
|
387 elt++;
|
|
388 }
|
|
389 }
|
|
390 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
391 {
|
|
392 if (rb->type == RUNE_BLANK)
|
|
393 gtk_output_blank (w, dl, rb, start_pixpos, cursor_start,
|
|
394 cursor_width);
|
|
395 else
|
|
396 {
|
|
397 /* #### Our flagging of when we need to redraw the
|
|
398 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
399 by the modeline at the moment it is a good bet
|
|
400 that if it gets redrawn then we should also
|
|
401 redraw the shadows. This won't be true forever.
|
|
402 We borrow the shadow_thickness_changed flag for
|
|
403 now. */
|
|
404 w->shadow_thickness_changed = 1;
|
714
|
405 gtk_output_horizontal_line (w, dl, rb);
|
462
|
406 }
|
|
407
|
|
408 elt++;
|
|
409 if (elt < end)
|
|
410 {
|
|
411 rb = Dynarr_atp (rba, elt);
|
|
412
|
|
413 findex = rb->findex;
|
|
414 xpos = rb->xpos;
|
|
415 }
|
|
416 }
|
|
417 else if (rb->type == RUNE_DGLYPH)
|
|
418 {
|
|
419 Lisp_Object instance;
|
|
420 struct display_box dbox;
|
|
421 struct display_glyph_area dga;
|
|
422 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
|
819
|
423 rb->object.dglyph.yoffset ,start_pixpos,
|
|
424 rb->width, &dbox, &dga);
|
462
|
425
|
793
|
426 window = wrap_window (w);
|
462
|
427 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
793
|
428 window, ERROR_ME_DEBUG_WARN, 1);
|
462
|
429 findex = rb->findex;
|
|
430
|
|
431 if (IMAGE_INSTANCEP (instance))
|
|
432 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
433 {
|
|
434 case IMAGE_TEXT:
|
|
435 {
|
|
436 /* #### This is way losing. See the comment in
|
|
437 add_glyph_rune(). */
|
|
438 Lisp_Object string =
|
|
439 XIMAGE_INSTANCE_TEXT_STRING (instance);
|
867
|
440 convert_ibyte_string_into_ichar_dynarr
|
462
|
441 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
442
|
|
443 gtk_output_string (w, dl, buf, xpos,
|
|
444 rb->object.dglyph.xoffset,
|
|
445 start_pixpos, -1, findex,
|
|
446 (rb->cursor_type == CURSOR_ON),
|
|
447 cursor_start, cursor_width,
|
|
448 cursor_height);
|
|
449 Dynarr_reset (buf);
|
|
450 }
|
|
451 break;
|
|
452
|
|
453 case IMAGE_MONO_PIXMAP:
|
|
454 case IMAGE_COLOR_PIXMAP:
|
714
|
455 redisplay_output_pixmap (w, instance, &dbox, &dga,
|
|
456 findex,cursor_start,
|
|
457 cursor_width, cursor_height, 0);
|
462
|
458 break;
|
|
459
|
|
460 case IMAGE_POINTER:
|
2500
|
461 ABORT ();
|
462
|
462
|
|
463 case IMAGE_WIDGET:
|
|
464 if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance),
|
|
465 Qlayout))
|
|
466 {
|
|
467 redisplay_output_layout (window, instance, &dbox,
|
|
468 &dga, findex,
|
|
469 cursor_start, cursor_width,
|
|
470 cursor_height);
|
|
471 break;
|
|
472 }
|
|
473
|
|
474 case IMAGE_SUBWINDOW:
|
|
475 redisplay_output_subwindow (w, instance, &dbox, &dga,
|
|
476 findex, cursor_start,
|
|
477 cursor_width, cursor_height);
|
|
478 break;
|
|
479
|
|
480 case IMAGE_NOTHING:
|
|
481 /* nothing is as nothing does */
|
|
482 break;
|
|
483
|
|
484 default:
|
2500
|
485 ABORT ();
|
462
|
486 }
|
|
487
|
|
488 xpos += rb->width;
|
|
489 elt++;
|
|
490 }
|
|
491 else
|
2500
|
492 ABORT ();
|
462
|
493 }
|
|
494 }
|
|
495
|
|
496 if (Dynarr_length (buf))
|
|
497 gtk_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex,
|
|
498 0, cursor_start, cursor_width, cursor_height);
|
|
499
|
|
500 /* #### This is really conditionalized well for optimized
|
|
501 performance. */
|
|
502 if (dl->modeline
|
|
503 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
504 && (f->clear
|
|
505 || f->windows_structure_changed
|
|
506 || w->shadow_thickness_changed))
|
|
507 gtk_bevel_modeline (w, dl);
|
|
508
|
|
509 Dynarr_free (buf);
|
|
510 }
|
|
511
|
|
512 /*****************************************************************************
|
|
513 gtk_bevel_modeline
|
|
514
|
|
515 Draw a 3d border around the modeline on window W.
|
|
516 ****************************************************************************/
|
|
517 static void
|
|
518 gtk_bevel_modeline (struct window *w, struct display_line *dl)
|
|
519 {
|
|
520 struct frame *f = XFRAME (w->frame);
|
|
521 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
522 int x,y, width, height;
|
|
523
|
|
524 x = WINDOW_MODELINE_LEFT (w);
|
|
525 width = WINDOW_MODELINE_RIGHT (w) - x;
|
|
526 y = dl->ypos - dl->ascent - shadow_thickness;
|
|
527 height = dl->ascent + dl->descent + 2 * shadow_thickness;
|
|
528
|
|
529 gtk_output_shadows (f, x, y, width, height, shadow_thickness);
|
|
530 }
|
|
531
|
|
532 /*****************************************************************************
|
|
533 gtk_get_gc
|
|
534
|
|
535 Given a number of parameters return a GC with those properties.
|
|
536 ****************************************************************************/
|
|
537 GdkGC *
|
|
538 gtk_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
|
|
539 Lisp_Object bg_pmap, Lisp_Object lwidth)
|
|
540 {
|
|
541 GdkGCValues gcv;
|
|
542 unsigned long mask;
|
|
543
|
|
544 memset (&gcv, ~0, sizeof (gcv));
|
|
545 gcv.graphics_exposures = FALSE;
|
|
546 /* Make absolutely sure that we don't pick up a clipping region in
|
|
547 the GC returned by this function. */
|
|
548 gcv.clip_mask = 0;
|
|
549 gcv.clip_x_origin = 0;
|
|
550 gcv.clip_y_origin = 0;
|
|
551 gcv.fill = GDK_SOLID;
|
|
552 mask = GDK_GC_EXPOSURES | GDK_GC_CLIP_MASK | GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN;
|
|
553 mask |= GDK_GC_FILL;
|
|
554
|
|
555 if (!NILP (font))
|
|
556 {
|
|
557 gcv.font = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (font));
|
|
558 mask |= GDK_GC_FONT;
|
|
559 }
|
|
560
|
|
561 /* evil kludge! */
|
|
562 if (!NILP (fg) && !COLOR_INSTANCEP (fg) && !INTP (fg))
|
|
563 {
|
|
564 /* #### I fixed once case where this was getting it. It was a
|
|
565 bad macro expansion (compiler bug). */
|
|
566 fprintf (stderr, "Help! gtk_get_gc got a bogus fg value! fg = ");
|
|
567 debug_print (fg);
|
|
568 fg = Qnil;
|
|
569 }
|
|
570
|
|
571 if (!NILP (fg))
|
|
572 {
|
|
573 if (COLOR_INSTANCEP (fg))
|
|
574 gcv.foreground = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (fg));
|
|
575 else
|
|
576 gcv.foreground.pixel = XINT (fg);
|
|
577 mask |= GDK_GC_FOREGROUND;
|
|
578 }
|
|
579
|
|
580 if (!NILP (bg))
|
|
581 {
|
|
582 if (COLOR_INSTANCEP (bg))
|
|
583 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (bg));
|
|
584 else
|
|
585 gcv.background.pixel = XINT (fg);
|
|
586 mask |= GDK_GC_BACKGROUND;
|
|
587 }
|
|
588
|
|
589 if (IMAGE_INSTANCEP (bg_pmap)
|
|
590 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
591 {
|
|
592 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
|
|
593 {
|
|
594 gcv.fill = GDK_OPAQUE_STIPPLED;
|
|
595 gcv.stipple = XIMAGE_INSTANCE_GTK_PIXMAP (bg_pmap);
|
|
596 mask |= (GDK_GC_STIPPLE | GDK_GC_FILL);
|
|
597 }
|
|
598 else
|
|
599 {
|
|
600 gcv.fill = GDK_TILED;
|
|
601 gcv.tile = XIMAGE_INSTANCE_GTK_PIXMAP (bg_pmap);
|
|
602 mask |= (GDK_GC_TILE | GDK_GC_FILL);
|
|
603 }
|
|
604 }
|
|
605
|
|
606 if (!NILP (lwidth))
|
|
607 {
|
|
608 gcv.line_width = XINT (lwidth);
|
|
609 mask |= GDK_GC_LINE_WIDTH;
|
|
610 }
|
|
611
|
2054
|
612 return gc_cache_lookup (DEVICE_GTK_GC_CACHE (d), &gcv, (GdkGCValuesMask) mask);
|
462
|
613 }
|
|
614
|
|
615 /*****************************************************************************
|
|
616 gtk_output_string
|
|
617
|
|
618 Given a string and a starting position, output that string in the
|
|
619 given face. If cursor is true, draw a cursor around the string.
|
|
620 Correctly handles multiple charsets in the string.
|
|
621
|
|
622 The meaning of the parameters is something like this:
|
|
623
|
|
624 W Window that the text is to be displayed in.
|
|
625 DL Display line that this text is on. The values in the
|
|
626 structure are used to determine the vertical position and
|
|
627 clipping range of the text.
|
867
|
628 BUF Dynamic array of Ichars specifying what is actually to be
|
462
|
629 drawn.
|
|
630 XPOS X position in pixels where the text should start being drawn.
|
|
631 XOFFSET Number of pixels to be chopped off the left side of the
|
|
632 text. The effect is as if the text were shifted to the
|
|
633 left this many pixels and clipped at XPOS.
|
|
634 CLIP_START Clip everything left of this X position.
|
|
635 WIDTH Clip everything right of XPOS + WIDTH.
|
|
636 FINDEX Index for the face cache element describing how to display
|
|
637 the text.
|
|
638 CURSOR #### I don't understand this. There's something
|
|
639 strange and overcomplexified with this variable.
|
|
640 Chuck, explain please?
|
|
641 CURSOR_START Starting X position of cursor.
|
|
642 CURSOR_WIDTH Width of cursor in pixels.
|
|
643 CURSOR_HEIGHT Height of cursor in pixels.
|
|
644
|
|
645 Starting Y position of cursor is the top of the text line.
|
|
646 The cursor is drawn sometimes whether or not CURSOR is set. ???
|
|
647 ****************************************************************************/
|
714
|
648 static
|
|
649 void gdk_draw_text_image (GdkDrawable *drawable,
|
|
650 GdkFont *font,
|
|
651 GdkGC *gc,
|
|
652 gint x,
|
|
653 gint y,
|
|
654 const gchar *text,
|
|
655 gint text_length);
|
462
|
656
|
|
657 void
|
|
658 gtk_output_string (struct window *w, struct display_line *dl,
|
867
|
659 Ichar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
462
|
660 int width, face_index findex, int cursor,
|
|
661 int cursor_start, int cursor_width, int cursor_height)
|
|
662 {
|
2367
|
663 /* !!#### Needs review */
|
462
|
664 /* General variables */
|
|
665 struct frame *f = XFRAME (w->frame);
|
|
666 struct device *d = XDEVICE (f->device);
|
|
667 Lisp_Object device;
|
|
668 Lisp_Object window;
|
|
669 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
670
|
|
671 int clip_end;
|
|
672
|
|
673 /* Cursor-related variables */
|
|
674 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
675 int cursor_clip;
|
|
676 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
677 WINDOW_BUFFER (w));
|
|
678 struct face_cachel *cursor_cachel = 0;
|
|
679
|
|
680 /* Text-related variables */
|
|
681 Lisp_Object bg_pmap;
|
|
682 GdkGC *bgc, *gc;
|
|
683 int height;
|
|
684 int len = Dynarr_length (buf);
|
851
|
685 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
|
462
|
686 struct textual_run *runs = alloca_array (struct textual_run, len);
|
|
687 int nruns;
|
|
688 int i;
|
|
689 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
690
|
793
|
691 device = wrap_device (d);
|
|
692 window = wrap_window (w);
|
462
|
693
|
|
694 if (width < 0)
|
|
695 width = gtk_text_width (f, cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
696 height = dl->ascent + dl->descent - dl->clip;
|
|
697
|
|
698 /* Regularize the variables passed in. */
|
|
699
|
|
700 if (clip_start < xpos)
|
|
701 clip_start = xpos;
|
|
702 clip_end = xpos + width;
|
|
703 if (clip_start >= clip_end)
|
|
704 /* It's all clipped out. */
|
|
705 return;
|
|
706
|
|
707 xpos -= xoffset;
|
|
708
|
|
709 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
|
|
710 Dynarr_length (buf));
|
|
711
|
|
712 cursor_clip = (cursor_start >= clip_start &&
|
|
713 cursor_start < clip_end);
|
|
714
|
|
715 /* This cursor code is really a mess. */
|
|
716 if (!NILP (w->text_cursor_visible_p)
|
|
717 && (cursor
|
|
718 || cursor_clip
|
|
719 || (cursor_width
|
|
720 && (cursor_start + cursor_width >= clip_start)
|
|
721 && !NILP (bar_cursor_value))))
|
|
722 {
|
|
723 /* These have to be in separate statements in order to avoid a
|
|
724 compiler bug. */
|
|
725 face_index sucks = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
726 cursor_cachel = WINDOW_FACE_CACHEL (w, sucks);
|
|
727
|
|
728 /* We have to reset this since any call to WINDOW_FACE_CACHEL
|
|
729 may cause the cache to resize and any pointers to it to
|
|
730 become invalid. */
|
|
731 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
732 }
|
|
733
|
|
734 bg_pmap = cachel->background_pixmap;
|
|
735 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
736 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
737 bg_pmap = Qnil;
|
|
738
|
|
739 if ((cursor && focus && NILP (bar_cursor_value)
|
|
740 && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
|
|
741 bgc = 0;
|
|
742 else
|
|
743 bgc = gtk_get_gc (d, Qnil, cachel->foreground, cachel->background,
|
|
744 bg_pmap, Qnil);
|
|
745
|
|
746 if (bgc)
|
|
747 gdk_draw_rectangle (GDK_DRAWABLE (x_win), bgc, TRUE, clip_start,
|
|
748 dl->ypos - dl->ascent, clip_end - clip_start,
|
|
749 height);
|
|
750
|
|
751 for (i = 0; i < nruns; i++)
|
|
752 {
|
|
753 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
|
754 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
|
755 GdkFont *gdk_font = FONT_INSTANCE_GTK_FONT (fi);
|
|
756 int this_width;
|
|
757 int need_clipping;
|
|
758
|
|
759 if (EQ (font, Vthe_null_font_instance))
|
|
760 continue;
|
|
761
|
|
762 this_width = gtk_text_width_single_run (cachel, runs + i);
|
|
763 need_clipping = (dl->clip || clip_start > xpos ||
|
|
764 clip_end < xpos + this_width);
|
|
765
|
|
766 /* XDrawImageString only clears the area equal to the height of
|
|
767 the given font. It is possible that a font is being displayed
|
|
768 on a line taller than it is, so this would cause us to fail to
|
|
769 clear some areas. */
|
|
770 if ((int) fi->height < (int) (height + dl->clip))
|
|
771 {
|
|
772 int clear_start = max (xpos, clip_start);
|
|
773 int clear_end = min (xpos + this_width, clip_end);
|
|
774
|
|
775 if (cursor)
|
|
776 {
|
|
777 int ypos1_line, ypos1_string, ypos2_line, ypos2_string;
|
|
778
|
|
779 ypos1_string = dl->ypos - fi->ascent;
|
|
780 ypos2_string = dl->ypos + fi->descent;
|
|
781 ypos1_line = dl->ypos - dl->ascent;
|
|
782 ypos2_line = dl->ypos + dl->descent - dl->clip;
|
|
783
|
|
784 /* Make sure we don't clear below the real bottom of the
|
|
785 line. */
|
|
786 if (ypos1_string > ypos2_line)
|
|
787 ypos1_string = ypos2_line;
|
|
788 if (ypos2_string > ypos2_line)
|
|
789 ypos2_string = ypos2_line;
|
|
790
|
|
791 if (ypos1_line < ypos1_string)
|
|
792 {
|
|
793 redisplay_clear_region (window, findex, clear_start, ypos1_line,
|
|
794 clear_end - clear_start,
|
|
795 ypos1_string - ypos1_line);
|
|
796 }
|
|
797
|
|
798 if (ypos2_line > ypos2_string)
|
|
799 {
|
|
800 redisplay_clear_region (window, findex, clear_start, ypos2_string,
|
|
801 clear_end - clear_start,
|
|
802 ypos2_line - ypos2_string);
|
|
803 }
|
|
804 }
|
|
805 else
|
|
806 {
|
|
807 redisplay_clear_region (window, findex, clear_start,
|
|
808 dl->ypos - dl->ascent, clear_end - clear_start,
|
|
809 height);
|
|
810 }
|
|
811 }
|
|
812
|
|
813 if (cursor && cursor_cachel && focus && NILP (bar_cursor_value))
|
|
814 {
|
|
815 gc = gtk_get_gc (d, font, cursor_cachel->foreground,
|
|
816 cursor_cachel->background, Qnil, Qnil);
|
|
817 }
|
|
818 else
|
|
819 {
|
|
820 gc = gtk_get_gc (d, font, cachel->foreground, cachel->background,
|
|
821 Qnil, Qnil);
|
|
822 }
|
|
823
|
|
824 if (need_clipping)
|
|
825 {
|
|
826 GdkRectangle clip_box;
|
|
827
|
|
828 clip_box.x = 0;
|
|
829 clip_box.y = 0;
|
|
830 clip_box.width = clip_end - clip_start;
|
|
831 clip_box.height = height;
|
|
832
|
|
833 gdk_gc_set_clip_rectangle (gc, &clip_box);
|
|
834 gdk_gc_set_clip_origin (gc, clip_start, dl->ypos - dl->ascent);
|
|
835 }
|
|
836
|
|
837 /* The X specific called different functions (XDraw*String
|
|
838 vs. XDraw*String16), but apparently gdk_draw_text takes care
|
|
839 of that for us.
|
|
840
|
|
841 BUT, gdk_draw_text also does too much, by dividing the length
|
|
842 by 2. So we fake them out my multiplying the length by the
|
|
843 dimension of the text. This will do the right thing for
|
|
844 single-dimension runs as well of course.
|
|
845 */
|
|
846 (bgc ? gdk_draw_text : gdk_draw_text_image) (GDK_DRAWABLE (x_win), gdk_font, gc, xpos,
|
|
847 dl->ypos, (char *) runs[i].ptr,
|
|
848 runs[i].len * runs[i].dimension);
|
|
849
|
|
850 /* We draw underlines in the same color as the text. */
|
|
851 if (cachel->underline)
|
|
852 {
|
2054
|
853 int upos, uthick;
|
462
|
854
|
|
855 /* Cannot get at font properties in Gtk, so we resort to
|
|
856 guessing */
|
|
857 upos = dl->descent / 2;
|
|
858 uthick = 1;
|
|
859
|
778
|
860 if ((dl->ypos + upos) < (dl->ypos + dl->descent - dl->clip))
|
462
|
861 {
|
|
862 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip)
|
|
863 uthick = dl->descent - dl->clip - upos;
|
|
864
|
|
865 if (uthick == 1)
|
|
866 {
|
|
867 gdk_draw_line (GDK_DRAWABLE (x_win), gc, xpos, dl->ypos + upos,
|
|
868 xpos + this_width, dl->ypos + upos);
|
|
869 }
|
|
870 else if (uthick > 1)
|
|
871 {
|
|
872 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, xpos,
|
|
873 dl->ypos + upos, this_width, uthick);
|
|
874 }
|
|
875 }
|
|
876 }
|
|
877
|
|
878 if (cachel->strikethru) {
|
2054
|
879 gint ascent,descent,upos, uthick;
|
462
|
880 GdkFont *gfont = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (font));
|
|
881
|
|
882 /* Cannot get at font properties in Gtk, so we resort to
|
|
883 guessing */
|
|
884
|
|
885 ascent = gfont->ascent;
|
|
886 descent = gfont->descent;
|
|
887 uthick = 1;
|
|
888
|
|
889 upos = ascent - ((ascent + descent) / 2) + 1;
|
|
890
|
|
891 /* Generally, upos will be positive (above the baseline),so subtract */
|
|
892 if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip)
|
|
893 {
|
|
894 if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip)
|
|
895 uthick = dl->descent - dl->clip + upos;
|
|
896
|
|
897 if (uthick == 1)
|
|
898 {
|
|
899 gdk_draw_line (GDK_DRAWABLE (x_win), gc, xpos, dl->ypos - upos,
|
|
900 xpos + this_width, dl->ypos - upos);
|
|
901 }
|
|
902 else if (uthick > 1)
|
|
903 {
|
|
904 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, xpos, dl->ypos + upos,
|
|
905 this_width, uthick);
|
|
906 }
|
|
907 }
|
|
908 }
|
|
909
|
|
910 /* Restore the GC */
|
|
911 if (need_clipping)
|
|
912 {
|
|
913 gdk_gc_set_clip_rectangle (gc, NULL);
|
|
914 gdk_gc_set_clip_origin (gc, 0, 0);
|
|
915 }
|
|
916
|
|
917 /* If we are actually superimposing the cursor then redraw with just
|
|
918 the appropriate section highlighted. */
|
|
919 if (cursor_clip && !cursor && focus && cursor_cachel)
|
|
920 {
|
|
921 GdkGC *cgc;
|
|
922 GdkRectangle clip_box;
|
|
923
|
|
924 cgc = gtk_get_gc (d, font, cursor_cachel->foreground,
|
|
925 cursor_cachel->background, Qnil, Qnil);
|
|
926
|
|
927 clip_box.x = 0;
|
|
928 clip_box.y = 0;
|
|
929 clip_box.width = cursor_width;
|
|
930 clip_box.height = height;
|
|
931
|
|
932 gdk_gc_set_clip_rectangle (cgc, &clip_box);
|
|
933 gdk_gc_set_clip_origin (cgc, cursor_start, dl->ypos - dl->ascent);
|
|
934
|
|
935 /* The X specific called different functions (XDraw*String
|
|
936 vs. XDraw*String16), but apparently gdk_draw_text takes care
|
|
937 of that for us.
|
|
938
|
|
939 BUT, gdk_draw_text also does too much, by dividing the
|
|
940 length by 2. So we fake them out my multiplying the
|
|
941 length by the dimension of the text. This will do the
|
|
942 right thing for single-dimension runs as well of course.
|
|
943 */
|
|
944 gdk_draw_text_image (GDK_DRAWABLE (x_win), gdk_font, cgc, xpos,
|
|
945 dl->ypos, (char *) runs[i].ptr,
|
|
946 runs[i].len * runs[i].dimension);
|
|
947
|
|
948 gdk_gc_set_clip_rectangle (cgc, NULL);
|
|
949 gdk_gc_set_clip_origin (cgc, 0, 0);
|
|
950 }
|
|
951
|
|
952 xpos += this_width;
|
|
953 }
|
|
954
|
|
955 /* Draw the non-focus box or bar-cursor as needed. */
|
|
956 /* Can't this logic be simplified? */
|
|
957 if (cursor_cachel
|
|
958 && ((cursor && !focus && NILP (bar_cursor_value))
|
|
959 || (cursor_width
|
|
960 && (cursor_start + cursor_width >= clip_start)
|
|
961 && !NILP (bar_cursor_value))))
|
|
962 {
|
|
963 int tmp_height, tmp_y;
|
|
964 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
965 int need_clipping = (cursor_start < clip_start
|
|
966 || clip_end < cursor_start + cursor_width);
|
|
967
|
|
968 /* #### This value is correct (as far as I know) because
|
|
969 all of the times we need to draw this cursor, we will
|
|
970 be called with exactly one character, so we know we
|
|
971 can always use runs[0].
|
|
972
|
|
973 This is bogus as all hell, however. The cursor handling in
|
|
974 this function is way bogus and desperately needs to be
|
|
975 cleaned up. (In particular, the drawing of the cursor should
|
|
976 really really be separated out of this function. This may be
|
|
977 a bit tricky now because this function itself does way too
|
|
978 much stuff, a lot of which needs to be moved into
|
|
979 redisplay.c) This is the only way to be able to easily add
|
|
980 new cursor types or (e.g.) make the bar cursor be able to
|
|
981 span two characters instead of overlaying just one. */
|
|
982 int bogusly_obtained_ascent_value =
|
|
983 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent;
|
|
984
|
|
985 if (!NILP (bar_cursor_value))
|
|
986 {
|
|
987 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
988 make_int (bar_width));
|
|
989 }
|
|
990 else
|
|
991 {
|
|
992 gc = gtk_get_gc (d, Qnil, cursor_cachel->background,
|
|
993 Qnil, Qnil, Qnil);
|
|
994 }
|
|
995
|
|
996 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
|
|
997 tmp_height = cursor_height;
|
|
998 if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height))
|
|
999 {
|
|
1000 tmp_y = dl->ypos - dl->ascent + height - tmp_height;
|
|
1001 if (tmp_y < (int) (dl->ypos - dl->ascent))
|
|
1002 tmp_y = dl->ypos - dl->ascent;
|
|
1003 tmp_height = dl->ypos - dl->ascent + height - tmp_y;
|
|
1004 }
|
|
1005
|
|
1006 if (need_clipping)
|
|
1007 {
|
|
1008 GdkRectangle clip_box;
|
|
1009 clip_box.x = 0;
|
|
1010 clip_box.y = 0;
|
|
1011 clip_box.width = clip_end - clip_start;
|
|
1012 clip_box.height = tmp_height;
|
|
1013
|
|
1014 gdk_gc_set_clip_rectangle (gc, &clip_box);
|
|
1015 gdk_gc_set_clip_origin (gc, clip_start, tmp_y);
|
|
1016 }
|
|
1017
|
|
1018 if (!focus && NILP (bar_cursor_value))
|
|
1019 {
|
|
1020 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE,
|
|
1021 cursor_start, tmp_y,
|
|
1022 cursor_width - 1, tmp_height - 1);
|
|
1023 }
|
|
1024 else if (focus && !NILP (bar_cursor_value))
|
|
1025 {
|
|
1026 gdk_draw_line (GDK_DRAWABLE (x_win), gc,
|
|
1027 cursor_start + bar_width - 1, tmp_y,
|
|
1028 cursor_start + bar_width - 1, tmp_y + tmp_height - 1);
|
|
1029 }
|
|
1030
|
|
1031 /* Restore the GC */
|
|
1032 if (need_clipping)
|
|
1033 {
|
|
1034 gdk_gc_set_clip_rectangle (gc, NULL);
|
|
1035 gdk_gc_set_clip_origin (gc, 0, 0);
|
|
1036 }
|
|
1037 }
|
|
1038 }
|
|
1039
|
|
1040 static void
|
|
1041 our_draw_bitmap (GdkDrawable *drawable,
|
|
1042 GdkGC *gc,
|
|
1043 GdkPixmap *src,
|
|
1044 gint xsrc,
|
|
1045 gint ysrc,
|
|
1046 gint xdest,
|
|
1047 gint ydest,
|
|
1048 gint width,
|
|
1049 gint height);
|
|
1050
|
714
|
1051 static void
|
462
|
1052 gtk_output_gdk_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
|
714
|
1053 int y, int xoffset, int yoffset,
|
|
1054 int width, int height,
|
462
|
1055 GdkColor *fg, GdkColor *bg, GdkGC *override_gc)
|
|
1056 {
|
|
1057 struct device *d = XDEVICE (f->device);
|
|
1058 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1059
|
|
1060 GdkGC *gc;
|
|
1061 GdkGCValues gcv;
|
|
1062 unsigned long pixmap_mask;
|
|
1063
|
|
1064 if (!override_gc)
|
|
1065 {
|
|
1066 memset (&gcv, ~0, sizeof (gcv));
|
|
1067 gcv.graphics_exposures = FALSE;
|
|
1068 gcv.foreground = *fg;
|
|
1069 gcv.background = *bg;
|
|
1070 pixmap_mask = GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_EXPOSURES;
|
|
1071
|
|
1072 if (IMAGE_INSTANCE_GTK_MASK (p))
|
|
1073 {
|
|
1074 gcv.function = GDK_COPY;
|
|
1075 gcv.clip_mask = IMAGE_INSTANCE_GTK_MASK (p);
|
714
|
1076 gcv.clip_x_origin = x - xoffset;
|
|
1077 gcv.clip_y_origin = y - yoffset;
|
462
|
1078 pixmap_mask |= (GDK_GC_FUNCTION | GDK_GC_CLIP_MASK | GDK_GC_CLIP_X_ORIGIN |
|
|
1079 GDK_GC_CLIP_Y_ORIGIN);
|
|
1080 /* Can't set a clip rectangle below because we already have a mask.
|
|
1081 We could conceivably create a new clipmask by zeroing out
|
|
1082 everything outside the clip region. Is it worth it?
|
|
1083 Is it possible to get an equivalent effect by changing the
|
|
1084 args to XCopyArea below rather than messing with a clip box?
|
714
|
1085 - dkindred@cs.cmu.edu
|
|
1086 Yes. We don't clip at all now - andy@xemacs.org
|
|
1087 */
|
462
|
1088 }
|
|
1089
|
|
1090 gc = gc_cache_lookup (DEVICE_GTK_GC_CACHE (d), &gcv, pixmap_mask);
|
|
1091 }
|
|
1092 else
|
|
1093 {
|
|
1094 gc = override_gc;
|
|
1095 /* override_gc might have a mask already--we don't want to nuke it.
|
|
1096 Maybe we can insist that override_gc have no mask, or use
|
|
1097 one of the suggestions above. */
|
|
1098 }
|
|
1099
|
|
1100 if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0)
|
|
1101 {
|
|
1102 gdk_draw_pixmap (GDK_DRAWABLE (x_win), gc,
|
|
1103 IMAGE_INSTANCE_GTK_PIXMAP (p),
|
714
|
1104 xoffset, yoffset, x, y, width, height);
|
462
|
1105 }
|
|
1106 else
|
|
1107 {
|
|
1108 our_draw_bitmap (GDK_DRAWABLE (x_win), gc,
|
|
1109 IMAGE_INSTANCE_GTK_PIXMAP (p),
|
714
|
1110 xoffset, yoffset, x, y, width, height);
|
462
|
1111 }
|
|
1112 }
|
|
1113
|
|
1114 static void
|
714
|
1115 gtk_output_pixmap (struct window *w,
|
|
1116 Lisp_Object image_instance,
|
|
1117 struct display_box *db,
|
|
1118 struct display_glyph_area *dga,
|
|
1119 face_index findex,
|
|
1120 int cursor_start,
|
|
1121 int cursor_width,
|
|
1122 int cursor_height,
|
2286
|
1123 int UNUSED (bg_pixmap))
|
462
|
1124 {
|
|
1125 struct frame *f = XFRAME (w->frame);
|
|
1126 struct device *d = XDEVICE (f->device);
|
|
1127 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
|
1128 Lisp_Object window;
|
|
1129
|
|
1130 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1131
|
793
|
1132 window = wrap_window (w);
|
462
|
1133
|
|
1134 /* Output the pixmap. */
|
|
1135 {
|
|
1136 Lisp_Object tmp_pixel;
|
|
1137 GdkColor *tmp_bcolor, *tmp_fcolor;
|
|
1138
|
|
1139 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1140 tmp_fcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1141 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1142 tmp_bcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1143
|
714
|
1144 gtk_output_gdk_pixmap (f, p, db->xpos, db->ypos,
|
|
1145 dga->xoffset, dga->yoffset,
|
|
1146 dga->width, dga->height,
|
|
1147 tmp_fcolor, tmp_bcolor, NULL);
|
462
|
1148 }
|
|
1149
|
|
1150 /* Draw a cursor over top of the pixmap. */
|
714
|
1151 if (cursor_width && cursor_height && (cursor_start >= db->xpos)
|
462
|
1152 && !NILP (w->text_cursor_visible_p)
|
714
|
1153 && (cursor_start < (db->xpos + dga->width)))
|
462
|
1154 {
|
|
1155 GdkGC *gc;
|
|
1156 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1157 struct face_cachel *cursor_cachel =
|
|
1158 WINDOW_FACE_CACHEL (w,
|
|
1159 get_builtin_face_cache_index
|
|
1160 (w, Vtext_cursor_face));
|
|
1161
|
|
1162 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1163
|
714
|
1164 if (cursor_width > db->xpos + dga->width - cursor_start)
|
|
1165 cursor_width = db->xpos + dga->width - cursor_start;
|
462
|
1166
|
|
1167 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, focus ? TRUE : FALSE,
|
714
|
1168 cursor_start, db->ypos, cursor_width,
|
462
|
1169 cursor_height);
|
|
1170 }
|
|
1171 }
|
|
1172
|
|
1173 /*****************************************************************************
|
|
1174 gtk_output_vertical_divider
|
|
1175
|
|
1176 Draw a vertical divider down the right side of the given window.
|
|
1177 ****************************************************************************/
|
|
1178 static void
|
3087
|
1179 gtk_output_vertical_divider (struct window *w, int UNUSED(clear))
|
462
|
1180 {
|
|
1181 struct frame *f = XFRAME (w->frame);
|
|
1182 struct device *d = XDEVICE (f->device);
|
|
1183 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1184 GdkGC *background_gc;
|
|
1185 Lisp_Object tmp_pixel;
|
|
1186 GdkGCValues gcv;
|
|
1187 unsigned long mask;
|
|
1188 int x, y1, y2, width, shadow_thickness, spacing, line_width;
|
|
1189 face_index div_face = get_builtin_face_cache_index (w, Vvertical_divider_face);
|
|
1190
|
|
1191 width = window_divider_width (w);
|
|
1192 shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
|
|
1193 spacing = XINT (w->vertical_divider_spacing);
|
|
1194 line_width = XINT (w->vertical_divider_line_width);
|
|
1195 x = WINDOW_RIGHT (w) - width;
|
|
1196 y1 = WINDOW_TOP (w);
|
|
1197 y2 = WINDOW_BOTTOM (w);
|
|
1198
|
|
1199 memset (&gcv, ~0, sizeof (gcv));
|
|
1200
|
|
1201 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
|
|
1202
|
|
1203 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1204 gcv.foreground = gcv.background;
|
|
1205 gcv.graphics_exposures = FALSE;
|
|
1206 mask = GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_EXPOSURES;
|
|
1207
|
|
1208 background_gc = gc_cache_lookup (DEVICE_GTK_GC_CACHE (d), &gcv, mask);
|
|
1209
|
|
1210 /* Clear the divider area first. This needs to be done when a
|
|
1211 window split occurs. */
|
|
1212 /* if (clear) */
|
|
1213 gdk_draw_rectangle (GDK_DRAWABLE (x_win), background_gc, TRUE,
|
|
1214 x, y1, width, y2 - y1);
|
|
1215
|
|
1216 #if 0
|
|
1217 /* Draw the divider line. */
|
|
1218 gdk_draw_rectangle (GDK_DRAWABLE (x_win), background_gc, TRUE,
|
|
1219 x + spacing + shadow_thickness, y1,
|
|
1220 line_width, y2 - y1);
|
|
1221 #endif
|
|
1222
|
|
1223 /* Draw the shadows around the divider line */
|
|
1224 gtk_output_shadows (f, x + spacing, y1,
|
|
1225 width - 2 * spacing, y2 - y1,
|
|
1226 shadow_thickness);
|
|
1227 }
|
|
1228
|
|
1229 /*****************************************************************************
|
|
1230 gtk_output_blank
|
|
1231
|
|
1232 Output a blank by clearing the area it covers in the foreground color
|
|
1233 of its face.
|
|
1234 ****************************************************************************/
|
|
1235 static void
|
|
1236 gtk_output_blank (struct window *w, struct display_line *dl, struct rune *rb,
|
|
1237 int start_pixpos, int cursor_start, int cursor_width)
|
|
1238 {
|
|
1239 struct frame *f = XFRAME (w->frame);
|
|
1240 struct device *d = XDEVICE (f->device);
|
|
1241
|
|
1242 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1243 GdkGC *gc;
|
|
1244 struct face_cachel *cursor_cachel =
|
|
1245 WINDOW_FACE_CACHEL (w,
|
|
1246 get_builtin_face_cache_index
|
|
1247 (w, Vtext_cursor_face));
|
|
1248 Lisp_Object bg_pmap;
|
|
1249 Lisp_Object buffer = WINDOW_BUFFER (w);
|
|
1250 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
1251 buffer);
|
|
1252
|
|
1253 int x = rb->xpos;
|
|
1254 int y = dl->ypos - dl->ascent;
|
|
1255 int width = rb->width;
|
|
1256 int height = dl->ascent + dl->descent - dl->clip;
|
|
1257
|
|
1258 if (start_pixpos > x)
|
|
1259 {
|
|
1260 if (start_pixpos >= (x + width))
|
|
1261 return;
|
|
1262 else
|
|
1263 {
|
|
1264 width -= (start_pixpos - x);
|
|
1265 x = start_pixpos;
|
|
1266 }
|
|
1267 }
|
|
1268
|
|
1269 bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
|
|
1270 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
1271 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
1272 bg_pmap = Qnil;
|
|
1273
|
|
1274 if (NILP (bg_pmap))
|
|
1275 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
|
|
1276 Qnil, Qnil, Qnil);
|
|
1277 else
|
|
1278 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
|
|
1279 WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
|
|
1280 Qnil);
|
|
1281
|
|
1282 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, y, width, height);
|
|
1283
|
|
1284 /* If this rune is marked as having the cursor, then it is actually
|
|
1285 representing a tab. */
|
|
1286 if (!NILP (w->text_cursor_visible_p)
|
|
1287 && (rb->cursor_type == CURSOR_ON
|
|
1288 || (cursor_width
|
|
1289 && (cursor_start + cursor_width > x)
|
|
1290 && cursor_start < (x + width))))
|
|
1291 {
|
|
1292 int cursor_height, cursor_y;
|
|
1293 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1294 struct Lisp_Font_Instance *fi;
|
|
1295
|
|
1296 fi = XFONT_INSTANCE (FACE_CACHEL_FONT
|
|
1297 (WINDOW_FACE_CACHEL (w, rb->findex),
|
|
1298 Vcharset_ascii));
|
|
1299
|
|
1300 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1301
|
|
1302 cursor_y = dl->ypos - fi->ascent;
|
|
1303 cursor_height = fi->height;
|
|
1304 if (cursor_y + cursor_height > y + height)
|
|
1305 cursor_height = y + height - cursor_y;
|
|
1306
|
|
1307 if (focus)
|
|
1308 {
|
|
1309 if (NILP (bar_cursor_value))
|
|
1310 {
|
|
1311 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE,
|
|
1312 cursor_start, cursor_y,
|
|
1313 fi->width, cursor_height);
|
|
1314 }
|
|
1315 else
|
|
1316 {
|
|
1317 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1318
|
|
1319 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1320 make_int (bar_width));
|
|
1321 gdk_draw_line (GDK_DRAWABLE (x_win), gc, cursor_start + bar_width - 1,
|
|
1322 cursor_y, cursor_start + bar_width - 1,
|
|
1323 cursor_y + cursor_height - 1);
|
|
1324 }
|
|
1325 }
|
|
1326 else if (NILP (bar_cursor_value))
|
|
1327 {
|
|
1328 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE,
|
|
1329 cursor_start, cursor_y,
|
|
1330 fi->width - 1, cursor_height - 1);
|
|
1331 }
|
|
1332 }
|
|
1333 }
|
|
1334
|
|
1335 /*****************************************************************************
|
714
|
1336 gtk_output_horizontal_line
|
462
|
1337
|
|
1338 Output a horizontal line in the foreground of its face.
|
|
1339 ****************************************************************************/
|
|
1340 static void
|
714
|
1341 gtk_output_horizontal_line (struct window *w,
|
|
1342 struct display_line *dl,
|
|
1343 struct rune *rb)
|
462
|
1344 {
|
|
1345 struct frame *f = XFRAME (w->frame);
|
|
1346 struct device *d = XDEVICE (f->device);
|
|
1347 GtkStyle *style = FRAME_GTK_TEXT_WIDGET (f)->style;
|
|
1348
|
|
1349 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1350 GdkGC *gc;
|
|
1351
|
|
1352 int x = rb->xpos;
|
|
1353 int width = rb->width;
|
|
1354 int height = dl->ascent + dl->descent - dl->clip;
|
|
1355
|
|
1356 int ypos1, ypos2, ypos3, ypos4;
|
|
1357
|
|
1358 ypos1 = dl->ypos - dl->ascent;
|
|
1359 ypos2 = ypos1 + rb->object.hline.yoffset;
|
|
1360 ypos3 = ypos2 + rb->object.hline.thickness;
|
|
1361 ypos4 = dl->ypos + dl->descent - dl->clip;
|
|
1362
|
|
1363 /* First clear the area not covered by the line. */
|
|
1364 if (height - rb->object.hline.thickness > 0)
|
|
1365 {
|
|
1366 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
|
|
1367 Qnil, Qnil, Qnil);
|
|
1368
|
|
1369 if (ypos2 - ypos1 > 0)
|
|
1370 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, ypos1, width, ypos2 - ypos1);
|
|
1371 if (ypos4 - ypos3 > 0)
|
|
1372 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, ypos1, width, ypos2 - ypos1);
|
|
1373 }
|
|
1374
|
|
1375 gtk_paint_hline (style, x_win, GTK_STATE_NORMAL, NULL, FRAME_GTK_TEXT_WIDGET (f),
|
|
1376 "hline", x, x + width, ypos2);
|
|
1377 #if 0
|
|
1378 /* Now draw the line. */
|
|
1379 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
|
|
1380 Qnil, Qnil, Qnil);
|
|
1381
|
|
1382 if (ypos2 < ypos1)
|
|
1383 ypos2 = ypos1;
|
|
1384 if (ypos3 > ypos4)
|
|
1385 ypos3 = ypos4;
|
|
1386
|
|
1387 if (ypos3 - ypos2 > 0)
|
|
1388 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, ypos2, width, ypos3 - ypos2);
|
|
1389 #endif
|
|
1390 }
|
|
1391
|
|
1392 /*****************************************************************************
|
|
1393 gtk_output_shadows
|
|
1394
|
|
1395 Draw a shadow around the given area using the standard theme engine routines.
|
|
1396 ****************************************************************************/
|
|
1397 void
|
|
1398 gtk_output_shadows (struct frame *f, int x, int y, int width, int height,
|
|
1399 int shadow_thickness)
|
|
1400 {
|
|
1401 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1402 GtkStyle *style = FRAME_GTK_TEXT_WIDGET (f)->style;
|
|
1403 GtkShadowType stype = GTK_SHADOW_OUT;
|
|
1404
|
|
1405 if (shadow_thickness < 0)
|
|
1406 {
|
|
1407 stype = GTK_SHADOW_IN;
|
|
1408 }
|
|
1409 else if (shadow_thickness == 0)
|
|
1410 {
|
|
1411 stype = GTK_SHADOW_NONE;
|
|
1412 }
|
|
1413
|
|
1414 /* Do we want to have some magic constants to set
|
|
1415 GTK_SHADOW_ETCHED_IN or GTK_SHADOW_ETCHED_OUT? */
|
|
1416
|
|
1417 gtk_paint_shadow (style, x_win, GTK_STATE_NORMAL, stype, NULL,
|
|
1418 FRAME_GTK_TEXT_WIDGET (f), "modeline",
|
|
1419 x, y, width, height);
|
|
1420 }
|
|
1421
|
|
1422 /*****************************************************************************
|
|
1423 gtk_clear_to_window_end
|
|
1424
|
|
1425 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
1426 text area is handled separately since they may each have their own
|
|
1427 background color.
|
|
1428 ****************************************************************************/
|
|
1429 static void
|
|
1430 gtk_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
1431 {
|
|
1432 int height = ypos2 - ypos1;
|
|
1433
|
|
1434 if (height)
|
|
1435 {
|
|
1436 struct frame *f = XFRAME (w->frame);
|
|
1437 Lisp_Object window;
|
|
1438 int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
|
|
1439 layout_bounds bounds;
|
|
1440
|
|
1441 bounds = calculate_display_line_boundaries (w, bflag);
|
793
|
1442 window = wrap_window (w);
|
462
|
1443
|
|
1444 if (window_is_leftmost (w))
|
|
1445 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
1446 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1447
|
|
1448 if (bounds.left_in - bounds.left_out > 0)
|
|
1449 redisplay_clear_region (window,
|
|
1450 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
1451 bounds.left_out, ypos1,
|
|
1452 bounds.left_in - bounds.left_out, height);
|
|
1453
|
|
1454 if (bounds.right_in - bounds.left_in > 0)
|
|
1455 redisplay_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
|
|
1456 bounds.right_in - bounds.left_in, height);
|
|
1457
|
|
1458 if (bounds.right_out - bounds.right_in > 0)
|
|
1459 redisplay_clear_region (window,
|
|
1460 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
1461 bounds.right_in, ypos1,
|
|
1462 bounds.right_out - bounds.right_in, height);
|
|
1463
|
|
1464 if (window_is_rightmost (w))
|
|
1465 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
1466 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1467 }
|
|
1468 }
|
|
1469
|
|
1470 /****************************************************************************
|
|
1471 gtk_clear_region
|
|
1472
|
|
1473 Clear the area in the box defined by the given parameters using the
|
|
1474 given face.
|
|
1475 ****************************************************************************/
|
|
1476 static void
|
2286
|
1477 gtk_clear_region (Lisp_Object UNUSED (locale), struct device* d,
|
|
1478 struct frame* f, face_index UNUSED (findex), int x, int y,
|
462
|
1479 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
|
|
1480 Lisp_Object background_pixmap)
|
|
1481 {
|
|
1482 GdkWindow *x_win;
|
|
1483 GdkGC *gc = NULL;
|
|
1484
|
|
1485 x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1486
|
|
1487 if (!UNBOUNDP (background_pixmap))
|
|
1488 {
|
|
1489 gc = gtk_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
|
|
1490 }
|
|
1491
|
|
1492 if (gc)
|
|
1493 {
|
|
1494 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc,TRUE,
|
|
1495 x, y, width, height);
|
|
1496 }
|
|
1497 else
|
|
1498 {
|
|
1499 gdk_window_clear_area (x_win, x, y, width, height);
|
|
1500 }
|
|
1501 }
|
|
1502
|
|
1503 /*****************************************************************************
|
|
1504 gtk_output_eol_cursor
|
|
1505
|
|
1506 Draw a cursor at the end of a line. The end-of-line cursor is
|
|
1507 narrower than the normal cursor.
|
|
1508 ****************************************************************************/
|
|
1509 static void
|
|
1510 gtk_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
|
|
1511 face_index findex)
|
|
1512 {
|
|
1513 struct frame *f = XFRAME (w->frame);
|
|
1514 struct device *d = XDEVICE (f->device);
|
|
1515 Lisp_Object window;
|
|
1516
|
|
1517 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1518 GdkGC *gc;
|
|
1519 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
1520 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt);
|
|
1521
|
|
1522 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1523 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
1524 WINDOW_BUFFER (w));
|
|
1525
|
|
1526 int x = xpos;
|
|
1527 int y = dl->ypos - dl->ascent;
|
|
1528 int width = EOL_CURSOR_WIDTH;
|
|
1529 int height = dl->ascent + dl->descent - dl->clip;
|
|
1530 int cursor_height, cursor_y;
|
|
1531 int defheight, defascent;
|
|
1532
|
793
|
1533 window = wrap_window (w);
|
462
|
1534 redisplay_clear_region (window, findex, x, y, width, height);
|
|
1535
|
|
1536 if (NILP (w->text_cursor_visible_p))
|
|
1537 return;
|
|
1538
|
|
1539 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1540
|
|
1541 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
|
|
1542
|
|
1543 /* make sure the cursor is entirely contained between y and y+height */
|
|
1544 cursor_height = min (defheight, height);
|
|
1545 cursor_y = max (y, min (y + height - cursor_height,
|
|
1546 dl->ypos - defascent));
|
|
1547
|
|
1548 if (focus)
|
|
1549 {
|
|
1550 if (NILP (bar_cursor_value))
|
|
1551 {
|
|
1552 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, cursor_y, width, cursor_height);
|
|
1553 }
|
|
1554 else
|
|
1555 {
|
|
1556 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1557
|
|
1558 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1559 make_int (bar_width));
|
|
1560 gdk_draw_line (GDK_DRAWABLE (x_win), gc, x + bar_width - 1, cursor_y,
|
|
1561 x + bar_width - 1, cursor_y + cursor_height - 1);
|
|
1562 }
|
|
1563 }
|
|
1564 else if (NILP (bar_cursor_value))
|
|
1565 {
|
|
1566 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE, x, cursor_y, width - 1,
|
|
1567 cursor_height - 1);
|
|
1568 }
|
|
1569 }
|
|
1570
|
|
1571 static void
|
|
1572 gtk_clear_frame_window (Lisp_Object window)
|
|
1573 {
|
|
1574 struct window *w = XWINDOW (window);
|
|
1575
|
|
1576 if (!NILP (w->vchild))
|
|
1577 {
|
|
1578 gtk_clear_frame_windows (w->vchild);
|
|
1579 return;
|
|
1580 }
|
|
1581
|
|
1582 if (!NILP (w->hchild))
|
|
1583 {
|
|
1584 gtk_clear_frame_windows (w->hchild);
|
|
1585 return;
|
|
1586 }
|
|
1587
|
|
1588 gtk_clear_to_window_end (w, WINDOW_TEXT_TOP (w), WINDOW_TEXT_BOTTOM (w));
|
|
1589 }
|
|
1590
|
|
1591 static void
|
|
1592 gtk_clear_frame_windows (Lisp_Object window)
|
|
1593 {
|
|
1594 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
1595 gtk_clear_frame_window (window);
|
|
1596 }
|
|
1597
|
|
1598 static void
|
|
1599 gtk_clear_frame (struct frame *f)
|
|
1600 {
|
|
1601 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1602 int x, y, width, height;
|
|
1603 Lisp_Object frame;
|
|
1604
|
|
1605 x = FRAME_LEFT_BORDER_START (f);
|
|
1606 width = (FRAME_PIXWIDTH (f) - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
|
|
1607 FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -
|
|
1608 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) -
|
|
1609 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f));
|
|
1610 /* #### This adjustment by 1 should be being done in the macros.
|
|
1611 There is some small differences between when the menubar is on
|
|
1612 and off that we still need to deal with. */
|
|
1613 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
1614 height = (FRAME_PIXHEIGHT (f) - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
|
|
1615 FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -
|
|
1616 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) -
|
|
1617 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f)) + 1;
|
|
1618
|
|
1619 gdk_window_clear_area (x_win, x, y, width, height);
|
|
1620
|
793
|
1621 frame = wrap_frame (f);
|
462
|
1622
|
|
1623 if (!UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vdefault_face, frame))
|
|
1624 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vleft_margin_face, frame))
|
|
1625 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vright_margin_face, frame)))
|
|
1626 {
|
|
1627 gtk_clear_frame_windows (f->root_window);
|
|
1628 }
|
|
1629 }
|
|
1630
|
|
1631 static int
|
|
1632 gtk_flash (struct device *d)
|
|
1633 {
|
|
1634 GdkGCValues gcv;
|
|
1635 GdkGC *gc;
|
|
1636 GdkColor tmp_fcolor, tmp_bcolor;
|
|
1637 Lisp_Object tmp_pixel, frame;
|
|
1638 struct frame *f = device_selected_frame (d);
|
|
1639 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
|
|
1640
|
793
|
1641 frame = wrap_frame (f);
|
462
|
1642
|
|
1643 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
|
|
1644 tmp_fcolor = * (COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel)));
|
|
1645 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
|
|
1646 tmp_bcolor = * (COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel)));
|
|
1647
|
|
1648 memset (&gcv, ~0, sizeof (gcv)); /* initialize all slots to ~0 */
|
|
1649 gcv.foreground.pixel = (tmp_fcolor.pixel ^ tmp_bcolor.pixel);
|
|
1650 gcv.function = GDK_XOR;
|
|
1651 gcv.graphics_exposures = FALSE;
|
|
1652 gc = gc_cache_lookup (DEVICE_GTK_GC_CACHE (XDEVICE (f->device)), &gcv,
|
|
1653 GDK_GC_FOREGROUND | GDK_GC_FUNCTION | GDK_GC_EXPOSURES);
|
|
1654
|
|
1655 gdk_draw_rectangle (GDK_DRAWABLE (GET_GTK_WIDGET_WINDOW (FRAME_GTK_SHELL_WIDGET (f))),
|
|
1656 gc, TRUE, w->pixel_left, w->pixel_top,
|
|
1657 w->pixel_width, w->pixel_height);
|
|
1658
|
|
1659 gdk_flush ();
|
|
1660
|
|
1661 #ifdef HAVE_SELECT
|
|
1662 {
|
|
1663 int usecs = 100000;
|
|
1664 struct timeval tv;
|
|
1665 tv.tv_sec = usecs / 1000000L;
|
|
1666 tv.tv_usec = usecs % 1000000L;
|
|
1667 /* I'm sure someone is going to complain about this... */
|
|
1668 select (0, 0, 0, 0, &tv);
|
|
1669 }
|
|
1670 #else
|
778
|
1671 #ifdef HAVE_POLL
|
|
1672 poll (0, 0, 100);
|
|
1673 #else
|
462
|
1674 bite me
|
778
|
1675 #endif
|
|
1676 #endif
|
462
|
1677
|
|
1678 gdk_draw_rectangle (GDK_DRAWABLE (GET_GTK_WIDGET_WINDOW (FRAME_GTK_SHELL_WIDGET (f))),
|
|
1679 gc, TRUE, w->pixel_left, w->pixel_top,
|
|
1680 w->pixel_width, w->pixel_height);
|
|
1681
|
|
1682 gdk_flush ();
|
|
1683
|
|
1684 return 1;
|
|
1685 }
|
|
1686
|
|
1687 static void
|
2286
|
1688 gtk_bevel_area (struct window *w, face_index UNUSED (findex),
|
462
|
1689 int x, int y, int width, int height,
|
2286
|
1690 int shadow_thickness, int UNUSED (edges),
|
|
1691 enum edge_style UNUSED (style))
|
462
|
1692 {
|
|
1693 struct frame *f = XFRAME (w->frame);
|
|
1694
|
|
1695 gtk_output_shadows (f, x, y, width, height, shadow_thickness);
|
|
1696 }
|
|
1697
|
|
1698
|
|
1699
|
|
1700 /* Make audible bell. */
|
|
1701 static void
|
2286
|
1702 gtk_ring_bell (struct device *UNUSED (d), int volume, int UNUSED (pitch),
|
|
1703 int UNUSED (duration))
|
462
|
1704 {
|
714
|
1705 /* Gdk does not allow us to control the duration / pitch / volume */
|
|
1706 if (volume > 0)
|
|
1707 {
|
|
1708 gdk_beep ();
|
|
1709 }
|
462
|
1710 }
|
|
1711
|
|
1712
|
|
1713 /************************************************************************/
|
|
1714 /* initialization */
|
|
1715 /************************************************************************/
|
|
1716
|
|
1717 void
|
|
1718 console_type_create_redisplay_gtk (void)
|
|
1719 {
|
|
1720 /* redisplay methods */
|
|
1721 CONSOLE_HAS_METHOD (gtk, text_width);
|
|
1722 CONSOLE_HAS_METHOD (gtk, output_display_block);
|
|
1723 CONSOLE_HAS_METHOD (gtk, divider_height);
|
|
1724 CONSOLE_HAS_METHOD (gtk, eol_cursor_width);
|
|
1725 CONSOLE_HAS_METHOD (gtk, output_vertical_divider);
|
|
1726 CONSOLE_HAS_METHOD (gtk, clear_to_window_end);
|
|
1727 CONSOLE_HAS_METHOD (gtk, clear_region);
|
|
1728 CONSOLE_HAS_METHOD (gtk, clear_frame);
|
|
1729 CONSOLE_HAS_METHOD (gtk, flash);
|
|
1730 CONSOLE_HAS_METHOD (gtk, ring_bell);
|
|
1731 CONSOLE_HAS_METHOD (gtk, bevel_area);
|
|
1732 CONSOLE_HAS_METHOD (gtk, output_string);
|
714
|
1733 CONSOLE_HAS_METHOD (gtk, output_pixmap);
|
462
|
1734 }
|
|
1735
|
|
1736 /* This makes me feel incredibly dirty... but there is no other way to
|
|
1737 get this done right other than calling clear_area before every
|
|
1738 single $#!%@ing piece of text, which I do NOT want to do. */
|
|
1739 #define USE_X_SPECIFIC_DRAW_ROUTINES 1
|
|
1740
|
|
1741 #include <gdk/gdkx.h>
|
|
1742
|
714
|
1743 static
|
|
1744 void gdk_draw_text_image (GdkDrawable *drawable,
|
|
1745 GdkFont *font,
|
|
1746 GdkGC *gc,
|
|
1747 gint x,
|
|
1748 gint y,
|
|
1749 const gchar *text,
|
|
1750 gint text_length)
|
462
|
1751 {
|
|
1752 #if !USE_X_SPECIFIC_DRAW_ROUTINES
|
|
1753 int width = gdk_text_measure (font, text, text_length);
|
|
1754 int height = gdk_text_height (font, text, text_length);
|
|
1755
|
|
1756 gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height);
|
|
1757 gdk_draw_text (drawable, font, gc, x, y, text, text_length);
|
|
1758 #else
|
|
1759 GdkWindowPrivate *drawable_private;
|
|
1760 GdkFontPrivate *font_private;
|
|
1761 GdkGCPrivate *gc_private;
|
|
1762
|
|
1763 g_return_if_fail (drawable != NULL);
|
|
1764 g_return_if_fail (font != NULL);
|
|
1765 g_return_if_fail (gc != NULL);
|
|
1766 g_return_if_fail (text != NULL);
|
|
1767
|
|
1768 drawable_private = (GdkWindowPrivate*) drawable;
|
|
1769 if (drawable_private->destroyed)
|
|
1770 return;
|
|
1771 gc_private = (GdkGCPrivate*) gc;
|
|
1772 font_private = (GdkFontPrivate*) font;
|
|
1773
|
|
1774 if (font->type == GDK_FONT_FONT)
|
|
1775 {
|
|
1776 XFontStruct *xfont = (XFontStruct *) font_private->xfont;
|
|
1777 XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid);
|
|
1778 if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
|
1779 {
|
|
1780 XDrawImageString (drawable_private->xdisplay, drawable_private->xwindow,
|
|
1781 gc_private->xgc, x, y, text, text_length);
|
|
1782 }
|
|
1783 else
|
|
1784 {
|
|
1785 XDrawImageString16 (drawable_private->xdisplay, drawable_private->xwindow,
|
|
1786 gc_private->xgc, x, y, (XChar2b *) text, text_length / 2);
|
|
1787 }
|
|
1788 }
|
|
1789 else if (font->type == GDK_FONT_FONTSET)
|
|
1790 {
|
|
1791 XFontSet fontset = (XFontSet) font_private->xfont;
|
|
1792 XmbDrawImageString (drawable_private->xdisplay, drawable_private->xwindow,
|
|
1793 fontset, gc_private->xgc, x, y, text, text_length);
|
|
1794 }
|
|
1795 else
|
|
1796 g_error("undefined font type\n");
|
|
1797 #endif
|
|
1798 }
|
|
1799
|
|
1800 static void
|
|
1801 our_draw_bitmap (GdkDrawable *drawable,
|
|
1802 GdkGC *gc,
|
|
1803 GdkPixmap *src,
|
|
1804 gint xsrc,
|
|
1805 gint ysrc,
|
|
1806 gint xdest,
|
|
1807 gint ydest,
|
|
1808 gint width,
|
|
1809 gint height)
|
|
1810 {
|
|
1811 GdkWindowPrivate *drawable_private;
|
|
1812 GdkWindowPrivate *src_private;
|
|
1813 GdkGCPrivate *gc_private;
|
|
1814
|
|
1815 g_return_if_fail (drawable != NULL);
|
|
1816 g_return_if_fail (src != NULL);
|
|
1817 g_return_if_fail (gc != NULL);
|
|
1818
|
|
1819 drawable_private = (GdkWindowPrivate*) drawable;
|
|
1820 src_private = (GdkWindowPrivate*) src;
|
|
1821 if (drawable_private->destroyed || src_private->destroyed)
|
|
1822 return;
|
|
1823 gc_private = (GdkGCPrivate*) gc;
|
|
1824
|
|
1825 if (width == -1)
|
|
1826 width = src_private->width;
|
|
1827 if (height == -1)
|
|
1828 height = src_private->height;
|
|
1829
|
|
1830 XCopyPlane (drawable_private->xdisplay,
|
|
1831 src_private->xwindow,
|
|
1832 drawable_private->xwindow,
|
|
1833 gc_private->xgc,
|
|
1834 xsrc, ysrc,
|
|
1835 width, height,
|
|
1836 xdest, ydest, 1L);
|
|
1837 }
|