X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/4d553a13abdadb4bb469bc0b59c003d48066dce5..2246281fb0e2ab610d14efa7166a9ceb02597643:/src/dispnew.c diff --git a/src/dispnew.c b/src/dispnew.c index be6e6330e3..81a0f1f5c8 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -29,10 +29,8 @@ Boston, MA 02111-1307, USA. */ #endif #include "lisp.h" -#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "termopts.h" -#include "termhooks.h" /* cm.h must come after dispextern.h on Windows. */ #include "dispextern.h" #include "cm.h" @@ -40,6 +38,7 @@ Boston, MA 02111-1307, USA. */ #include "charset.h" #include "keyboard.h" #include "frame.h" +#include "termhooks.h" #include "window.h" #include "commands.h" #include "disptab.h" @@ -215,9 +214,9 @@ int inverse_video; EMACS_INT baud_rate; /* Either nil or a symbol naming the window system under which Emacs - is running. */ + creates the first frame. */ -Lisp_Object Vwindow_system; +Lisp_Object Vinitial_window_system; /* Version number of X windows: 10, 11 or nil. */ @@ -3307,8 +3306,10 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, return Qnil; update_begin (f); +#ifdef MSDOS if (FRAME_MSDOS_P (f)) - set_terminal_modes (); + set_terminal_modes (FRAME_DISPLAY (f)); +#endif clear_frame (); clear_current_matrices (f); update_end (f); @@ -3834,9 +3835,12 @@ update_frame (f, force_p, inhibit_hairy_id_p) paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p); update_end (f); - if (TTY_TERMSCRIPT (FRAME_TTY (f))) - fflush (TTY_TERMSCRIPT (FRAME_TTY (f))); - fflush (TTY_OUTPUT (FRAME_TTY (f))); + if (FRAME_TERMCAP_P (f)) + { + if (TTY_TERMSCRIPT (FRAME_TTY (f))) + fflush (TTY_TERMSCRIPT (FRAME_TTY (f))); + fflush (TTY_OUTPUT (FRAME_TTY (f))); + } /* Check window matrices for lost pointers. */ #if GLYPH_DEBUG @@ -5693,21 +5697,24 @@ update_frame_line (f, vpos) ***********************************************************************/ /* Determine what's under window-relative pixel position (*X, *Y). - Return in *OBJECT the object (string or buffer) that's there. - Return in *POS the position in that object. Adjust *X and *Y - to character positions. */ + Return the object (string or buffer) that's there. + Return in *POS the position in that object. + Adjust *X and *Y to character positions. */ -void -buffer_posn_from_coords (w, x, y, dx, dy, object, pos) +Lisp_Object +buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) struct window *w; int *x, *y; - int *dx, *dy; - Lisp_Object *object; struct display_pos *pos; + Lisp_Object *object; + int *dx, *dy; + int *width, *height; { struct it it; struct buffer *old_current_buffer = current_buffer; struct text_pos startp; + Lisp_Object string; + struct glyph_row *row; int x0, x1; current_buffer = XBUFFER (w->buffer); @@ -5725,7 +5732,10 @@ buffer_posn_from_coords (w, x, y, dx, dy, object, pos) *dx = x0 + it.first_visible_x - it.current_x; *dy = *y - it.current_y; - *object = w->buffer; + string = w->buffer; + if (STRINGP (it.string)) + string = it.string; + *pos = it.current; #ifdef HAVE_WINDOW_SYSTEM if (it.what == IT_IMAGE) @@ -5733,25 +5743,33 @@ buffer_posn_from_coords (w, x, y, dx, dy, object, pos) struct image *img; if ((img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL && !NILP (img->spec)) - { - struct glyph_row *row = MATRIX_ROW (w->current_matrix, it.vpos); - struct glyph *glyph; + *object = img->spec; + } +#endif - if (it.hpos < row->used[TEXT_AREA] - && (glyph = row->glyphs[TEXT_AREA] + it.hpos, - glyph->type == IMAGE_GLYPH)) - { - *dy -= row->ascent - glyph->ascent; - *object = img->spec; - } + row = MATRIX_ROW (w->current_matrix, it.vpos); + if (row->enabled_p) + { + if (it.hpos < row->used[TEXT_AREA]) + { + struct glyph *glyph = row->glyphs[TEXT_AREA] + it.hpos; + *width = glyph->pixel_width; + *height = glyph->ascent + glyph->descent; +#ifdef HAVE_WINDOW_SYSTEM + if (glyph->type == IMAGE_GLYPH) + *dy -= row->ascent - glyph->ascent; +#endif + } + else + { + *width = 0; + *height = row->height; } } else -#endif - if (STRINGP (it.string)) - *object = it.string; - - *pos = it.current; + { + *width = *height = 0; + } /* Add extra (default width) columns if clicked after EOL. */ x1 = max(0, it.current_x + it.pixel_width - it.first_visible_x); @@ -5760,21 +5778,24 @@ buffer_posn_from_coords (w, x, y, dx, dy, object, pos) *x = it.hpos; *y = it.vpos; + + return string; } /* Value is the string under window-relative coordinates X/Y in the - mode or header line of window W, or nil if none. MODE_LINE_P non-zero - means look at the mode line. *CHARPOS is set to the position in - the string returned. */ + mode line or header line (PART says which) of window W, or nil if none. + *CHARPOS is set to the position in the string returned. */ Lisp_Object -mode_line_string (w, x, y, dx, dy, part, charpos) +mode_line_string (w, part, x, y, charpos, object, dx, dy, width, height) struct window *w; - int *x, *y; - int *dx, *dy; enum window_part part; + int *x, *y; int *charpos; + Lisp_Object *object; + int *dx, *dy; + int *width, *height; { struct glyph_row *row; struct glyph *glyph, *end; @@ -5801,22 +5822,36 @@ mode_line_string (w, x, y, dx, dy, part, charpos) { string = glyph->object; *charpos = glyph->charpos; + *width = glyph->pixel_width; + *height = glyph->ascent + glyph->descent; +#ifdef HAVE_WINDOW_SYSTEM + if (glyph->type == IMAGE_GLYPH) + { + struct image *img; + img = IMAGE_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id); + if (img != NULL) + *object = img->spec; + y0 -= row->ascent - glyph->ascent; + } +#endif } else - /* Add extra (default width) columns if clicked after EOL. */ - *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); + { + /* Add extra (default width) columns if clicked after EOL. */ + *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); + *width = 0; + *height = row->height; + } } else { *x = 0; x0 = 0; + *width = *height = 0; } - if (dx) - { - *dx = x0; - *dy = y0; - } + *dx = x0; + *dy = y0; return string; } @@ -5827,12 +5862,14 @@ mode_line_string (w, x, y, dx, dy, part, charpos) the string returned. */ Lisp_Object -marginal_area_string (w, x, y, dx, dy, part, charpos) +marginal_area_string (w, part, x, y, charpos, object, dx, dy, width, height) struct window *w; - int *x, *y; - int *dx, *dy; enum window_part part; + int *x, *y; int *charpos; + Lisp_Object *object; + int *dx, *dy; + int *width, *height; { struct glyph_row *row = w->current_matrix->rows; struct glyph *glyph, *end; @@ -5877,32 +5914,36 @@ marginal_area_string (w, x, y, dx, dy, part, charpos) { string = glyph->object; *charpos = glyph->charpos; + *width = glyph->pixel_width; + *height = glyph->ascent + glyph->descent; #ifdef HAVE_WINDOW_SYSTEM if (glyph->type == IMAGE_GLYPH) { struct image *img; img = IMAGE_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id); if (img != NULL) - string = img->spec; + *object = img->spec; y0 -= row->ascent - glyph->ascent; } #endif } else - /* Add extra (default width) columns if clicked after EOL. */ - *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); + { + /* Add extra (default width) columns if clicked after EOL. */ + *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); + *width = 0; + *height = row->height; + } } else { x0 = 0; *x = 0; + *width = *height = 0; } - if (dx) - { - *dx = x0; - *dy = y0; - } + *dx = x0; + *dy = y0; return string; } @@ -6528,7 +6569,7 @@ init_display () /* Now is the time to initialize this; it's used by init_sys_modes during startup. */ - Vwindow_system = Qnil; + Vinitial_window_system = Qnil; /* If the user wants to use a window system, we shouldn't bother initializing the terminal. This is especially important when the @@ -6557,7 +6598,7 @@ init_display () #endif ) { - Vwindow_system = intern ("x"); + Vinitial_window_system = intern ("x"); #ifdef HAVE_X11 Vwindow_system_version = make_number (11); #else @@ -6577,7 +6618,7 @@ init_display () #ifdef HAVE_NTGUI if (!inhibit_window_system) { - Vwindow_system = intern ("w32"); + Vinitial_window_system = intern ("w32"); Vwindow_system_version = make_number (1); adjust_frame_glyphs_initially (); return; @@ -6587,7 +6628,7 @@ init_display () #ifdef MAC_OS if (!inhibit_window_system) { - Vwindow_system = intern ("mac"); + Vinitial_window_system = intern ("mac"); Vwindow_system_version = make_number (1); adjust_frame_glyphs_initially (); return; @@ -6634,10 +6675,26 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ #endif /* VMS */ { - struct tty_display_info *tty; - - tty = term_init (selected_frame, 0, terminal_type); - change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 1); + struct display *d; + struct frame *f = XFRAME (selected_frame); + + /* Open a display on the controlling tty. */ + d = term_init (0, terminal_type, 1); /* Errors are fatal. */ + + /* Convert the initial frame to use the new display. */ + if (! f->output_method == output_initial) + abort (); + f->output_method = d->type; + f->display = d; + + d->reference_count++; + d->display_info.tty->top_frame = selected_frame; + change_frame_size (XFRAME (selected_frame), FrameRows (d->display_info.tty), FrameCols (d->display_info.tty), 0, 0, 1); + + /* Delete the initial display. */ + if (--initial_display->reference_count == 0 + && initial_display->delete_display_hook) + (*initial_display->delete_display_hook) (initial_display); } { @@ -6673,7 +6730,7 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ and internal_terminal_init. */ && (strcmp (terminal_type, "internal") != 0 || inhibit_window_system) #endif - && NILP (Vwindow_system)) + && NILP (Vinitial_window_system)) { /* For the initial frame, we don't have any way of knowing what are the foreground and background colors of the terminal. */ @@ -6785,8 +6842,8 @@ A non-nil value is useful if the terminal can automatically preserve Emacs's frame display when you reenter Emacs. It is up to you to set this variable if your terminal can do that. */); - DEFVAR_LISP ("window-system", &Vwindow_system, - doc: /* Name of window system that Emacs is displaying through. + DEFVAR_LISP ("initial-window-system", &Vinitial_window_system, + doc: /* Name of the window system that Emacs uses for the first frame. The value is a symbol--for instance, `x' for X windows. The value is nil if Emacs is using a text-only terminal. */); @@ -6822,7 +6879,7 @@ See `buffer-display-table' for more information. */); if (noninteractive) #endif { - Vwindow_system = Qnil; + Vinitial_window_system = Qnil; Vwindow_system_version = Qnil; } }