comparison src/redisplay-xlike-inc.c @ 4962:e813cf16c015

merge
author Ben Wing <ben@xemacs.org>
date Mon, 01 Feb 2010 05:29:05 -0600
parents ea701c23ed84 b3ce27ca7647
children 0d4c9d0f6a8d
comparison
equal deleted inserted replaced
4961:b90f8cf474e0 4962:e813cf16c015
1 /* Common code between X and GTK. 1 /* Common code between X and GTK -- redisplay-related.
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3 Copyright (C) 1994 Lucid, Inc. 3 Copyright (C) 1994 Lucid, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 2002, 2003, 2005, 2009, 2010 Ben Wing. 5 Copyright (C) 2002, 2003, 2005, 2009, 2010 Ben Wing.
6 6
26 /* Author: Chuck Thompson */ 26 /* Author: Chuck Thompson */
27 /* Gtk flavor by William Perry */ 27 /* Gtk flavor by William Perry */
28 /* X and GTK code merged by Ben Wing, 1-10 */ 28 /* X and GTK code merged by Ben Wing, 1-10 */
29 29
30 /* Lots of work done by Ben Wing for Mule */ 30 /* Lots of work done by Ben Wing for Mule */
31
32 /* Before including this file, you need to define either THIS_IS_X or
33 THIS_IS_GTK. See comments in console-xlike-inc.h. */
31 34
32 #include <config.h> 35 #include <config.h>
33 #include "lisp.h" 36 #include "lisp.h"
34 37
35 #include "buffer.h" 38 #include "buffer.h"
46 #ifdef MULE 49 #ifdef MULE
47 #include "mule-ccl.h" 50 #include "mule-ccl.h"
48 #endif 51 #endif
49 #include "charset.h" 52 #include "charset.h"
50 53
54 #define NEED_GCCACHE_H
55 #define NEED_GLYPHS_H
56 #define NEED_OBJECTS_IMPL_H
57 #include "console-xlike-inc.h"
58
59 #include "sysproc.h" /* for select() */
60
51 #ifdef THIS_IS_X 61 #ifdef THIS_IS_X
52 #include "console-x-impl.h"
53 #include "glyphs-x.h"
54 #include "objects-x-impl.h"
55 #include "xgccache.h"
56 #else /* THIS_IS_GTK */
57 #include "console-gtk-impl.h"
58 #include "gccache-gtk.h"
59 #include "glyphs-gtk.h"
60 #include "objects-gtk-impl.h"
61 #endif /* THIS_IS_GTK */
62
63 #include "EmacsFrame.h" 62 #include "EmacsFrame.h"
64 #include "EmacsFrameP.h" 63 #include "EmacsFrameP.h"
65 64
66 #include "sysproc.h" /* for select() */
67
68 #ifdef THIS_IS_X
69 #include <X11/bitmaps/gray> 65 #include <X11/bitmaps/gray>
70 #endif /* THIS_IS_X */ 66 #endif /* THIS_IS_X */
71 67
72 #define EOL_CURSOR_WIDTH 5 68 #define EOL_CURSOR_WIDTH 5
73 69
74 /* About some of the types below:
75
76 X has two ways of representing a color: (a) as an unsigned long
77 representing a color pixel value, i.e. the actual value stored in memory
78 or a file at a particular pixel location to indicate that the pixel
79 takes on a specific color; and (b) an XColor structure, which
80 encapsulates both the RGB components of a color and the associated color
81 pixel value.
82
83 We call the former type XLIKE_PIXCOLOR and the latter XLIKE_COLOR.
84 GTK uses the same GdkColor structure for both, and normally passes in
85 a pointer. We provide routines to handle the two logical color types. */
86
87 #ifdef THIS_IS_X
88
89 /***************************************************************************/
90 /* Definitions implementing X flavor of XLIKE */
91 /***************************************************************************/
92
93 #define XLIKE_NAME x
94 #define USED_IF_X(var) var
95
96 /* types */
97 #define XLIKE_DISPLAY Display *
98 #define XLIKE_WINDOW Window
99 #define XLIKE_GC GC
100 #define XLIKE_RECTANGLE XRectangle
101 #define XLIKE_GCVALUES XGCValues
102 #define XLIKE_COLOR XColor
103 #define XLIKE_PIXCOLOR unsigned long
104
105 /* constants */
106 #define XLIKE_NONE None
107 #define XLIKE_FALSE False
108
109 #define XLIKE_GC_BACKGROUND GCBackground
110 #define XLIKE_GC_CLIP_MASK GCClipMask
111 #define XLIKE_GC_CLIP_X_ORIGIN GCClipXOrigin
112 #define XLIKE_GC_CLIP_Y_ORIGIN GCClipYOrigin
113 #define XLIKE_GC_EXPOSURES GCGraphicsExposures
114 #define XLIKE_GC_FILL GCFillStyle
115 #define XLIKE_GC_FONT GCFont
116 #define XLIKE_GC_FOREGROUND GCForeground
117 #define XLIKE_GC_FUNCTION GCFunction
118 #define XLIKE_GC_LINE_WIDTH GCLineWidth
119 #define XLIKE_GC_STIPPLE GCStipple
120 #define XLIKE_GC_TILE GCTile
121
122 #define XLIKE_GX_COPY GXcopy
123 #define XLIKE_GX_XOR GXxor
124
125 #define XLIKE_FILL_MEMBER fill_style
126 #define XLIKE_FILL_STIPPLED FillStippled
127 #define XLIKE_FILL_OPAQUE_STIPPLED FillOpaqueStippled
128 #define XLIKE_FILL_TILED FillTiled
129 #define XLIKE_FILL_SOLID FillSolid
130
131 /* functions */
132 #define GET_XLIKE_DISPLAY(d) DEVICE_X_DISPLAY (d)
133 #define GET_XLIKE_WINDOW(w) XtWindow (FRAME_X_TEXT_WIDGET (f))
134 #define XLIKE_FILL_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
135 XFillRectangle (dpy, x_win, gc, x, y, width, height)
136 #define XLIKE_DRAW_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
137 XDrawRectangle (dpy, x_win, gc, x, y, width, height)
138 #define XLIKE_DRAW_LINE(dpy, x_win, gc, x1, y1, x2, y2) \
139 XDrawLine (dpy, x_win, gc, x1, y1, x2, y2)
140 #define XLIKE_OUTPUT_XLIKE_PIXMAP x_output_x_pixmap
141
142 #define XLIKE_DISPLAY_LINE_HEIGHT(dl) DISPLAY_LINE_HEIGHT (dl)
143 #define XLIKE_DISPLAY_LINE_YPOS(dl) DISPLAY_LINE_YPOS (dl)
144 #define XLIKE_DISPLAY_LINE_TOP_CLIP(dl) ((dl)->top_clip)
145 #define XLIKE_SET_CLIP_RECTANGLE(dpy, gc, xorig, yorig, prect) \
146 /* #### why not Unsorted? */ \
147 XSetClipRectangles (dpy, gc, xorig, yorig, prect, 1, YXBanded)
148 #define XLIKE_CLEAR_CLIP_MASK(dpy, gc) \
149 do \
150 { \
151 XSetClipMask (dpy, gc, None); \
152 XSetClipOrigin (dpy, gc, 0, 0); \
153 } \
154 while (0)
155 #define XLIKE_FLUSH(dpy) XSync (dpy, False)
156 #define XLIKE_CLEAR_AREA(dpy, win, x, y, width, height) \
157 XClearArea (dpy, win, x, y, width, height, False)
158
159 #define IMAGE_INSTANCE_XLIKE_MASK IMAGE_INSTANCE_X_MASK
160 #define XIMAGE_INSTANCE_XLIKE_PIXMAP XIMAGE_INSTANCE_X_PIXMAP
161 #define COLOR_INSTANCE_XLIKE_COLOR COLOR_INSTANCE_X_COLOR
162 #define FONT_INSTANCE_XLIKE_FONT FONT_INSTANCE_X_FONT
163 #define DEVICE_XLIKE_GC_CACHE DEVICE_X_GC_CACHE
164 #define DEVICE_XLIKE_GRAY_PIXMAP DEVICE_X_GRAY_PIXMAP
165 #define XLIKE_COLOR_TO_PIXCOLOR(ci) ((ci).pixel)
166 #define XLIKE_SET_PIXCOLOR_COPY(lval, rval) ((lval) = (rval))
167 #define XLIKE_SET_PIXCOLOR_NUM(lval, rval) ((lval) = (rval))
168 #define XLIKE_FONT_NUM(val) ((val)->fid)
169
170 #define XLIKE_OUTPUT_XLIKE_PIXMAP x_output_x_pixmap
171
172 /************ End X flavor of XLIKE **********/
173
174
175
176
177 #else /* THIS_IS_GTK */
178
179 /***************************************************************************/
180 /* Definitions implementing GTK flavor of XLIKE */
181 /***************************************************************************/
182
183 #define XLIKE_NAME gtk
184 #define USED_IF_X(var) UNUSED (var)
185
186 /*types */
187 #define XLIKE_DISPLAY void *
188 #define XLIKE_WINDOW GdkWindow *
189 #define XLIKE_GC GdkGC *
190 #define XLIKE_RECTANGLE GdkRectangle
191 #define XLIKE_GCVALUES GdkGCValues
192 #define XLIKE_COLOR GdkColor *
193 #define XLIKE_PIXCOLOR GdkColor *
194
195 /* constants */
196 #define XLIKE_NONE 0
197 #define XLIKE_FALSE FALSE
198
199 #define XLIKE_GC_BACKGROUND GDK_GC_BACKGROUND
200 #define XLIKE_GC_CLIP_MASK GDK_GC_CLIP_MASK
201 #define XLIKE_GC_CLIP_X_ORIGIN GDK_GC_CLIP_X_ORIGIN
202 #define XLIKE_GC_CLIP_Y_ORIGIN GDK_GC_CLIP_Y_ORIGIN
203 #define XLIKE_GC_EXPOSURES GDK_GC_EXPOSURES
204 #define XLIKE_GC_FILL GDK_GC_FILL
205 #define XLIKE_GC_FONT GDK_GC_FONT
206 #define XLIKE_GC_FOREGROUND GDK_GC_FOREGROUND
207 #define XLIKE_GC_FUNCTION GDK_GC_FUNCTION
208 #define XLIKE_GC_LINE_WIDTH GDK_GC_LINE_WIDTH
209 #define XLIKE_GC_STIPPLE GDK_GC_STIPPLE
210 #define XLIKE_GC_TILE GDK_GC_TILE
211
212 #define XLIKE_GX_COPY GDK_COPY
213 #define XLIKE_GX_XOR GDK_XOR
214
215 #define XLIKE_FILL_MEMBER fill
216 #define XLIKE_FILL_STIPPLED GDK_STIPPLED
217 #define XLIKE_FILL_OPAQUE_STIPPLED GDK_OPAQUE_STIPPLED
218 #define XLIKE_FILL_TILED GDK_TILED
219 #define XLIKE_FILL_SOLID GDK_SOLID
220
221 /* functions */
222
223 #define GET_XLIKE_DISPLAY(d) NULL
224 #define GET_XLIKE_WINDOW(w) GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (w))
225 #define XLIKE_FILL_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
226 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, y, width, height)
227 #define XLIKE_DRAW_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
228 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE, x, y, width, height)
229 #define XLIKE_DRAW_LINE(dpy, x_win, gc, x1, y1, x2, y2) \
230 gdk_draw_line (GDK_DRAWABLE (x_win), gc, x1, y1, x2, y2)
231 #define XLIKE_OUTPUT_XLIKE_PIXMAP gtk_output_gdk_pixmap
232
233 /* FIXME: This is totally bogus. It removes dl->top_clip from the
234 equations. If there is a bug involving this, fix it properly!
235 Or just ensure that top_clip is 0. */
236 #define XLIKE_DISPLAY_LINE_HEIGHT(dl) \
237 ((dl)->ascent + ((dl)->descent - (dl)->clip)
238 #define XLIKE_DISPLAY_LINE_YPOS(dl) ((dl)->ypos - (dl)->ascent)
239 #define XLIKE_DISPLAY_LINE_TOP_CLIP(dl) ((0)
240 #define XLIKE_SET_CLIP_RECTANGLE(dpy, gc, xorig, yorig, prect) \
241 do \
242 { \
243 gdk_gc_set_clip_rectangle (gc, prect); \
244 gdk_gc_set_clip_origin (gc, xorig, yorig); \
245 } \
246 while (0)
247 #define XLIKE_CLEAR_CLIP_MASK(dpy, gc) \
248 do \
249 { \
250 gdk_gc_set_clip_rectangle (gc, NULL); \
251 gdk_gc_set_clip_origin (gc, 0, 0); \
252 } \
253 while (0)
254 #define XLIKE_FLUSH(dpy) gdk_flush ()
255 #define XLIKE_CLEAR_AREA(dpy, win, x, y, width, height) \
256 gdk_window_clear_area (win, x, y, width, height)
257
258 #define IMAGE_INSTANCE_XLIKE_MASK IMAGE_INSTANCE_GTK_MASK
259 #define XIMAGE_INSTANCE_XLIKE_PIXMAP XIMAGE_INSTANCE_GTK_PIXMAP
260 #define COLOR_INSTANCE_XLIKE_COLOR COLOR_INSTANCE_GTK_COLOR
261 #define FONT_INSTANCE_XLIKE_FONT FONT_INSTANCE_GTK_FONT
262 #define DEVICE_XLIKE_GRAY_PIXMAP DEVICE_GTK_GRAY_PIXMAP
263 #define DEVICE_XLIKE_GC_CACHE DEVICE_GTK_GC_CACHE
264 #define XLIKE_COLOR_TO_PIXCOLOR(ci) (ci)
265 #define XLIKE_SET_PIXCOLOR_COPY(lval, rval) ((lval) = *(rval))
266 #define XLIKE_SET_PIXCOLOR_NUM(lval, rval) ((lval).pixel = (rval))
267 #define XLIKE_FONT_NUM(val) (val)
268
269 #define XLIKE_OUTPUT_XLIKE_PIXMAP gtk_output_gdk_pixmap
270
271 static void gtk_output_pixmap (struct window *w,
272 Lisp_Object image_instance,
273 struct display_box *db,
274 struct display_glyph_area *dga,
275 face_index findex,
276 int cursor_start,
277 int cursor_width,
278 int cursor_height,
279 int bgpixmap);
280 static void gtk_clear_region (Lisp_Object locale, struct device* d,
281 struct frame* f, face_index findex, int x, int y,
282 int width, int height, Lisp_Object fcolor,
283 Lisp_Object bcolor,
284 Lisp_Object background_pixmap);
285 static void gtk_bevel_modeline (struct window *w, struct display_line *dl);
286
287 #if 0
288 static void __describe_gc (GdkGC *);
289 #endif
290
291 /************ End GTK flavor of XLIKE **********/
292
293 #endif /* (not) THIS_IS_X */
294
295
296
297 /***************************************************************************/
298 /* Common definitions */
299 /***************************************************************************/
300
301 #define XCOLOR_INSTANCE_XLIKE_COLOR(x) \
302 COLOR_INSTANCE_XLIKE_COLOR (XCOLOR_INSTANCE (x))
303
304 #define XLIKE_PASTE_1(a,b) a##_##b
305 #define XLIKE_PASTE(a,b) XLIKE_PASTE_1(a,b)
306 #define XLIKE_CONSOLE_HAS_METHOD_1(xlike, name) CONSOLE_HAS_METHOD (xlike, name)
307 #define XLIKE_CONSOLE_HAS_METHOD(name) \
308 XLIKE_CONSOLE_HAS_METHOD_1 (XLIKE_NAME, name)
309
310 /* Device methods */ 70 /* Device methods */
311 71
312 #define XLIKE_text_width XLIKE_PASTE (XLIKE_NAME, text_width) 72 #define XLIKE_text_width XFUN (text_width)
313 #define XLIKE_output_display_block XLIKE_PASTE (XLIKE_NAME, output_display_block) 73 #define XLIKE_output_display_block XFUN (output_display_block)
314 #define XLIKE_divider_height XLIKE_PASTE (XLIKE_NAME, divider_height) 74 #define XLIKE_divider_height XFUN (divider_height)
315 #define XLIKE_eol_cursor_width XLIKE_PASTE (XLIKE_NAME, eol_cursor_width) 75 #define XLIKE_eol_cursor_width XFUN (eol_cursor_width)
316 #define XLIKE_output_vertical_divider XLIKE_PASTE (XLIKE_NAME, output_vertical_divider) 76 #define XLIKE_output_vertical_divider XFUN (output_vertical_divider)
317 #define XLIKE_clear_region XLIKE_PASTE (XLIKE_NAME, clear_region) 77 #define XLIKE_clear_region XFUN (clear_region)
318 #define XLIKE_clear_frame XLIKE_PASTE (XLIKE_NAME, clear_frame) 78 #define XLIKE_clear_frame XFUN (clear_frame)
319 #define XLIKE_flash XLIKE_PASTE (XLIKE_NAME, flash) 79 #define XLIKE_flash XFUN (flash)
320 #define XLIKE_ring_bell XLIKE_PASTE (XLIKE_NAME, ring_bell) 80 #define XLIKE_ring_bell XFUN (ring_bell)
321 #define XLIKE_bevel_area XLIKE_PASTE (XLIKE_NAME, bevel_area) 81 #define XLIKE_bevel_area XFUN (bevel_area)
322 #define XLIKE_output_string XLIKE_PASTE (XLIKE_NAME, output_string) 82 #define XLIKE_output_string XFUN (output_string)
323 #define XLIKE_output_pixmap XLIKE_PASTE (XLIKE_NAME, output_pixmap) 83 #define XLIKE_output_pixmap XFUN (output_pixmap)
324 #define XLIKE_window_output_begin XLIKE_PASTE (XLIKE_NAME, window_output_begin) 84 #define XLIKE_output_xlike_pixmap XFUN (output_xlike_pixmap)
325 #define XLIKE_window_output_end XLIKE_PASTE (XLIKE_NAME, window_output_end) 85 #define XLIKE_window_output_begin XFUN (window_output_begin)
86 #define XLIKE_window_output_end XFUN (window_output_end)
326 87
327 /* Miscellaneous split functions */ 88 /* Miscellaneous split functions */
328 89
329 #define console_type_create_redisplay_XLIKE XLIKE_PASTE (console_type_create_redisplay, XLIKE_NAME) 90 #define console_type_create_redisplay_XLIKE XLIKE_PASTE (console_type_create_redisplay, XLIKE_NAME)
330 #define XLIKE_get_gc XLIKE_PASTE (XLIKE_NAME, get_gc) 91 #define XLIKE_get_gc XFUN (get_gc)
331 #define XLIKE_output_blank XLIKE_PASTE (XLIKE_NAME, output_blank) 92 #define XLIKE_output_blank XFUN (output_blank)
332 #define XLIKE_text_width_single_run XLIKE_PASTE (XLIKE_NAME, text_width_single_run) 93 #define XLIKE_text_width_single_run XFUN (text_width_single_run)
333 94
334 static void XLIKE_output_blank (struct window *w, struct display_line *dl, 95 static void XLIKE_output_blank (struct window *w, struct display_line *dl,
335 struct rune *rb, int start_pixpos, 96 struct rune *rb, int start_pixpos,
336 int cursor_start, int cursor_width); 97 int cursor_start, int cursor_width);
337 static void XLIKE_output_horizontal_line (struct window *w, 98 static void XLIKE_output_horizontal_line (struct window *w,
338 struct display_line *dl, 99 struct display_line *dl,
339 struct rune *rb); 100 struct rune *rb);
340
341 static void XLIKE_output_vertical_divider (struct window *w, int clear);
342
343 static void XLIKE_output_eol_cursor (struct window *w, 101 static void XLIKE_output_eol_cursor (struct window *w,
344 struct display_line *dl, 102 struct display_line *dl,
345 int xpos, face_index findex); 103 int xpos, face_index findex);
346 static void XLIKE_clear_frame (struct frame *f);
347 static void XLIKE_clear_frame_windows (Lisp_Object window); 104 static void XLIKE_clear_frame_windows (Lisp_Object window);
348 static void XLIKE_window_output_begin (struct window *w);
349 static void XLIKE_window_output_end (struct window *w);
350 static void XLIKE_bevel_area (struct window *w, face_index findex, 105 static void XLIKE_bevel_area (struct window *w, face_index findex,
351 int x, int y, int width, int height, 106 int x, int y, int width, int height,
352 int shadow_thickness, int edges, 107 int shadow_thickness, int edges,
353 enum edge_style style); 108 enum edge_style style);
354 static void XLIKE_ring_bell (struct device *d, int volume, int pitch, 109 static void XLIKE_ring_bell (struct device *d, int volume, int pitch,
355 int duration); 110 int duration);
111
112 #ifdef THIS_IS_X
113 static void XLIKE_window_output_begin (struct window *UNUSED (w));
114 static void XLIKE_window_output_end (struct window *w);
115 #endif /* THIS_IS_X */
116
356 117
357 /****************************************************************************/ 118 /****************************************************************************/
358 /* */ 119 /* */
359 /* Separate textual runs */ 120 /* Separate textual runs */
360 /* */ 121 /* */
733 #endif 494 #endif
734 else if (FONT_INSTANCE_XLIKE_FONT (fi)) 495 else if (FONT_INSTANCE_XLIKE_FONT (fi))
735 { 496 {
736 if (run->dimension == 2) 497 if (run->dimension == 2)
737 { 498 {
738 #ifdef THIS_IS_X
739 return XTextWidth16 (FONT_INSTANCE_X_FONT (fi),
740 (XChar2b *) run->ptr, run->len);
741 #else /* THIS_IS_GTK */
742 /* stderr_out ("Measuring wide characters\n"); */ 499 /* stderr_out ("Measuring wide characters\n"); */
743 return gdk_text_width_wc (FONT_INSTANCE_GTK_FONT (fi), 500 return XLIKE_TEXT_WIDTH_WIDE (FONT_INSTANCE_XLIKE_FONT (fi),
744 (GdkWChar *) run->ptr, run->len); 501 run->ptr, run->len);
745 #endif /* THIS_IS_GTK */
746 } 502 }
747 else 503 else
748 { 504 {
749 #ifdef THIS_IS_X 505 return XLIKE_TEXT_WIDTH (FONT_INSTANCE_XLIKE_FONT (fi),
750 return XTextWidth (FONT_INSTANCE_X_FONT (fi), 506 run->ptr, run->len);
751 (char *) run->ptr, run->len);
752 #else /* THIS_IS_GTK */
753 return gdk_text_width (FONT_INSTANCE_GTK_FONT (fi),
754 (char *) run->ptr, run->len);
755 #endif /* THIS_IS_GTK */
756 } 507 }
757 } 508 }
758 else 509 else
759 abort(); 510 abort();
760 return 0; /* shut up GCC */ 511 return 0; /* shut up GCC */
761 } 512 }
513
762 514
763 /* 515 /*
764 XLIKE_text_width 516 XLIKE_text_width
765 517
766 Given a string and a merged face, return the string's length in pixels 518 Given a string and a merged face, return the string's length in pixels
1056 bevel_modeline (w, dl); 808 bevel_modeline (w, dl);
1057 809
1058 Dynarr_free (buf); 810 Dynarr_free (buf);
1059 } 811 }
1060 812
813 /* Called as gtk_get_gc from gtk-glue.c */
814
815 XLIKE_GC XLIKE_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg,
816 Lisp_Object bg, Lisp_Object bg_pmap,
817 Lisp_Object lwidth);
818
1061 /***************************************************************************** 819 /*****************************************************************************
1062 XLIKE_get_gc 820 XLIKE_get_gc
1063 821
1064 Given a number of parameters return a GC with those properties. 822 Given a number of parameters return a GC with those properties.
1065 ****************************************************************************/ 823 ****************************************************************************/
1066 static XLIKE_GC 824 XLIKE_GC
1067 XLIKE_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, 825 XLIKE_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg,
1068 Lisp_Object bg, Lisp_Object bg_pmap, Lisp_Object lwidth) 826 Lisp_Object bg, Lisp_Object bg_pmap, Lisp_Object lwidth)
1069 { 827 {
1070 XLIKE_GCVALUES gcv; 828 XLIKE_GCVALUES gcv;
1071 unsigned long mask; 829 unsigned long mask;
1075 /* Make absolutely sure that we don't pick up a clipping region in 833 /* Make absolutely sure that we don't pick up a clipping region in
1076 the GC returned by this function. */ 834 the GC returned by this function. */
1077 gcv.clip_mask = XLIKE_NONE; 835 gcv.clip_mask = XLIKE_NONE;
1078 gcv.clip_x_origin = 0; 836 gcv.clip_x_origin = 0;
1079 gcv.clip_y_origin = 0; 837 gcv.clip_y_origin = 0;
1080 gcv.XLIKE_FILL_MEMBER = XLIKE_FILL_SOLID; 838 XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_SOLID);
1081 mask = XLIKE_GC_EXPOSURES | XLIKE_GC_CLIP_MASK | XLIKE_GC_CLIP_X_ORIGIN | XLIKE_GC_CLIP_Y_ORIGIN; 839 mask = XLIKE_GC_EXPOSURES | XLIKE_GC_CLIP_MASK | XLIKE_GC_CLIP_X_ORIGIN | XLIKE_GC_CLIP_Y_ORIGIN;
1082 mask |= XLIKE_GC_FILL; 840 mask |= XLIKE_GC_FILL;
1083 841
1084 if (!NILP (font) 842 if (!NILP (font)
1085 #ifdef USE_XFT 843 #ifdef USE_XFT
1105 } 863 }
1106 864
1107 if (!NILP (fg)) 865 if (!NILP (fg))
1108 { 866 {
1109 if (COLOR_INSTANCEP (fg)) 867 if (COLOR_INSTANCEP (fg))
1110 XLIKE_SET_PIXCOLOR_COPY 868 XLIKE_SET_GC_COLOR (gcv.foreground, XCOLOR_INSTANCE_XLIKE_COLOR (fg));
1111 (gcv.foreground,
1112 XLIKE_COLOR_TO_PIXCOLOR (XCOLOR_INSTANCE_XLIKE_COLOR (fg)));
1113 else 869 else
1114 XLIKE_SET_PIXCOLOR_NUM (gcv.foreground, XINT (fg)); 870 XLIKE_SET_GC_PIXEL (gcv.foreground, XINT (fg));
1115 mask |= XLIKE_GC_FOREGROUND; 871 mask |= XLIKE_GC_FOREGROUND;
1116 } 872 }
1117 873
1118 if (!NILP (bg)) 874 if (!NILP (bg))
1119 { 875 {
1120 if (COLOR_INSTANCEP (bg)) 876 if (COLOR_INSTANCEP (bg))
1121 XLIKE_SET_PIXCOLOR_COPY 877 XLIKE_SET_GC_COLOR (gcv.background, XCOLOR_INSTANCE_XLIKE_COLOR (bg));
1122 (gcv.background,
1123 XLIKE_COLOR_TO_PIXCOLOR (XCOLOR_INSTANCE_XLIKE_COLOR (bg)));
1124 else 878 else
1125 XLIKE_SET_PIXCOLOR_NUM (gcv.background, XINT (bg)); 879 XLIKE_SET_GC_PIXEL (gcv.background, XINT (bg));
1126 mask |= XLIKE_GC_BACKGROUND; 880 mask |= XLIKE_GC_BACKGROUND;
1127 } 881 }
1128 882
1129 /* This special case comes from a request to draw text with a face which has 883 /* This special case comes from a request to draw text with a face which has
1130 the dim property. We'll use a stippled foreground GC. */ 884 the dim property. We'll use a stippled foreground GC. */
1131 if (EQ (bg_pmap, Qdim)) 885 if (EQ (bg_pmap, Qdim))
1132 { 886 {
1133 assert (DEVICE_XLIKE_GRAY_PIXMAP (d) != XLIKE_NONE); 887 assert (DEVICE_XLIKE_GRAY_PIXMAP (d) != XLIKE_NONE);
1134 888
1135 gcv.XLIKE_FILL_MEMBER = XLIKE_FILL_STIPPLED; 889 XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_STIPPLED);
1136 gcv.stipple = DEVICE_XLIKE_GRAY_PIXMAP (d); 890 gcv.stipple = DEVICE_XLIKE_GRAY_PIXMAP (d);
1137 mask |= (XLIKE_GC_FILL | XLIKE_GC_STIPPLE); 891 mask |= (XLIKE_GC_FILL | XLIKE_GC_STIPPLE);
1138 } 892 }
1139 else if (IMAGE_INSTANCEP (bg_pmap) 893 else if (IMAGE_INSTANCEP (bg_pmap)
1140 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap))) 894 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
1141 { 895 {
1142 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0) 896 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
1143 { 897 {
1144 gcv.XLIKE_FILL_MEMBER = XLIKE_FILL_OPAQUE_STIPPLED; 898 XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_OPAQUE_STIPPLED);
1145 gcv.stipple = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pmap); 899 gcv.stipple = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pmap);
1146 mask |= (XLIKE_GC_STIPPLE | XLIKE_GC_FILL); 900 mask |= (XLIKE_GC_STIPPLE | XLIKE_GC_FILL);
1147 } 901 }
1148 else 902 else
1149 { 903 {
1150 gcv.XLIKE_FILL_MEMBER = XLIKE_FILL_TILED; 904 XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_TILED);
1151 gcv.tile = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pmap); 905 gcv.tile = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pmap);
1152 mask |= (XLIKE_GC_TILE | XLIKE_GC_FILL); 906 mask |= (XLIKE_GC_TILE | XLIKE_GC_FILL);
1153 } 907 }
1154 } 908 }
1155 909
1260 xftDraw = FRAME_X_XFTDRAW (f); 1014 xftDraw = FRAME_X_XFTDRAW (f);
1261 1015
1262 /* #### This will probably cause asserts when passed a Lisp integer for a 1016 /* #### This will probably cause asserts when passed a Lisp integer for a
1263 color. See ca. line 759 this file. 1017 color. See ca. line 759 this file.
1264 #### Maybe xft_convert_color should take an XColor, not a pixel. */ 1018 #### Maybe xft_convert_color should take an XColor, not a pixel. */
1265 #define XFT_FROB_LISP_COLOR(color, dim) \ 1019 #define XFT_FROB_LISP_COLOR(color, dim) \
1266 xft_convert_color (dpy, cmap, visual, \ 1020 xft_convert_color (dpy, cmap, visual, \
1267 COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)).pixel, \ 1021 XCOLOR_INSTANCE_X_COLOR (color).pixel, (dim))
1268 (dim))
1269 #endif /* USE_XFT */ 1022 #endif /* USE_XFT */
1270 1023
1271 if (width < 0) 1024 if (width < 0)
1272 width = XLIKE_text_width (w, cachel, Dynarr_atp (buf, 0), 1025 width = XLIKE_text_width (w, cachel, Dynarr_atp (buf, 0),
1273 Dynarr_length (buf)); 1026 Dynarr_length (buf));
1846 gint width, 1599 gint width,
1847 gint height); 1600 gint height);
1848 #endif /* THIS_IS_GTK */ 1601 #endif /* THIS_IS_GTK */
1849 1602
1850 1603
1851 void 1604 static void
1852 XLIKE_OUTPUT_XLIKE_PIXMAP (struct frame *f, Lisp_Image_Instance *p, int x, 1605 XLIKE_output_xlike_pixmap (struct frame *f, Lisp_Image_Instance *p, int x,
1853 int y, int xoffset, int yoffset, 1606 int y, int xoffset, int yoffset,
1854 int width, int height, 1607 int width, int height,
1855 XLIKE_PIXCOLOR fg, XLIKE_PIXCOLOR bg, 1608 XLIKE_COLOR fg, XLIKE_COLOR bg,
1856 XLIKE_GC override_gc) 1609 XLIKE_GC override_gc)
1857 { 1610 {
1858 struct device *d = XDEVICE (f->device); 1611 struct device *d = XDEVICE (f->device);
1859 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d); 1612 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d);
1860 XLIKE_WINDOW x_win = GET_XLIKE_WINDOW (f); 1613 XLIKE_WINDOW x_win = GET_XLIKE_WINDOW (f);
1864 1617
1865 if (!override_gc) 1618 if (!override_gc)
1866 { 1619 {
1867 memset (&gcv, ~0, sizeof (gcv)); 1620 memset (&gcv, ~0, sizeof (gcv));
1868 gcv.graphics_exposures = XLIKE_FALSE; 1621 gcv.graphics_exposures = XLIKE_FALSE;
1869 XLIKE_SET_PIXCOLOR_COPY (gcv.foreground, fg); 1622 XLIKE_SET_GC_COLOR (gcv.foreground, fg);
1870 XLIKE_SET_PIXCOLOR_COPY (gcv.background, bg); 1623 XLIKE_SET_GC_COLOR (gcv.background, bg);
1871 pixmap_mask = XLIKE_GC_FOREGROUND | XLIKE_GC_BACKGROUND | XLIKE_GC_EXPOSURES; 1624 pixmap_mask = XLIKE_GC_FOREGROUND | XLIKE_GC_BACKGROUND | XLIKE_GC_EXPOSURES;
1872 1625
1873 if (IMAGE_INSTANCE_XLIKE_MASK (p)) 1626 if (IMAGE_INSTANCE_XLIKE_MASK (p))
1874 { 1627 {
1875 gcv.function = XLIKE_GX_COPY; 1628 gcv.function = XLIKE_GX_COPY;
1912 IMAGE_INSTANCE_X_PIXMAP_SLICE 1665 IMAGE_INSTANCE_X_PIXMAP_SLICE
1913 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset, 1666 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset,
1914 yoffset, width, 1667 yoffset, width,
1915 height, x, y); 1668 height, x, y);
1916 #else /* THIS_IS_GTK */ 1669 #else /* THIS_IS_GTK */
1670 USED (dpy);
1917 gdk_draw_pixmap (GDK_DRAWABLE (x_win), gc, 1671 gdk_draw_pixmap (GDK_DRAWABLE (x_win), gc,
1918 IMAGE_INSTANCE_GTK_PIXMAP (p), 1672 IMAGE_INSTANCE_GTK_PIXMAP (p),
1919 xoffset, yoffset, x, y, width, height); 1673 xoffset, yoffset, x, y, width, height);
1920 #endif /* THIS_IS_GTK */ 1674 #endif /* THIS_IS_GTK */
1921 } 1675 }
1924 #ifdef THIS_IS_X 1678 #ifdef THIS_IS_X
1925 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE 1679 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE
1926 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, 1680 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc,
1927 xoffset, yoffset, width, height, x, y, 1L); 1681 xoffset, yoffset, width, height, x, y, 1L);
1928 #else /* THIS_IS_GTK */ 1682 #else /* THIS_IS_GTK */
1683 USED (dpy);
1929 our_draw_bitmap (GDK_DRAWABLE (x_win), gc, 1684 our_draw_bitmap (GDK_DRAWABLE (x_win), gc,
1930 IMAGE_INSTANCE_GTK_PIXMAP (p), 1685 IMAGE_INSTANCE_GTK_PIXMAP (p),
1931 xoffset, yoffset, x, y, width, height); 1686 xoffset, yoffset, x, y, width, height);
1932 #endif /* THIS_IS_GTK */ 1687 #endif /* THIS_IS_GTK */
1933 } 1688 }
1953 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex); 1708 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
1954 tmp_fcolor = XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel); 1709 tmp_fcolor = XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel);
1955 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex); 1710 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
1956 tmp_bcolor = XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel); 1711 tmp_bcolor = XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel);
1957 1712
1958 XLIKE_OUTPUT_XLIKE_PIXMAP (f, p, db->xpos, db->ypos, 1713 XLIKE_output_xlike_pixmap (f, p, db->xpos, db->ypos,
1959 dga->xoffset, dga->yoffset, 1714 dga->xoffset, dga->yoffset,
1960 dga->width, dga->height, 1715 dga->width, dga->height,
1961 XLIKE_COLOR_TO_PIXCOLOR (tmp_fcolor), 1716 tmp_fcolor, tmp_bcolor, 0);
1962 XLIKE_COLOR_TO_PIXCOLOR (tmp_bcolor), 0);
1963 } 1717 }
1964 1718
1965 /* Draw a cursor over top of the pixmap. */ 1719 /* Draw a cursor over top of the pixmap. */
1966 if (cursor_width && cursor_height && (cursor_start >= db->xpos) 1720 if (cursor_width && cursor_height && (cursor_start >= db->xpos)
1967 && !NILP (w->text_cursor_visible_p) 1721 && !NILP (w->text_cursor_visible_p)
2004 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d); 1758 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d);
2005 XLIKE_WINDOW x_win = GET_XLIKE_WINDOW (f); 1759 XLIKE_WINDOW x_win = GET_XLIKE_WINDOW (f);
2006 Lisp_Object tmp_pixel; 1760 Lisp_Object tmp_pixel;
2007 XLIKE_GCVALUES gcv; 1761 XLIKE_GCVALUES gcv;
2008 XLIKE_GC background_gc; 1762 XLIKE_GC background_gc;
2009 #ifdef THIS_IS_X
2010 enum edge_style style; 1763 enum edge_style style;
2011 #endif /* THIS_IS_X */
2012 unsigned long mask; 1764 unsigned long mask;
2013 int x, y1, y2, width, shadow_thickness, spacing, line_width; 1765 int x, y1, y2, width, shadow_thickness, spacing, line_width;
2014 face_index div_face = 1766 face_index div_face =
2015 get_builtin_face_cache_index (w, Vvertical_divider_face); 1767 get_builtin_face_cache_index (w, Vvertical_divider_face);
2016 1768
2025 memset (&gcv, ~0, sizeof (gcv)); 1777 memset (&gcv, ~0, sizeof (gcv));
2026 1778
2027 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face); 1779 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
2028 1780
2029 /* First, get the GC's. */ 1781 /* First, get the GC's. */
2030 XLIKE_SET_PIXCOLOR_COPY 1782 XLIKE_SET_GC_COLOR (gcv.background, XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
2031 (gcv.background,
2032 XLIKE_COLOR_TO_PIXCOLOR (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel)));
2033 gcv.foreground = gcv.background; 1783 gcv.foreground = gcv.background;
2034 gcv.graphics_exposures = XLIKE_FALSE; 1784 gcv.graphics_exposures = XLIKE_FALSE;
2035 mask = XLIKE_GC_FOREGROUND | XLIKE_GC_BACKGROUND | XLIKE_GC_EXPOSURES; 1785 mask = XLIKE_GC_FOREGROUND | XLIKE_GC_BACKGROUND | XLIKE_GC_EXPOSURES;
2036 1786
2037 background_gc = gc_cache_lookup (DEVICE_XLIKE_GC_CACHE (d), &gcv, mask); 1787 background_gc = gc_cache_lookup (DEVICE_XLIKE_GC_CACHE (d), &gcv, mask);
2040 window split occurs. */ 1790 window split occurs. */
2041 #ifdef THIS_IS_X 1791 #ifdef THIS_IS_X
2042 if (clear) 1792 if (clear)
2043 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False); 1793 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False);
2044 #else /* THIS_IS_GTK */ 1794 #else /* THIS_IS_GTK */
1795 USED (dpy);
2045 /* if (clear) */ 1796 /* if (clear) */
2046 gdk_draw_rectangle (GDK_DRAWABLE (x_win), background_gc, TRUE, 1797 gdk_draw_rectangle (GDK_DRAWABLE (x_win), background_gc, TRUE,
2047 x, y1, width, y2 - y1); 1798 x, y1, width, y2 - y1);
2048 #endif /* THIS_IS_GTK */ 1799 #endif /* THIS_IS_GTK */
2049 1800
2051 /* #### FIXME Why not? Formerly '#if 0' in the GDK code */ 1802 /* #### FIXME Why not? Formerly '#if 0' in the GDK code */
2052 /* Draw the divider line. */ 1803 /* Draw the divider line. */
2053 XLIKE_FILL_RECTANGLE (dpy, x_win, background_gc, 1804 XLIKE_FILL_RECTANGLE (dpy, x_win, background_gc,
2054 x + spacing + shadow_thickness, y1, 1805 x + spacing + shadow_thickness, y1,
2055 line_width, y2 - y1); 1806 line_width, y2 - y1);
2056 1807 #endif /* not THIS_IS_GTK */
2057 /* This code not formerly present in GTK version, maybe the omittal 1808
2058 is intentional? */
2059 if (shadow_thickness < 0) 1809 if (shadow_thickness < 0)
2060 { 1810 {
2061 shadow_thickness = -shadow_thickness; 1811 shadow_thickness = -shadow_thickness;
2062 style = EDGE_BEVEL_IN; 1812 style = EDGE_BEVEL_IN;
2063 } 1813 }
2064 else 1814 else
2065 { 1815 {
2066 style = EDGE_BEVEL_OUT; 1816 style = EDGE_BEVEL_OUT;
2067 } 1817 }
2068 #endif /* not THIS_IS_GTK */
2069 1818
2070 /* Draw the shadows around the divider line */ 1819 /* Draw the shadows around the divider line */
2071 #ifdef THIS_IS_X 1820 XLIKE_bevel_area (w, div_face, x + spacing, y1,
2072 x_bevel_area (w, div_face, x + spacing, y1, 1821 width - 2 * spacing, y2 - y1,
2073 width - 2 * spacing, y2 - y1, 1822 shadow_thickness, EDGE_ALL, style);
2074 shadow_thickness, EDGE_ALL, style);
2075 #else /* THIS_IS_GTK */
2076 gtk_output_shadows (f, x + spacing, y1,
2077 width - 2 * spacing, y2 - y1,
2078 shadow_thickness);
2079 #endif /* THIS_IS_GTK */
2080 } 1823 }
2081 1824
2082 /***************************************************************************** 1825 /*****************************************************************************
2083 XLIKE_output_blank 1826 XLIKE_output_blank
2084 1827
2426 struct frame *f = device_selected_frame (d); 2169 struct frame *f = device_selected_frame (d);
2427 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d); 2170 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d);
2428 XLIKE_WINDOW win = GET_XLIKE_WINDOW (f); 2171 XLIKE_WINDOW win = GET_XLIKE_WINDOW (f);
2429 XLIKE_GC gc = NULL; 2172 XLIKE_GC gc = NULL;
2430 XLIKE_GCVALUES gcv; 2173 XLIKE_GCVALUES gcv;
2431 XLIKE_COLOR tmp_fcolor, tmp_bcolor; 2174 XLIKE_PIXEL tmp_fcolor, tmp_bcolor;
2432 Lisp_Object tmp_pixel, frame; 2175 Lisp_Object tmp_pixel, frame;
2433 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f)); 2176 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
2434 int flash_height; 2177 int flash_height;
2435 2178
2436 frame = wrap_frame (f); 2179 frame = wrap_frame (f);
2437 2180
2438 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame); 2181 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
2439 XLIKE_SET_PIXCOLOR_COPY (tmp_fcolor, 2182 tmp_fcolor = XLIKE_COLOR_TO_PIXEL (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
2440 XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
2441 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame); 2183 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
2442 XLIKE_SET_PIXCOLOR_COPY (tmp_bcolor, 2184 tmp_bcolor = XLIKE_COLOR_TO_PIXEL (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
2443 XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
2444 memset (&gcv, ~0, sizeof (gcv)); /* initialize all slots to ~0 */ 2185 memset (&gcv, ~0, sizeof (gcv)); /* initialize all slots to ~0 */
2445 XLIKE_SET_PIXCOLOR_NUM (gcv.foreground, 2186 XLIKE_SET_GC_PIXEL (gcv.foreground, tmp_fcolor ^ tmp_bcolor);
2446 (tmp_fcolor.pixel ^ tmp_bcolor.pixel));
2447 gcv.function = XLIKE_GX_XOR; 2187 gcv.function = XLIKE_GX_XOR;
2448 gcv.graphics_exposures = XLIKE_FALSE; 2188 gcv.graphics_exposures = XLIKE_FALSE;
2449 gc = gc_cache_lookup (DEVICE_XLIKE_GC_CACHE (XDEVICE (f->device)), &gcv, 2189 gc = gc_cache_lookup (DEVICE_XLIKE_GC_CACHE (XDEVICE (f->device)), &gcv,
2450 XLIKE_GC_FOREGROUND | XLIKE_GC_FUNCTION | XLIKE_GC_EXPOSURES); 2190 XLIKE_GC_FOREGROUND | XLIKE_GC_FUNCTION | XLIKE_GC_EXPOSURES);
2451 default_face_height_and_width (frame, &flash_height, 0); 2191 default_face_height_and_width (frame, &flash_height, 0);