remove Lisp_Free struct type
[bpt/emacs.git] / src / dispnew.c
index 9492960..1637809 100644 (file)
@@ -1,6 +1,6 @@
 /* Updating of data structures for redisplay.
 
-Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation,
+Copyright (C) 1985-1988, 1993-1995, 1997-2014 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -92,7 +92,7 @@ static void check_matrix_pointers (struct glyph_matrix *,
 static void mirror_line_dance (struct window *, int, int, int *, char *);
 static bool update_window_tree (struct window *, bool);
 static bool update_window (struct window *, bool);
-static bool update_frame_1 (struct frame *, bool, bool);
+static bool update_frame_1 (struct frame *, bool, bool, bool);
 static bool scrolling (struct frame *);
 static void set_window_cursor_after_update (struct window *);
 static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
@@ -561,12 +561,12 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
                w->window_end_valid = 0;
 
              while (i < matrix->nrows)
-               matrix->rows[i++].enabled_p = 0;
+               matrix->rows[i++].enabled_p = false;
            }
          else
            {
              for (i = 0; i < matrix->nrows; ++i)
-               matrix->rows[i].enabled_p = 0;
+               matrix->rows[i].enabled_p = false;
            }
        }
       else if (matrix == w->desired_matrix)
@@ -576,7 +576,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
             had better be the case when we adjust matrices between
             redisplays.  */
          for (i = 0; i < matrix->nrows; ++i)
-           matrix->rows[i].enabled_p = 0;
+           matrix->rows[i].enabled_p = false;
        }
     }
 
@@ -684,7 +684,7 @@ clear_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end)
   eassert (end >= 0 && end <= matrix->nrows);
 
   for (; start < end; ++start)
-    matrix->rows[start].enabled_p = 0;
+    matrix->rows[start].enabled_p = false;
 }
 
 
@@ -864,7 +864,7 @@ blank_row (struct window *w, struct glyph_row *row, int y)
   if (row->y + row->height > max_y)
     row->visible_height -= row->y + row->height - max_y;
 
-  row->enabled_p = 1;
+  row->enabled_p = true;
 }
 
 
@@ -1062,7 +1062,7 @@ prepare_desired_row (struct glyph_row *row)
       bool rp = row->reversed_p;
 
       clear_glyph_row (row);
-      row->enabled_p = 1;
+      row->enabled_p = true;
       row->reversed_p = rp;
     }
 }
@@ -2055,7 +2055,8 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
     w->left_col = 0;
     w->pixel_top = 0;
     w->top_line = 0;
-    w->pixel_width = FRAME_PIXEL_WIDTH (f);
+    w->pixel_width = (FRAME_PIXEL_WIDTH (f)
+                     - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
     w->total_cols = FRAME_TOTAL_COLS (f);
     w->pixel_height = FRAME_MENU_BAR_HEIGHT (f);
     w->total_lines = FRAME_MENU_BAR_LINES (f);
@@ -2416,7 +2417,7 @@ build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct w
 
          /* Only when a desired row has been displayed, we want
             the corresponding frame row to be updated.  */
-         frame_row->enabled_p = 1;
+         frame_row->enabled_p = true;
 
           /* Maybe insert a vertical border between horizontally adjacent
             windows.  */
@@ -2564,7 +2565,7 @@ make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_
   assign_row (current_row, desired_row);
 
   /* Enable current_row to mark it as valid.  */
-  current_row->enabled_p = 1;
+  current_row->enabled_p = true;
   current_row->mouse_face_p = mouse_face_p;
 
   /* If we are called on frame matrices, perform analogous operations
@@ -2606,7 +2607,7 @@ mirror_make_current (struct window *w, int frame_row)
                assign_row (current_row, desired_row);
              else
                swap_glyph_pointers (desired_row, current_row);
-             current_row->enabled_p = 1;
+             current_row->enabled_p = true;
 
              /* Set the Y coordinate of the mode/header line's row.
                 It is needed in draw_row_with_mouse_face to find the
@@ -2661,7 +2662,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
 
       /* RETAINED_P is zero for empty lines.  */
       if (!retained_p[copy_from[i]])
-       new_rows[i].enabled_p = 0;
+       new_rows[i].enabled_p = false;
     }
 
   /* Do the same for window matrices, if MATRIX is a frame matrix.  */
@@ -2796,7 +2797,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
 
                  /* If frame line is empty, window line is empty, too.  */
                  if (!retained_p[copy_from[i]])
