]> code.delx.au - gnu-emacs/blobdiff - src/dispnew.c
TODO update
[gnu-emacs] / src / dispnew.c
index 10206ecd43b50ae0562e18998d8626968170726b..563ee64b9255cb5592429135caa506569b33352d 100644 (file)
@@ -1,6 +1,7 @@
 /* Updating of data structures for redisplay.
 
-Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc.
+Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation,
+Inc.
 
 This file is part of GNU Emacs.
 
@@ -21,15 +22,11 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define DISPEXTERN_INLINE EXTERN_INLINE
 
-#include <signal.h>
 #include <stdio.h>
-#include <ctype.h>
-#include <setjmp.h>
 #include <unistd.h>
 
 #include "lisp.h"
 #include "termchar.h"
-#include "termopts.h"
 /* cm.h must come after dispextern.h on Windows.  */
 #include "dispextern.h"
 #include "cm.h"
@@ -48,53 +45,26 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "syssignal.h"
 
-#ifdef HAVE_X_WINDOWS
-#include "xterm.h"
-#endif /* HAVE_X_WINDOWS */
-
-#ifdef HAVE_NTGUI
-#include "w32term.h"
-#endif /* HAVE_NTGUI */
-
-#ifdef HAVE_NS
-#include "nsterm.h"
-#endif
+#ifdef HAVE_WINDOW_SYSTEM
+#include TERM_HEADER
+#endif /* HAVE_WINDOW_SYSTEM */
 
 /* Include systime.h after xterm.h to avoid double inclusion of time.h.  */
 
 #include "systime.h"
 #include <errno.h>
 
-/* Get number of chars of output now in the buffer of a stdio stream.
-   This ought to be built in stdio, but it isn't.  Some s- files
-   override this because their stdio internals differ.  */
-#ifdef __GNU_LIBRARY__
-
-/* The s- file might have overridden the definition with one that
-   works for the system's C library.  But we are using the GNU C
-   library, so this is the right definition for every system.  */
-#ifdef GNU_LIBRARY_PENDING_OUTPUT_COUNT
-#define PENDING_OUTPUT_COUNT GNU_LIBRARY_PENDING_OUTPUT_COUNT
-#else
-#undef PENDING_OUTPUT_COUNT
-#define        PENDING_OUTPUT_COUNT(FILE) ((FILE)->__bufp - (FILE)->__buffer)
-#endif
-
-/* not __GNU_LIBRARY__ and no PENDING_OUTPUT_COUNT defined  */
-#elif !defined (PENDING_OUTPUT_COUNT)
-
-#if HAVE_STDIO_EXT_H && HAVE___FPENDING
+#ifdef DISPNEW_NEEDS_STDIO_EXT
 #include <stdio_ext.h>
-#define PENDING_OUTPUT_COUNT(FILE) __fpending (FILE)
-#else
-#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base)
 #endif
 
-#endif /* not __GNU_LIBRARY__ and no PENDING_OUTPUT_COUNT defined */
-
 #if defined (HAVE_TERM_H) && defined (GNU_LINUX)
 #include <term.h>              /* for tgetent */
 #endif
+
+#ifdef WINDOWSNT
+#include "w32.h"
+#endif
 \f
 /* Structure to pass dimensions around.  Used for character bounding
    boxes, glyph matrix dimensions and alike.  */
@@ -112,7 +82,7 @@ static void update_frame_line (struct frame *, int);
 static int required_matrix_height (struct window *);
 static int required_matrix_width (struct window *);
 static void adjust_frame_glyphs (struct frame *);
-static void change_frame_size_1 (struct frame *, int, int, int, int, int);
+static void change_frame_size_1 (struct frame *, int, int, bool, bool, bool);
 static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t);
 static void fill_up_frame_row_with_spaces (struct glyph_row *, int);
 static void build_frame_matrix_from_window_tree (struct glyph_matrix *,
@@ -122,20 +92,20 @@ static void build_frame_matrix_from_leaf_window (struct glyph_matrix *,
 static void adjust_frame_message_buffer (struct frame *);
 static void adjust_decode_mode_spec_buffer (struct frame *);
 static void fill_up_glyph_row_with_spaces (struct glyph_row *);
-static void clear_window_matrices (struct window *, int);
+static void clear_window_matrices (struct window *, bool);
 static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int);
-static int scrolling_window (struct window *, int);
-static int update_window_line (struct window *, int, int *);
+static int scrolling_window (struct window *, bool);
+static bool update_window_line (struct window *, int, bool *);
 static void mirror_make_current (struct window *, int);
 #ifdef GLYPH_DEBUG
 static void check_matrix_pointers (struct glyph_matrix *,
                                    struct glyph_matrix *);
 #endif
 static void mirror_line_dance (struct window *, int, int, int *, char *);
-static int update_window_tree (struct window *, int);
-static int update_window (struct window *, int);
-static int update_frame_1 (struct frame *, int, int);
-static int scrolling (struct frame *);
+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 scrolling (struct frame *);
 static void set_window_cursor_after_update (struct window *);
 static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
 static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
@@ -146,14 +116,14 @@ static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
 static EMACS_TIME preemption_period;
 static EMACS_TIME preemption_next_check;
 
-/* Nonzero upon entry to redisplay means do not assume anything about
+/* True upon entry to redisplay means do not assume anything about
    current contents of actual terminal frame; clear and redraw it.  */
 
-int frame_garbaged;
+bool frame_garbaged;
 
-/* Nonzero means last display completed.  Zero means it was preempted.  */
+/* True means last display completed.  False means it was preempted.  */
 
-int display_completed;
+bool display_completed;
 
 Lisp_Object Qdisplay_table, Qredisplay_dont_pause;
 
@@ -170,13 +140,13 @@ Lisp_Object selected_frame;
 
 struct frame *last_nonminibuf_frame;
 
-/* 1 means SIGWINCH happened when not safe.  */
+/* True means SIGWINCH happened when not safe.  */
 
-static int delayed_size_change;
+static bool delayed_size_change;
 
 /* 1 means glyph initialization has been completed at startup.  */
 
-static int glyphs_initialized_initially_p;
+static bool glyphs_initialized_initially_p;
 
 /* Updated window if != 0.  Set by update_window.  */
 
@@ -202,15 +172,15 @@ static int glyph_pool_count;
 
 static struct frame *frame_matrix_frame;
 
-/* Non-zero means that fonts have been loaded since the last glyph
+/* True means that fonts have been loaded since the last glyph
    matrix adjustments.  Redisplay must stop, and glyph matrices must
-   be adjusted when this flag becomes non-zero during display.  The
+   be adjusted when this flag becomes true during display.  The
    reason fonts can be loaded so late is that fonts of fontsets are
    loaded on demand.  Another reason is that a line contains many
    characters displayed by zero width or very narrow glyphs of
    variable-width fonts.  */
 
-int fonts_changed_p;
+bool fonts_changed_p;
 
 /* Convert vpos and hpos from frame to window and vice versa.
    This may only be used for terminal frames.  */
@@ -246,16 +216,14 @@ static int history_idx;
    history.  */
 
 static uprintmax_t history_tick;
-
-static void add_frame_display_history (struct frame *, int);
 \f
 /* Add to the redisplay history how window W has been displayed.
    MSG is a trace containing the information how W's glyph matrix
-   has been constructed.  PAUSED_P non-zero means that the update
+   has been constructed.  PAUSED_P means that the update
    has been interrupted for pending input.  */
 
 static void
-add_window_display_history (struct window *w, const char *msg, int paused_p)
+add_window_display_history (struct window *w, const char *msg, bool paused_p)
 {
   char *buf;
 
@@ -268,9 +236,9 @@ add_window_display_history (struct window *w, const char *msg, int paused_p)
            "%"pMu": window %p (`%s')%s\n%s",
            history_tick++,
            w,
-           ((BUFFERP (WGET (w, buffer))
-             && STRINGP (BVAR (XBUFFER (WGET (w, buffer)), name)))
-            ? SSDATA (BVAR (XBUFFER (WGET (w, buffer)), name))
+           ((BUFFERP (w->buffer)
+             && STRINGP (BVAR (XBUFFER (w->buffer), name)))
+            ? SSDATA (BVAR (XBUFFER (w->buffer), name))
             : "???"),
            paused_p ? " ***paused***" : "",
            msg);
@@ -278,11 +246,11 @@ add_window_display_history (struct window *w, const char *msg, int paused_p)
 
 
 /* Add to the redisplay history that frame F has been displayed.
-   PAUSED_P non-zero means that the update has been interrupted for
+   PAUSED_P means that the update has been interrupted for
    pending input.  */
 
 static void
-add_frame_display_history (struct frame *f, int paused_p)
+add_frame_display_history (struct frame *f, bool paused_p)
 {
   char *buf;
 
@@ -331,7 +299,7 @@ DEFUN ("dump-redisplay-history", Fdump_redisplay_history,
 void
 __executable_start (void)
 {
-  abort ();
+  emacs_abort ();
 }
 #endif
 \f
@@ -381,7 +349,7 @@ free_glyph_matrix (struct glyph_matrix *matrix)
       /* Detect the case that more matrices are freed than were
         allocated.  */
       if (--glyph_matrix_count < 0)
-       abort ();
+       emacs_abort ();
 
       /* Free glyph memory if MATRIX owns it.  */
       if (matrix->pool == NULL)
@@ -408,7 +376,7 @@ margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin
 
   if (NUMBERP (margin))
     {
-      int width = XFASTINT (WGET (w, total_cols));
+      int width = XFASTINT (w->total_cols);
       double d = max (0, XFLOATINT (margin));
       d = min (width / 2 - 1, d);
       n = (int) ((double) total_glyphs / width * d);
@@ -419,10 +387,10 @@ margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin
   return n;
 }
 
-/* Return non-zero if ROW's hash value is correct, zero if not.
+/* Return true if ROW's hash value is correct.
    Optimized away if ENABLE_CHECKING is not defined.  */
 
-static int
+static bool
 verify_row_hash (struct glyph_row *row)
 {
   return row->hash == row_hash (row);
@@ -455,9 +423,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
 {
   int i;
   int new_rows;
-  int marginal_areas_changed_p = 0;
-  int header_line_changed_p = 0;
-  int header_line_p = 0;
+  bool marginal_areas_changed_p = 0;
+  bool header_line_changed_p = 0;
+  bool header_line_p = 0;
   int left = -1, right = -1;
   int window_width = -1, window_height = -1;
 
@@ -478,8 +446,8 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
      the matrix means preventing redisplay.  */
   if (matrix->pool == NULL)
     {
-      left = margin_glyphs_to_reserve (w, dim.width, WGET (w, left_margin_cols));
-      right = margin_glyphs_to_reserve (w, dim.width, WGET (w, right_margin_cols));
+      left = margin_glyphs_to_reserve (w, dim.width, w->left_margin_cols);
+      right = margin_glyphs_to_reserve (w, dim.width, w->right_margin_cols);
       eassert (left >= 0 && right >= 0);
       marginal_areas_changed_p = (left != matrix->left_margin_glyphs
                                  || right != matrix->right_margin_glyphs);
@@ -518,9 +486,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
       if (w)
        {
          left = margin_glyphs_to_reserve (w, dim.width,
-                                          WGET (w, left_margin_cols));
+                                          w->left_margin_cols);
          right = margin_glyphs_to_reserve (w, dim.width,
-                                           WGET (w, right_margin_cols));
+                                           w->right_margin_cols);
        }
       else
        left = right = 0;
@@ -643,9 +611,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
 
              /* Window end is invalid, if inside of the rows that
                 are invalidated below.  */
-             if (INTEGERP (WGET (w, window_end_vpos))
-                 && XFASTINT (WGET (w, window_end_vpos)) >= i)
-               WSET (w, window_end_valid, Qnil);
+             if (INTEGERP (w->window_end_vpos)
+                 && XFASTINT (w->window_end_vpos) >= i)
+               wset_window_end_valid (w, Qnil);
 
              while (i < matrix->nrows)
                matrix->rows[i++].enabled_p = 0;
@@ -760,30 +728,28 @@ increment_matrix_positions (struct glyph_matrix *matrix, int start, int end,
 }
 
 
-/* Enable a range of rows in glyph matrix MATRIX.  START and END are
-   the row indices of the first and last + 1 row to enable.  If
-   ENABLED_P is non-zero, enabled_p flags in rows will be set to 1.  */
+/* Clear the enable_p flags in a range of rows in glyph matrix MATRIX.
+   START and END are the row indices of the first and last + 1 row to clear.  */
 
 void
-enable_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end, int enabled_p)
+clear_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end)
 {
   eassert (start <= end);
   eassert (start >= 0 && start < matrix->nrows);
   eassert (end >= 0 && end <= matrix->nrows);
 
   for (; start < end; ++start)
-    matrix->rows[start].enabled_p = enabled_p != 0;
+    matrix->rows[start].enabled_p = 0;
 }
 
 
 /* Clear MATRIX.
 
-   This empties all rows in MATRIX by setting the enabled_p flag for
-   all rows of the matrix to zero.  The function prepare_desired_row
-   will eventually really clear a row when it sees one with a zero
-   enabled_p flag.
+   Empty all rows in MATRIX by clearing their enabled_p flags.
+   The function prepare_desired_row will eventually really clear a row
+   when it sees one with a false enabled_p flag.
 
-   Resets update hints to defaults value.  The only update hint
+   Reset update hints to default values.  The only update hint
    currently present is the flag MATRIX->no_scrolling_p.  */
 
 void
@@ -791,7 +757,7 @@ clear_glyph_matrix (struct glyph_matrix *matrix)
 {
   if (matrix)
     {
-      enable_glyph_matrix_rows (matrix, 0, matrix->nrows, 0);
+      clear_glyph_matrix_rows (matrix, 0, matrix->nrows);
       matrix->no_scrolling_p = 0;
     }
 }
@@ -844,12 +810,12 @@ clear_current_matrices (register struct frame *f)
   /* Clear the matrix of the menu bar window, if such a window exists.
      The menu bar window is currently used to display menus on X when
      no toolkit support is compiled in.  */
-  if (WINDOWP (FGET (f, menu_bar_window)))
-    clear_glyph_matrix (XWINDOW (FGET (f, menu_bar_window))->current_matrix);
+  if (WINDOWP (f->menu_bar_window))
+    clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
 
   /* Clear the matrix of the tool-bar window, if any.  */
-  if (WINDOWP (FGET (f, tool_bar_window)))
-    clear_glyph_matrix (XWINDOW (FGET (f, tool_bar_window))->current_matrix);
+  if (WINDOWP (f->tool_bar_window))
+    clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
 
   /* Clear current window matrices.  */
   eassert (WINDOWP (FRAME_ROOT_WINDOW (f)));
@@ -865,11 +831,11 @@ clear_desired_matrices (register struct frame *f)
   if (f->desired_matrix)
     clear_glyph_matrix (f->desired_matrix);
 
-  if (WINDOWP (FGET (f, menu_bar_window)))
-    clear_glyph_matrix (XWINDOW (FGET (f, menu_bar_window))->desired_matrix);
+  if (WINDOWP (f->menu_bar_window))
+    clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix);
 
-  if (WINDOWP (FGET (f, tool_bar_window)))
-    clear_glyph_matrix (XWINDOW (FGET (f, tool_bar_window))->desired_matrix);
+  if (WINDOWP (f->tool_bar_window))
+    clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix);
 
   /* Do it for window matrices.  */
   eassert (WINDOWP (FRAME_ROOT_WINDOW (f)));
@@ -877,23 +843,23 @@ clear_desired_matrices (register struct frame *f)
 }
 
 
