X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fredisplay-x.c;h=f2acc68f4d3a3ad3b60e9630422c5668976deb14;hb=f94fbd3020e40c3685853c905014f2ae310b02c7;hp=d599c914d2d539af2bd9c685db49b0c26a3c6be2;hpb=ea1ea793fe6e244ef5555ed983423a204101af13;p=chise%2Fxemacs-chise.git.1 diff --git a/src/redisplay-x.c b/src/redisplay-x.c index d599c91..f2acc68 100644 --- a/src/redisplay-x.c +++ b/src/redisplay-x.c @@ -123,7 +123,7 @@ struct textual_run static int separate_textual_runs (unsigned char *text_storage, struct textual_run *run_storage, - CONST Emchar *str, Charcount len) + const Charc *str, Charcount len) { Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a possible valid charset when @@ -137,16 +137,25 @@ separate_textual_runs (unsigned char *text_storage, for (i = 0; i < len; i++) { - Emchar ch = str[i]; - Lisp_Object charset; + Charc cc = str[i]; + Lisp_Object charset = CHARC_CHARSET (cc); + int code_point = CHARC_CODE_POINT (cc); int byte1, byte2; int dimension; int graphic; - BREAKUP_CHAR (ch, charset, byte1, byte2); dimension = XCHARSET_DIMENSION (charset); graphic = XCHARSET_GRAPHIC (charset); - + if (dimension == 1) + { + byte1 = code_point; + byte2 = 0; + } + else + { + byte1 = code_point >> 8; + byte2 = code_point & 0xFF; + } if (!EQ (charset, prev_charset)) { run_storage[runs_so_far].ptr = text_storage; @@ -165,9 +174,9 @@ separate_textual_runs (unsigned char *text_storage, #ifdef MULE { Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset); - need_ccl_conversion = !NILP (ccl_prog); - if (need_ccl_conversion) - setup_ccl_program (&char_converter, ccl_prog); + if ((!NILP (ccl_prog)) + && (setup_ccl_program (&char_converter, ccl_prog) >= 0)) + need_ccl_conversion = 1; } #endif } @@ -219,7 +228,7 @@ static int x_text_width_single_run (struct face_cachel *cachel, struct textual_run *run) { Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset); - struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst); + Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst); if (!fi->proportional_p) return fi->width * run->len; else @@ -241,7 +250,7 @@ x_text_width_single_run (struct face_cachel *cachel, struct textual_run *run) */ static int -x_text_width (struct frame *f, struct face_cachel *cachel, CONST Emchar *str, +x_text_width (struct frame *f, struct face_cachel *cachel, const Charc *str, Charcount len) { int width_so_far = 0; @@ -286,24 +295,24 @@ x_eol_cursor_width (void) } /***************************************************************************** - x_output_begin + x_window_output_begin Perform any necessary initialization prior to an update. ****************************************************************************/ static void -x_output_begin (struct device *d) +x_window_output_begin (struct window *w) { } /***************************************************************************** - x_output_end + x_window_output_end Perform any necessary flushing of queues when an update has completed. ****************************************************************************/ static void -x_output_end (struct device *d) +x_window_output_end (struct window *w) { - XFlush (DEVICE_X_DISPLAY (d)); + XFlush (DEVICE_X_DISPLAY (WINDOW_XDEVICE (w))); } /***************************************************************************** @@ -318,7 +327,7 @@ x_output_display_block (struct window *w, struct display_line *dl, int block, int cursor_width, int cursor_height) { struct frame *f = XFRAME (w->frame); - Emchar_dynarr *buf = Dynarr_new (Emchar); + Charc_dynarr *buf; Lisp_Object window; struct display_block *db = Dynarr_atp (dl->display_blocks, block); @@ -341,21 +350,22 @@ x_output_display_block (struct window *w, struct display_line *dl, int block, findex = rb->findex; xpos = rb->xpos; if (rb->type == RUNE_CHAR) - charset = CHAR_CHARSET (rb->object.chr.ch); + charset = CHARC_CHARSET (rb->object.cglyph); if (end < 0) end = Dynarr_length (rba); - Dynarr_reset (buf); + buf = Dynarr_new (Charc); while (elt < end) { rb = Dynarr_atp (rba, elt); if (rb->findex == findex && rb->type == RUNE_CHAR - && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON - && EQ (charset, CHAR_CHARSET (rb->object.chr.ch))) + && (!CHARC_ASCII_EQ (rb->object.cglyph, '\n')) + && rb->cursor_type != CURSOR_ON + && EQ (charset, CHARC_CHARSET (rb->object.cglyph))) { - Dynarr_add (buf, rb->object.chr.ch); + Dynarr_add (buf, rb->object.cglyph); width += rb->width; elt++; } @@ -376,17 +386,17 @@ x_output_display_block (struct window *w, struct display_line *dl, int block, { findex = rb->findex; xpos = rb->xpos; - charset = CHAR_CHARSET (rb->object.chr.ch); + charset = CHARC_CHARSET (rb->object.cglyph); if (rb->cursor_type == CURSOR_ON) { - if (rb->object.chr.ch == '\n') + if (CHARC_ASCII_EQ (rb->object.cglyph, '\n')) { x_output_eol_cursor (w, dl, xpos, findex); } else { - Dynarr_add (buf, rb->object.chr.ch); + Dynarr_add (buf, rb->object.cglyph); x_output_string (w, dl, buf, xpos, 0, start_pixpos, rb->width, findex, 1, cursor_start, cursor_width, @@ -397,12 +407,12 @@ x_output_display_block (struct window *w, struct display_line *dl, int block, xpos += rb->width; elt++; } - else if (rb->object.chr.ch == '\n') + else if (CHARC_ASCII_EQ (rb->object.cglyph, '\n')) { /* Clear in case a cursor was formerly here. */ - redisplay_clear_region (window, findex, xpos, + redisplay_clear_region (window, findex, xpos, DISPLAY_LINE_YPOS (dl), - rb->width, + rb->width, DISPLAY_LINE_HEIGHT (dl)); elt++; } @@ -439,71 +449,60 @@ x_output_display_block (struct window *w, struct display_line *dl, int block, Lisp_Object instance; struct display_box dbox; struct display_glyph_area dga; + redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset, - start_pixpos, rb->width, - &dbox, &dga); + rb->object.dglyph.yoffset, start_pixpos, + rb->width, &dbox, &dga); - XSETWINDOW (window, w); + XSETWINDOW (window, w); instance = glyph_image_instance (rb->object.dglyph.glyph, window, ERROR_ME_NOT, 1); findex = rb->findex; if (IMAGE_INSTANCEP (instance)) - switch (XIMAGE_INSTANCE_TYPE (instance)) - { - case IMAGE_TEXT: + { + switch (XIMAGE_INSTANCE_TYPE (instance)) { - /* #### This is way losing. See the comment in - add_glyph_rune(). */ - Lisp_Object string = - XIMAGE_INSTANCE_TEXT_STRING (instance); - convert_bufbyte_string_into_emchar_dynarr - (XSTRING_DATA (string), XSTRING_LENGTH (string), buf); - - x_output_string (w, dl, buf, xpos, - rb->object.dglyph.xoffset, - start_pixpos, -1, findex, - (rb->cursor_type == CURSOR_ON), - cursor_start, cursor_width, - cursor_height); - Dynarr_reset (buf); + case IMAGE_MONO_PIXMAP: + case IMAGE_COLOR_PIXMAP: + redisplay_output_pixmap (w, instance, &dbox, &dga, findex, + cursor_start, cursor_width, + cursor_height, 0); + break; + + case IMAGE_WIDGET: + if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance), + Qlayout)) + { + redisplay_output_layout (window, instance, &dbox, &dga, findex, + cursor_start, cursor_width, + cursor_height); + break; + } + case IMAGE_SUBWINDOW: + redisplay_output_subwindow (w, instance, &dbox, &dga, findex, + cursor_start, cursor_width, + cursor_height); + break; + + case IMAGE_NOTHING: + /* nothing is as nothing does */ + break; + + case IMAGE_TEXT: + case IMAGE_POINTER: + default: + ABORT (); } - break; - - case IMAGE_MONO_PIXMAP: - case IMAGE_COLOR_PIXMAP: - redisplay_output_pixmap (w, instance, &dbox, &dga, findex, - cursor_start, cursor_width, - cursor_height, 0); - break; - - case IMAGE_WIDGET: - case IMAGE_SUBWINDOW: - redisplay_output_subwindow (w, instance, &dbox, &dga, findex, - cursor_start, cursor_width, - cursor_height); - break; - - case IMAGE_LAYOUT: - redisplay_output_layout (w, instance, &dbox, &dga, findex, - cursor_start, cursor_width, - cursor_height); - break; - - case IMAGE_NOTHING: - /* nothing is as nothing does */ - break; - - case IMAGE_POINTER: - default: - abort (); - } + IMAGE_INSTANCE_OPTIMIZE_OUTPUT + (XIMAGE_INSTANCE (instance)) = 0; + } xpos += rb->width; elt++; } else - abort (); + ABORT (); } } @@ -526,7 +525,7 @@ x_output_display_block (struct window *w, struct display_line *dl, int block, /***************************************************************************** x_bevel_area - Draw a shadows for the given area in the given face. + Draw shadows for the given area in the given face. ****************************************************************************/ static void x_bevel_area (struct window *w, face_index findex, @@ -682,7 +681,7 @@ x_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg, { /* #### I fixed once case where this was getting it. It was a bad macro expansion (compiler bug). */ - fprintf (stderr, "Help! x_get_gc got a bogus fg value! fg = "); + stderr_out ("Help! x_get_gc got a bogus fg value! fg = "); debug_print (fg); fg = Qnil; } @@ -776,7 +775,7 @@ x_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg, ****************************************************************************/ void x_output_string (struct window *w, struct display_line *dl, - Emchar_dynarr *buf, int xpos, int xoffset, int clip_start, + Charc_dynarr *buf, int xpos, int xoffset, int clip_start, int width, face_index findex, int cursor, int cursor_start, int cursor_width, int cursor_height) { @@ -880,7 +879,7 @@ x_output_string (struct window *w, struct display_line *dl, for (i = 0; i < nruns; i++) { Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset); - struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font); + Lisp_Font_Instance *fi = XFONT_INSTANCE (font); int this_width; int need_clipping; @@ -983,7 +982,9 @@ x_output_string (struct window *w, struct display_line *dl, /* We draw underlines in the same color as the text. */ if (cachel->underline) { - unsigned long upos, uthick; + /* upos is naturally signed, why would anyone think otherwise? + uthick is signed to avoid unsigned propagation. */ + long upos, uthick; XFontStruct *xfont; xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)); @@ -1011,7 +1012,9 @@ x_output_string (struct window *w, struct display_line *dl, } if (cachel->strikethru) { - unsigned long ascent,descent,upos, uthick; + /* ascent, descent, and upos are naturally signed; why would anyone + think otherwise? uthick is signed to avoid unsigned propagation. */ + long ascent, descent, upos, uthick; XFontStruct *xfont; xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)); @@ -1166,9 +1169,9 @@ x_output_string (struct window *w, struct display_line *dl, } void -x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x, +x_output_x_pixmap (struct frame *f, Lisp_Image_Instance *p, int x, int y, int xoffset, int yoffset, - int width, int height, unsigned long fg, unsigned long bg, + int width, int height, unsigned long fg, unsigned long bg, GC override_gc) { struct device *d = XDEVICE (f->device); @@ -1219,15 +1222,15 @@ x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x, pixel values, instead of symbolic of fg/bg. */ if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0) { - XCopyArea (dpy, - IMAGE_INSTANCE_X_PIXMAP_SLICE + XCopyArea (dpy, + IMAGE_INSTANCE_X_PIXMAP_SLICE (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset, yoffset, width, height, x, y); } else { - XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE + XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset, yoffset, width, height, x, y, 1L); } @@ -1241,11 +1244,11 @@ x_output_pixmap (struct window *w, Lisp_Object image_instance, { struct frame *f = XFRAME (w->frame); struct device *d = XDEVICE (f->device); - struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance); + Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance); Display *dpy = DEVICE_X_DISPLAY (d); Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f)); - + /* Output the pixmap. */ { Lisp_Object tmp_pixel; @@ -1320,8 +1323,8 @@ x_output_vertical_divider (struct window *w, int clear) spacing = XINT (w->vertical_divider_spacing); line_width = XINT (w->vertical_divider_line_width); x = WINDOW_RIGHT (w) - width; - y1 = WINDOW_TOP (w) + FRAME_TOP_GUTTER_BOUNDS (f); - y2 = WINDOW_BOTTOM (w) + FRAME_BOTTOM_GUTTER_BOUNDS (f); + y1 = WINDOW_TOP (w); + y2 = WINDOW_BOTTOM (w); memset (&gcv, ~0, sizeof (XGCValues)); @@ -1430,7 +1433,7 @@ x_output_blank (struct window *w, struct display_line *dl, struct rune *rb, { int cursor_height, cursor_y; int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); - struct Lisp_Font_Instance *fi; + Lisp_Font_Instance *fi; fi = XFONT_INSTANCE (FACE_CACHEL_FONT (WINDOW_FACE_CACHEL (w, rb->findex), @@ -1718,6 +1721,7 @@ x_redraw_exposed_window (struct window *w, int x, int y, int width, int height) f->windows_structure_changed = 1; } + redisplay_clear_top_of_window (w); if (window_needs_vertical_divider (w)) { x_output_vertical_divider (w, 0); @@ -1920,7 +1924,7 @@ x_clear_frame_window (Lisp_Object window) return; } - redisplay_clear_to_window_end (w, WINDOW_TEXT_TOP (w), + redisplay_clear_to_window_end (w, WINDOW_TEXT_TOP (w), WINDOW_TEXT_BOTTOM (w)); } @@ -1983,6 +1987,7 @@ x_flash (struct device *d) struct frame *f = device_selected_frame (d); struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f)); Widget shell = FRAME_X_SHELL_WIDGET (f); + int flash_height; XSETFRAME (frame, f); @@ -1999,8 +2004,22 @@ x_flash (struct device *d) gcv.graphics_exposures = False; gc = gc_cache_lookup (DEVICE_X_GC_CACHE (XDEVICE (f->device)), &gcv, (GCForeground | GCFunction | GCGraphicsExposures)); - XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top, - w->pixel_width, w->pixel_height); + default_face_height_and_width (frame, &flash_height, 0); + + /* If window is tall, flash top and bottom line. */ + if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height) + { + XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top, + w->pixel_width, flash_height); + XFillRectangle (dpy, win, gc, w->pixel_left, + w->pixel_top + w->pixel_height - flash_height, + w->pixel_width, flash_height); + } + else + /* If it is short, flash it all. */ + XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top, + w->pixel_width, w->pixel_height); + XSync (dpy, False); #ifdef HAVE_SELECT @@ -2020,8 +2039,20 @@ x_flash (struct device *d) #endif /* HAVE_POLL */ #endif /* HAVE_SELECT */ - XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top, - w->pixel_width, w->pixel_height); + /* If window is tall, flash top and bottom line. */ + if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height) + { + XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top, + w->pixel_width, flash_height); + XFillRectangle (dpy, win, gc, w->pixel_left, + w->pixel_top + w->pixel_height - flash_height, + w->pixel_width, flash_height); + } + else + /* If it is short, flash it all. */ + XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top, + w->pixel_width, w->pixel_height); + XSync (dpy, False); return 1; @@ -2049,8 +2080,8 @@ x_ring_bell (struct device *d, int volume, int pitch, int duration) /* #### grab server? */ XGetKeyboardControl (display, &state); - ctl.bell_pitch = (pitch >= 0 ? pitch : state.bell_pitch); - ctl.bell_duration = (duration >= 0 ? duration : state.bell_duration); + ctl.bell_pitch = (pitch >= 0 ? pitch : (int) state.bell_pitch); + ctl.bell_duration = (duration >= 0 ? duration : (int) state.bell_duration); XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl); XBell (display, (volume * 2) - 100); @@ -2080,8 +2111,8 @@ console_type_create_redisplay_x (void) CONSOLE_HAS_METHOD (x, output_vertical_divider); CONSOLE_HAS_METHOD (x, clear_region); CONSOLE_HAS_METHOD (x, clear_frame); - CONSOLE_HAS_METHOD (x, output_begin); - CONSOLE_HAS_METHOD (x, output_end); + CONSOLE_HAS_METHOD (x, window_output_begin); + CONSOLE_HAS_METHOD (x, window_output_end); CONSOLE_HAS_METHOD (x, flash); CONSOLE_HAS_METHOD (x, ring_bell); CONSOLE_HAS_METHOD (x, bevel_area);