-                   m->rows[window_to].enabled_p = 0;
+                   m->rows[window_to].enabled_p = false;
                }
              else if (to_inside_window_p)
                {
@@ -2821,7 +2822,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
 
                      /* If frame line is empty, window line is empty, too.  */
                      if (!retained_p[copy_from[i]])
-                       m->rows[window_to].enabled_p = 0;
+                       m->rows[window_to].enabled_p = false;
                    }
                  sync_p = 1;
                }
@@ -3069,7 +3070,7 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
 
       /* Update the display  */
       update_begin (f);
-      paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p);
+      paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p, 1);
       update_end (f);
 
       if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
@@ -3099,12 +3100,17 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
    glyphs.  This is like the second part of update_frame, but it
    doesn't call build_frame_matrix, because we already have the
    desired matrix prepared, and don't want it to be overwritten by the
-   text of the normal display.  */
+   text of the normal display.
+
+   ROW and COL, if non-negative, are the row and column of the TTY
+   frame where to position the cursor after the frame update is
+   complete.  Negative values mean ask update_frame_1 to position the
+   cursor "normally", i.e. at point in the selected window.  */
 void
-update_frame_with_menu (struct frame *f)
+update_frame_with_menu (struct frame *f, int row, int col)
 {
   struct window *root_window = XWINDOW (f->root_window);
-  bool paused_p;
+  bool paused_p, cursor_at_point_p;
 
   eassert (FRAME_TERMCAP_P (f));
 
@@ -3114,9 +3120,14 @@ update_frame_with_menu (struct frame *f)
 
   /* Update the display.  */
   update_begin (f);
+  cursor_at_point_p = !(row >= 0 && col >= 0);
   /* Force update_frame_1 not to stop due to pending input, and not
      try scrolling.  */
-  paused_p = update_frame_1 (f, 1, 1);
+  paused_p = update_frame_1 (f, 1, 1, cursor_at_point_p);
+  /* ROW and COL tell us where in the menu to position the cursor, so
+     that screen readers know the active region on the screen.  */
+  if (!cursor_at_point_p)
+    cursor_to (f, row, col);
   update_end (f);
 
   if (FRAME_TTY (f)->termscript)
@@ -3131,12 +3142,11 @@ update_frame_with_menu (struct frame *f)
   check_window_matrix_pointers (root_window);
 #endif
   add_frame_display_history (f, paused_p);
-#else
-  IF_LINT ((void) paused_p);
 #endif
 
   /* Reset flags indicating that a window should be updated.  */
   set_window_update_flags (root_window, false);
+  display_completed = !paused_p;
 }
 
 \f
@@ -3432,7 +3442,7 @@ update_window (struct window *w, bool force_p)
               in the first redisplay.  */
            if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
              for (i = vpos + 1; i < w->current_matrix->nrows - 1; ++i)
-               MATRIX_ROW (w->current_matrix, i)->enabled_p = 0;
+               SET_MATRIX_ROW_ENABLED_P (w->current_matrix, i, false);
          }
 
       /* Was display preempted?  */
@@ -4069,14 +4079,14 @@ scrolling_window (struct window *w, bool header_line_p)
          && row_equal_p (c, d, 1))
        {
          assign_row (c, d);
-         d->enabled_p = 0;
+         d->enabled_p = false;
        }
       else
        break;
     }
 
   /* Give up if some rows in the desired matrix are not enabled.  */
-  if (!MATRIX_ROW (desired_matrix, i)->enabled_p)
+  if (! MATRIX_ROW_ENABLED_P (desired_matrix, i))
     return -1;
 
   first_old = first_new = i;