-/* Clear matrices in window tree rooted in W.  If DESIRED_P is
-   non-zero clear desired matrices, otherwise clear current matrices.  */
+/* Clear matrices in window tree rooted in W.  If DESIRED_P,
+   clear desired matrices, otherwise clear current matrices.  */
 
 static void
-clear_window_matrices (struct window *w, int desired_p)
+clear_window_matrices (struct window *w, bool desired_p)
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
+      if (!NILP (w->hchild))
        {
-         eassert (WINDOWP (WGET (w, hchild)));
-         clear_window_matrices (XWINDOW (WGET (w, hchild)), desired_p);
+         eassert (WINDOWP (w->hchild));
+         clear_window_matrices (XWINDOW (w->hchild), desired_p);
        }
-      else if (!NILP (WGET (w, vchild)))
+      else if (!NILP (w->vchild))
        {
-         eassert (WINDOWP (WGET (w, vchild)));
-         clear_window_matrices (XWINDOW (WGET (w, vchild)), desired_p);
+         eassert (WINDOWP (w->vchild));
+         clear_window_matrices (XWINDOW (w->vchild), desired_p);
        }
       else
        {
@@ -902,11 +868,11 @@ clear_window_matrices (struct window *w, int desired_p)
          else
            {
              clear_glyph_matrix (w->current_matrix);
-             WSET (w, window_end_valid, Qnil);
+             wset_window_end_valid (w, Qnil);
            }
        }
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -970,7 +936,7 @@ blank_row (struct window *w, struct glyph_row *row, int y)
   clear_glyph_row (row);
   row->y = y;
   row->ascent = row->phys_ascent = 0;
-  row->height = row->phys_height = FRAME_LINE_HEIGHT (XFRAME (WGET (w, frame)));
+  row->height = row->phys_height = FRAME_LINE_HEIGHT (XFRAME (w->frame));
   row->visible_height = row->height;
 
   if (row->y < min_y)
@@ -1066,7 +1032,7 @@ swap_glyphs_in_rows (struct glyph_row *a, struct glyph_row *b)
    these should all go together for the row's hash value to be
    correct.  */
 
-static inline void
+static void
 swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b)
 {
   int i;
@@ -1095,7 +1061,7 @@ swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b)
    that glyph pointers, the `used' counts, and the hash values in the
    structures are left unchanged.  */
 
-static inline void
+static void
 copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
 {
   struct glyph *pointers[1 + LAST_AREA];
@@ -1122,7 +1088,7 @@ copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
    exchanged between TO and FROM.  Pointers must be exchanged to avoid
    a memory leak.  */
 
-static inline void
+static void
 assign_row (struct glyph_row *to, struct glyph_row *from)
 {
   swap_glyph_pointers (to, from);
@@ -1133,12 +1099,12 @@ assign_row (struct glyph_row *to, struct glyph_row *from)
 /* Test whether the glyph memory of the glyph row WINDOW_ROW, which is
    a row in a window matrix, is a slice of the glyph memory of the
    glyph row FRAME_ROW which is a row in a frame glyph matrix.  Value
-   is non-zero if the glyph memory of WINDOW_ROW is part of the glyph
+   is true if the glyph memory of WINDOW_ROW is part of the glyph
    memory of FRAME_ROW.  */
 
 #ifdef GLYPH_DEBUG
 
-static int
+static bool
 glyph_row_slice_p (struct glyph_row *window_row, struct glyph_row *frame_row)
 {
   struct glyph *window_glyph_start = window_row->glyphs[0];
@@ -1185,7 +1151,7 @@ prepare_desired_row (struct glyph_row *row)
 {
   if (!row->enabled_p)
     {
-      int rp = row->reversed_p;
+      bool rp = row->reversed_p;
 
       clear_glyph_row (row);
       row->enabled_p = 1;
@@ -1284,12 +1250,11 @@ line_draw_cost (struct glyph_matrix *matrix, int vpos)
 }
 
 
-/* Test two glyph rows A and B for equality.  Value is non-zero if A
-   and B have equal contents.  MOUSE_FACE_P non-zero means compare the
-   mouse_face_p flags of A and B, too.  */
+/* Return true if the glyph rows A and B have equal contents.
+   MOUSE_FACE_P means compare the mouse_face_p flags of A and B, too.  */
 
-static inline int
-row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p)
+static bool
+row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p)
 {
   eassert (verify_row_hash (a));
   eassert (verify_row_hash (b));
@@ -1404,14 +1369,14 @@ free_glyph_pool (struct glyph_pool *pool)
    is changed from a large value to a smaller one.  But, if someone
    does it once, we can expect that he will do it again.
 
-   Value is non-zero if the pool changed in a way which makes
+   Return true if the pool changed in a way which makes
    re-adjusting window glyph matrices necessary.  */
 
-static int
+static bool
 realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim)
 {
   ptrdiff_t needed;
-  int changed_p;
+  bool changed_p;
 
   changed_p = (pool->glyphs == 0
               || matrix_dim.height != pool->nrows
@@ -1516,7 +1481,7 @@ check_matrix_invariants (struct window *w)
   struct glyph_row *row = matrix->rows;
   struct glyph_row *last_text_row = NULL;
   struct buffer *saved = current_buffer;
-  struct buffer *buffer = XBUFFER (WGET (w, buffer));
+  struct buffer *buffer = XBUFFER (w->buffer);
   int c;
 
   /* This can sometimes happen for a fresh window.  */
@@ -1585,7 +1550,7 @@ check_matrix_invariants (struct window *w)
 
    X and Y are column/row within the frame glyph matrix where
    sub-matrices for the window tree rooted at WINDOW must be
-   allocated.  DIM_ONLY_P non-zero means that the caller of this
+   allocated.  DIM_ONLY_P means that the caller of this
    function is only interested in the result matrix dimension, and
    matrix adjustments should not be performed.
 
@@ -1662,7 +1627,7 @@ check_matrix_invariants (struct window *w)
 
 static struct dim
 allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
-                                      int dim_only_p, int *window_change_flags)
+                                      bool dim_only_p, int *window_change_flags)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
   int x0 = x, y0 = y;
@@ -1670,7 +1635,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
   struct dim total;
   struct dim dim;
   struct window *w;
-  int in_horz_combination_p;
+  bool in_horz_combination_p;
 
   /* What combination is WINDOW part of?  Compute this once since the
      result is the same for all windows in the `next' chain.  The
@@ -1679,8 +1644,8 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
      points to the mini-buffer window, if any, which is arranged
      vertically below other windows.  */
   in_horz_combination_p
-    = (!NILP (WGET (XWINDOW (window), parent))
-       && !NILP (WGET (XWINDOW (WGET (XWINDOW (window), parent)), hchild)));
+    = (!NILP (XWINDOW (window)->parent)
+       && !NILP (XWINDOW (XWINDOW (window)->parent)->hchild));
 
   /* For WINDOW and all windows on the same level.  */
   do
@@ -1689,12 +1654,12 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
 
       /* Get the dimension of the window sub-matrix for W, depending
         on whether this is a combination or a leaf window.  */
-      if (!NILP (WGET (w, hchild)))
-       dim = allocate_matrices_for_frame_redisplay (WGET (w, hchild), x, y,
+      if (!NILP (w->hchild))
+       dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y,
                                                     dim_only_p,
                                                     window_change_flags);
-      else if (!NILP (WGET (w, vchild)))
-       dim = allocate_matrices_for_frame_redisplay (WGET (w, vchild), x, y,
+      else if (!NILP (w->vchild))
+       dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y,
                                                     dim_only_p,
                                                     window_change_flags);
       else
@@ -1718,17 +1683,17 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
              || dim.width != w->desired_matrix->matrix_w
              || dim.height != w->desired_matrix->matrix_h
              || (margin_glyphs_to_reserve (w, dim.width,
-                                           WGET (w, left_margin_cols))
+                                           w->left_margin_cols)
                  != w->desired_matrix->left_margin_glyphs)
              || (margin_glyphs_to_reserve (w, dim.width,
-                                           WGET (w, right_margin_cols))
+                                           w->right_margin_cols)
                  != w->desired_matrix->right_margin_glyphs))
            *window_change_flags |= CHANGED_LEAF_MATRIX;
 
          /* Actually change matrices, if allowed.  Do not consider
             CHANGED_LEAF_MATRIX computed above here because the pool
             may have been changed which we don't now here.  We trust
-            that we only will be called with DIM_ONLY_P != 0 when
+            that we only will be called with DIM_ONLY_P when
             necessary.  */
          if (!dim_only_p)
            {
@@ -1750,7 +1715,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
       hmax = max (hmax, dim.height);
 
       /* Next window on same level.  */
-      window = WGET (w, next);
+      window = w->next;
     }
   while (!NILP (window));
 