@@ -4089,7 +4099,7 @@ scrolling_window (struct window *w, bool header_line_p)
     {
       int bottom;
 
-      if (!MATRIX_ROW (desired_matrix, i)->enabled_p)
+      if (! MATRIX_ROW_ENABLED_P (desired_matrix, i))
        return 0;
       bottom = MATRIX_ROW_BOTTOM_Y (MATRIX_ROW (desired_matrix, i));
       if (bottom <= yb)
@@ -4121,7 +4131,7 @@ scrolling_window (struct window *w, bool header_line_p)
   j = last_old;
   while (i - 1 > first_new
          && j - 1 > first_old
-         && MATRIX_ROW (current_matrix, j - 1)->enabled_p
+         && MATRIX_ROW_ENABLED_P (current_matrix, j - 1)
         && (MATRIX_ROW (current_matrix, j - 1)->y
             == MATRIX_ROW (desired_matrix, i - 1)->y)
         && !MATRIX_ROW (desired_matrix, i - 1)->redraw_fringe_bitmaps_p
@@ -4198,7 +4208,7 @@ scrolling_window (struct window *w, bool header_line_p)
 
   for (i = first_old; i < last_old; ++i)
     {
-      if (MATRIX_ROW (current_matrix, i)->enabled_p)
+      if (MATRIX_ROW_ENABLED_P (current_matrix, i))
        {
          entry = add_row_entry (MATRIX_ROW (current_matrix, i));
          old_lines[i] = entry;
@@ -4391,7 +4401,7 @@ scrolling_window (struct window *w, bool header_line_p)
               preceding for-loop, we no longer have such an overlap,
               and thus the assigned row should always be enabled.  */
            eassert (to->enabled_p);
-           from->enabled_p = 0;
+           from->enabled_p = false;
            to->overlapped_p = to_overlapped_p;
          }
       }
@@ -4413,12 +4423,14 @@ scrolling_window (struct window *w, bool header_line_p)
 /* Update the desired frame matrix of frame F.
 
    FORCE_P means that the update should not be stopped by pending input.
-   INHIBIT_HAIRY_ID_P means that scrolling should not be tried.
+   INHIBIT_ID_P means that scrolling by insert/delete should not be tried.
+   SET_CURSOR_P false means do not set cursor at point in selected window.
 
    Value is true if update was stopped due to pending input.  */
 
 static bool
-update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
+update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p,
+               bool set_cursor_p)
 {
   /* Frame matrices to work on.  */
   struct glyph_matrix *current_matrix = f->current_matrix;
@@ -4490,7 +4502,7 @@ update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
   pause_p = 0 < i && i < FRAME_LINES (f) - 1;
 
   /* Now just clean up termcap drivers and set cursor, etc.  */
-  if (!pause_p)
+  if (!pause_p && set_cursor_p)
     {
       if ((cursor_in_echo_area
           /* If we are showing a message instead of the mini-buffer,
@@ -4761,7 +4773,7 @@ update_frame_line (struct frame *f, int vpos)
          olen--;
     }
 
-  current_row->enabled_p = 1;
+  current_row->enabled_p = true;
   current_row->used[TEXT_AREA] = desired_row->used[TEXT_AREA];
 
   /* If desired line is empty, just clear the line.  */
@@ -5463,8 +5475,7 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
                     bool pretend, bool delay, bool safe, bool pixelwise)
 {
   int new_text_width, new_text_height, new_root_width;
-  int old_root_width = (FRAME_PIXEL_WIDTH (f)
-                       - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+  int old_root_width = WINDOW_PIXEL_WIDTH (XWINDOW (FRAME_ROOT_WINDOW (f)));
   int new_cols, new_lines;
   ptrdiff_t count = SPECPDL_INDEX ();
 
@@ -5488,6 +5499,8 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
     {
       new_text_width = (new_width == 0) ? FRAME_TEXT_WIDTH (f) : new_width;
       new_text_height = (new_height == 0) ? FRAME_TEXT_HEIGHT (f) : new_height;
+      /* Consider rounding here: Currently, the root window can be
+        larger than the frame in terms of columns/lines.  */
       new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
       new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
     }
@@ -5507,7 +5520,6 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
      fringe columns.  Do this after rounding - see discussion of
      bug#9723.  */
   new_root_width = (new_text_width
-                   /* PXM: Use the configured scrollbar width !??  */
                    + FRAME_SCROLL_BAR_AREA_WIDTH (f)
                    + FRAME_TOTAL_FRINGE_WIDTH (f));
   /* If we're not changing the frame size, quit now.  */
@@ -5515,7 +5527,11 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
      example, fullscreen and remove/add scroll bar.  */
   if (new_text_height == FRAME_TEXT_HEIGHT (f)
       && new_text_width == FRAME_TEXT_WIDTH (f)
-      && new_root_width == old_root_width)
+      && new_root_width == old_root_width
+      && (FRAME_PIXEL_HEIGHT (f) ==
+         FRAME_TEXT_TO_PIXEL_HEIGHT (f, new_text_height))
+      && (FRAME_PIXEL_WIDTH (f) ==
+         FRAME_TEXT_TO_PIXEL_WIDTH (f, new_text_width)))
     return;
 
   block_input ();
@@ -5534,7 +5550,7 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
       /* MSDOS frames cannot PRETEND, as they change frame size by
         manipulating video hardware.  */
       if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
-       FrameRows (FRAME_TTY (f)) = new_height;
+       FrameRows (FRAME_TTY (f)) = new_lines;
     }
 
   if (new_text_width != FRAME_TEXT_WIDTH (f)