@@ -1781,7 +1746,7 @@ static int
 required_matrix_height (struct window *w)
 {
 #ifdef HAVE_WINDOW_SYSTEM
-  struct frame *f = XFRAME (WGET (w, frame));
+  struct frame *f = XFRAME (w->frame);
 
   if (FRAME_WINDOW_P (f))
     {
@@ -1807,7 +1772,7 @@ static int
 required_matrix_width (struct window *w)
 {
 #ifdef HAVE_WINDOW_SYSTEM
-  struct frame *f = XFRAME (WGET (w, frame));
+  struct frame *f = XFRAME (w->frame);
   if (FRAME_WINDOW_P (f))
     {
       int ch_width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -1824,7 +1789,7 @@ required_matrix_width (struct window *w)
     }
 #endif /* HAVE_WINDOW_SYSTEM */
 
-  return XINT (WGET (w, total_cols));
+  return XINT (w->total_cols);
 }
 
 
@@ -1836,10 +1801,10 @@ allocate_matrices_for_window_redisplay (struct window *w)
 {
   while (w)
     {
-      if (!NILP (WGET (w, vchild)))
-       allocate_matrices_for_window_redisplay (XWINDOW (WGET (w, vchild)));
-      else if (!NILP (WGET (w, hchild)))
-       allocate_matrices_for_window_redisplay (XWINDOW (WGET (w, hchild)));
+      if (!NILP (w->vchild))
+       allocate_matrices_for_window_redisplay (XWINDOW (w->vchild));
+      else if (!NILP (w->hchild))
+       allocate_matrices_for_window_redisplay (XWINDOW (w->hchild));
       else
        {
          /* W is a leaf window.  */
@@ -1858,7 +1823,7 @@ allocate_matrices_for_window_redisplay (struct window *w)
          adjust_glyph_matrix (w, w->current_matrix, 0, 0, dim);
        }
 
-      w = NILP (WGET (w, next)) ? NULL : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? NULL : XWINDOW (w->next);
     }
 }
 
@@ -1873,7 +1838,7 @@ adjust_glyphs (struct frame *f)
 {
   /* Block input so that expose events and other events that access
      glyph matrices are not processed while we are changing them.  */
-  BLOCK_INPUT;
+  block_input ();
 
   if (f)
     adjust_frame_glyphs (f);
@@ -1885,7 +1850,7 @@ adjust_glyphs (struct frame *f)
        adjust_frame_glyphs (XFRAME (lisp_frame));
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 }
 
 
@@ -1904,21 +1869,21 @@ static void
 adjust_frame_glyphs_initially (void)
 {
   struct frame *sf = SELECTED_FRAME ();
-  struct window *root = XWINDOW (FGET (sf, root_window));
-  struct window *mini = XWINDOW (WGET (root, next));
+  struct window *root = XWINDOW (sf->root_window);
+  struct window *mini = XWINDOW (root->next);
   int frame_lines = FRAME_LINES (sf);
   int frame_cols = FRAME_COLS (sf);
   int top_margin = FRAME_TOP_MARGIN (sf);
 
   /* Do it for the root window.  */
-  WSET (root, top_line, make_number (top_margin));
-  WSET (root, total_lines, make_number (frame_lines - 1 - top_margin));
-  WSET (root, total_cols, make_number (frame_cols));
+  wset_top_line (root, make_number (top_margin));
+  wset_total_lines (root, make_number (frame_lines - 1 - top_margin));
+  wset_total_cols (root, make_number (frame_cols));
 
   /* Do it for the mini-buffer window.  */
-  WSET (mini, top_line, make_number (frame_lines - 1));
-  WSET (mini, total_lines, make_number (1));
-  WSET (mini, total_cols, make_number (frame_cols));
+  wset_top_line (mini, make_number (frame_lines - 1));
+  wset_total_lines (mini, make_number (1));
+  wset_total_cols (mini, make_number (frame_cols));
 
   adjust_frame_glyphs (sf);
   glyphs_initialized_initially_p = 1;
@@ -1943,28 +1908,28 @@ adjust_frame_glyphs (struct frame *f)
   f->glyphs_initialized_p = 1;
 }
 
-/* Return 1 if any window in the tree has nonzero window margins.  See
+/* Return true if any window in the tree has nonzero window margins.  See
    the hack at the end of adjust_frame_glyphs_for_frame_redisplay.  */
-static int
+static bool
 showing_window_margins_p (struct window *w)
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
+      if (!NILP (w->hchild))
        {
-         if (showing_window_margins_p (XWINDOW (WGET (w, hchild))))
+         if (showing_window_margins_p (XWINDOW (w->hchild)))
            return 1;
        }
-      else if (!NILP (WGET (w, vchild)))
+      else if (!NILP (w->vchild))
        {
-         if (showing_window_margins_p (XWINDOW (WGET (w, vchild))))
+         if (showing_window_margins_p (XWINDOW (w->vchild)))
            return 1;
        }
-      else if (!NILP (WGET (w, left_margin_cols))
-              || !NILP (WGET (w, right_margin_cols)))
+      else if (!NILP (w->left_margin_cols)
+              || !NILP (w->right_margin_cols))
        return 1;
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
   return 0;
 }
@@ -1978,18 +1943,18 @@ fake_current_matrices (Lisp_Object window)
 {
   struct window *w;
 
-  for (; !NILP (window); window = WGET (w, next))
+  for (; !NILP (window); window = w->next)
     {
       w = XWINDOW (window);
 
-      if (!NILP (WGET (w, hchild)))
-       fake_current_matrices (WGET (w, hchild));
-      else if (!NILP (WGET (w, vchild)))
-       fake_current_matrices (WGET (w, vchild));
+      if (!NILP (w->hchild))
+       fake_current_matrices (w->hchild);
+      else if (!NILP (w->vchild))
+       fake_current_matrices (w->vchild);
       else
        {
          int i;
-         struct frame *f = XFRAME (WGET (w, frame));
+         struct frame *f = XFRAME (w->frame);
          struct glyph_matrix *m = w->current_matrix;
          struct glyph_matrix *fm = f->current_matrix;
 
@@ -2076,7 +2041,7 @@ static void
 adjust_frame_glyphs_for_frame_redisplay (struct frame *f)
 {
   struct dim matrix_dim;
-  int pool_changed_p;
+  bool pool_changed_p;
   int window_change_flags;
   int top_window_y;
 
@@ -2187,24 +2152,24 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
   {
     /* Allocate a dummy window if not already done.  */
     struct window *w;
-    if (NILP (FGET (f, menu_bar_window)))
+    if (NILP (f->menu_bar_window))
       {
        Lisp_Object frame;
-       FSET (f, menu_bar_window, make_window ());
-       w = XWINDOW (FGET (f, menu_bar_window));
+       fset_menu_bar_window (f, make_window ());
+       w = XWINDOW (f->menu_bar_window);
        XSETFRAME (frame, f);
-       WSET (w, frame, frame);
+       wset_frame (w, frame);
        w->pseudo_window_p = 1;
       }
     else
-      w = XWINDOW (FGET (f, menu_bar_window));
+      w = XWINDOW (f->menu_bar_window);
 
     /* Set window dimensions to frame dimensions and allocate or
        adjust glyph matrices of W.  */
-    WSET (w, top_line, make_number (0));
-    WSET (w, left_col, make_number (0));
-    WSET (w, total_lines, make_number (FRAME_MENU_BAR_LINES (f)));
-    WSET (w, total_cols, make_number (FRAME_TOTAL_COLS (f)));
+    wset_top_line (w, make_number (0));
+    wset_left_col (w, make_number (0));
+    wset_total_lines (w, make_number (FRAME_MENU_BAR_LINES (f)));
+    wset_total_cols (w, make_number (FRAME_TOTAL_COLS (f)));
     allocate_matrices_for_window_redisplay (w);
   }
 #endif /* not USE_X_TOOLKIT && not USE_GTK */
@@ -2215,22 +2180,22 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
     /* Allocate/ reallocate matrices of the tool bar window.  If we
        don't have a tool bar window yet, make one.  */
     struct window *w;
-    if (NILP (FGET (f, tool_bar_window)))
+    if (NILP (f->tool_bar_window))
       {
        Lisp_Object frame;
-       FSET (f, tool_bar_window, make_window ());
-       w = XWINDOW (FGET (f, tool_bar_window));
+       fset_tool_bar_window (f, make_window ());
+       w = XWINDOW (f->tool_bar_window);
        XSETFRAME (frame, f);
-       WSET (w, frame, frame);
+       wset_frame (w, frame);
        w->pseudo_window_p = 1;
       }
     else
-      w = XWINDOW (FGET (f, tool_bar_window));
+      w = XWINDOW (f->tool_bar_window);
 
-    WSET (w, top_line, make_number (FRAME_MENU_BAR_LINES (f)));
-    WSET (w, left_col, make_number (0));
-    WSET (w, total_lines, make_number (FRAME_TOOL_BAR_LINES (f)));
-    WSET (w, total_cols, make_number (FRAME_TOTAL_COLS (f)));
+    wset_top_line (w, make_number (FRAME_MENU_BAR_LINES (f)));
+    wset_left_col (w, make_number (0));
+    wset_total_lines (w, make_number (FRAME_TOOL_BAR_LINES (f)));
+    wset_total_cols (w, make_number (FRAME_TOTAL_COLS (f)));
     allocate_matrices_for_window_redisplay (w);
   }
 #endif
@@ -2281,32 +2246,32 @@ free_glyphs (struct frame *f)
     {
       /* Block interrupt input so that we don't get surprised by an X
          event while we're in an inconsistent state.  */
-      BLOCK_INPUT;
+      block_input ();
       f->glyphs_initialized_p = 0;
 
       /* Release window sub-matrices.  */
-      if (!NILP (FGET (f, root_window)))
-        free_window_matrices (XWINDOW (FGET (f, root_window)));
+      if (!NILP (f->root_window))
+        free_window_matrices (XWINDOW (f->root_window));
 
       /* Free the dummy window for menu bars without X toolkit and its
         glyph matrices.  */
-      if (!NILP (FGET (f, menu_bar_window)))
+      if (!NILP (f->menu_bar_window))
        {
-         struct window *w = XWINDOW (FGET (f, menu_bar_window));
+         struct window *w = XWINDOW (f->menu_bar_window);
          free_glyph_matrix (w->desired_matrix);
          free_glyph_matrix (w->current_matrix);
          w->desired_matrix = w->current_matrix = NULL;
-         FSET (f, menu_bar_window, Qnil);
+         fset_menu_bar_window (f, Qnil);
        }
 
       /* Free the tool bar window and its glyph matrices.  */
-      if (!NILP (FGET (f, tool_bar_window)))
+      if (!NILP (f->tool_bar_window))
        {
-         struct window *w = XWINDOW (FGET (f, tool_bar_window));
+         struct window *w = XWINDOW (f->tool_bar_window);
          free_glyph_matrix (w->desired_matrix);
          free_glyph_matrix (w->current_matrix);
          w->desired_matrix = w->current_matrix = NULL;
-         FSET (f, tool_bar_window, Qnil);
+         fset_tool_bar_window (f, Qnil);
        }
 
       /* Release frame glyph matrices.  Reset fields to zero in
@@ -2326,7 +2291,7 @@ free_glyphs (struct frame *f)
          f->desired_pool = f->current_pool = NULL;
        }
 
-      UNBLOCK_INPUT;
+      unblock_input ();
     }
 }
 
@@ -2340,10 +2305,10 @@ free_window_matrices (struct window *w)
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
-       free_window_matrices (XWINDOW (WGET (w, hchild)));
-      else if (!NILP (WGET (w, vchild)))
-       free_window_matrices (XWINDOW (WGET (w, vchild)));
+      if (!NILP (w->hchild))
+       free_window_matrices (XWINDOW (w->hchild));
+      else if (!NILP (w->vchild))
+       free_window_matrices (XWINDOW (w->vchild));
       else
        {
          /* This is a leaf window.  Free its memory and reset fields
@@ -2355,7 +2320,7 @@ free_window_matrices (struct window *w)
        }
 
       /* Next window on same level.  */
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -2376,9 +2341,9 @@ check_glyph_memory (void)
 
   /* Check that nothing is left allocated.  */
   if (glyph_matrix_count)
-    abort ();
+    emacs_abort ();
   if (glyph_pool_count)
-    abort ();
+    emacs_abort ();
 }
 
 
@@ -2476,14 +2441,14 @@ build_frame_matrix_from_window_tree (struct glyph_matrix *matrix, struct window
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
-       build_frame_matrix_from_window_tree (matrix, XWINDOW (WGET (w, hchild)));
-      else if (!NILP (WGET (w, vchild)))
-       build_frame_matrix_from_window_tree (matrix, XWINDOW (WGET (w, vchild)));
+      if (!NILP (w->hchild))
+       build_frame_matrix_from_window_tree (matrix, XWINDOW (w->hchild));
+      else if (!NILP (w->vchild))
+       build_frame_matrix_from_window_tree (matrix, XWINDOW (w->vchild));
       else
        build_frame_matrix_from_leaf_window (matrix, w);
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -2492,7 +2457,7 @@ build_frame_matrix_from_window_tree (struct glyph_matrix *matrix, struct window
    desired frame matrix built.  W is a leaf window whose desired or
    current matrix is to be added to FRAME_MATRIX.  W's flag
    must_be_updated_p determines which matrix it contributes to
-   FRAME_MATRIX.  If must_be_updated_p is non-zero, W's desired matrix
+   FRAME_MATRIX.  If W->must_be_updated_p, W's desired matrix
    is added to FRAME_MATRIX, otherwise W's current matrix is added.
    Adding a desired matrix means setting up used counters and such in
    frame rows, while adding a current window matrix to FRAME_MATRIX
@@ -2543,7 +2508,7 @@ build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct w
     {
       struct glyph_row *frame_row = frame_matrix->rows + frame_y;
       struct glyph_row *window_row = window_matrix->rows + window_y;
-      int current_row_p = window_matrix == w->current_matrix;
+      bool current_row_p = window_matrix == w->current_matrix;
 
       /* Fill up the frame row with spaces up to the left margin of the
         window row.  */
@@ -2622,7 +2587,7 @@ spec_glyph_lookup_face (struct window *w, GLYPH *glyph)
   /* Convert the glyph's specified face to a realized (cache) face.  */
   if (lface_id > 0)
     {
-      int face_id = merge_faces (XFRAME (WGET (w, frame)),
+      int face_id = merge_faces (XFRAME (w->frame),
                                 Qt, lface_id, DEFAULT_FACE_ID);
       SET_GLYPH_FACE (*glyph, face_id);
     }
@@ -2696,7 +2661,7 @@ fill_up_frame_row_with_spaces (struct glyph_row *row, int upto)
    function must be called before updates to make explicit that we are
    working on frame matrices or not.  */
 
-static inline void
+static void
 set_frame_matrix_frame (struct frame *f)
 {
   frame_matrix_frame = f;
@@ -2711,12 +2676,12 @@ set_frame_matrix_frame (struct frame *f)
    done in frame matrices, and that we have to perform analogous
    operations in window matrices of frame_matrix_frame.  */
 
-static inline void
+static void
 make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_matrix, int row)
 {
   struct glyph_row *current_row = MATRIX_ROW (current_matrix, row);
   struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row);
-  int mouse_face_p = current_row->mouse_face_p;
+  bool mouse_face_p = current_row->mouse_face_p;
 
   /* Do current_row = desired_row.  This exchanges glyph pointers
      between both rows, and does a structure assignment otherwise.  */
@@ -2729,7 +2694,7 @@ make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_
   /* If we are called on frame matrices, perform analogous operations
      for window matrices.  */
   if (frame_matrix_frame)
-    mirror_make_current (XWINDOW (FGET (frame_matrix_frame, root_window)), row);
+    mirror_make_current (XWINDOW (frame_matrix_frame->root_window), row);
 }
 
 
@@ -2743,10 +2708,10 @@ mirror_make_current (struct window *w, int frame_row)
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
-       mirror_make_current (XWINDOW (WGET (w, hchild)), frame_row);
-      else if (!NILP (WGET (w, vchild)))
-       mirror_make_current (XWINDOW (WGET (w, vchild)), frame_row);
+      if (!NILP (w->hchild))
+       mirror_make_current (XWINDOW (w->hchild), frame_row);
+      else if (!NILP (w->vchild))
+       mirror_make_current (XWINDOW (w->vchild), frame_row);
       else
        {
          /* Row relative to window W.  Don't use FRAME_TO_WINDOW_VPOS
@@ -2779,7 +2744,7 @@ mirror_make_current (struct window *w, int frame_row)
            }
        }
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -2813,7 +2778,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
   /* Assign new rows, maybe clear lines.  */
   for (i = 0; i < nlines; ++i)
     {
-      int enabled_before_p = new_rows[i].enabled_p;
+      bool enabled_before_p = new_rows[i].enabled_p;
 
       eassert (i + unchanged_at_top < matrix->nrows);
       eassert (unchanged_at_top + copy_from[i] < matrix->nrows);
@@ -2827,7 +2792,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
 
   /* Do the same for window matrices, if MATRIX is a frame matrix.  */
   if (frame_matrix_frame)
-    mirror_line_dance (XWINDOW (FGET (frame_matrix_frame, root_window)),
+    mirror_line_dance (XWINDOW (frame_matrix_frame->root_window),
                       unchanged_at_top, nlines, copy_from, retained_p);
 }
 
@@ -2838,16 +2803,16 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
 static void
 sync_window_with_frame_matrix_rows (struct window *w)
 {
-  struct frame *f = XFRAME (WGET (w, frame));
+  struct frame *f = XFRAME (w->frame);
   struct glyph_row *window_row, *window_row_end, *frame_row;
   int left, right, x, width;
 
   /* Preconditions: W must be a leaf window on a tty frame.  */
-  eassert (NILP (WGET (w, hchild)) && NILP (WGET (w, vchild)));
+  eassert (NILP (w->hchild) && NILP (w->vchild));
   eassert (!FRAME_WINDOW_P (f));
 
-  left = margin_glyphs_to_reserve (w, 1, WGET (w, left_margin_cols));
-  right = margin_glyphs_to_reserve (w, 1, WGET (w, right_margin_cols));
+  left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols);
+  right = margin_glyphs_to_reserve (w, 1, w->right_margin_cols);
   x = w->current_matrix->matrix_x;
   width = w->current_matrix->matrix_w;
 
@@ -2879,15 +2844,15 @@ frame_row_to_window (struct window *w, int row)
 
   while (w && !found)
     {
-      if (!NILP (WGET (w, hchild)))
-       found = frame_row_to_window (XWINDOW (WGET (w, hchild)), row);
-      else if (!NILP (WGET (w, vchild)))
-       found = frame_row_to_window (XWINDOW (WGET (w, vchild)), row);
+      if (!NILP (w->hchild))
+       found = frame_row_to_window (XWINDOW (w->hchild), row);
+      else if (!NILP (w->vchild))
+       found = frame_row_to_window (XWINDOW (w->vchild), row);
       else if (row >= WINDOW_TOP_EDGE_LINE (w)
               && row < WINDOW_BOTTOM_EDGE_LINE (w))
        found = w;
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 
   return found;
@@ -2910,18 +2875,19 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
-       mirror_line_dance (XWINDOW (WGET (w, hchild)), unchanged_at_top,
+      if (!NILP (w->hchild))
+       mirror_line_dance (XWINDOW (w->hchild), unchanged_at_top,
                           nlines, copy_from, retained_p);
-      else if (!NILP (WGET (w, vchild)))
-       mirror_line_dance (XWINDOW (WGET (w, vchild)), unchanged_at_top,
+      else if (!NILP (w->vchild))
+       mirror_line_dance (XWINDOW (w->vchild), unchanged_at_top,
                           nlines, copy_from, retained_p);
       else
        {
          /* W is a leaf window, and we are working on its current
             matrix m.  */
          struct glyph_matrix *m = w->current_matrix;
-         int i, sync_p = 0;
+         int i;
+         bool sync_p = 0;
          struct glyph_row *old_rows;
 
          /* Make a copy of the original rows of matrix m.  */
@@ -2943,22 +2909,19 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
              int window_from = frame_from - m->matrix_y;
 
              /* Is assigned line inside window?  */
-             int from_inside_window_p
+             bool from_inside_window_p
                = window_from >= 0 && window_from < m->matrix_h;
 
              /* Is assigned to line inside window?  */
-             int to_inside_window_p
+             bool to_inside_window_p
                = window_to >= 0 && window_to < m->matrix_h;
 
              if (from_inside_window_p && to_inside_window_p)
                {
-                 /* Enabled setting before assignment.  */
-                 int enabled_before_p;
-
                  /* Do the assignment.  The enabled_p flag is saved
                     over the assignment because the old redisplay did
                     that.  */
-                 enabled_before_p = m->rows[window_to].enabled_p;
+                 bool enabled_before_p = m->rows[window_to].enabled_p;
                  m->rows[window_to] = old_rows[window_from];
                  m->rows[window_to].enabled_p = enabled_before_p;
 
@@ -2970,7 +2933,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
                {
                  /* A copy between windows.  This is an infrequent
                     case not worth optimizing.  */
-                 struct frame *f = XFRAME (WGET (w, frame));
+                 struct frame *f = XFRAME (w->frame);
                  struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
                  struct window *w2;
                  struct glyph_matrix *m2;
@@ -3007,7 +2970,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
        }
 
       /* Next window on same level.  */
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -3025,18 +2988,18 @@ check_window_matrix_pointers (struct window *w)
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
-       check_window_matrix_pointers (XWINDOW (WGET (w, hchild)));
-      else if (!NILP (WGET (w, vchild)))
-       check_window_matrix_pointers (XWINDOW (WGET (w, vchild)));
+      if (!NILP (w->hchild))
+       check_window_matrix_pointers (XWINDOW (w->hchild));
+      else if (!NILP (w->vchild))
+       check_window_matrix_pointers (XWINDOW (w->vchild));
       else
        {
-         struct frame *f = XFRAME (WGET (w, frame));
+         struct frame *f = XFRAME (w->frame);
          check_matrix_pointers (w->desired_matrix, f->desired_matrix);
          check_matrix_pointers (w->current_matrix, f->current_matrix);
        }
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -3063,7 +3026,7 @@ check_matrix_pointers (struct glyph_matrix *window_matrix,
     {
       if (!glyph_row_slice_p (window_matrix->rows + i,
                              frame_matrix->rows + j))
-        abort ();
+        emacs_abort ();
       ++i, ++j;
     }
 }
@@ -3084,10 +3047,10 @@ check_matrix_pointers (struct glyph_matrix *window_matrix,
 static int
 window_to_frame_vpos (struct window *w, int vpos)
 {
-  eassert (!FRAME_WINDOW_P (XFRAME (WGET (w, frame))));
+  eassert (!FRAME_WINDOW_P (XFRAME (w->frame)));
   eassert (vpos >= 0 && vpos <= w->desired_matrix->nrows);
   vpos += WINDOW_TOP_EDGE_LINE (w);
-  eassert (vpos >= 0 && vpos <= FRAME_LINES (XFRAME (WGET (w, frame))));
+  eassert (vpos >= 0 && vpos <= FRAME_LINES (XFRAME (w->frame)));
   return vpos;
 }
 
@@ -3098,7 +3061,7 @@ window_to_frame_vpos (struct window *w, int vpos)
 static int
 window_to_frame_hpos (struct window *w, int hpos)
 {
-  eassert (!FRAME_WINDOW_P (XFRAME (WGET (w, frame))));
+  eassert (!FRAME_WINDOW_P (XFRAME (w->frame)));
   hpos += WINDOW_LEFT_EDGE_COL (w);
   return hpos;
 }
@@ -3179,18 +3142,17 @@ DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
 
 /* Update frame F based on the data in desired matrices.
 
-   If FORCE_P is non-zero, don't let redisplay be stopped by detecting
-   pending input.  If INHIBIT_HAIRY_ID_P is non-zero, don't try
-   scrolling.
+   If FORCE_P, don't let redisplay be stopped by detecting pending input.
+   If INHIBIT_HAIRY_ID_P, don't try scrolling.
 
-   Value is non-zero if redisplay was stopped due to pending input.  */
+   Value is true if redisplay was stopped due to pending input.  */
 
-int
-update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p)
+bool
+update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
 {
-  /* 1 means display has been paused because of pending input.  */
-  int paused_p;
-  struct window *root_window = XWINDOW (FGET (f, root_window));
+  /* True means display has been paused because of pending input.  */
+  bool paused_p;
+  struct window *root_window = XWINDOW (f->root_window);
 
   if (redisplay_dont_pause)
     force_p = 1;
@@ -3225,13 +3187,13 @@ update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p)
 
       /* Update the menu bar on X frames that don't have toolkit
         support.  */
-      if (WINDOWP (FGET (f, menu_bar_window)))
-       update_window (XWINDOW (FGET (f, menu_bar_window)), 1);
+      if (WINDOWP (f->menu_bar_window))
+       update_window (XWINDOW (f->menu_bar_window), 1);
 
       /* Update the tool-bar window, if present.  */
-      if (WINDOWP (FGET (f, tool_bar_window)))
+      if (WINDOWP (f->tool_bar_window))
        {
-         struct window *w = XWINDOW (FGET (f, tool_bar_window));
+         struct window *w = XWINDOW (f->tool_bar_window);
 
          /* Update tool-bar window.  */
          if (w->must_be_updated_p)
@@ -3243,10 +3205,9 @@ update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p)
 
              /* Swap tool-bar strings.  We swap because we want to
                 reuse strings.  */
-             tem = FGET (f, current_tool_bar_string);
-             FSET (f, current_tool_bar_string,
-                   FGET (f, desired_tool_bar_string));
-             FSET (f, desired_tool_bar_string, tem);
+             tem = f->current_tool_bar_string;
+             fset_current_tool_bar_string (f, f->desired_tool_bar_string);
+             fset_desired_tool_bar_string (f, tem);
            }
        }
 
@@ -3308,35 +3269,35 @@ update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p)
                         Window-based updates
  ************************************************************************/
 
-/* Perform updates in window tree rooted at W.  FORCE_P non-zero means
-   don't stop updating when input is pending.  */
+/* Perform updates in window tree rooted at W.
+   If FORCE_P, don't stop updating if input is pending.  */
 
-static int
-update_window_tree (struct window *w, int force_p)
+static bool
+update_window_tree (struct window *w, bool force_p)
 {
-  int paused_p = 0;
+  bool paused_p = 0;
 
   while (w && !paused_p)
     {
-      if (!NILP (WGET (w, hchild)))
-       paused_p |= update_window_tree (XWINDOW (WGET (w, hchild)), force_p);
-      else if (!NILP (WGET (w, vchild)))
-       paused_p |= update_window_tree (XWINDOW (WGET (w, vchild)), force_p);
+      if (!NILP (w->hchild))
+       paused_p |= update_window_tree (XWINDOW (w->hchild), force_p);
+      else if (!NILP (w->vchild))
+       paused_p |= update_window_tree (XWINDOW (w->vchild), force_p);
       else if (w->must_be_updated_p)
        paused_p |= update_window (w, force_p);
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 
   return paused_p;
 }
 
 
-/* Update window W if its flag must_be_updated_p is non-zero.  If
-   FORCE_P is non-zero, don't stop updating if input is pending.  */
+/* Update window W if its flag must_be_updated_p is set.
+   If FORCE_P, don't stop updating if input is pending.  */
 
 void
-update_single_window (struct window *w, int force_p)
+update_single_window (struct window *w, bool force_p)
 {
   if (w->must_be_updated_p)
     {
@@ -3485,7 +3446,7 @@ redraw_overlapping_rows (struct window *w, int yb)
 static void
 check_current_matrix_flags (struct window *w)
 {
-  int last_seen_p = 0;
+  bool last_seen_p = 0;
   int i, yb = window_text_bottom_y (w);
 
   for (i = 0; i < w->current_matrix->nrows - 1; ++i)
@@ -3494,21 +3455,21 @@ check_current_matrix_flags (struct window *w)
       if (!last_seen_p && MATRIX_ROW_BOTTOM_Y (row) >= yb)
        last_seen_p = 1;
       else if (last_seen_p && row->enabled_p)
-       abort ();
+       emacs_abort ();
     }
 }
 
 #endif /* GLYPH_DEBUG */
 
 
-/* Update display of window W.  FORCE_P non-zero means that we should
-   not stop when detecting pending input.  */
+/* Update display of window W.
+   If FORCE_P, don't stop updating when input is pending.  */
 
-static int
-update_window (struct window *w, int force_p)
+static bool
+update_window (struct window *w, bool force_p)
 {
   struct glyph_matrix *desired_matrix = w->desired_matrix;
-  int paused_p;
+  bool paused_p;
 #if !PERIODIC_PREEMPTION_CHECKING
   int preempt_count = baud_rate / 2400 + 1;
 #endif
@@ -3531,7 +3492,8 @@ update_window (struct window *w, int force_p)
       struct glyph_row *row, *end;
       struct glyph_row *mode_line_row;
       struct glyph_row *header_line_row;
-      int yb, changed_p = 0, mouse_face_overwritten_p = 0;
+      int yb;
+      bool changed_p = 0, mouse_face_overwritten_p = 0;
 #if ! PERIODIC_PREEMPTION_CHECKING
       int n_updated = 0;
 #endif
@@ -3718,15 +3680,15 @@ update_marginal_area (struct window *w, int area, int vpos)
 
 
 /* Update the display of the text area of row VPOS in window W.
-   Value is non-zero if display has changed.  */
+   Value is true if display has changed.  */
 
-static int
+static bool
 update_text_area (struct window *w, int vpos)
 {
   struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
   struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
   struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
-  int changed_p = 0;
+  bool changed_p = 0;
 
   /* Let functions in xterm.c know what area subsequent X positions
      will be relative to.  */
@@ -3776,9 +3738,9 @@ update_text_area (struct window *w, int vpos)
       int stop, i, x;
       struct glyph *current_glyph = current_row->glyphs[TEXT_AREA];
       struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA];
-      int overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p;
+      bool overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p;
       int desired_stop_pos = desired_row->used[TEXT_AREA];
-      int abort_skipping = 0;
+      bool abort_skipping = 0;
 
       /* If the desired row extends its face to the text area end, and
         unless the current row also does so at the same position,
@@ -3798,7 +3760,7 @@ update_text_area (struct window *w, int vpos)
         in common.  */
       while (i < stop)
        {
-         int can_skip_p = !abort_skipping;
+         bool can_skip_p = !abort_skipping;
 
          /* Skip over glyphs that both rows have in common.  These
             don't have to be written.  We can't skip if the last
@@ -3813,7 +3775,7 @@ update_text_area (struct window *w, int vpos)
              struct glyph *glyph = &current_row->glyphs[TEXT_AREA][i - 1];
              int left, right;
 
-             rif->get_glyph_overhangs (glyph, XFRAME (WGET (w, frame)),
+             rif->get_glyph_overhangs (glyph, XFRAME (w->frame),
                                        &left, &right);
              can_skip_p = (right == 0 && !abort_skipping);
            }
@@ -3846,7 +3808,7 @@ update_text_area (struct window *w, int vpos)
                  int left, right;
 
                  rif->get_glyph_overhangs (current_glyph,
-                                           XFRAME (WGET (w, frame)),
+                                           XFRAME (w->frame),
                                            &left, &right);
                  while (left > 0 && i > 0)
                    {
@@ -3872,7 +3834,7 @@ update_text_area (struct window *w, int vpos)
              int start_x = x, start_hpos = i;
              struct glyph *start = desired_glyph;
              int current_x = x;
-             int skip_first_p = !can_skip_p;
+             bool skip_first_p = !can_skip_p;
 
              /* Find the next glyph that's equal again.  */
              while (i < stop
@@ -3963,16 +3925,15 @@ update_text_area (struct window *w, int vpos)
 }
 
 
-/* Update row VPOS in window W.  Value is non-zero if display has been
-   changed.  */
+/* Update row VPOS in window W.  Value is true if display has been changed.  */
 
-static int
-update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p)
+static bool
+update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
 {
   struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
   struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
   struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
-  int changed_p = 0;
+  bool changed_p = 0;
 
   /* Set the row being updated.  This is important to let xterm.c
      know what line height values are in effect.  */
@@ -3989,10 +3950,15 @@ update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p)
 
       /* Update display of the left margin area, if there is one.  */
       if (!desired_row->full_width_p
-         && !NILP (WGET (w, left_margin_cols)))
+         && !NILP (w->left_margin_cols))
        {
          changed_p = 1;
          update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
+         /* Setting this flag will ensure the vertical border, if
+            any, between this window and the one on its left will be
+            redrawn.  This is necessary because updating the left
+            margin area can potentially draw over the border.  */
+         current_row->redraw_fringe_bitmaps_p = 1;
        }
 
       /* Update the display of the text area.  */
@@ -4005,7 +3971,7 @@ update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p)
 
       /* Update display of the right margin area, if there is one.  */
       if (!desired_row->full_width_p
-         && !NILP (WGET (w, right_margin_cols)))
+         && !NILP (w->right_margin_cols))
        {
          changed_p = 1;
          update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
@@ -4038,7 +4004,7 @@ update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p)
 static void
 set_window_cursor_after_update (struct window *w)
 {
-  struct frame *f = XFRAME (WGET (w, frame));
+  struct frame *f = XFRAME (w->frame);
   struct redisplay_interface *rif = FRAME_RIF (f);
   int cx, cy, vpos, hpos;
 
@@ -4120,18 +4086,18 @@ set_window_cursor_after_update (struct window *w)
    tree rooted at W.  */
 
 void
-set_window_update_flags (struct window *w, int on_p)
+set_window_update_flags (struct window *w, bool on_p)
 {
   while (w)
     {
-      if (!NILP (WGET (w, hchild)))
-       set_window_update_flags (XWINDOW (WGET (w, hchild)), on_p);
-      else if (!NILP (WGET (w, vchild)))
-       set_window_update_flags (XWINDOW (WGET (w, vchild)), on_p);
+      if (!NILP (w->hchild))
+       set_window_update_flags (XWINDOW (w->hchild), on_p);
+      else if (!NILP (w->vchild))
+       set_window_update_flags (XWINDOW (w->vchild), on_p);
       else
        w->must_be_updated_p = on_p;
 
-      w = NILP (WGET (w, next)) ? 0 : XWINDOW (WGET (w, next));
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 }
 
@@ -4196,7 +4162,7 @@ static struct run **runs;
 
 /* Add glyph row ROW to the scrolling hash table.  */
 
-static inline struct row_entry *
+static struct row_entry *
 add_row_entry (struct glyph_row *row)
 {
   struct row_entry *entry;
@@ -4223,7 +4189,7 @@ add_row_entry (struct glyph_row *row)
 
 
 /* Try to reuse part of the current display of W by scrolling lines.
-   HEADER_LINE_P non-zero means W has a header line.
+   HEADER_LINE_P means W has a header line.
 
    The algorithm is taken from Communications of the ACM, Apr78 "A
    Technique for Isolating Differences Between Files."  It should take
@@ -4249,7 +4215,7 @@ add_row_entry (struct glyph_row *row)
    1   if we did scroll.  */
 
 static int
-scrolling_window (struct window *w, int header_line_p)
+scrolling_window (struct window *w, bool header_line_p)
 {
   struct glyph_matrix *desired_matrix = w->desired_matrix;
   struct glyph_matrix *current_matrix = w->current_matrix;
@@ -4262,7 +4228,7 @@ scrolling_window (struct window *w, int header_line_p)
   struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
 
   /* Skip over rows equal at the start.  */
-  for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i)
+  for (i = header_line_p; i < current_matrix->nrows - 1; ++i)
     {
       struct glyph_row *d = MATRIX_ROW (desired_matrix, i);
       struct glyph_row *c = MATRIX_ROW (current_matrix, i);
@@ -4521,7 +4487,7 @@ scrolling_window (struct window *w, int header_line_p)
        for (j = nruns - 1; j > i; --j)
          {
            struct run *p = runs[j];
-           int truncated_p = 0;
+           bool truncated_p = 0;
 
            if (p->nrows > 0
                && p->desired_y < r->desired_y + r->height
@@ -4584,7 +4550,7 @@ scrolling_window (struct window *w, int header_line_p)
        for (j = 0; j < r->nrows; ++j)
          {
            struct glyph_row *from, *to;
-           int to_overlapped_p;
+           bool to_overlapped_p;
 
            to = MATRIX_ROW (current_matrix, r->desired_vpos + j);
            from = MATRIX_ROW (desired_matrix, r->desired_vpos + j);
@@ -4619,20 +4585,19 @@ scrolling_window (struct window *w, int header_line_p)
 
 /* Update the desired frame matrix of frame F.
 
-   FORCE_P non-zero means that the update should not be stopped by
-   pending input.  INHIBIT_HAIRY_ID_P non-zero means that scrolling
-   should not be tried.
+   FORCE_P means that the update should not be stopped by pending input.
+   INHIBIT_HAIRY_ID_P means that scrolling should not be tried.
 
-   Value is non-zero if update was stopped due to pending input.  */
+   Value is true if update was stopped due to pending input.  */
 
-static int
-update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
+static bool
+update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
 {
   /* Frame matrices to work on.  */
   struct glyph_matrix *current_matrix = f->current_matrix;
   struct glyph_matrix *desired_matrix = f->desired_matrix;
   int i;
-  int pause_p;
+  bool pause_p;
   int preempt_count = baud_rate / 2400 + 1;
 
   eassert (current_matrix && desired_matrix);
@@ -4724,7 +4689,8 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
        }
     }
 
-  pause_p = (i < FRAME_LINES (f) - 1) ? i : 0;
+  lint_assume (0 <= FRAME_LINES (f));
+  pause_p = 0 < i && i < FRAME_LINES (f) - 1;
 
   /* Now just clean up termcap drivers and set cursor, etc.  */
   if (!pause_p)
@@ -4814,8 +4780,8 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
              int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
              int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
 
-             if (INTEGERP (WGET (w, left_margin_cols)))
-               x += XFASTINT (WGET (w, left_margin_cols));
+             if (INTEGERP (w->left_margin_cols))
+               x += XFASTINT (w->left_margin_cols);
 
              /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
              cursor_to (f, y, x);
@@ -4834,7 +4800,7 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
 
 /* Do line insertions/deletions on frame F for frame-based redisplay.  */
 
-static int
+static bool
 scrolling (struct frame *frame)
 {
   int unchanged_at_top, unchanged_at_bottom;
@@ -4850,7 +4816,7 @@ scrolling (struct frame *frame)
   struct glyph_matrix *desired_matrix = frame->desired_matrix;
 
   if (!current_matrix)
-    abort ();
+    emacs_abort ();
 
   /* Compute hash codes of all the lines.  Also calculate number of
      changed lines, number of unchanged lines at the beginning, and
@@ -4977,10 +4943,10 @@ update_frame_line (struct frame *f, int vpos)
   struct glyph_matrix *desired_matrix = f->desired_matrix;
   struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos);
   struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos);
-  int must_write_whole_line_p;
-  int write_spaces_p = FRAME_MUST_WRITE_SPACES (f);
-  int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
-                         != FACE_TTY_DEFAULT_BG_COLOR);
+  bool must_write_whole_line_p;
+  bool write_spaces_p = FRAME_MUST_WRITE_SPACES (f);
+  bool colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
+                          != FACE_TTY_DEFAULT_BG_COLOR);
 
   if (colored_spaces_p)
     write_spaces_p = 1;
@@ -5305,16 +5271,16 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
 
   /* We used to set current_buffer directly here, but that does the
      wrong thing with `face-remapping-alist' (bug#2044).  */
-  Fset_buffer (WGET (w, buffer));
+  Fset_buffer (w->buffer);
   itdata = bidi_shelve_cache ();
-  SET_TEXT_POS_FROM_MARKER (startp, WGET (w, start));
+  SET_TEXT_POS_FROM_MARKER (startp, w->start);
   CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp)));
   BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
   start_display (&it, w, startp);
   /* start_display takes into account the header-line row, but IT's
      vpos still counts from the glyph row that includes the window's
      start position.  Adjust for a possible header-line row.  */
-  it.vpos += WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0;
+  it.vpos += WINDOW_WANTS_HEADER_LINE_P (w);
 
   x0 = *x;
 
@@ -5351,7 +5317,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
   *dx = x0 + it.first_visible_x - it.current_x;
   *dy = *y - it.current_y;
 
-  string =  WGET (w, buffer);
+  string =  w->buffer;
   if (STRINGP (it.string))
     string = it.string;
   *pos = it.current;
@@ -5369,7 +5335,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
       if (STRINGP (it.string))
        BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
       else
-       BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (WGET (w, buffer)),
+       BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer),
                                                     CHARPOS (pos->pos));
     }
 
@@ -5518,7 +5484,7 @@ marginal_area_string (struct window *w, enum window_part part,
   else if (part == ON_RIGHT_MARGIN)
     area = RIGHT_MARGIN_AREA;
   else
-    abort ();
+    emacs_abort ();
 
   for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row)
     if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row))
@@ -5593,18 +5559,14 @@ marginal_area_string (struct window *w, enum window_part part,
 
 #ifdef SIGWINCH
 
+static void deliver_window_change_signal (int);
+
 static void
-window_change_signal (int signalnum) /* If we don't have an argument, */
-                               /* some compilers complain in signal calls.  */
+handle_window_change_signal (int sig)
 {
   int width, height;
-  int old_errno = errno;
-
   struct tty_display_info *tty;
 
-  signal (SIGWINCH, window_change_signal);
-  SIGNAL_THREAD_CHECK (signalnum);
-
   /* The frame size change obviously applies to a single
      termcap-controlled terminal, but we can't decide which.
      Therefore, we resize the frames corresponding to each tty.
@@ -5632,20 +5594,24 @@ window_change_signal (int signalnum) /* If we don't have an argument, */
           change_frame_size (XFRAME (frame), height, width, 0, 1, 0);
     }
   }
+}
 
-  errno = old_errno;
+static void
+deliver_window_change_signal (int sig)
+{
+  deliver_process_signal (sig, handle_window_change_signal);
 }
 #endif /* SIGWINCH */
 
 
-/* Do any change in frame size that was requested by a signal.  SAFE
-   non-zero means this function is called from a place where it is
-   safe to change frame sizes  while a redisplay is in progress.  */
+/* Do any change in frame size that was requested by a signal.
+   SAFE means this function is called from a place where it is
+   safe to change frame sizes while a redisplay is in progress.  */
 
 void
-do_pending_window_change (int safe)
+do_pending_window_change (bool safe)
 {
-  /* If window_change_signal should have run before, run it now.  */
+  /* If window change signal handler should have run before, run it now.  */
   if (redisplaying_p && !safe)
     return;
 
@@ -5670,16 +5636,17 @@ do_pending_window_change (int safe)
 /* Change the frame height and/or width.  Values may be given as zero to
    indicate no change is to take place.
 
-   If DELAY is non-zero, then assume we're being called from a signal
-   handler, and queue the change for later - perhaps the next
-   redisplay.  Since this tries to resize windows, we can't call it
+   If DELAY, assume we're being called from a signal handler, and
+   queue the change for later - perhaps the next redisplay.
+   Since this tries to resize windows, we can't call it
    from a signal handler.
 
-   SAFE non-zero means this function is called from a place where it's
+   SAFE means this function is called from a place where it's
    safe to change frame sizes while a redisplay is in progress.  */
 
 void
-change_frame_size (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe)
+change_frame_size (struct frame *f, int newheight, int newwidth,
+                  bool pretend, bool delay, bool safe)
 {
   Lisp_Object tail, frame;
 
@@ -5698,7 +5665,8 @@ change_frame_size (register struct frame *f, int newheight, int newwidth, int pr
 }
 
 static void
-change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe)
+change_frame_size_1 (struct frame *f, int newheight, int newwidth,
+                    bool pretend, bool delay, bool safe)
 {
   int new_frame_total_cols;
   ptrdiff_t count = SPECPDL_INDEX ();
@@ -5740,7 +5708,7 @@ change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int
       && new_frame_total_cols == FRAME_TOTAL_COLS (f))
     return;
 
-  BLOCK_INPUT;
+  block_input ();
 
 #ifdef MSDOS
   /* We only can set screen dimensions to certain values supported
@@ -5768,9 +5736,8 @@ change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int
       if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
        FrameCols (FRAME_TTY (f)) = newwidth;
 
-      if (WINDOWP (FGET (f, tool_bar_window)))
-       WSET (XWINDOW (FGET (f, tool_bar_window)),
-             total_cols, make_number (newwidth));
+      if (WINDOWP (f->tool_bar_window))
+       wset_total_cols (XWINDOW (f->tool_bar_window), make_number (newwidth));
     }
 
   FRAME_LINES (f) = newheight;
@@ -5793,9 +5760,9 @@ change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int
   SET_FRAME_GARBAGED (f);
   f->resized_p = 1;
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
-  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+  record_unwind_current_buffer ();
 
   run_window_configuration_change_hook (f);
 
@@ -5824,9 +5791,9 @@ FILE = nil means just close any termscript file currently open.  */)
 
   if (tty->termscript != 0)
   {
-    BLOCK_INPUT;
+    block_input ();
     fclose (tty->termscript);
-    UNBLOCK_INPUT;
+    unblock_input ();
   }
   tty->termscript = 0;
 
@@ -5857,7 +5824,7 @@ when TERMINAL is nil.  */)
 
   /* ??? Perhaps we should do something special for multibyte strings here.  */
   CHECK_STRING (string);
-  BLOCK_INPUT;
+  block_input ();
 
   if (!t)
     error ("Unknown terminal device");
@@ -5882,7 +5849,7 @@ when TERMINAL is nil.  */)
     }
   fwrite (SDATA (string), 1, SBYTES (string), out);
   fflush (out);
-  UNBLOCK_INPUT;
+  unblock_input ();
   return Qnil;
 }
 
@@ -5955,16 +5922,17 @@ additional wait period, in milliseconds; this is for backwards compatibility.
 
    TIMEOUT is number of seconds to wait (float or integer),
    or t to wait forever.
-   READING is 1 if reading input.
-   If DO_DISPLAY is >0 display process output while waiting.
-   If DO_DISPLAY is >1 perform an initial redisplay before waiting.
+   READING is true if reading input.
+   If DISPLAY_OPTION is >0 display process output while waiting.
+   If DISPLAY_OPTION is >1 perform an initial redisplay before waiting.
 */
 
 Lisp_Object
-sit_for (Lisp_Object timeout, int reading, int do_display)
+sit_for (Lisp_Object timeout, bool reading, int display_option)
 {
   intmax_t sec;
   int nsec;
+  bool do_display = display_option > 0;
 
   swallow_events (do_display);
 
@@ -5972,7 +5940,7 @@ sit_for (Lisp_Object timeout, int reading, int do_display)
       || !NILP (Vexecuting_kbd_macro))
     return Qnil;
 
-  if (do_display >= 2)
+  if (display_option > 1)
     redisplay_preserve_echo_area (2);
 
   if (INTEGERP (timeout))
@@ -6003,8 +5971,8 @@ sit_for (Lisp_Object timeout, int reading, int do_display)
     wrong_type_argument (Qnumberp, timeout);
 
 
-#ifdef SIGIO
-  gobble_input (0);
+#ifdef USABLE_SIGIO
+  gobble_input ();
 #endif
 
   wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display,
@@ -6070,8 +6038,7 @@ pass nil for VARIABLE.  */)
   (Lisp_Object variable)
 {
   Lisp_Object state, tail, frame, buf;
-  Lisp_Object *vecp, *end;
-  ptrdiff_t n;
+  ptrdiff_t n, idx;
 
   if (! NILP (variable))
     {
@@ -6083,18 +6050,16 @@ pass nil for VARIABLE.  */)
   else
     state = frame_and_buffer_state;
 
-  vecp = XVECTOR (state)->contents;
-  end = vecp + ASIZE (state);
-
+  idx = 0;
   FOR_EACH_FRAME (tail, frame)
     {
-      if (vecp == end)
+      if (idx == ASIZE (state))
        goto changed;
-      if (!EQ (*vecp++, frame))
+      if (!EQ (AREF (state, idx++), frame))
        goto changed;
-      if (vecp == end)
+      if (idx == ASIZE (state))
        goto changed;
-      if (!EQ (*vecp++, FGET (XFRAME (frame), name)))
+      if (!EQ (AREF (state, idx++), XFRAME (frame)->name))
        goto changed;
     }
   /* Check that the buffer info matches.  */
@@ -6104,23 +6069,23 @@ pass nil for VARIABLE.  */)
       /* Ignore buffers that aren't included in buffer lists.  */
       if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ')
        continue;
-      if (vecp == end)
+      if (idx == ASIZE (state))
        goto changed;
-      if (!EQ (*vecp++, buf))
+      if (!EQ (AREF (state, idx++), buf))
        goto changed;
-      if (vecp == end)
+      if (idx == ASIZE (state))
        goto changed;
-      if (!EQ (*vecp++, BVAR (XBUFFER (buf), read_only)))
+      if (!EQ (AREF (state, idx++), BVAR (XBUFFER (buf), read_only)))
        goto changed;
-      if (vecp == end)
+      if (idx == ASIZE (state))
        goto changed;
-      if (!EQ (*vecp++, Fbuffer_modified_p (buf)))
+      if (!EQ (AREF (state, idx++), Fbuffer_modified_p (buf)))
        goto changed;
     }
-  if (vecp == end)
+  if (idx == ASIZE (state))
     goto changed;
   /* Detect deletion of a buffer at the end of the list.  */
-  if (EQ (*vecp, Qlambda))
+  if (EQ (AREF (state, idx), Qlambda))
     return Qnil;
 
   /* Come here if we decide the data has changed.  */
@@ -6147,11 +6112,13 @@ pass nil for VARIABLE.  */)
     }
 
   /* Record the new data in the (possibly reallocated) vector.  */
-  vecp = XVECTOR (state)->contents;
+  idx = 0;
   FOR_EACH_FRAME (tail, frame)
     {
-      *vecp++ = frame;
-      *vecp++ = FGET (XFRAME (frame), name);
+      ASET (state, idx, frame);
+      idx++;
+      ASET (state, idx, XFRAME (frame)->name);
+      idx++;
     }
   for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
     {
@@ -6159,19 +6126,23 @@ pass nil for VARIABLE.  */)
       /* Ignore buffers that aren't included in buffer lists.  */
       if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ')
        continue;
-      *vecp++ = buf;
-      *vecp++ = BVAR (XBUFFER (buf), read_only);
-      *vecp++ = Fbuffer_modified_p (buf);
+      ASET (state, idx, buf);
+      idx++;
+      ASET (state, idx, BVAR (XBUFFER (buf), read_only));
+      idx++;
+      ASET (state, idx, Fbuffer_modified_p (buf));
+      idx++;
     }
   /* Fill up the vector with lambdas (always at least one).  */
-  *vecp++ = Qlambda;
-  while (vecp - XVECTOR (state)->contents
-        < ASIZE (state))
-    *vecp++ = Qlambda;
+  ASET (state, idx, Qlambda);
+  idx++;
+  while (idx < ASIZE (state))
+    {
+      ASET (state, idx, Qlambda);
+      idx++;
+    }
   /* Make sure we didn't overflow the vector.  */
-  if (vecp - XVECTOR (state)->contents
-      > ASIZE (state))
-    abort ();
+  eassert (idx <= ASIZE (state));
   return Qt;
 }
 
@@ -6210,7 +6181,11 @@ init_display (void)
 #ifndef CANNOT_DUMP
   if (initialized)
 #endif /* CANNOT_DUMP */
-    signal (SIGWINCH, window_change_signal);
+    {
+      struct sigaction action;
+      emacs_sigaction_init (&action, deliver_window_change_signal);
+      sigaction (SIGWINCH, &action, 0);
+    }
 #endif /* SIGWINCH */
 
   /* If running as a daemon, no need to initialize any frames/terminal. */
@@ -6309,12 +6284,14 @@ init_display (void)
     struct terminal *t;
     struct frame *f = XFRAME (selected_frame);
 
+    init_foreground_group ();
+
     /* Open a display on the controlling tty. */
     t = init_tty (0, terminal_type, 1); /* Errors are fatal. */
 
     /* Convert the initial frame to use the new display. */
     if (f->output_method != output_initial)
-      abort ();
+      emacs_abort ();
     f->output_method = t->type;
     f->terminal = t;