emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A _big_ patch is on its way into the emacs sources


From: Kim F. Storm
Subject: A _big_ patch is on its way into the emacs sources
Date: 15 May 2003 01:59:10 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

As announced some time ago, I have been working on enhancing the
display engine to support per-window fringe and scroll bar settings,
and also move the location of the fringes from the edge of the window
to between the (optional) display margins and the text area (see
the to-do list).

In addition, I have worked on improving the overall readability of the
code by more clearly distinguishing between pixel values and
column/line values in the naming of struct members, variables,
functions and macros.

This is now in a working state where I'm ready to commit the changes,
but to give everybody a change to see what's coming, below is a
preview of the total patch (including ChangeLog changes).

I still have to write a news entry for the new functionality.

Index: ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/src/ChangeLog,v
retrieving revision 1.3229
diff -c -r1.3229 ChangeLog
*** ChangeLog   14 May 2003 18:52:13 -0000      1.3229
--- ChangeLog   14 May 2003 21:52:06 -0000
***************
*** 1,3 ****
--- 1,541 ----
+ 2003-05-15  Kim F. Storm  <address@hidden>
+ 
+       The following changes serves several purposes:
+ 
+       1) Swap the position of fringes and display margins in windows, i.e.
+       the fringes are now displayed between the margins and the text area
+       (by default).
+ 
+       2) Allow fringe and scroll bar parameters to be set per-buffer and
+       per-window (like display margins).  Such settings are now stored
+       in window configurations, preserved when frames are resized, and
+       copied when windows are split vertically or horisontally.
+       Several bugs related to display margins have been fixed.
+ 
+       3) Consistently use FRAME_FONT and FRAME_FONTSET macros.
+       
+       4) Use FRAME_COLUMN_WIDTH (f) consistently throughout the code
+       rather than FRAME_WIDTH (FRAME_FONT (f)).
+ 
+       5) Introduce a consistent naming of variables, members and macros
+       depending on whether their value is measured in units of pixels
+       or in canonical columns/lines.  Pixel values are named _width and
+       _height, while canonical columns/lines are named _cols and _lines.
+       Pixel positions are named _x and _y, while column/line positions
+       are named _col or _line.
+ 
+       6) Consolidate more of the X, W32, and MAC gui code by moving
+       common data into struct frame.
+ 
+       7) Cleanup and consolidate the macros controlling frame and window
+       layout into frame.h and window.h, and generalize the use of the
+       various window_box_ functions (enhanced to handle the new fringe
+       position and the per-window fringe and scroll bar settings).
+ 
+       * frame.h (struct frame): Rename members height to text_lines,
+       width to text_cols, window_height to total_lines, window_width to
+       total_cols, new_height to new_text_lines, new_width to
+       new_text_cols.  All uses changed.
+       (struct frame): New members which consolidate common members of
+       x_output, w32_output, and mac_output structures: left_pos,
+       top_pos, pixel_height, pixel_width, x_pixels_diff, y_pixels_diff,
+       win_gravity, size_hint_flags, border_width, internal_border_width,
+       line_height, fringe_cols, left_fringe_width, right_fringe_width,
+       want_fullscreen.  All uses changed.
+       (struct frame): New member column_width contaning the canonical
+       column width, analogue to line_height.  All uses changed.
+       (struct frame): Rename members scroll_bar_pixel_width to
+       config_scroll_bar_width, and scroll_bar_cols to
+       config_scroll_bar_cols.  All uses changed.
+       (struct frame): New member scroll_bar_actual_width which
+       consolidates and renames the vertical_scroll_bar_extra member of
+       x_output, w32_output, and mac_output structures.  All uses changed.
+       (FRAME_PIXEL_HEIGHT): Renamed from PIXEL_HEIGHT and moved
+       from x/w32/macterm.h files.  All uses changed.  Also change code
+       which referred to f->output_data...->pixel_height.
+       (FRAME_PIXEL_WIDTH): Renamed from PIXEL_WIDTH and moved
+       from x/w32/macterm.h files.  All uses changed.  Also change code
+       which referred to f->output_data...->pixel_width.
+       (FRAME_LINES): Renamed from FRAME_HEIGHT.  All uses changed.
+       Also change code which referred to f->height.
+       (FRAME_COLS): Renamed from FRAME_WIDTH.  All uses changed.
+       Also change code which referred to f->width.
+       (FRAME_NEW_HEIGHT, FRAME_NEW_WIDTH): Remove macros; change uses
+       to update new_text_lines and new_text_cols members directly.
+       (FRAME_CONFIG_SCROLL_BAR_WIDTH): Renamed from
+       FRAME_SCROLL_BAR_PIXEL_WIDTH.  All uses changed.
+       (FRAME_CONFIG_SCROLL_BAR_COLS): Renamed from
+       FRAME_SCROLL_BAR_COLS.  All uses changed.
+       (FRAME_LEFT_SCROLL_BAR_COLS, FRAME_RIGHT_SCROLL_BAR_COLS):
+       Renamed from FRAME_LEFT_SCROLL_BAR_WIDTH and
+       FRAME_RIGHT_SCROLL_BAR_WIDTH, resp.  All uses changed.
+       (FRAME_SCROLL_BAR_AREA_WIDTH, FRAME_LEFT_SCROLL_BAR_AREA_WIDTH)
+       (FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH): New macros.
+       (FRAME_TOTAL_COLS): Renamed from FRAME_WINDOW_WIDTH.
+       (SET_FRAME_COLS): Renamed from SET_FRAME_WIDTH.
+       (FRAME_TOTAL_COLS_ARG): Renamed from FRAME_WINDOW_WIDTH_ARG.
+       (WINDOW_VERTICAL_SCROLL_BAR_COLUMN): Remove unused macro.
+       (WINDOW_VERTICAL_SCROLL_BAR_HEIGHT): Remove unused macro.
+       (FRAME_LINE_HEIGHT): Renamed from CANON_Y_UNIT.  Unconditionally
+       return line_height member (it now has proper value also for
+       non-window frames).
+       (FRAME_COLUMN_WIDTH): Renamed from CANON_X_UNIT.  Unconditionally
+       return new column_width member (rather than the default font width).
+       (FRAME_FRINGE_COLS, FRAME_LEFT_FRINGE_WIDTH)
+       (FRAME_RIGHT_FRINGE_WIDTH): Renamed from FRAME_X_... and moved
+       from x/w32/macterm.h files.  Unconditionally return corresponding
+       member of frame structure (they now have proper values also for
+       non-window frames).
+       (FRAME_TOTAL_FRINGE_WIDTH): Renamed from FRAME_FRINGE_WIDTH.
+       Calculate return value from left and right widths.
+       (FRAME_INTERNAL_BORDER_WIDTH): Unconditionally return
+       internal_border_width member (has proper value for non-window frame).
+       (FRAME_PIXEL_X_FROM_CANON_X): Renamed from PIXEL_X_FROM_CANON_X.
+       (FRAME_PIXEL_Y_FROM_CANON_Y): Renamed from PIXEL_Y_FROM_CANON_Y.
+       (FRAME_CANON_X_FROM_PIXEL_X): Renamed from CANON_X_FROM_PIXEL_X.
+       (FRAME_CANON_Y_FROM_PIXEL_Y): Renamed from CANON_Y_FROM_PIXEL_Y.
+       (FRAME_LINE_TO_PIXEL_Y): Renamed from CHAR_TO_PIXEL_ROW,
+       consolidated from xterm.h, macterm.h, and w32term.h.
+       (FRAME_COL_TO_PIXEL_X): Renamed from CHAR_TO_PIXEL_COL,
+       consolidated from xterm.h, macterm.h, and w32term.h.
+       (FRAME_TEXT_COLS_TO_PIXEL_WIDTH): Renamed from
+       CHAR_TO_PIXEL_WIDTH consolidated from x/mac/w32term.h.
+       (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT): Renamed from
+       CHAR_TO_PIXEL_HEIGHT consolidated from x/mac/w32term.h.
+       (FRAME_PIXEL_Y_TO_LINE): Renamed from PIXEL_TO_CHAR_ROW
+       consolidated from x/mac/w32term.h.
+       (FRAME_PIXEL_X_TO_COL): Renamed from PIXEL_TO_CHAR_COL
+       consolidated from x/mac/w32term.h.
+       (FRAME_PIXEL_WIDTH_TO_TEXT_COLS): Renamed from
+       PIXEL_TO_CHAR_WIDTH consolidated from x/mac/w32term.h.
+       (FRAME_PIXEL_HEIGHT_TO_TEXT_LINES): Renamed from
+       PIXEL_TO_CHAR_HEIGHT consolidated from x/mac/w32term.h.
+ 
+       * window.h (struct window): Rename members left to left_col,
+       top to top_line, height to total_lines, width to total_cols,
+       left_margin_width to left_margin_cols, right_margin_width to
+       right_margin_cols, orig_height to orig_total_lines, orig_top to
+       orig_top_line.  All uses changed.
+       (struct window): New members left_fringe_width, right_fringe_width,
+       fringes_outside_margins, scroll_bar_width, vertical_scroll_bar_type.
+       (WINDOW_XFRAME, WINDOW_FRAME_COLUMN_WIDTH, WINDOW_FRAME_LINE_HEIGHT):
+       New macros primarily used to simplify other macros.
+       (WINDOW_TOTAL_COLS): New macro.  Change relevant code that
+       referred to XINT (w->width).
+       (WINDOW_TOTAL_LINES): New macro.  Change relevant code that
+       referred to XINT (w->height).
+       (WINDOW_TOTAL_WIDTH): New macro.  Change relevant code that
+       referred to XINT (w->width) * canon_x_unit.
+       (WINDOW_TOTAL_HEIGHT): New macro.  Change relevant code that
+       referred to XINT (w->height) * canon_y_unit.
+       (WINDOW_LEFT_EDGE_COL): New macro.  Change relevant code that
+       referred to XINT (w->left).
+       (WINDOW_RIGHT_EDGE_COL): Renamed from WINDOW_RIGHT_EDGE.  Change
+       all uses and code that referred to XINT (w->left) + XINT (w->width).
+       (WINDOW_TOP_EDGE_LINE): New macro.  Change relevant code that
+       referred to XINT (w->top).
+       (WINDOW_BOTTOM_EDGE_LINE): New macro.  Change relevant code that
+       referred to XINT (w->top) + XINT (w->height).
+       (WINDOW_LEFT_EDGE_X): New macro.  Change relevant code that
+       referred to XINT (w->left) * canon_x_unit.
+       (WINDOW_RIGHT_EDGE_X): New macro.  Change relevant code that
+       referred to (XINT (w->left) + XINT (w->width)) * canon_x_unit.
+       (WINDOW_TOP_EDGE_Y): New macro.  Change relevant code that
+       referred to XINT (w->top) * canon_y_unit.
+       (WINDOW_BOTTOM_EDGE_Y): New macro.  Change relevant code that
+       referred to (XINT (w->top) + XINT (w->height)) * canon_y_unit.
+       (WINDOW_LEFTMOST_P): New macro.
+       (WINDOW_BOX_LEFT_EDGE_COL): Renamed from WINDOW_LEFT_MARGIN.
+       All uses changed.
+       (WINDOW_BOX_RIGHT_EDGE_COL): Renamed from WINDOW_RIGHT_MARGIN.
+       All uses changed.
+       (WINDOW_BOX_LEFT_EDGE_X): Renamed from
+       WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X, moved from dispextern.h.
+       Do not exclude left fringe width.
+       (WINDOW_BOX_RIGHT_EDGE_X): Renamed from
+       WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X, moved from dispextern.h.
+       Do not exclude fringe widths.
+       (WINDOW_LEFT_FRINGE_WIDTH, WINDOW_RIGHT_FRINGE_WIDTH)
+       (WINDOW_FRINGE_COLS, WINDOW_TOTAL_FRINGE_WIDTH): New macros.
+       Change relevant code that referred to FRAME_LEFT_FRINGE_WIDTH,
+       FRAME_RIGHT_FRINGE_WIDTH, FRAME_FRINGE_COLS, and
+       FRAME_TOTAL_FRINGE_WIDTH to allow per-window fringe settings.
+       (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS): New macro.
+       (WINDOW_VERTICAL_SCROLL_BAR_TYPE, WINDOW_HAS_VERTICAL_SCROLL_BAR)
+       (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT)
+       (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT)
+       (WINDOW_CONFIG_SCROLL_BAR_WIDTH, WINDOW_CONFIG_SCROLL_BAR_COLS):
+       New macros.  Change code which referenced corresponding
+       FRAME_VERTICAL_SCROLL_BAR_TYPE, FRAME_HAS_VERTICAL_SCROLL_BARS,
+       FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT,
+       FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT,
+       FRAME_SCROLL_BAR_PIXEL_WIDTH, and FRAME_SCROLL_BAR_COLS macros to
+       allow per-window scroll-bar settings.
+       (WINDOW_LEFT_SCROLL_BAR_COLS, WINDOW_RIGHT_SCROLL_BAR_COLS): New macros.
+       (WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH): New macro.  Change code that
+       referred to FRAME_LEFT_SCROLL_BAR_WIDTH.
+       (WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH): New macro.  Change code
+       that referred to FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT and
+       FRAME_SCROLL_BAR_WIDTH.
+       (WINDOW_SCROLL_BAR_COLS, WINDOW_SCROLL_BAR_AREA_WIDTH)
+       (WINDOW_SCROLL_BAR_AREA_X): New macros. 
+       (WINDOW_HEADER_LINE_HEIGHT): Renamed from
+       WINDOW_DISPLAY_HEADER_LINE_HEIGHT, moved from dispextern.h.
+       (WINDOW_BOX_HEIGHT_NO_MODE_LINE): Renamed from
+       WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE, moved from dispextern.h.
+       (WINDOW_BOX_TEXT_HEIGHT): Renamed from
+       WINDOW_DISPLAY_PIXEL_WIDTH, moved from dispextern.h.
+       (WINDOW_TO_FRAME_PIXEL_X, WINDOW_TO_FRAME_PIXEL_Y)
+       (FRAME_TO_WINDOW_PIXEL_X, FRAME_TO_WINDOW_PIXEL_Y)
+       (WINDOW_TEXT_TO_FRAME_PIXEL_X): Moved here from dispextern.h.
+       (WINDOW_LEFT_MARGIN_WIDTH): Renamed from
+       WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH, moved from dispextern.h.
+       (WINDOW_RIGHT_MARGIN_WIDTH): Renamed from
+       WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH, moved from dispextern.h.
+       (window_from_coordinates): Update prototype.
+       (Fset_window_buffer): Update EXFUN.
+       (set_window_buffer): Update prototype.
+       
+       * dispextern.h (struct glyph_matrix): Rename members window_left_x
+       to window_left_col, window_top_y to window_top_line. All uses
+       changed.
+       (FRAME_INTERNAL_BORDER_WIDTH_SAFE): Remove macro; can now safely
+       use FRAME_INTERNAL_BORDER_WIDTH macro instead as
+       internal_border_width is now set to 0 for non-window frames.
+       (WINDOW_DISPLAY_PIXEL_WIDTH, WINDOW_DISPLAY_PIXEL_HEIGHT)
+       (WINDOW_DISPLAY_MODE_LINE_HEIGHT, WINDOW_DISPLAY_HEADER_LINE_HEIGHT)
+       (WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE, WINDOW_DISPLAY_TEXT_HEIGHT)
+       (WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X, WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X)
+       (WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y, WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y)
+       (WINDOW_TO_FRAME_PIXEL_X, WINDOW_TO_FRAME_PIXEL_Y)
+       (FRAME_TO_WINDOW_PIXEL_X, FRAME_TO_WINDOW_PIXEL_Y)
+       (WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH)
+       (WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH, WINDOW_WANTS_MODELINE_P):
+       Move to window.h and renamed [see window.h changes]. 
+       (WINDOW_AREA_TO_FRAME_PIXEL_X, WINDOW_AREA_PIXEL_WIDTH)
+       (WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH): Remove macros.
+       (WINDOW_WANTS_MODELINE_P, WINDOW_WANTS_HEADER_LINE_P): Use
+       WINDOW_TOTAL_LINES.
+       (frame_update_line_height): Remove prototype.
+ 
+       * buffer.h (struct buffer): Rename members measured in columns:
+       left_margin_width to left_margin_cols, right_margin_width to
+       right_margin_cols.  All uses changed.
+       New members left_fringe_width, right_fringe_width,
+       fringes_outside_margins for per-buffer fringe settings.
+       New members scroll_bar_width and vertical_scroll_bar_type for
+       per-buffer scroll bar settings.
+ 
+       * buffer.c (init_buffer_once): Set buffer_defaults and
+       buffer_local_flags for new buffer-local variables
+       left_fringe_width, right_fringe_width, fringes_outside_margins,
+       scroll_bar_width, and vertical_scroll_bar_type.
+       (syms_of_buffer): Defvar_per_buffer them, and defvar_lisp_nopro
+       default-* variables for them.
+ 
+       * dispnew.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (mode_line_string): No need to adjust width for mode lines, as it
+       is already adjusted by the caller.
+       (marginal_area_string): Handle fringes inside/outside margins.
+       
+       * frame.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (make_frame): Initialize left_fringe_width, right_fringe_width,
+       fringe_cols, scroll_bar_actual_width, border_width,
+       internal_border_width, column_width, line_height, x_pixels_diff,
+       y_pixels_diff, want_fullscreen, size_hint_flags, and win_gravity
+       members with values suitable for a non-window frames.
+ 
+       * gtkutil.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       
+       * indent.c: Make (few) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * keyboard.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (make_lispy_event): Use window positions returned from
+       window_from_coordinates when constructing the lisp event for
+       MOUSE_CLICK_EVENT and DRAG_N_DROP_EVENT, rather than calculating
+       (incorrect) values locally.
+       (make_lispy_movement): Use window positions returned from
+       window_from_coordinates when constructing the lisp event, rather
+       than calculating (incorrect) values locally.
+ 
+       * scroll.c: Make (some) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * sunfns.c (Fsun_menu_internal): Adapt to per-window fringes and
+       scroll-bars.
+ 
+       * sysdep.c: Make (few) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * term.c: Make (some) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * widget.c: Make (few) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * window.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (make_window): Initialize new members
+       left_margin_cols, right_margin_cols, left_fringe_width,
+       right_fringe_width, fringes_outside_margins, scroll_bar_width,
+       and vertical_scroll_bar_type.
+       (coordinates_in_window): Adapted to new fringe/margin positions
+       and per-window fringes and scroll-bars.  
+       Fix bug related to incorrectly adjusting coordinates by
+       frame's internal_border_width (the effect normally negible since 
+       the internal_border_width is typically 0 or 1 pixel, but very
+       noticeable for an internal_border_width of e.g. 25 pixels).
+       Upon successful return (other than ON_NOTHING), the coordinates
+       are now always properly converted to window relative for the
+       given display element.
+       (window_from_coordinates): Add new parameters wx and wy to
+       return the window relative x and y position in the returned
+       window and part.  A null arg means, don't return the position.
+       All callers changed.
+       (adjust_window_margins): New function which may reduce the width
+       of the display margins if a window's text area is too small after
+       resizing or splitting windows.
+       (size_window): Fix bug that did not account for display margin
+       widths when checking the minimum width of a window; use
+       adjust_window_margins.
+       (set_window_buffer): Call Fset_window_fringes and
+       Fset_window_scroll_bars to setup per-window elements.
+       Add new arg KEEP_MARGINS_P.  Non-nil means to keep window's
+       existing display margin, fringe widths, and scroll bar settings
+       (e.g. after splitting a window or resizing the frame).  All
+       callers changed.
+       (Fset_window_buffer): New arg KEEP_MARGINS.  All callers changed.
+       (Fsplit_window): Duplicate original window's display margin,
+       fringe, and scroll-bar settings; then call Fset_window_buffer with
+       KEEP_MARGINS non-nil.  This fixes a bug which caused a split
+       window to only preserve the display margins in one of the windows.
+       When splitting horisontally, call adjust_window_margins on both
+       windows to ensure that the text area of the new windows is non too
+       narrow.  This fixes a bug which could cause emacs to trap if the
+       width of the split window was less than the width of the display
+       margins.
+       (window_box_text_cols): Renamed from window_internal_width.  All
+       uses changed.  Adapt to per-window fringes and scroll bars.
+       Fix bug that caused vertical separator to be subtracted also on
+       window frames.  Fix another bug that did not reduce the returned
+       value by the columns used for display margins.
+       (window_scroll_line_based): Fix bug related to scrolling too much
+       when display margins are present (implicitly fixed by the fix to
+       window_box_text_cols).
+       (scroll_left, scroll_right): Fix bug related to scrolling too far
+       by default when display margins are present (implicitly fixed by
+       the fix to window_box_text_cols).
+       (struct saved_window): Rename members left to left_col, top to
+       top_line, width to total_cols, height to total_lines, orig_top to
+       orig_top_line, orig_height to orig_total_lines.  All uses changed.
+       New members left_margin_cols, right_margin_cols,
+       left_fringe_width, right_fringe_width, fringes_outside_margins,
+       scroll_bar_width, and vertical_scroll_bar_type for saving
+       per-window display elements.
+       (Fset_window_configuration): Restore display margins, fringes,
+       and scroll bar settings.  This fixes a bug which caused display
+       margins to be discarded when saving and restoring a window
+       configuration.
+       (save_window_save): Save display margins, fringes, and scroll bar
+       settings.  This fixes a bug which caused display margins to be
+       discarded when saving and restoring a window configuration.
+       (Fset_window_margins): Do nothing if display margins are not
+       really changed.  Otherwise, call adjust_window_margins to ensure
+       the text area doesn't get too narrow.  This fixes a bug which
+       could cause emacs to trap if setting display margins wider than
+       the width of the window.
+       (Fset_window_fringes): New defun to allow user to specifically set
+       this window's fringe widths and position vs. display margins.
+       (Fwindow_fringes): New defun to return window's actual fringe
+       settings.
+       (Fset_window_scroll_bars): New defun to allow user to specifically
+       set this window's scroll bar width and position.
+       (Fwindow_scroll_bars): New defun to return window's actual scroll
+       bar settings.
+       (compare_window_configurations): Also compare display margins,
+       fringes, and scroll bar settings.
+       (syms_of_window): Defsubr new defuns for fringe and scroll bars.
+ 
+       * xdisp.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (window_box_width): Adapt to per-window fringes and scroll bars,
+       and new fringe vs. display margin position. Note that returned
+       value is no longer guaranteed to be a whole multiple of the frame
+       column width, since per-window fringes may now be any width.
+       (window_box_left_offset): New function like window_box_left, but
+       value is relative to left border of window (rather than frame).
+       (window_box_right_offset): New function like window_box_right,
+       but value is relative to left border of window.
+       (window_box_left): Adapt to per-window fringes and scroll bars,
+       and new fringe vs. display margin position.  Simplify by using
+       WINDOW_LEFT_EDGE_X and window_box_left_offset.
+       (window_box): Allow null args for unnecessary return values;
+       change/simplify relevant callers.
+       (x_y_to_hpos_vpos): Adapt to per-window fringes and scroll bars,
+       and new fringe vs. display margin position.  Use
+       window_box_left_offset and window_box_right_offset
+       (get_glyph_string_clip_rect): Adapt to per-window fringes and
+       scroll bars, and new fringe vs. display margin position.  Use
+       WINDOW_LEFT_EDGE_X and WINDOW_TOTAL_WIDTH.
+       (draw_fringe_bitmap): Rework to handle per-window fringes and new
+       fringe vs. display margin position.
+       (hscroll_window_tree): Use window_box_width instead of window_box.
+       (redisplay_window):  Adapt to per-window scroll bars.
+       (draw_glyphs):  Rework to handle per-window fringes and scroll
+       bars, and new fringe vs. display margin position.  Use
+       WINDOW_LEFT_EDGE_X, WINDOW_TOTAL_WIDTH, and window_box_left.
+       (x_clear_end_of_line):  Adapt to per-window fringes and scroll
+       bars, and new fringe vs. display margin position.  Fix bug which
+       increased total width of full_width rows by width of scroll bars
+       although window's total width already includes that.
+       (x_fix_overlapping_area): Simplify using window_box_left_offset.
+       (expose_area): Simplify using window_box_left_offset.
+       (x_draw_vertical_border): Handle per-window scroll bar settings,
+       mixing windows with left, right and no scroll bars.
+ 
+       * xfaces.c [WINDOWSNT]: Move redefinition of FONT_WIDTH macro to
+       where it's used in x_list_fonts (for clarity).
+       (frame_update_line_height): Remove unused function; functionality
+       is now done directly when setting the default font in x_set_font.
+ 
+       * xfns.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * xmenu.c: Make (some) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * xterm.h (struct x_output): Move members left_pos, top_pos,
+       border_width, pixel_height, pixel_width, line_height,
+       internal_border_width, vertical_scroll_bar_extra,
+       left_fringe_width, right_fringe_width, fringe_cols,
+       fringes_extra, win_gravity, size_hint_flags, want_fullscreen,
+       x_pixels_diff, and y_pixels_diff to struct frame (frame.h).
+       (FRAME_INTERNAL_BORDER_WIDTH, FRAME_LINE_HEIGHT): Move to frame.h.
+       (FRAME_DEFAULT_FONT_WIDTH): Remove macro.
+       (PIXEL_WIDTH, PIXEL_HEIGHT)
+       (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH)
+       (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Moved to
+       frame.h and renamed [see frame.h changes].
+       (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH)
+       (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL)
+       (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Moved to frame.h
+       and renamed [see frame.h changes].
+       
+       * xterm.c: Make (several) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (x_draw_glyph_string_box): Adapt to per-window fringes and
+       scroll-bars.
+       (scroll_run): Adapt to new fringe position.
+       (glyph_rect): Use window coordinates returned from
+       window_from_coordinates rather than frame_to_window_pixel_xy.
+       (XTset_vertical_scroll_bar): Adapt to per-window fringes and
+       scroll-bars.
+       (handle_one_xevent): Simplify a USE_GTK conditional.
+       (x_clip_to_row): Remove superfluous whole_line_p arg and code
+       (fringes are now inside margins, i.e. always in the clipping area).
+       All callers changed.
+       (x_new_font): Set FRAME_COLUMN_WIDTH and FRAME_LINE_HEIGHT
+       directly, then call compute_fringe_widths.  Don't call
+       frame_update_line_height.
+ 
+       * w32term.h (struct w32_output): Move members left_pos, top_pos,
+       border_width, pixel_height, pixel_width, line_height,
+       internal_border_width, vertical_scroll_bar_extra,
+       left_fringe_width, right_fringe_width, fringe_cols,
+       fringes_extra, win_gravity, size_hint_flags, want_fullscreen,
+       x_pixels_diff, and y_pixels_diff to struct frame (frame.h).
+       (FRAME_INTERNAL_BORDER_WIDTH, FRAME_LINE_HEIGHT): Move to frame.h.
+       (FRAME_DEFAULT_FONT_WIDTH): Remove macro.
+       (PIXEL_WIDTH, PIXEL_HEIGHT)
+       (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH)
+       (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Moved to
+       frame.h and renamed [see frame.h changes].
+       (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH)
+       (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL)
+       (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Moved to frame.h
+       and renamed [see frame.h changes].
+       
+       * w32term.c: Make (several) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (x_draw_glyph_string_box): Adapt to per-window fringes and
+       scroll-bars.
+       (glyph_rect): Use window coordinates returned from
+       window_from_coordinates rather than frame_to_window_pixel_xy.
+       (XTset_vertical_scroll_bar): Adapt to per-window fringes and
+       scroll-bars.
+       (w32_clip_to_row): Remove superfluous whole_line_p arg and code
+       (fringes are now inside margins, i.e. always in the clipping area).
+       All callers changed.
+       (x_new_font): Set FRAME_COLUMN_WIDTH and FRAME_LINE_HEIGHT
+       directly, then call compute_fringe_widths.  Don't call
+       frame_update_line_height.
+ 
+       * w32console.c: Make (few) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * w32fns.c: Make (many) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * w32menu.c: Make (few) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * macterm.h (struct mac_output): Move members left_pos, top_pos,
+       border_width, pixel_height, pixel_width, line_height,
+       internal_border_width, vertical_scroll_bar_extra,
+       left_fringe_width, right_fringe_width, fringe_cols,
+       fringes_extra, win_gravity, size_hint_flags, want_fullscreen,
+       x_pixels_diff, y_pixels_diff to struct frame (frame.h).
+       (FRAME_INTERNAL_BORDER_WIDTH, FRAME_LINE_HEIGHT): Move to frame.h.
+       (FRAME_DEFAULT_FONT_WIDTH): Remove macro.
+       (PIXEL_WIDTH, PIXEL_HEIGHT)
+       (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH)
+       (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Moved to
+       frame.h and renamed [see frame.h changes].
+       (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH)
+       (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL)
+       (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Moved to frame.h
+       and renamed [see frame.h changes].
+       
+       * macterm.c: Make (several) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (x_draw_glyph_string_box): Adapt to per-window fringes and
+       scroll-bars.
+       (glyph_rect): Use window coordinates returned from
+       window_from_coordinates rather than frame_to_window_pixel_xy.
+       (XTset_vertical_scroll_bar): Adapt to per-window fringes and
+       scroll-bars.
+       (x_clip_to_row): Remove superfluous whole_line_p arg and code
+       (fringes are now inside margins, i.e. always in the clipping area).
+       All callers changed.
+       (x_new_font): Set FRAME_COLUMN_WIDTH and FRAME_LINE_HEIGHT
+       directly, then call compute_fringe_widths.  Don't call
+       frame_update_line_height.
+ 
+       * macfns.c: Make (several) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (x_real_positions): Set f->x_pixels_diff and f->y_pixels_diff to 0. 
+ 
+       * macmenu.c: Make (few) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+ 
+       * msdos.h (struct x_output): Remove members left_pos, top_pos,
+       and line_height, and use corresponding new members in struct
+       frame.  All uses changed.
+       (FRAME_LINE_HEIGHT, FRAME_INTERNAL_BORDER_WIDTH): Remove macros;
+       superseeded by corresponding macros in frame.h.
+ 
+       * msdos.c: Make (several) trivial substitutions for renamed and
+       new macros in dispextern.h, frame.h and window.h.
+       (IT_note_mouse_highlight): Use updated window coordinates returned
+       by window_from_coordinates, rather than adjusting them locally. 
+       (internal_terminal_init): No need to initialize line_height here;
+       it now defaults to 1.
+ 
  2003-05-14  Stefan Monnier  <address@hidden>
  
        * window.h (Qwindowp, Qwindow_live_p, Vwindow_list)
Index: buffer.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.c,v
retrieving revision 1.417
diff -c -r1.417 buffer.c
*** buffer.c    16 Apr 2003 05:07:38 -0000      1.417
--- buffer.c    14 May 2003 21:52:07 -0000
***************
*** 1608,1614 ****
    Fset_window_buffer (EQ (selected_window, minibuf_window)
                      ? Fnext_window (minibuf_window, Qnil, Qnil)
                      : selected_window,
!                     buf);
  
    return buf;
  }
--- 1608,1614 ----
    Fset_window_buffer (EQ (selected_window, minibuf_window)
                      ? Fnext_window (minibuf_window, Qnil, Qnil)
                      : selected_window,
!                     buf, Qnil);
  
    return buf;
  }
***************
*** 4928,4933 ****
--- 4928,4940 ----
    buffer_defaults.cache_long_line_scans = Qnil;
    buffer_defaults.file_truename = Qnil;
    XSETFASTINT (buffer_defaults.display_count, 0);
+   XSETFASTINT (buffer_defaults.left_margin_cols, 0);
+   XSETFASTINT (buffer_defaults.right_margin_cols, 0);
+   buffer_defaults.left_fringe_width = Qnil;
+   buffer_defaults.right_fringe_width = Qnil;
+   buffer_defaults.fringes_outside_margins = Qnil;
+   buffer_defaults.scroll_bar_width = Qnil;
+   buffer_defaults.vertical_scroll_bar_type = Qt;
    buffer_defaults.indicate_empty_lines = Qnil;
    buffer_defaults.scroll_up_aggressively = Qnil;
    buffer_defaults.scroll_down_aggressively = Qnil;
***************
*** 4990,4997 ****
    XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx);
    /* Make this one a permanent local.  */
    buffer_permanent_local_flags[idx++] = 1;
!   XSETFASTINT (buffer_local_flags.left_margin_width, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.right_margin_width, idx); ++idx;
    XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx;
    XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx;
    XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx;
--- 4997,5009 ----
    XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx);
    /* Make this one a permanent local.  */
    buffer_permanent_local_flags[idx++] = 1;
!   XSETFASTINT (buffer_local_flags.left_margin_cols, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.right_margin_cols, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.left_fringe_width, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.right_fringe_width, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.fringes_outside_margins, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.scroll_bar_width, idx); ++idx;
!   XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx;
    XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx;
    XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx;
    XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx;
***************
*** 5241,5255 ****
  #endif
  
    DEFVAR_LISP_NOPRO ("default-left-margin-width",
!                    &buffer_defaults.left_margin_width,
                     doc: /* Default value of `left-margin-width' for buffers 
that don't override it.
  This is the same as (default-value 'left-margin-width).  */);
  
    DEFVAR_LISP_NOPRO ("default-right-margin-width",
!                    &buffer_defaults.right_margin_width,
!                    doc: /* Default value of `right_margin_width' for buffers 
that don't override it.
  This is the same as (default-value 'right-margin-width).  */);
  
    DEFVAR_LISP_NOPRO ("default-indicate-empty-lines",
                     &buffer_defaults.indicate_empty_lines,
                     doc: /* Default value of `indicate-empty-lines' for 
buffers that don't override it.
--- 5253,5292 ----
  #endif
  
    DEFVAR_LISP_NOPRO ("default-left-margin-width",
!                    &buffer_defaults.left_margin_cols,
                     doc: /* Default value of `left-margin-width' for buffers 
that don't override it.
  This is the same as (default-value 'left-margin-width).  */);
  
    DEFVAR_LISP_NOPRO ("default-right-margin-width",
!                    &buffer_defaults.right_margin_cols,
!                    doc: /* Default value of `right-margin-width' for buffers 
that don't override it.
  This is the same as (default-value 'right-margin-width).  */);
  
+   DEFVAR_LISP_NOPRO ("default-left-fringe-width",
+                    &buffer_defaults.left_fringe_width,
+                    doc: /* Default value of `left-fringe-width' for buffers 
that don't override it.
+ This is the same as (default-value 'left-fringe-width).  */);
+ 
+   DEFVAR_LISP_NOPRO ("default-right-fringe-width",
+                    &buffer_defaults.right_fringe_width,
+                    doc: /* Default value of `right-fringe-width' for buffers 
that don't override it.
+ This is the same as (default-value 'right-fringe-width).  */);
+ 
+   DEFVAR_LISP_NOPRO ("default-fringes-outside-margins",
+                    &buffer_defaults.fringes_outside_margins,
+                    doc: /* Default value of `fringes-outside-margins' for 
buffers that don't override it.
+ This is the same as (default-value 'fringes-outside-margins).  */);
+ 
+   DEFVAR_LISP_NOPRO ("default-scroll-bar-width",
+                    &buffer_defaults.scroll_bar_width,
+                    doc: /* Default value of `scroll-bar-width' for buffers 
that don't override it.
+ This is the same as (default-value 'scroll-bar-width).  */);
+ 
+   DEFVAR_LISP_NOPRO ("default-vertical-scroll-bar",
+                    &buffer_defaults.vertical_scroll_bar_type,
+                    doc: /* Default value of `vertical-scroll-bar' for buffers 
that don't override it.
+ This is the same as (default-value 'vertical-scroll-bar).  */);
+ 
    DEFVAR_LISP_NOPRO ("default-indicate-empty-lines",
                     &buffer_defaults.indicate_empty_lines,
                     doc: /* Default value of `indicate-empty-lines' for 
buffers that don't override it.
***************
*** 5518,5532 ****
  
  See also the functions `display-table-slot' and `set-display-table-slot'.  
*/);
  
!   DEFVAR_PER_BUFFER ("left-margin-width", &current_buffer->left_margin_width,
                     Qnil,
                     doc: /* *Width of left marginal area for display of a 
buffer.
  A value of nil means no marginal area.  */);
  
!   DEFVAR_PER_BUFFER ("right-margin-width", 
&current_buffer->right_margin_width,
                     Qnil,
                     doc: /* *Width of right marginal area for display of a 
buffer.
  A value of nil means no marginal area.  */);
  
    DEFVAR_PER_BUFFER ("indicate-empty-lines",
                     &current_buffer->indicate_empty_lines, Qnil,
--- 5555,5598 ----
  
  See also the functions `display-table-slot' and `set-display-table-slot'.  
*/);
  
!   DEFVAR_PER_BUFFER ("left-margin-width", &current_buffer->left_margin_cols,
                     Qnil,
                     doc: /* *Width of left marginal area for display of a 
buffer.
  A value of nil means no marginal area.  */);
  
!   DEFVAR_PER_BUFFER ("right-margin-width", &current_buffer->right_margin_cols,
                     Qnil,
                     doc: /* *Width of right marginal area for display of a 
buffer.
  A value of nil means no marginal area.  */);
+ 
+   DEFVAR_PER_BUFFER ("left-fringe-width", &current_buffer->left_fringe_width,
+                    Qnil,
+                    doc: /* *Width of this buffer's left fringe (in pixels).
+ A value of 0 means no left fringe is shown in this buffer's window.
+ A value of nil means to use the left fringe width from the window's frame.  
*/);
+ 
+   DEFVAR_PER_BUFFER ("right-fringe-width", 
&current_buffer->right_fringe_width,
+                    Qnil,
+                    doc: /* *Width of this buffer's right fringe (in pixels).
+ A value of 0 means no right fringe is shown in this buffer's window.
+ A value of nil means to use the right fringe width from the window's frame.  
*/);
+ 
+   DEFVAR_PER_BUFFER ("fringes-outside-margins", 
&current_buffer->fringes_outside_margins,
+                    Qnil,
+                    doc: /* *Non-nil means to display fringes outside display 
margins.
+ A value of nil means to display fringes between margins and buffer text.  */);
+ 
+   DEFVAR_PER_BUFFER ("scroll-bar-width", &current_buffer->scroll_bar_width,
+                    Qnil,
+                    doc: /* *Width of this buffer's scroll bars in pixels.
+ A value of nil means to use the scroll bar width from the window's frame.  
*/);
+ 
+   DEFVAR_PER_BUFFER ("vertical-scroll-bar", 
&current_buffer->vertical_scroll_bar_type,
+                    Qnil,
+                    doc: /* *Position of this buffer's vertical scroll bar.
+ A value of left or right means to place the vertical scroll bar at that side
+ of the window; a value of nil means that this window has no vertical scroll 
bar.
+ A value of t means to use the vertical scroll bar type from the window's 
frame.  */);
  
    DEFVAR_PER_BUFFER ("indicate-empty-lines",
                     &current_buffer->indicate_empty_lines, Qnil,
Index: buffer.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.h,v
retrieving revision 1.88
diff -c -r1.88 buffer.h
*** buffer.h    17 Apr 2003 21:52:01 -0000      1.88
--- buffer.h    14 May 2003 21:52:08 -0000
***************
*** 715,721 ****
  
    /* Widths of left and right marginal areas for windows displaying
       this buffer.  */
!   Lisp_Object left_margin_width, right_margin_width;
  
    /* Non-nil means indicate lines not displaying text (in a style
       like vi).  */
--- 715,733 ----
  
    /* Widths of left and right marginal areas for windows displaying
       this buffer.  */
!   Lisp_Object left_margin_cols, right_margin_cols;
! 
!   /* Widths of left and right fringe areas for windows displaying
!      this buffer.  */
!   Lisp_Object left_fringe_width, right_fringe_width;
! 
!   /* Non-nil means fringes are drawn outside display margins;
!      othersize draw them between margin areas and text.  */
!   Lisp_Object fringes_outside_margins;
! 
!   /* Width and type of scroll bar areas for windows displaying
!      this buffer.  */
!   Lisp_Object scroll_bar_width, vertical_scroll_bar_type;
  
    /* Non-nil means indicate lines not displaying text (in a style
       like vi).  */
Index: dispextern.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispextern.h,v
retrieving revision 1.152
diff -c -r1.152 dispextern.h
*** dispextern.h        31 Mar 2003 20:33:14 -0000      1.152
--- dispextern.h        14 May 2003 21:52:08 -0000
***************
*** 550,561 ****
    int matrix_w, matrix_h;
  
    /* If this structure describes a window matrix of window W,
!      window_left_x is the value of W->left, window_top_y the value of
!      W->top, window_height and window_width are width and height of W,
!      as returned by window_box, and window_vscroll is the value of
!      W->vscroll at the time the matrix was last adjusted.  Only set
!      for window-based redisplay.  */
!   int window_left_x, window_top_y, window_height, window_width, 
window_vscroll;
  
    /* Number of glyphs reserved for left and right marginal areas when
       the matrix was last adjusted.  */
--- 550,563 ----
    int matrix_w, matrix_h;
  
    /* If this structure describes a window matrix of window W,
!      window_left_col is the value of W->left_col, window_top_line the
!      value of W->top_line, window_height and window_width are width and
!      height of W, as returned by window_box, and window_vscroll is the
!      value of W->vscroll at the time the matrix was last adjusted.
!      Only set for window-based redisplay.  */
!   int window_left_col, window_top_line;
!   int window_height, window_width;
!   int window_vscroll;
  
    /* Number of glyphs reserved for left and right marginal areas when
       the matrix was last adjusted.  */
***************
*** 866,878 ****
  
  #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P(W, ROW)         \
       (MATRIX_ROW_PARTIALLY_VISIBLE_P ((ROW))                  \
!       && (ROW)->y < WINDOW_DISPLAY_HEADER_LINE_HEIGHT ((W)))
  
  /* Non-zero if ROW is partially visible at the bottom of window W.  */
  
  #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P(W, ROW)                    \
       (MATRIX_ROW_PARTIALLY_VISIBLE_P ((ROW))                                \
!       && (ROW)->y + (ROW)->height > WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE ((W)))
  
  /* Return the bottom Y + 1 of ROW.   */
  
--- 868,880 ----
  
  #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P(W, ROW)         \
       (MATRIX_ROW_PARTIALLY_VISIBLE_P ((ROW))                  \
!       && (ROW)->y < WINDOW_HEADER_LINE_HEIGHT ((W)))
  
  /* Non-zero if ROW is partially visible at the bottom of window W.  */
  
  #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P(W, ROW)                    \
       (MATRIX_ROW_PARTIALLY_VISIBLE_P ((ROW))                                \
!       && (ROW)->y + (ROW)->height > WINDOW_BOX_HEIGHT_NO_MODE_LINE ((W)))
  
  /* Return the bottom Y + 1 of ROW.   */
  
***************
*** 1197,1352 ****
  #define DESIRED_HEADER_LINE_HEIGHT(W) \
       MATRIX_HEADER_LINE_HEIGHT ((W)->desired_matrix)
  
- /* Like FRAME_INTERNAL_BORDER_WIDTH but checks whether frame F is a
-    window-system frame.  */
- 
- #define FRAME_INTERNAL_BORDER_WIDTH_SAFE(F) \
-      (FRAME_WINDOW_P (F) ? FRAME_INTERNAL_BORDER_WIDTH (F) : 0)
- 
- /* Width of display region of window W.  For terminal frames, this
-    equals the width of W since there are no vertical scroll bars.  For
-    window system frames, the value has to be corrected by the pixel
-    width of vertical scroll bars, and fringes.  */
- 
- #define WINDOW_DISPLAY_PIXEL_WIDTH(W)                                 \
-      (((XFASTINT ((W)->width)                                         \
-         - FRAME_SCROLL_BAR_WIDTH (XFRAME (WINDOW_FRAME ((W))))                
\
-       - FRAME_FRINGE_COLS (XFRAME (WINDOW_FRAME ((W)))))              \
-        * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W))))))
- 
- /* Height of the display region of W, including a mode line, if any.  */
- 
- #define WINDOW_DISPLAY_PIXEL_HEIGHT(W)                                        
\
-      (XFASTINT ((W)->height)                                          \
-       * CANON_Y_UNIT (XFRAME (WINDOW_FRAME ((W)))))
- 
- /* Height in pixels of the mode line.  May be zero if W doesn't have a
-    mode line.  */
- 
- #define WINDOW_DISPLAY_MODE_LINE_HEIGHT(W)    \
-      (WINDOW_WANTS_MODELINE_P ((W))           \
-       ? CURRENT_MODE_LINE_HEIGHT (W)          \
-       : 0)
- 
- /* Height in pixels of the header line.  Zero if W doesn't have a header
-    line.  */
- 
- #define WINDOW_DISPLAY_HEADER_LINE_HEIGHT(W)  \
-      (WINDOW_WANTS_HEADER_LINE_P ((W))                \
-       ? CURRENT_HEADER_LINE_HEIGHT (W)                \
-       : 0)
- 
- /* Pixel height of window W without mode line.  */
- 
- #define WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE(W) \
-      (WINDOW_DISPLAY_PIXEL_HEIGHT ((W))               \
-       - WINDOW_DISPLAY_MODE_LINE_HEIGHT ((W)))
- 
- /* Pixel height of window W without mode and header line.  */
- 
- #define WINDOW_DISPLAY_TEXT_HEIGHT(W)         \
-      (WINDOW_DISPLAY_PIXEL_HEIGHT ((W))               \
-       - WINDOW_DISPLAY_MODE_LINE_HEIGHT ((W)) \
-       - WINDOW_DISPLAY_HEADER_LINE_HEIGHT ((W)))
- 
- /* Left edge of W in pixels relative to its frame.  */
- 
- #define WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X(W)                           \
-      (FRAME_INTERNAL_BORDER_WIDTH_SAFE (XFRAME (WINDOW_FRAME ((W))))  \
-       + (WINDOW_LEFT_MARGIN ((W))                                     \
-          * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W)))))                        
\
-       + FRAME_LEFT_FRINGE_WIDTH (XFRAME (WINDOW_FRAME ((W)))))
- 
- /* Right edge of window W in pixels, relative to its frame.  */
- 
- #define WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X(W)          \
-      (WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X ((W))          \
-       + WINDOW_DISPLAY_PIXEL_WIDTH ((W)))
- 
- /* Top edge of W in pixels relative to its frame.  */
- 
- #define WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y(W)                            \
-      (FRAME_INTERNAL_BORDER_WIDTH_SAFE (XFRAME (WINDOW_FRAME ((W))))  \
-       + (XFASTINT ((W)->top)                                          \
-          * CANON_Y_UNIT (XFRAME (WINDOW_FRAME ((W))))))
- 
- /* Bottom edge of window W relative to its frame.  */
- 
- #define WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y(W)         \
-      (WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y ((W))           \
-       + WINDOW_DISPLAY_PIXEL_HEIGHT ((W)))
- 
- /* Convert window W relative pixel X to frame pixel coordinates.  */
- 
- #define WINDOW_TO_FRAME_PIXEL_X(W, X) \
-      ((X) + WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X ((W)))
- 
- /* Convert window W relative pixel Y to frame pixel coordinates.  */
- 
- #define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
-      ((Y) + WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y ((W)))
- 
- /* Convert frame relative pixel X to window relative pixel X.  */
- 
- #define FRAME_TO_WINDOW_PIXEL_X(W, X) \
-      ((X) - WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X ((W)))
- 
- /* Convert frame relative pixel Y to window relative pixel Y.  */
- 
- #define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
-      ((Y) - WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y ((W)))
- 
- /* Width of left margin area in pixels.  */
- 
- #define WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH(W)               \
-      (NILP ((W)->left_margin_width)                   \
-       ? 0                                             \
-       : (XINT ((W)->left_margin_width)                        \
-        * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W))))))
- 
- /* Width of right marginal area in pixels.  */
- 
- #define WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH(W)      \
-      (NILP ((W)->right_margin_width)                  \
-       ? 0                                             \
-       : (XINT ((W)->right_margin_width)                       \
-        * CANON_X_UNIT (XFRAME (WINDOW_FRAME ((W))))))
- 
- /* Width of text area in pixels.  */
- 
- #define WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH(W)               \
-      (WINDOW_DISPLAY_PIXEL_WIDTH ((W))                        \
-       - WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W))    \
-       - WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH ((W)))
- 
- /* Convert a text area relative x-position in window W to frame X
-    pixel coordinates.  */
- 
- #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)            \
-      (WINDOW_TO_FRAME_PIXEL_X ((W), (X))              \
-       + WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W)))
- 
- /* Translate an x-position relative to AREA in window W to frame pixel
-    coordinates.  */
- 
- #define WINDOW_AREA_TO_FRAME_PIXEL_X(W, AREA, X)      \
-      (WINDOW_TO_FRAME_PIXEL_X ((W), (X))              \
-       + (((AREA) > LEFT_MARGIN_AREA)                  \
-        ? WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W))   \
-        : 0)                                           \
-       + (((AREA) > TEXT_AREA)                         \
-        ? WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH ((W))   \
-        : 0))
- 
- /* Return the pixel width of AREA in W.  */
- 
- #define WINDOW_AREA_PIXEL_WIDTH(W, AREA)              \
-      (((AREA) == TEXT_AREA)                           \
-       ? WINDOW_DISPLAY_TEXT_AREA_PIXEL_WIDTH ((W))    \
-       : (((AREA) == LEFT_MARGIN_AREA)                 \
-        ? WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH ((W))   \
-        : WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH ((W))))
- 
  /* Value is non-zero if window W wants a mode line.  */
  
  #define WINDOW_WANTS_MODELINE_P(W)                                    \
--- 1199,1204 ----
***************
*** 1355,1361 ****
        && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W))))         \
        && BUFFERP ((W)->buffer)                                                
\
        && !NILP (XBUFFER ((W)->buffer)->mode_line_format)              \
!       && XFASTINT ((W)->height) > 1)
  
  /* Value is non-zero if window W wants a header line.  */
  
--- 1207,1213 ----
        && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W))))         \
        && BUFFERP ((W)->buffer)                                                
\
        && !NILP (XBUFFER ((W)->buffer)->mode_line_format)              \
!       && WINDOW_TOTAL_LINES (W) > 1)
  
  /* Value is non-zero if window W wants a header line.  */
  
***************
*** 1365,1371 ****
        && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W))))         \
        && BUFFERP ((W)->buffer)                                                
\
        && !NILP (XBUFFER ((W)->buffer)->header_line_format)            \
!       && XFASTINT ((W)->height) > 1 + !NILP (XBUFFER 
((W)->buffer)->mode_line_format))
  
  
  /* Return proper value to be used as baseline offset of font that has
--- 1217,1223 ----
        && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W))))         \
        && BUFFERP ((W)->buffer)                                                
\
        && !NILP (XBUFFER ((W)->buffer)->header_line_format)            \
!       && WINDOW_TOTAL_LINES (W) > 1 + !NILP (XBUFFER 
((W)->buffer)->mode_line_format))
  
  
  /* Return proper value to be used as baseline offset of font that has
***************
*** 1391,1397 ****
        BOFF = DESCENT +  (F_HEIGHT - HEIGHT) / 2 - F_DESCENT
        DESCENT = FONT->descent
        HEIGHT = FONT_HEIGHT (FONT)
!       F_DESCENT = (F->output_data.x->font->descent
                     - F->output_data.x->baseline_offset)
        F_HEIGHT = FRAME_LINE_HEIGHT (F)
  */
--- 1243,1249 ----
        BOFF = DESCENT +  (F_HEIGHT - HEIGHT) / 2 - F_DESCENT
        DESCENT = FONT->descent
        HEIGHT = FONT_HEIGHT (FONT)
!       F_DESCENT = (FRAME_FONT (F)->descent
                     - F->output_data.x->baseline_offset)
        F_HEIGHT = FRAME_LINE_HEIGHT (F)
  */
***************
*** 2065,2071 ****
    short truncation_pixel_width, continuation_pixel_width;
  
    /* First and last visible x-position in the display area.  If window
!      is hscrolled by n columns, first_visible_x == n * CANON_X_UNIT
       (f), and last_visible_x == pixel width of W + first_visible_x.  */
    int first_visible_x, last_visible_x;
  
--- 1917,1923 ----
    short truncation_pixel_width, continuation_pixel_width;
  
    /* First and last visible x-position in the display area.  If window
!      is hscrolled by n columns, first_visible_x == n * FRAME_COLUMN_WIDTH
       (f), and last_visible_x == pixel width of W + first_visible_x.  */
    int first_visible_x, last_visible_x;
  
***************
*** 2714,2720 ****
  unsigned long load_color P_ ((struct frame *, struct face *, Lisp_Object,
                              enum lface_attribute_index));
  void unload_color P_ ((struct frame *, unsigned long));
- int frame_update_line_height P_ ((struct frame *));
  int ascii_face_of_lisp_face P_ ((struct frame *, int));
  void prepare_face_for_display P_ ((struct frame *, struct face *));
  int xstricmp P_ ((const unsigned char *, const unsigned char *));
--- 2566,2571 ----
Index: dispnew.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispnew.c,v
retrieving revision 1.315
diff -c -r1.315 dispnew.c
*** dispnew.c   14 Apr 2003 16:29:18 -0000      1.315
--- dispnew.c   14 May 2003 21:52:10 -0000
***************
*** 428,435 ****
  
  #else /* GLYPH_DEBUG == 0 */
  
! #define WINDOW_TO_FRAME_VPOS(W, VPOS) ((VPOS) + XFASTINT ((W)->top))
! #define WINDOW_TO_FRAME_HPOS(W, HPOS) ((HPOS) + XFASTINT ((W)->left))
  
  #endif /* GLYPH_DEBUG == 0 */
  
--- 428,435 ----
  
  #else /* GLYPH_DEBUG == 0 */
  
! #define WINDOW_TO_FRAME_VPOS(W, VPOS) ((VPOS) + WINDOW_TOP_EDGE_LINE (W))
! #define WINDOW_TO_FRAME_HPOS(W, HPOS) ((HPOS) + WINDOW_LEFT_EDGE_COL (W))
  
  #endif /* GLYPH_DEBUG == 0 */
  
***************
*** 576,582 ****
  
    if (NUMBERP (margin))
      {
!       int width = XFASTINT (w->width);
        double d = max (0, XFLOATINT (margin));
        d = min (width / 2 - 1, d);
        n = (int) ((double) total_glyphs / width * d);
--- 576,582 ----
  
    if (NUMBERP (margin))
      {
!       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);
***************
*** 623,629 ****
    int header_line_changed_p = 0;
    int header_line_p = 0;
    int left = -1, right = -1;
!   int window_x, window_y, window_width = -1, window_height;
  
    /* See if W had a header line that has disappeared now, or vice versa.  */
    if (w)
--- 623,629 ----
    int header_line_changed_p = 0;
    int header_line_p = 0;
    int left = -1, right = -1;
!   int window_width = -1, window_height;
  
    /* See if W had a header line that has disappeared now, or vice versa.  */
    if (w)
***************
*** 638,646 ****
       the matrix means preventing redisplay.  */
    if (matrix->pool == NULL)
      {
!       window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
!       left = margin_glyphs_to_reserve (w, dim.width, w->left_margin_width);
!       right = margin_glyphs_to_reserve (w, dim.width, w->right_margin_width);
        xassert (left >= 0 && right >= 0);
        marginal_areas_changed_p = (left != matrix->left_margin_glyphs
                                  || right != matrix->right_margin_glyphs);
--- 638,646 ----
       the matrix means preventing redisplay.  */
    if (matrix->pool == NULL)
      {
!       window_box (w, -1, 0, 0, &window_width, &window_height);
!       left = margin_glyphs_to_reserve (w, dim.width, w->left_margin_cols);
!       right = margin_glyphs_to_reserve (w, dim.width, w->right_margin_cols);
        xassert (left >= 0 && right >= 0);
        marginal_areas_changed_p = (left != matrix->left_margin_glyphs
                                  || right != matrix->right_margin_glyphs);
***************
*** 648,655 ****
        if (!marginal_areas_changed_p
          && !fonts_changed_p
          && !header_line_changed_p
!         && matrix->window_left_x == XFASTINT (w->left)
!         && matrix->window_top_y == XFASTINT (w->top)
          && matrix->window_height == window_height
          && matrix->window_vscroll == w->vscroll
          && matrix->window_width == window_width)
--- 648,655 ----
        if (!marginal_areas_changed_p
          && !fonts_changed_p
          && !header_line_changed_p
!         && matrix->window_left_col == WINDOW_LEFT_EDGE_COL (w)
!         && matrix->window_top_line == WINDOW_TOP_EDGE_LINE (w)
          && matrix->window_height == window_height
          && matrix->window_vscroll == w->vscroll
          && matrix->window_width == window_width)
***************
*** 679,687 ****
        if (w)
        {
          left = margin_glyphs_to_reserve (w, dim.width,
!                                          w->left_margin_width);
          right = margin_glyphs_to_reserve (w, dim.width,
!                                           w->right_margin_width);
        }
        else
        left = right = 0;
--- 679,687 ----
        if (w)
        {
          left = margin_glyphs_to_reserve (w, dim.width,
!                                          w->left_margin_cols);
          right = margin_glyphs_to_reserve (w, dim.width,
!                                           w->right_margin_cols);
        }
        else
        left = right = 0;
***************
*** 790,797 ****
              && !header_line_changed_p
              && new_rows == 0
              && dim.width == matrix->matrix_w
!             && matrix->window_left_x == XFASTINT (w->left)
!             && matrix->window_top_y == XFASTINT (w->top)
              && matrix->window_width == window_width)
            {
              /* Find the last row in the window.  */
--- 790,797 ----
              && !header_line_changed_p
              && new_rows == 0
              && dim.width == matrix->matrix_w
!             && matrix->window_left_col == WINDOW_LEFT_EDGE_COL (w)
!             && matrix->window_top_line == WINDOW_TOP_EDGE_LINE (w)
              && matrix->window_width == window_width)
            {
              /* Find the last row in the window.  */
***************
*** 839,846 ****
       was last adjusted.  This is used to optimize redisplay above.  */
    if (w)
      {
!       matrix->window_left_x = XFASTINT (w->left);
!       matrix->window_top_y = XFASTINT (w->top);
        matrix->window_height = window_height;
        matrix->window_width = window_width;
        matrix->window_vscroll = w->vscroll;
--- 839,846 ----
       was last adjusted.  This is used to optimize redisplay above.  */
    if (w)
      {
!       matrix->window_left_col = WINDOW_LEFT_EDGE_COL (w);
!       matrix->window_top_line = WINDOW_TOP_EDGE_LINE (w);
        matrix->window_height = window_height;
        matrix->window_width = window_width;
        matrix->window_vscroll = w->vscroll;
***************
*** 983,990 ****
    xassert (start >= 0 && start < matrix->nrows);
    xassert (end >= 0 && end <= matrix->nrows);
  
!   min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
!   max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w);
  
    for (; start < end; ++start)
      {
--- 983,990 ----
    xassert (start >= 0 && start < matrix->nrows);
    xassert (end >= 0 && end <= matrix->nrows);
  
!   min_y = WINDOW_HEADER_LINE_HEIGHT (w);
!   max_y = WINDOW_BOX_HEIGHT_NO_MODE_LINE (w);
  
    for (; start < end; ++start)
      {
***************
*** 1143,1155 ****
  {
    int min_y, max_y;
  
!   min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
!   max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w);
  
    clear_glyph_row (row);
    row->y = y;
    row->ascent = row->phys_ascent = 0;
!   row->height = row->phys_height = CANON_Y_UNIT (XFRAME (w->frame));
    row->visible_height = row->height;
  
    if (row->y < min_y)
--- 1143,1155 ----
  {
    int min_y, max_y;
  
!   min_y = WINDOW_HEADER_LINE_HEIGHT (w);
!   max_y = WINDOW_BOX_HEIGHT_NO_MODE_LINE (w);
  
    clear_glyph_row (row);
    row->y = y;
    row->ascent = row->phys_ascent = 0;
!   row->height = row->phys_height = FRAME_LINE_HEIGHT (XFRAME (w->frame));
    row->visible_height = row->height;
  
    if (row->y < min_y)
***************
*** 1905,1914 ****
              || dim.width != w->desired_matrix->matrix_w
              || dim.height != w->desired_matrix->matrix_h
              || (margin_glyphs_to_reserve (w, dim.width,
!                                           w->right_margin_width)
                  != w->desired_matrix->left_margin_glyphs)
              || (margin_glyphs_to_reserve (w, dim.width,
!                                           w->left_margin_width)
                  != w->desired_matrix->right_margin_glyphs))
            *window_change_flags |= CHANGED_LEAF_MATRIX;
  
--- 1905,1914 ----
              || dim.width != w->desired_matrix->matrix_w
              || dim.height != w->desired_matrix->matrix_h
              || (margin_glyphs_to_reserve (w, dim.width,
!                                           w->right_margin_cols)
                  != w->desired_matrix->left_margin_glyphs)
              || (margin_glyphs_to_reserve (w, dim.width,
!                                           w->left_margin_cols)
                  != w->desired_matrix->right_margin_glyphs))
            *window_change_flags |= CHANGED_LEAF_MATRIX;
  
***************
*** 1985,1991 ****
      }
  #endif /* HAVE_WINDOW_SYSTEM */
  
!   return XINT (w->height);
  }
  
  
--- 1985,1991 ----
      }
  #endif /* HAVE_WINDOW_SYSTEM */
  
!   return WINDOW_TOTAL_LINES (w);
  }
  
  
***************
*** 2000,2006 ****
    if (FRAME_WINDOW_P (f))
      {
        int ch_width = FRAME_SMALLEST_CHAR_WIDTH (f);
!       int window_pixel_width = XFLOATINT (w->width) * CANON_X_UNIT (f);
  
        /* Compute number of glyphs needed in a glyph row.  */
        return (((window_pixel_width + ch_width - 1)
--- 2000,2006 ----
    if (FRAME_WINDOW_P (f))
      {
        int ch_width = FRAME_SMALLEST_CHAR_WIDTH (f);
!       int window_pixel_width = WINDOW_TOTAL_WIDTH (w);
  
        /* Compute number of glyphs needed in a glyph row.  */
        return (((window_pixel_width + ch_width - 1)
***************
*** 2013,2019 ****
      }
  #endif /* HAVE_WINDOW_SYSTEM */
  
!   return XINT (w->width);
  }
  
  
--- 2013,2019 ----
      }
  #endif /* HAVE_WINDOW_SYSTEM */
  
!   return XINT (w->total_cols);
  }
  
  
***************
*** 2098,2115 ****
    struct frame *sf = SELECTED_FRAME ();
    struct window *root = XWINDOW (sf->root_window);
    struct window *mini = XWINDOW (root->next);
!   int frame_height = FRAME_HEIGHT (sf);
!   int frame_width = FRAME_WIDTH (sf);
    int top_margin = FRAME_TOP_MARGIN (sf);
  
    /* Do it for the root window.  */
!   XSETFASTINT (root->top, top_margin);
!   XSETFASTINT (root->width, frame_width);
!   set_window_height (sf->root_window, frame_height - 1 - top_margin, 0);
  
    /* Do it for the mini-buffer window.  */
!   XSETFASTINT (mini->top, frame_height - 1);
!   XSETFASTINT (mini->width, frame_width);
    set_window_height (root->next, 1, 0);
  
    adjust_frame_glyphs (sf);
--- 2098,2115 ----
    struct frame *sf = SELECTED_FRAME ();
    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.  */
!   XSETFASTINT (root->top_line, top_margin);
!   XSETFASTINT (root->total_cols, frame_cols);
!   set_window_height (sf->root_window, frame_lines - 1 - top_margin, 0);
  
    /* Do it for the mini-buffer window.  */
!   XSETFASTINT (mini->top_line, frame_lines - 1);
!   XSETFASTINT (mini->total_cols, frame_cols);
    set_window_height (root->next, 1, 0);
  
    adjust_frame_glyphs (sf);
***************
*** 2161,2173 ****
          struct glyph_matrix *m = w->current_matrix;
          struct glyph_matrix *fm = f->current_matrix;
  
!         xassert (m->matrix_h == XFASTINT (w->height));
!         xassert (m->matrix_w == XFASTINT (w->width));
  
          for (i = 0; i < m->matrix_h; ++i)
            {
              struct glyph_row *r = m->rows + i;
!             struct glyph_row *fr = fm->rows + i + XFASTINT (w->top);
  
              xassert (r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA]
                       && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]);
--- 2161,2173 ----
          struct glyph_matrix *m = w->current_matrix;
          struct glyph_matrix *fm = f->current_matrix;
  
!         xassert (m->matrix_h == WINDOW_TOTAL_LINES (w));
!         xassert (m->matrix_w == WINDOW_TOTAL_COLS (w));
  
          for (i = 0; i < m->matrix_h; ++i)
            {
              struct glyph_row *r = m->rows + i;
!             struct glyph_row *fr = fm->rows + i + WINDOW_TOP_EDGE_LINE (w);
  
              xassert (r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA]
                       && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]);
***************
*** 2313,2320 ****
        /* Size of frame matrices must equal size of frame.  Note
         that we are called for X frames with window widths NOT equal
         to the frame width (from CHANGE_FRAME_SIZE_1).  */
!       xassert (matrix_dim.width == FRAME_WIDTH (f)
!              && matrix_dim.height == FRAME_HEIGHT (f));
  
        /* Pointers to glyph memory in glyph rows are exchanged during
         the update phase of redisplay, which means in general that a
--- 2313,2320 ----
        /* Size of frame matrices must equal size of frame.  Note
         that we are called for X frames with window widths NOT equal
         to the frame width (from CHANGE_FRAME_SIZE_1).  */
!       xassert (matrix_dim.width == FRAME_COLS (f)
!              && matrix_dim.height == FRAME_LINES (f));
  
        /* Pointers to glyph memory in glyph rows are exchanged during
         the update phase of redisplay, which means in general that a
***************
*** 2386,2395 ****
  
      /* Set window dimensions to frame dimensions and allocate or
         adjust glyph matrices of W.  */
!     XSETFASTINT (w->top, 0);
!     XSETFASTINT (w->left, 0);
!     XSETFASTINT (w->height, FRAME_MENU_BAR_LINES (f));
!     XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f));
      allocate_matrices_for_window_redisplay (w);
    }
  #endif /* not USE_X_TOOLKIT */
--- 2386,2395 ----
  
      /* Set window dimensions to frame dimensions and allocate or
         adjust glyph matrices of W.  */
!     XSETFASTINT (w->top_line, 0);
!     XSETFASTINT (w->left_col, 0);
!     XSETFASTINT (w->total_lines, FRAME_MENU_BAR_LINES (f));
!     XSETFASTINT (w->total_cols, FRAME_TOTAL_COLS (f));
      allocate_matrices_for_window_redisplay (w);
    }
  #endif /* not USE_X_TOOLKIT */
***************
*** 2407,2416 ****
    else
      w = XWINDOW (f->tool_bar_window);
  
!   XSETFASTINT (w->top, FRAME_MENU_BAR_LINES (f));
!   XSETFASTINT (w->left, 0);
!   XSETFASTINT (w->height, FRAME_TOOL_BAR_LINES (f));
!   XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f));
    allocate_matrices_for_window_redisplay (w);
  #endif
  }
--- 2407,2416 ----
    else
      w = XWINDOW (f->tool_bar_window);
  
!   XSETFASTINT (w->top_line, FRAME_MENU_BAR_LINES (f));
!   XSETFASTINT (w->left_col, 0);
!   XSETFASTINT (w->total_lines, FRAME_TOOL_BAR_LINES (f));
!   XSETFASTINT (w->total_cols, FRAME_TOTAL_COLS (f));
    allocate_matrices_for_window_redisplay (w);
  #endif
  }
***************
*** 3022,3035 ****
    xassert (NILP (w->hchild) && NILP (w->vchild));
    xassert (!FRAME_WINDOW_P (f));
  
!   left = margin_glyphs_to_reserve (w, 1, w->left_margin_width);
!   right = margin_glyphs_to_reserve (w, 1, w->right_margin_width);
    x = w->current_matrix->matrix_x;
    width = w->current_matrix->matrix_w;
  
    window_row = w->current_matrix->rows;
    window_row_end = window_row + w->current_matrix->nrows;
!   frame_row = f->current_matrix->rows + XFASTINT (w->top);
  
    for (; window_row < window_row_end; ++window_row, ++frame_row)
      {
--- 3022,3035 ----
    xassert (NILP (w->hchild) && NILP (w->vchild));
    xassert (!FRAME_WINDOW_P (f));
  
!   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;
  
    window_row = w->current_matrix->rows;
    window_row_end = window_row + w->current_matrix->nrows;
!   frame_row = f->current_matrix->rows + WINDOW_TOP_EDGE_LINE (w);
  
    for (; window_row < window_row_end; ++window_row, ++frame_row)
      {
***************
*** 3061,3068 ****
        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 >= XFASTINT (w->top)
!              && row < XFASTINT (w->top) + XFASTINT (w->height))
        found = w;
  
        w = NILP (w->next) ? 0 : XWINDOW (w->next);
--- 3061,3068 ----
        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 (w->next) ? 0 : XWINDOW (w->next);
***************
*** 3267,3274 ****
  
    xassert (!FRAME_WINDOW_P (f));
    xassert (vpos >= 0 && vpos <= w->desired_matrix->nrows);
!   vpos += XFASTINT (w->top);
!   xassert (vpos >= 0 && vpos <= FRAME_HEIGHT (f));
    return vpos;
  }
  
--- 3267,3274 ----
  
    xassert (!FRAME_WINDOW_P (f));
    xassert (vpos >= 0 && vpos <= w->desired_matrix->nrows);
!   vpos += WINDOW_TOP_EDGE_LINE (w);
!   xassert (vpos >= 0 && vpos <= FRAME_LINES (f));
    return vpos;
  }
  
***************
*** 3284,3290 ****
    struct frame *f = XFRAME (w->frame);
  
    xassert (!FRAME_WINDOW_P (f));
!   hpos += XFASTINT (w->left);
    return hpos;
  }
  
--- 3284,3290 ----
    struct frame *f = XFRAME (w->frame);
  
    xassert (!FRAME_WINDOW_P (f));
!   hpos += WINDOW_LEFT_EDGE_COL (w);
    return hpos;
  }
  
***************
*** 3644,3651 ****
      {
        int x, y;
        x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos)
!          + (INTEGERP (w->left_margin_width)
!             ? XFASTINT (w->left_margin_width)
              : 0));
        y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
        cursor_to (y, x);
--- 3644,3651 ----
      {
        int x, y;
        x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos)
!          + (INTEGERP (w->left_margin_cols)
!             ? XFASTINT (w->left_margin_cols)
              : 0));
        y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
        cursor_to (y, x);
***************
*** 3739,3746 ****
      {
        int x, y;
        x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos)
!          + (INTEGERP (w->left_margin_width)
!             ? XFASTINT (w->left_margin_width)
              : 0));
        y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
        cursor_to (y, x);
--- 3739,3746 ----
      {
        int x, y;
        x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos)
!          + (INTEGERP (w->left_margin_cols)
!             ? XFASTINT (w->left_margin_cols)
              : 0));
        y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
        cursor_to (y, x);
***************
*** 4480,4486 ****
  
        /* Update display of the left margin area, if there is one.  */
        if (!desired_row->full_width_p
!         && !NILP (w->left_margin_width))
        {
          changed_p = 1;
          update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
--- 4480,4486 ----
  
        /* Update display of the left margin area, if there is one.  */
        if (!desired_row->full_width_p
!         && !NILP (w->left_margin_cols))
        {
          changed_p = 1;
          update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
***************
*** 4496,4502 ****
  
        /* Update display of the right margin area, if there is one.  */
        if (!desired_row->full_width_p
!         && !NILP (w->right_margin_width))
        {
          changed_p = 1;
          update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
--- 4496,4502 ----
  
        /* Update display of the right margin area, if there is one.  */
        if (!desired_row->full_width_p
!         && !NILP (w->right_margin_cols))
        {
          changed_p = 1;
          update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
***************
*** 5126,5132 ****
        }
      }
  
!   pause = (i < FRAME_HEIGHT (f) - 1) ? i : 0;
  
    /* Now just clean up termcap drivers and set cursor, etc.  */
    if (!pause)
--- 5126,5132 ----
        }
      }
  
!   pause = (i < FRAME_LINES (f) - 1) ? i : 0;
  
    /* Now just clean up termcap drivers and set cursor, etc.  */
    if (!pause)
***************
*** 5143,5149 ****
          && FRAME_HAS_MINIBUF_P (f)
          && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window))
        {
!         int top = XINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top);
          int row, col;
  
          if (cursor_in_echo_area < 0)
--- 5143,5149 ----
          && FRAME_HAS_MINIBUF_P (f)
          && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window))
        {
!         int top = WINDOW_TOP_EDGE_LINE (XWINDOW (FRAME_MINIBUF_WINDOW (f)));
          int row, col;
  
          if (cursor_in_echo_area < 0)
***************
*** 5159,5165 ****
                 cursor at the end of the prompt.  If the mini-buffer
                 is several lines high, find the last line that has
                 any text on it.  */
!             row = FRAME_HEIGHT (f);
              do
                {
                  --row;
--- 5159,5165 ----
                 cursor at the end of the prompt.  If the mini-buffer
                 is several lines high, find the last line that has
                 any text on it.  */
!             row = FRAME_LINES (f);
              do
                {
                  --row;
***************
*** 5187,5195 ****
              if (col >= FRAME_CURSOR_X_LIMIT (f))
                {
                  /* If we have another row, advance cursor into it.  */
!                 if (row < FRAME_HEIGHT (f) - 1)
                    {
!                     col = FRAME_LEFT_SCROLL_BAR_WIDTH (f);
                      row++;
                    }
                  /* Otherwise move it back in range.  */
--- 5187,5195 ----
              if (col >= FRAME_CURSOR_X_LIMIT (f))
                {
                  /* If we have another row, advance cursor into it.  */
!                 if (row < FRAME_LINES (f) - 1)
                    {
!                     col = FRAME_LEFT_SCROLL_BAR_COLS (f);
                      row++;
                    }
                  /* Otherwise move it back in range.  */
***************
*** 5211,5225 ****
                 with the cursor in the lower half of it.  The window
                 is split, and a message causes a redisplay before
                 a new cursor position has been computed.  */
!             && w->cursor.vpos < XFASTINT (w->height))
            {
              int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
              int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
  
!             if (INTEGERP (w->left_margin_width))
!               x += XFASTINT (w->left_margin_width);
  
!             /* x = max (min (x, FRAME_WINDOW_WIDTH (f) - 1), 0); */
              cursor_to (y, x);
            }
        }
--- 5211,5225 ----
                 with the cursor in the lower half of it.  The window
                 is split, and a message causes a redisplay before
                 a new cursor position has been computed.  */
!             && w->cursor.vpos < WINDOW_TOTAL_LINES (w))
            {
              int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
              int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
  
!             if (INTEGERP (w->left_margin_cols))
!               x += XFASTINT (w->left_margin_cols);
  
!             /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
              cursor_to (y, x);
            }
        }
***************
*** 5241,5252 ****
    int unchanged_at_top, unchanged_at_bottom;
    int window_size;
    int changed_lines;
!   int *old_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
!   int *new_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
!   int *draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
!   int *old_draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
    register int i;
!   int free_at_end_vpos = FRAME_HEIGHT (frame);
    struct glyph_matrix *current_matrix = frame->current_matrix;
    struct glyph_matrix *desired_matrix = frame->desired_matrix;
  
--- 5241,5252 ----
    int unchanged_at_top, unchanged_at_bottom;
    int window_size;
    int changed_lines;
!   int *old_hash = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
!   int *new_hash = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
!   int *draw_cost = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
!   int *old_draw_cost = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
    register int i;
!   int free_at_end_vpos = FRAME_LINES (frame);
    struct glyph_matrix *current_matrix = frame->current_matrix;
    struct glyph_matrix *desired_matrix = frame->desired_matrix;
  
***************
*** 5258,5265 ****
       number of unchanged lines at the end.  */
    changed_lines = 0;
    unchanged_at_top = 0;
!   unchanged_at_bottom = FRAME_HEIGHT (frame);
!   for (i = 0; i < FRAME_HEIGHT (frame); i++)
      {
        /* Give up on this scrolling if some old lines are not enabled.  */
        if (!MATRIX_ROW_ENABLED_P (current_matrix, i))
--- 5258,5265 ----
       number of unchanged lines at the end.  */
    changed_lines = 0;
    unchanged_at_top = 0;
!   unchanged_at_bottom = FRAME_LINES (frame);
!   for (i = 0; i < FRAME_LINES (frame); i++)
      {
        /* Give up on this scrolling if some old lines are not enabled.  */
        if (!MATRIX_ROW_ENABLED_P (current_matrix, i))
***************
*** 5281,5287 ****
        if (old_hash[i] != new_hash[i])
        {
          changed_lines++;
!         unchanged_at_bottom = FRAME_HEIGHT (frame) - i - 1;
        }
        else if (i == unchanged_at_top)
        unchanged_at_top++;
--- 5281,5287 ----
        if (old_hash[i] != new_hash[i])
        {
          changed_lines++;
!         unchanged_at_bottom = FRAME_LINES (frame) - i - 1;
        }
        else if (i == unchanged_at_top)
        unchanged_at_top++;
***************
*** 5290,5299 ****
  
    /* If changed lines are few, don't allow preemption, don't scroll.  */
    if ((!scroll_region_ok && changed_lines < baud_rate / 2400)
!       || unchanged_at_bottom == FRAME_HEIGHT (frame))
      return 1;
  
!   window_size = (FRAME_HEIGHT (frame) - unchanged_at_top
                 - unchanged_at_bottom);
  
    if (scroll_region_ok)
--- 5290,5299 ----
  
    /* If changed lines are few, don't allow preemption, don't scroll.  */
    if ((!scroll_region_ok && changed_lines < baud_rate / 2400)
!       || unchanged_at_bottom == FRAME_LINES (frame))
      return 1;
  
!   window_size = (FRAME_LINES (frame) - unchanged_at_top
                 - unchanged_at_bottom);
  
    if (scroll_region_ok)
***************
*** 5306,5312 ****
    if (!scroll_region_ok && window_size >= 18 && baud_rate > 2400
        && (window_size >=
          10 * scrolling_max_lines_saved (unchanged_at_top,
!                                         FRAME_HEIGHT (frame) - 
unchanged_at_bottom,
                                          old_hash, new_hash, draw_cost)))
      return 0;
  
--- 5306,5312 ----
    if (!scroll_region_ok && window_size >= 18 && baud_rate > 2400
        && (window_size >=
          10 * scrolling_max_lines_saved (unchanged_at_top,
!                                         FRAME_LINES (frame) - 
unchanged_at_bottom,
                                          old_hash, new_hash, draw_cost)))
      return 0;
  
***************
*** 5365,5371 ****
  /* Char insertion/deletion cost vector, from term.c */
  
  extern int *char_ins_del_vector;
! #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WINDOW_WIDTH((f))])
  
  
  /* Perform a frame-based update on line VPOS in frame FRAME.  */
--- 5365,5371 ----
  /* Char insertion/deletion cost vector, from term.c */
  
  extern int *char_ins_del_vector;
! #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_TOTAL_COLS((f))])
  
  
  /* Perform a frame-based update on line VPOS in frame FRAME.  */
***************
*** 5441,5450 ****
        /* Don't call clear_end_of_line if we already wrote the whole
         line.  The cursor will not be at the right margin in that
         case but in the line below.  */
!       if (nlen < FRAME_WINDOW_WIDTH (f))
        {
          cursor_to (vpos, nlen);
!           clear_end_of_line (FRAME_WINDOW_WIDTH (f));
        }
        else
        /* Make sure we are in the right row, otherwise cursor movement
--- 5441,5450 ----
        /* Don't call clear_end_of_line if we already wrote the whole
         line.  The cursor will not be at the right margin in that
         case but in the line below.  */
!       if (nlen < FRAME_TOTAL_COLS (f))
        {
          cursor_to (vpos, nlen);
!           clear_end_of_line (FRAME_TOTAL_COLS (f));
        }
        else
        /* Make sure we are in the right row, otherwise cursor movement
***************
*** 5615,5621 ****
             no need to do clear-to-eol at the end of this function
             (and it would not be safe, since cursor is not going to
             be "at the margin" after the text is done).  */
!         if (nlen == FRAME_WINDOW_WIDTH (f))
            olen = 0;
  
          /* Function write_glyphs is prepared to do nothing
--- 5615,5621 ----
             no need to do clear-to-eol at the end of this function
             (and it would not be safe, since cursor is not going to
             be "at the margin" after the text is done).  */
!         if (nlen == FRAME_TOTAL_COLS (f))
            olen = 0;
  
          /* Function write_glyphs is prepared to do nothing
***************
*** 5705,5711 ****
    BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
    start_display (&it, w, startp);
  
!   left_area_width = WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH (w);
    move_it_to (&it, -1, *x + it.first_visible_x - left_area_width, *y, -1,
              MOVE_TO_X | MOVE_TO_Y);
  
--- 5705,5711 ----
    BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
    start_display (&it, w, startp);
  
!   left_area_width = WINDOW_LEFT_MARGIN_WIDTH (w);
    move_it_to (&it, -1, *x + it.first_visible_x - left_area_width, *y, -1,
              MOVE_TO_X | MOVE_TO_Y);
  
***************
*** 5743,5755 ****
  
    if (row->mode_line_p && row->enabled_p)
      {
-       /* The mode lines are displayed over scroll bars and fringes,
-        and X is window-relative.  Correct X by the scroll bar
-        and fringe width.  */
-       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
-       x += FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
-       x += FRAME_LEFT_FRINGE_WIDTH (f);
- 
        /* Find the glyph under X.  If we find one with a string object,
           it's the one we were looking for.  */
        glyph = row->glyphs[TEXT_AREA];
--- 5743,5748 ----
***************
*** 5801,5811 ****
         it's the one we were looking for.  */
        glyph = row->glyphs[area];
        end = glyph + row->used[area];
        if (area == RIGHT_MARGIN_AREA)
!       x0 = (window_box_width (w, TEXT_AREA)
!             + window_box_width (w, LEFT_MARGIN_AREA));
        else
!       x0 = 0;
        for (; glyph < end; x0 += glyph->pixel_width, ++glyph)
        if (x >= x0 && x < x0 + glyph->pixel_width)
          {
--- 5794,5811 ----
         it's the one we were looking for.  */
        glyph = row->glyphs[area];
        end = glyph + row->used[area];
+ 
        if (area == RIGHT_MARGIN_AREA)
!       x0 = ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!              ? WINDOW_LEFT_FRINGE_WIDTH (w) 
!              : WINDOW_TOTAL_FRINGE_WIDTH (w))
!             + window_box_width (w, LEFT_MARGIN_AREA)
!             + window_box_width (w, TEXT_AREA));
        else
!       x0 = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!             ? WINDOW_LEFT_FRINGE_WIDTH (w) 
!             : 0);
! 
        for (; glyph < end; x0 += glyph->pixel_width, ++glyph)
        if (x >= x0 && x < x0 + glyph->pixel_width)
          {
***************
*** 5885,5895 ****
        {
          struct frame *f = XFRAME (frame);
  
!         int height = FRAME_NEW_HEIGHT (f);
!         int width = FRAME_NEW_WIDTH (f);
! 
!         if (height != 0 || width != 0)
!           change_frame_size (f, height, width, 0, 0, safe);
        }
      }
  }
--- 5885,5893 ----
        {
          struct frame *f = XFRAME (frame);
  
!         if (f->new_text_lines != 0 || f->new_text_cols != 0)
!           change_frame_size (f, f->new_text_lines, f->new_text_cols,
!                              0, 0, safe);
        }
      }
  }
***************
*** 5931,5968 ****
       register struct frame *f;
       int newheight, newwidth, pretend, delay, safe;
  {
!   int new_frame_window_width;
    int count = SPECPDL_INDEX ();
  
    /* If we can't deal with the change now, queue it for later.  */
    if (delay || (redisplaying_p && !safe))
      {
!       FRAME_NEW_HEIGHT (f) = newheight;
!       FRAME_NEW_WIDTH (f) = newwidth;
        delayed_size_change = 1;
        return;
      }
  
    /* This size-change overrides any pending one for this frame.  */
!   FRAME_NEW_HEIGHT (f) = 0;
!   FRAME_NEW_WIDTH  (f) = 0;
  
    /* If an argument is zero, set it to the current value.  */
    if (newheight == 0)
!     newheight = FRAME_HEIGHT (f);
    if (newwidth == 0)
!     newwidth  = FRAME_WIDTH  (f);
  
    /* Compute width of windows in F.
       This is the width of the frame without vertical scroll bars.  */
!   new_frame_window_width = FRAME_WINDOW_WIDTH_ARG (f, newwidth);
  
    /* Round up to the smallest acceptable size.  */
    check_frame_size (f, &newheight, &newwidth);
  
    /* If we're not changing the frame size, quit now.  */
!   if (newheight == FRAME_HEIGHT (f)
!       && new_frame_window_width == FRAME_WINDOW_WIDTH (f))
      return;
  
    BLOCK_INPUT;
--- 5929,5966 ----
       register struct frame *f;
       int newheight, newwidth, pretend, delay, safe;
  {
!   int new_frame_total_cols;
    int count = SPECPDL_INDEX ();
  
    /* If we can't deal with the change now, queue it for later.  */
    if (delay || (redisplaying_p && !safe))
      {
!       f->new_text_lines = newheight;
!       f->new_text_cols = newwidth;
        delayed_size_change = 1;
        return;
      }
  
    /* This size-change overrides any pending one for this frame.  */
!   f->new_text_lines = 0;
!   f->new_text_cols = 0;
  
    /* If an argument is zero, set it to the current value.  */
    if (newheight == 0)
!     newheight = FRAME_LINES (f);
    if (newwidth == 0)
!     newwidth  = FRAME_COLS  (f);
  
    /* Compute width of windows in F.
       This is the width of the frame without vertical scroll bars.  */
!   new_frame_total_cols = FRAME_TOTAL_COLS_ARG (f, newwidth);
  
    /* Round up to the smallest acceptable size.  */
    check_frame_size (f, &newheight, &newwidth);
  
    /* If we're not changing the frame size, quit now.  */
!   if (newheight == FRAME_LINES (f)
!       && new_frame_total_cols == FRAME_TOTAL_COLS (f))
      return;
  
    BLOCK_INPUT;
***************
*** 5974,5992 ****
    dos_set_window_size (&newheight, &newwidth);
  #endif
  
!   if (newheight != FRAME_HEIGHT (f))
      {
        if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
        {
          /* Frame has both root and mini-buffer.  */
!         XSETFASTINT (XWINDOW (FRAME_ROOT_WINDOW (f))->top,
                       FRAME_TOP_MARGIN (f));
          set_window_height (FRAME_ROOT_WINDOW (f),
                             (newheight
                              - 1
                              - FRAME_TOP_MARGIN (f)),
                              0);
!         XSETFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top,
                       newheight - 1);
          set_window_height (FRAME_MINIBUF_WINDOW (f), 1, 0);
        }
--- 5972,5990 ----
    dos_set_window_size (&newheight, &newwidth);
  #endif
  
!   if (newheight != FRAME_LINES (f))
      {
        if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
        {
          /* Frame has both root and mini-buffer.  */
!         XSETFASTINT (XWINDOW (FRAME_ROOT_WINDOW (f))->top_line,
                       FRAME_TOP_MARGIN (f));
          set_window_height (FRAME_ROOT_WINDOW (f),
                             (newheight
                              - 1
                              - FRAME_TOP_MARGIN (f)),
                              0);
!         XSETFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top_line,
                       newheight - 1);
          set_window_height (FRAME_MINIBUF_WINDOW (f), 1, 0);
        }
***************
*** 5999,6019 ****
        FrameRows = newheight;
      }
  
!   if (new_frame_window_width  != FRAME_WINDOW_WIDTH (f))
      {
!       set_window_width (FRAME_ROOT_WINDOW (f), new_frame_window_width, 0);
        if (FRAME_HAS_MINIBUF_P (f))
!       set_window_width (FRAME_MINIBUF_WINDOW (f), new_frame_window_width, 0);
  
        if (FRAME_TERMCAP_P (f) && !pretend)
        FrameCols = newwidth;
  
        if (WINDOWP (f->tool_bar_window))
!       XSETFASTINT (XWINDOW (f->tool_bar_window)->width, newwidth);
      }
  
!   FRAME_HEIGHT (f) = newheight;
!   SET_FRAME_WIDTH (f, newwidth);
  
    {
      struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
--- 5997,6017 ----
        FrameRows = newheight;
      }
  
!   if (new_frame_total_cols != FRAME_TOTAL_COLS (f))
      {
!       set_window_width (FRAME_ROOT_WINDOW (f), new_frame_total_cols, 0);
        if (FRAME_HAS_MINIBUF_P (f))
!       set_window_width (FRAME_MINIBUF_WINDOW (f), new_frame_total_cols, 0);
  
        if (FRAME_TERMCAP_P (f) && !pretend)
        FrameCols = newwidth;
  
        if (WINDOWP (f->tool_bar_window))
!       XSETFASTINT (XWINDOW (f->tool_bar_window)->total_cols, newwidth);
      }
  
!   FRAME_LINES (f) = newheight;
!   SET_FRAME_COLS (f, newwidth);
  
    {
      struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
***************
*** 6038,6044 ****
  
    /* This isn't quite a no-op: it runs window-configuration-change-hook.  */
    Fset_window_buffer (FRAME_SELECTED_WINDOW (f),
!                     XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer);
  
    unbind_to (count, Qnil);
  }
--- 6036,6042 ----
  
    /* This isn't quite a no-op: it runs window-configuration-change-hook.  */
    Fset_window_buffer (FRAME_SELECTED_WINDOW (f),
!                     XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer, Qt);
  
    unbind_to (count, Qnil);
  }
***************
*** 6537,6544 ****
  
    {
      struct frame *sf = SELECTED_FRAME ();
!     int width = FRAME_WINDOW_WIDTH (sf);
!     int height = FRAME_HEIGHT (sf);
  
      unsigned int total_glyphs = height * (width + 2) * sizeof (struct glyph);
  
--- 6535,6542 ----
  
    {
      struct frame *sf = SELECTED_FRAME ();
!     int width = FRAME_TOTAL_COLS (sf);
!     int height = FRAME_LINES (sf);
  
      unsigned int total_glyphs = height * (width + 2) * sizeof (struct glyph);
  
Index: frame.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/frame.c,v
retrieving revision 1.295
diff -c -r1.295 frame.c
*** frame.c     1 Apr 2003 01:09:13 -0000       1.295
--- frame.c     14 May 2003 21:52:11 -0000
***************
*** 126,138 ****
    struct window *w = XWINDOW (window);
  
    XSETFASTINT (w->last_modified, 0);
!   XSETFASTINT (w->top, XFASTINT (w->top) + n);
!   XSETFASTINT (w->height, XFASTINT (w->height) - n);
  
!   if (INTEGERP (w->orig_top))
!     XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
!   if (INTEGERP (w->orig_height))
!     XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
  
    /* Handle just the top child in a vertical split.  */
    if (!NILP (w->vchild))
--- 126,138 ----
    struct window *w = XWINDOW (window);
  
    XSETFASTINT (w->last_modified, 0);
!   XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
!   XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
  
!   if (INTEGERP (w->orig_top_line))
!     XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
!   if (INTEGERP (w->orig_total_lines))
!     XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
  
    /* Handle just the top child in a vertical split.  */
    if (!NILP (w->vchild))
***************
*** 285,290 ****
--- 285,301 ----
    f->tool_bar_items = Qnil;
    f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
    f->n_tool_bar_items = 0;
+   f->left_fringe_width = f->right_fringe_width = 0;
+   f->fringe_cols = 0;
+   f->scroll_bar_actual_width = 0;
+   f->border_width = 0;
+   f->internal_border_width = 0;
+   f->column_width = 1;  /* !FRAME_WINDOW_P value */
+   f->line_height = 1;  /* !FRAME_WINDOW_P value */
+   f->x_pixels_diff = f->y_pixels_diff = 0;
+   f->want_fullscreen = FULLSCREEN_NONE;
+   f->size_hint_flags = 0;
+   f->win_gravity = 0;
  
    root_window = make_window ();
    if (mini_p)
***************
*** 309,325 ****
       just so that there is "something there."
       Correct size will be set up later with change_frame_size.  */
  
!   SET_FRAME_WIDTH (f, 10);
!   f->height = 10;
  
!   XSETFASTINT (XWINDOW (root_window)->width, 10);
!   XSETFASTINT (XWINDOW (root_window)->height, (mini_p ? 9 : 10));
  
    if (mini_p)
      {
!       XSETFASTINT (XWINDOW (mini_window)->width, 10);
!       XSETFASTINT (XWINDOW (mini_window)->top, 9);
!       XSETFASTINT (XWINDOW (mini_window)->height, 1);
      }
  
    /* Choose a buffer for the frame's root window.  */
--- 320,336 ----
       just so that there is "something there."
       Correct size will be set up later with change_frame_size.  */
  
!   SET_FRAME_COLS (f, 10);
!   FRAME_LINES (f) = 10;
  
!   XSETFASTINT (XWINDOW (root_window)->total_cols, 10);
!   XSETFASTINT (XWINDOW (root_window)->total_lines, (mini_p ? 9 : 10));
  
    if (mini_p)
      {
!       XSETFASTINT (XWINDOW (mini_window)->total_cols, 10);
!       XSETFASTINT (XWINDOW (mini_window)->top_line, 9);
!       XSETFASTINT (XWINDOW (mini_window)->total_lines, 1);
      }
  
    /* Choose a buffer for the frame's root window.  */
***************
*** 339,345 ****
         don't have the right size, glyph matrices aren't initialized
         etc.  Running Lisp functions at this point surely ends in a
         SEGV.  */
!     set_window_buffer (root_window, buf, 0);
      f->buffer_list = Fcons (buf, Qnil);
    }
  
--- 350,356 ----
         don't have the right size, glyph matrices aren't initialized
         etc.  Running Lisp functions at this point surely ends in a
         SEGV.  */
!     set_window_buffer (root_window, buf, 0, 0);
      f->buffer_list = Fcons (buf, Qnil);
    }
  
***************
*** 350,356 ****
                         (NILP (Vminibuffer_list)
                          ? get_minibuffer (0)
                          : Fcar (Vminibuffer_list)),
!                        0);
      }
  
    f->root_window = root_window;
--- 361,367 ----
                         (NILP (Vminibuffer_list)
                          ? get_minibuffer (0)
                          : Fcar (Vminibuffer_list)),
!                        0, 0);
      }
  
    f->root_window = root_window;
***************
*** 415,421 ****
      Fset_window_buffer (mini_window,
                        (NILP (Vminibuffer_list)
                         ? get_minibuffer (0)
!                        : Fcar (Vminibuffer_list)));
    return f;
  }
  
--- 426,432 ----
      Fset_window_buffer (mini_window,
                        (NILP (Vminibuffer_list)
                         ? get_minibuffer (0)
!                        : Fcar (Vminibuffer_list)), Qnil);
    return f;
  }
  
***************
*** 453,459 ****
    Fset_window_buffer (mini_window,
                      (NILP (Vminibuffer_list)
                       ? get_minibuffer (0)
!                      : Fcar (Vminibuffer_list)));
    return f;
  }
  #endif /* HAVE_WINDOW_SYSTEM */
--- 464,470 ----
    Fset_window_buffer (mini_window,
                      (NILP (Vminibuffer_list)
                       ? get_minibuffer (0)
!                      : Fcar (Vminibuffer_list)), Qnil);
    return f;
  }
  #endif /* HAVE_WINDOW_SYSTEM */
***************
*** 573,580 ****
  
    f = make_terminal_frame ();
  
!   change_frame_size (f, FRAME_HEIGHT (sf),
!                    FRAME_WIDTH (sf), 0, 0, 0);
    adjust_glyphs (f);
    calculate_costs (f);
    XSETFRAME (frame, f);
--- 584,591 ----
  
    f = make_terminal_frame ();
  
!   change_frame_size (f, FRAME_LINES (sf),
!                    FRAME_COLS (sf), 0, 0, 0);
    adjust_glyphs (f);
    calculate_costs (f);
    XSETFRAME (frame, f);
***************
*** 1228,1234 ****
    if (EQ (f->minibuffer_window, minibuf_window))
      {
        Fset_window_buffer (sf->minibuffer_window,
!                         XWINDOW (minibuf_window)->buffer);
        minibuf_window = sf->minibuffer_window;
  
        /* If the dying minibuffer window was selected,
--- 1239,1245 ----
    if (EQ (f->minibuffer_window, minibuf_window))
      {
        Fset_window_buffer (sf->minibuffer_window,
!                         XWINDOW (minibuf_window)->buffer, Qnil);
        minibuf_window = sf->minibuffer_window;
  
        /* If the dying minibuffer window was selected,
***************
*** 1603,1609 ****
      {
        struct frame *sf = XFRAME (selected_frame);
        Fset_window_buffer (sf->minibuffer_window,
!                         XWINDOW (minibuf_window)->buffer);
        minibuf_window = sf->minibuffer_window;
      }
  
--- 1614,1620 ----
      {
        struct frame *sf = XFRAME (selected_frame);
        Fset_window_buffer (sf->minibuffer_window,
!                         XWINDOW (minibuf_window)->buffer, Qnil);
        minibuf_window = sf->minibuffer_window;
      }
  
***************
*** 1642,1648 ****
      {
        struct frame *sf = XFRAME (selected_frame);
        Fset_window_buffer (sf->minibuffer_window,
!                         XWINDOW (minibuf_window)->buffer);
        minibuf_window = sf->minibuffer_window;
      }
  
--- 1653,1659 ----
      {
        struct frame *sf = XFRAME (selected_frame);
        Fset_window_buffer (sf->minibuffer_window,
!                         XWINDOW (minibuf_window)->buffer, Qnil);
        minibuf_window = sf->minibuffer_window;
      }
  
***************
*** 2080,2088 ****
                                    :"tty"));
      }
    store_in_alist (&alist, Qname, f->name);
!   height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
    store_in_alist (&alist, Qheight, make_number (height));
!   width = (FRAME_NEW_WIDTH (f) ? FRAME_NEW_WIDTH (f) : FRAME_WIDTH (f));
    store_in_alist (&alist, Qwidth, make_number (width));
    store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : 
Qnil));
    store_in_alist (&alist, Qminibuffer,
--- 2091,2099 ----
                                    :"tty"));
      }
    store_in_alist (&alist, Qname, f->name);
!   height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
    store_in_alist (&alist, Qheight, make_number (height));
!   width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
    store_in_alist (&alist, Qwidth, make_number (width));
    store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : 
Qnil));
    store_in_alist (&alist, Qminibuffer,
***************
*** 2336,2342 ****
      return make_number (x_pixel_height (f));
    else
  #endif
!     return make_number (FRAME_HEIGHT (f));
  }
  
  DEFUN ("frame-pixel-width", Fframe_pixel_width,
--- 2347,2353 ----
      return make_number (x_pixel_height (f));
    else
  #endif
!     return make_number (FRAME_LINES (f));
  }
  
  DEFUN ("frame-pixel-width", Fframe_pixel_width,
***************
*** 2359,2365 ****
      return make_number (x_pixel_width (f));
    else
  #endif
!     return make_number (FRAME_WIDTH (f));
  }
  
  DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
--- 2370,2376 ----
      return make_number (x_pixel_width (f));
    else
  #endif
!     return make_number (FRAME_COLS (f));
  }
  
  DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
***************
*** 2381,2388 ****
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       if (XINT (lines) != f->height)
!       x_set_window_size (f, 1, f->width, XINT (lines));
        do_pending_window_change (0);
      }
    else
--- 2392,2399 ----
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       if (XINT (lines) != FRAME_LINES (f))
!       x_set_window_size (f, 1, FRAME_COLS (f), XINT (lines));
        do_pending_window_change (0);
      }
    else
***************
*** 2409,2416 ****
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       if (XINT (cols) != f->width)
!       x_set_window_size (f, 1, XINT (cols), f->height);
        do_pending_window_change (0);
      }
    else
--- 2420,2427 ----
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       if (XINT (cols) != FRAME_COLS (f))
!       x_set_window_size (f, 1, XINT (cols), FRAME_LINES (f));
        do_pending_window_change (0);
      }
    else
***************
*** 2435,2442 ****
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       if (XINT (rows) != f->height || XINT (cols) != f->width
!         || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
        x_set_window_size (f, 1, XINT (cols), XINT (rows));
        do_pending_window_change (0);
      }
--- 2446,2454 ----
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       if (XINT (rows) != FRAME_LINES (f)
!         || XINT (cols) != FRAME_COLS (f)
!         || f->new_text_lines || f->new_text_cols)
        x_set_window_size (f, 1, XINT (cols), XINT (rows));
        do_pending_window_change (0);
      }
***************
*** 2541,2572 ****
       int *top_pos;
       int *left_pos;
  {
!   int newwidth = f->width, newheight = f->height;
  
!   *top_pos = FRAME_X_OUTPUT (f)->top_pos;
!   *left_pos = FRAME_X_OUTPUT (f)->left_pos;
  
!   if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_HEIGHT)
      {
        int ph;
  
        ph = FRAME_X_DISPLAY_INFO (f)->height;
!       newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
!       ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
!         - FRAME_X_OUTPUT (f)->y_pixels_diff;
!       newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
        *top_pos = 0;
      }
  
!   if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_WIDTH)
      {
        int pw;
  
        pw = FRAME_X_DISPLAY_INFO (f)->width;
!       newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
!       pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
!         - FRAME_X_OUTPUT (f)->x_pixels_diff;
!       newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
        *left_pos = 0;
      }
  
--- 2553,2583 ----
       int *top_pos;
       int *left_pos;
  {
!   int newwidth = FRAME_COLS (f);
!   int newheight = FRAME_LINES (f);
  
!   *top_pos = f->top_pos;
!   *left_pos = f->left_pos;
  
!   if (f->want_fullscreen & FULLSCREEN_HEIGHT)
      {
        int ph;
  
        ph = FRAME_X_DISPLAY_INFO (f)->height;
!       newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
!       ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
!       newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
        *top_pos = 0;
      }
  
!   if (f->want_fullscreen & FULLSCREEN_WIDTH)
      {
        int pw;
  
        pw = FRAME_X_DISPLAY_INFO (f)->width;
!       newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
!       pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
!       newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
        *left_pos = 0;
      }
  
***************
*** 2586,2593 ****
       int new_top;
       int new_left;
  {
!   if (new_top != FRAME_X_OUTPUT (f)->top_pos
!       || new_left != FRAME_X_OUTPUT (f)->left_pos)
      {
        int move_x = new_left;
        int move_y = new_top;
--- 2597,2603 ----
       int new_top;
       int new_left;
  {
!   if (new_top != f->top_pos || new_left != f->left_pos)
      {
        int move_x = new_left;
        int move_y = new_top;
***************
*** 2597,2603 ****
        move_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
  #endif
  
!       FRAME_X_OUTPUT (f)->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
        x_set_offset (f, move_x, move_y, 1);
      }
  }
--- 2607,2613 ----
        move_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
  #endif
  
!       f->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
        x_set_offset (f, move_x, move_y, 1);
      }
  }
***************
*** 2668,2682 ****
    icon_left = icon_top = Qunbound;
  
    /* Provide default values for HEIGHT and WIDTH.  */
!   if (FRAME_NEW_WIDTH (f))
!     width = FRAME_NEW_WIDTH (f);
!   else
!     width = FRAME_WIDTH (f);
! 
!   if (FRAME_NEW_HEIGHT (f))
!     height = FRAME_NEW_HEIGHT (f);
!   else
!     height = FRAME_HEIGHT (f);
  
    /* Process foreground_color and background_color before anything else.
       They are independent of other properties, but other properties (e.g.,
--- 2678,2685 ----
    icon_left = icon_top = Qunbound;
  
    /* Provide default values for HEIGHT and WIDTH.  */
!   width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
!   height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
  
    /* Process foreground_color and background_color before anything else.
       They are independent of other properties, but other properties (e.g.,
***************
*** 2760,2777 ****
    if (EQ (left, Qunbound))
      {
        left_no_change = 1;
!       if (FRAME_X_OUTPUT (f)->left_pos < 0)
!       left = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->left_pos), 
Qnil));
        else
!       XSETINT (left, FRAME_X_OUTPUT (f)->left_pos);
      }
    if (EQ (top, Qunbound))
      {
        top_no_change = 1;
!       if (FRAME_X_OUTPUT (f)->top_pos < 0)
!       top = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->top_pos), 
Qnil));
        else
!       XSETINT (top, FRAME_X_OUTPUT (f)->top_pos);
      }
  
    /* If one of the icon positions was not set, preserve or default it.  */
--- 2763,2780 ----
    if (EQ (left, Qunbound))
      {
        left_no_change = 1;
!       if (f->left_pos < 0)
!       left = Fcons (Qplus, Fcons (make_number (f->left_pos), Qnil));
        else
!       XSETINT (left, f->left_pos);
      }
    if (EQ (top, Qunbound))
      {
        top_no_change = 1;
!       if (f->top_pos < 0)
!       top = Fcons (Qplus, Fcons (make_number (f->top_pos), Qnil));
        else
!       XSETINT (top, f->top_pos);
      }
  
    /* If one of the icon positions was not set, preserve or default it.  */
***************
*** 2823,2857 ****
  
      XSETFRAME (frame, f);
  
!     if (width != FRAME_WIDTH (f)
!       || height != FRAME_HEIGHT (f)
!       || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
        Fset_frame_size (frame, make_number (width), make_number (height));
  
      if ((!NILP (left) || !NILP (top))
        && ! (left_no_change && top_no_change)
!       && ! (NUMBERP (left) && XINT (left) == FRAME_X_OUTPUT (f)->left_pos
!             && NUMBERP (top) && XINT (top) == FRAME_X_OUTPUT (f)->top_pos))
        {
        int leftpos = 0;
        int toppos = 0;
  
        /* Record the signs.  */
!       FRAME_X_OUTPUT (f)->size_hint_flags &= ~ (XNegative | YNegative);
        if (EQ (left, Qminus))
!         FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
        else if (INTEGERP (left))
          {
            leftpos = XINT (left);
            if (leftpos < 0)
!             FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qminus)
                 && CONSP (XCDR (left))
                 && INTEGERP (XCAR (XCDR (left))))
          {
            leftpos = - XINT (XCAR (XCDR (left)));
!           FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qplus)
                 && CONSP (XCDR (left))
--- 2826,2860 ----
  
      XSETFRAME (frame, f);
  
!     if (width != FRAME_COLS (f)
!       || height != FRAME_LINES (f)
!       || f->new_text_lines || f->new_text_cols)
        Fset_frame_size (frame, make_number (width), make_number (height));
  
      if ((!NILP (left) || !NILP (top))
        && ! (left_no_change && top_no_change)
!       && ! (NUMBERP (left) && XINT (left) == f->left_pos
!             && NUMBERP (top) && XINT (top) == f->top_pos))
        {
        int leftpos = 0;
        int toppos = 0;
  
        /* Record the signs.  */
!       f->size_hint_flags &= ~ (XNegative | YNegative);
        if (EQ (left, Qminus))
!         f->size_hint_flags |= XNegative;
        else if (INTEGERP (left))
          {
            leftpos = XINT (left);
            if (leftpos < 0)
!             f->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qminus)
                 && CONSP (XCDR (left))
                 && INTEGERP (XCAR (XCDR (left))))
          {
            leftpos = - XINT (XCAR (XCDR (left)));
!           f->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qplus)
                 && CONSP (XCDR (left))
***************
*** 2861,2879 ****
          }
  
        if (EQ (top, Qminus))
!         FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
        else if (INTEGERP (top))
          {
            toppos = XINT (top);
            if (toppos < 0)
!             FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qminus)
                 && CONSP (XCDR (top))
                 && INTEGERP (XCAR (XCDR (top))))
          {
            toppos = - XINT (XCAR (XCDR (top)));
!           FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qplus)
                 && CONSP (XCDR (top))
--- 2864,2882 ----
          }
  
        if (EQ (top, Qminus))
!         f->size_hint_flags |= YNegative;
        else if (INTEGERP (top))
          {
            toppos = XINT (top);
            if (toppos < 0)
!             f->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qminus)
                 && CONSP (XCDR (top))
                 && INTEGERP (XCAR (XCDR (top))))
          {
            toppos = - XINT (XCAR (XCDR (top)));
!           f->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qplus)
                 && CONSP (XCDR (top))
***************
*** 2884,2893 ****
  
  
        /* Store the numeric value of the position.  */
!       FRAME_X_OUTPUT (f)->top_pos = toppos;
!       FRAME_X_OUTPUT (f)->left_pos = leftpos;
  
!       FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity;
  
        /* Actually set that position, and convert to absolute.  */
        x_set_offset (f, leftpos, toppos, -1);
--- 2887,2896 ----
  
  
        /* Store the numeric value of the position.  */
!       f->top_pos = toppos;
!       f->left_pos = leftpos;
  
!       f->win_gravity = NorthWestGravity;
  
        /* Actually set that position, and convert to absolute.  */
        x_set_offset (f, leftpos, toppos, -1);
***************
*** 2918,2948 ****
  
    /* Represent negative positions (off the top or left screen edge)
       in a way that Fmodify_frame_parameters will understand correctly.  */
!   XSETINT (tem, FRAME_X_OUTPUT (f)->left_pos);
!   if (FRAME_X_OUTPUT (f)->left_pos >= 0)
      store_in_alist (alistptr, Qleft, tem);
    else
      store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
  
!   XSETINT (tem, FRAME_X_OUTPUT (f)->top_pos);
!   if (FRAME_X_OUTPUT (f)->top_pos >= 0)
      store_in_alist (alistptr, Qtop, tem);
    else
      store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
  
    store_in_alist (alistptr, Qborder_width,
!                 make_number (FRAME_X_OUTPUT (f)->border_width));
    store_in_alist (alistptr, Qinternal_border_width,
!                 make_number (FRAME_X_OUTPUT (f)->internal_border_width));
    store_in_alist (alistptr, Qleft_fringe,
!                 make_number (FRAME_X_OUTPUT (f)->left_fringe_width));
    store_in_alist (alistptr, Qright_fringe,
!                 make_number (FRAME_X_OUTPUT (f)->right_fringe_width));
    store_in_alist (alistptr, Qscroll_bar_width,
                  (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
                   ? make_number (0)
!                  : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
!                  ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
                   /* nil means "use default width"
                      for non-toolkit scroll bar.
                      ruler-mode.el depends on this.  */
--- 2921,2951 ----
  
    /* Represent negative positions (off the top or left screen edge)
       in a way that Fmodify_frame_parameters will understand correctly.  */
!   XSETINT (tem, f->left_pos);
!   if (f->left_pos >= 0)
      store_in_alist (alistptr, Qleft, tem);
    else
      store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
  
!   XSETINT (tem, f->top_pos);
!   if (f->top_pos >= 0)
      store_in_alist (alistptr, Qtop, tem);
    else
      store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
  
    store_in_alist (alistptr, Qborder_width,
!                 make_number (f->border_width));
    store_in_alist (alistptr, Qinternal_border_width,
!                 make_number (FRAME_INTERNAL_BORDER_WIDTH (f)));
    store_in_alist (alistptr, Qleft_fringe,
!                 make_number (FRAME_LEFT_FRINGE_WIDTH (f)));
    store_in_alist (alistptr, Qright_fringe,
!                 make_number (FRAME_RIGHT_FRINGE_WIDTH (f)));
    store_in_alist (alistptr, Qscroll_bar_width,
                  (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
                   ? make_number (0)
!                  : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
!                  ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
                   /* nil means "use default width"
                      for non-toolkit scroll bar.
                      ruler-mode.el depends on this.  */
***************
*** 2988,3000 ****
  {
  #ifndef HAVE_CARBON
    if (NILP (new_value))
!     FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_NONE;
    else if (EQ (new_value, Qfullboth))
!     FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_BOTH;
    else if (EQ (new_value, Qfullwidth))
!     FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_WIDTH;
    else if (EQ (new_value, Qfullheight))
!     FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_HEIGHT;
  #endif
  }
  
--- 2991,3003 ----
  {
  #ifndef HAVE_CARBON
    if (NILP (new_value))
!     f->want_fullscreen = FULLSCREEN_NONE;
    else if (EQ (new_value, Qfullboth))
!     f->want_fullscreen = FULLSCREEN_BOTH;
    else if (EQ (new_value, Qfullwidth))
!     f->want_fullscreen = FULLSCREEN_WIDTH;
    else if (EQ (new_value, Qfullheight))
!     f->want_fullscreen = FULLSCREEN_HEIGHT;
  #endif
  }
  
***************
*** 3112,3118 ****
  {
    CHECK_NUMBER (arg);
  
!   if (XINT (arg) == FRAME_X_OUTPUT (f)->border_width)
      return;
  
  #ifndef HAVE_CARBON
--- 3115,3121 ----
  {
    CHECK_NUMBER (arg);
  
!   if (XINT (arg) == f->border_width)
      return;
  
  #ifndef HAVE_CARBON
***************
*** 3120,3126 ****
      error ("Cannot change the border width of a window");
  #endif /* MAC_TODO */
  
!   FRAME_X_OUTPUT (f)->border_width = XINT (arg);
  }
  
  void
--- 3123,3129 ----
      error ("Cannot change the border width of a window");
  #endif /* MAC_TODO */
  
!   f->border_width = XINT (arg);
  }
  
  void
***************
*** 3128,3151 ****
       struct frame *f;
       Lisp_Object arg, oldval;
  {
!   int old = FRAME_X_OUTPUT (f)->internal_border_width;
  
    CHECK_NUMBER (arg);
!   FRAME_X_OUTPUT (f)->internal_border_width = XINT (arg);
!   if (FRAME_X_OUTPUT (f)->internal_border_width < 0)
!     FRAME_X_OUTPUT (f)->internal_border_width = 0;
  
  #ifdef USE_X_TOOLKIT
    if (FRAME_X_OUTPUT (f)->edit_widget)
      widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
  #endif
  
!   if (FRAME_X_OUTPUT (f)->internal_border_width == old)
      return;
  
    if (FRAME_X_WINDOW (f) != 0)
      {
!       x_set_window_size (f, 0, f->width, f->height);
        SET_FRAME_GARBAGED (f);
        do_pending_window_change (0);
      }
--- 3131,3154 ----
       struct frame *f;
       Lisp_Object arg, oldval;
  {
!   int old = FRAME_INTERNAL_BORDER_WIDTH (f);
  
    CHECK_NUMBER (arg);
!   FRAME_INTERNAL_BORDER_WIDTH (f) = XINT (arg);
!   if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0)
!     FRAME_INTERNAL_BORDER_WIDTH (f) = 0;
  
  #ifdef USE_X_TOOLKIT
    if (FRAME_X_OUTPUT (f)->edit_widget)
      widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
  #endif
  
!   if (FRAME_INTERNAL_BORDER_WIDTH (f) == old)
      return;
  
    if (FRAME_X_WINDOW (f) != 0)
      {
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
        SET_FRAME_GARBAGED (f);
        do_pending_window_change (0);
      }
***************
*** 3223,3229 ****
         However, if the window hasn't been created yet, we shouldn't
         call x_set_window_size.  */
        if (FRAME_X_WINDOW (f))
!       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
        do_pending_window_change (0);
      }
  }
--- 3226,3232 ----
         However, if the window hasn't been created yet, we shouldn't
         call x_set_window_size.  */
        if (FRAME_X_WINDOW (f))
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
        do_pending_window_change (0);
      }
  }
***************
*** 3233,3262 ****
       struct frame *f;
       Lisp_Object arg, oldval;
  {
!   int wid = FONT_WIDTH (FRAME_FONT (f));
  
    if (NILP (arg))
      {
        x_set_scroll_bar_default_width (f);
  
        if (FRAME_X_WINDOW (f))
!         x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
        do_pending_window_change (0);
      }
    else if (INTEGERP (arg) && XINT (arg) > 0
!          && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
      {
        if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
        XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
  
!       FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
!       FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
        if (FRAME_X_WINDOW (f))
!       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
        do_pending_window_change (0);
      }
  
!   change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
  }
--- 3236,3265 ----
       struct frame *f;
       Lisp_Object arg, oldval;
  {
!   int wid = FRAME_COLUMN_WIDTH (f);
  
    if (NILP (arg))
      {
        x_set_scroll_bar_default_width (f);
  
        if (FRAME_X_WINDOW (f))
!         x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
        do_pending_window_change (0);
      }
    else if (INTEGERP (arg) && XINT (arg) > 0
!          && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
      {
        if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
        XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
  
!       FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
        if (FRAME_X_WINDOW (f))
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
        do_pending_window_change (0);
      }
  
!   change_frame_size (f, 0, FRAME_COLS (f), 0, 0, 0);
    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
  }
***************
*** 3706,3723 ****
    /* Default values if we fall through.
       Actually, if that happens we should get
       window manager prompting.  */
!   SET_FRAME_WIDTH (f, DEFAULT_COLS);
!   f->height = DEFAULT_ROWS;
    /* Window managers expect that if program-specified
       positions are not (0,0), they're intentional, not defaults.  */
!   FRAME_X_OUTPUT (f)->top_pos = 0;
!   FRAME_X_OUTPUT (f)->left_pos = 0;
  
!   /* Ensure that old new_width and new_height will not override the
       values set here.  */
    /* ++KFS: This was specific to W32, but seems ok for all platforms */
!   FRAME_NEW_WIDTH (f) = 0;
!   FRAME_NEW_HEIGHT (f) = 0;
  
    tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
    tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
--- 3709,3725 ----
    /* Default values if we fall through.
       Actually, if that happens we should get
       window manager prompting.  */
!   SET_FRAME_COLS (f, DEFAULT_COLS);
!   FRAME_LINES (f) = DEFAULT_ROWS;
    /* Window managers expect that if program-specified
       positions are not (0,0), they're intentional, not defaults.  */
!   f->top_pos = 0;
!   f->left_pos = 0;
  
!   /* Ensure that old new_text_cols and new_text_lines will not override the
       values set here.  */
    /* ++KFS: This was specific to W32, but seems ok for all platforms */
!   f->new_text_cols = f->new_text_lines = 0;
  
    tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
    tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
***************
*** 3727,3738 ****
        if (!EQ (tem0, Qunbound))
        {
          CHECK_NUMBER (tem0);
!         f->height = XINT (tem0);
        }
        if (!EQ (tem1, Qunbound))
        {
          CHECK_NUMBER (tem1);
!         SET_FRAME_WIDTH (f, XINT (tem1));
        }
        if (!NILP (tem2) && !EQ (tem2, Qunbound))
        window_prompting |= USSize;
--- 3729,3740 ----
        if (!EQ (tem0, Qunbound))
        {
          CHECK_NUMBER (tem0);
!         FRAME_LINES (f) = XINT (tem0);
        }
        if (!EQ (tem1, Qunbound))
        {
          CHECK_NUMBER (tem1);
!         SET_FRAME_COLS (f, XINT (tem1));
        }
        if (!NILP (tem2) && !EQ (tem2, Qunbound))
        window_prompting |= USSize;
***************
*** 3740,3754 ****
        window_prompting |= PSize;
      }
  
!   FRAME_X_OUTPUT (f)->vertical_scroll_bar_extra
!     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
!        ? 0
! #ifndef HAVE_X_WINDOWS
!        /* +KFS: This was specific for W32 and MAC.. why?  */
!        : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
!        ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
! #endif
!        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (FRAME_X_OUTPUT (f)->font)));
  
    /* This used to be done _before_ calling x_figure_window_size, but
       since the height is reset here, this was really a no-op.  I
--- 3742,3749 ----
        window_prompting |= PSize;
      }
  
!   f->scroll_bar_actual_width
!     = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
  
    /* This used to be done _before_ calling x_figure_window_size, but
       since the height is reset here, this was really a no-op.  I
***************
*** 3780,3792 ****
        margin = 0;
  
        bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
!       f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
      }
  
    compute_fringe_widths (f, 0);
  
!   FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
!   FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
  
    tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
    tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
--- 3775,3787 ----
        margin = 0;
  
        bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
!       FRAME_LINES (f) += (bar_height + FRAME_LINE_HEIGHT (f) - 1) / 
FRAME_LINE_HEIGHT (f);
      }
  
    compute_fringe_widths (f, 0);
  
!   FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f));
!   FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES 
(f));
  
    tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
    tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
***************
*** 3795,3851 ****
      {
        if (EQ (tem0, Qminus))
        {
!         FRAME_X_OUTPUT (f)->top_pos = 0;
          window_prompting |= YNegative;
        }
        else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
               && CONSP (XCDR (tem0))
               && INTEGERP (XCAR (XCDR (tem0))))
        {
!         FRAME_X_OUTPUT (f)->top_pos = - XINT (XCAR (XCDR (tem0)));
          window_prompting |= YNegative;
        }
        else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
               && CONSP (XCDR (tem0))
               && INTEGERP (XCAR (XCDR (tem0))))
        {
!         FRAME_X_OUTPUT (f)->top_pos = XINT (XCAR (XCDR (tem0)));
        }
        else if (EQ (tem0, Qunbound))
!       FRAME_X_OUTPUT (f)->top_pos = 0;
        else
        {
          CHECK_NUMBER (tem0);
!         FRAME_X_OUTPUT (f)->top_pos = XINT (tem0);
!         if (FRAME_X_OUTPUT (f)->top_pos < 0)
            window_prompting |= YNegative;
        }
  
        if (EQ (tem1, Qminus))
        {
!         FRAME_X_OUTPUT (f)->left_pos = 0;
          window_prompting |= XNegative;
        }
        else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
               && CONSP (XCDR (tem1))
               && INTEGERP (XCAR (XCDR (tem1))))
        {
!         FRAME_X_OUTPUT (f)->left_pos = - XINT (XCAR (XCDR (tem1)));
          window_prompting |= XNegative;
        }
        else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
               && CONSP (XCDR (tem1))
               && INTEGERP (XCAR (XCDR (tem1))))
        {
!         FRAME_X_OUTPUT (f)->left_pos = XINT (XCAR (XCDR (tem1)));
        }
        else if (EQ (tem1, Qunbound))
!       FRAME_X_OUTPUT (f)->left_pos = 0;
        else
        {
          CHECK_NUMBER (tem1);
!         FRAME_X_OUTPUT (f)->left_pos = XINT (tem1);
!         if (FRAME_X_OUTPUT (f)->left_pos < 0)
            window_prompting |= XNegative;
        }
  
--- 3790,3846 ----
      {
        if (EQ (tem0, Qminus))
        {
!         f->top_pos = 0;
          window_prompting |= YNegative;
        }
        else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
               && CONSP (XCDR (tem0))
               && INTEGERP (XCAR (XCDR (tem0))))
        {
!         f->top_pos = - XINT (XCAR (XCDR (tem0)));
          window_prompting |= YNegative;
        }
        else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
               && CONSP (XCDR (tem0))
               && INTEGERP (XCAR (XCDR (tem0))))
        {
!         f->top_pos = XINT (XCAR (XCDR (tem0)));
        }
        else if (EQ (tem0, Qunbound))
!       f->top_pos = 0;
        else
        {
          CHECK_NUMBER (tem0);
!         f->top_pos = XINT (tem0);
!         if (f->top_pos < 0)
            window_prompting |= YNegative;
        }
  
        if (EQ (tem1, Qminus))
        {
!         f->left_pos = 0;
          window_prompting |= XNegative;
        }
        else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
               && CONSP (XCDR (tem1))
               && INTEGERP (XCAR (XCDR (tem1))))
        {
!         f->left_pos = - XINT (XCAR (XCDR (tem1)));
          window_prompting |= XNegative;
        }
        else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
               && CONSP (XCDR (tem1))
               && INTEGERP (XCAR (XCDR (tem1))))
        {
!         f->left_pos = XINT (XCAR (XCDR (tem1)));
        }
        else if (EQ (tem1, Qunbound))
!       f->left_pos = 0;
        else
        {
          CHECK_NUMBER (tem1);
!         f->left_pos = XINT (tem1);
!         if (f->left_pos < 0)
            window_prompting |= XNegative;
        }
  
***************
*** 3855,3861 ****
        window_prompting |= PPosition;
      }
  
!   if (FRAME_X_OUTPUT (f)->want_fullscreen != FULLSCREEN_NONE)
      {
        int left, top;
        int width, height;
--- 3850,3856 ----
        window_prompting |= PPosition;
      }
  
!   if (f->want_fullscreen != FULLSCREEN_NONE)
      {
        int left, top;
        int width, height;
***************
*** 3863,3892 ****
        /* It takes both for some WM:s to place it where we want */
        window_prompting = USPosition | PPosition;
        x_fullscreen_adjust (f, &width, &height, &top, &left);
!       f->width = width;
!       f->height = height;
!       FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
!       FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
!       FRAME_X_OUTPUT (f)->left_pos = left;
!       FRAME_X_OUTPUT (f)->top_pos = top;
      }
  
    if (window_prompting & XNegative)
      {
        if (window_prompting & YNegative)
!       FRAME_X_OUTPUT (f)->win_gravity = SouthEastGravity;
        else
!       FRAME_X_OUTPUT (f)->win_gravity = NorthEastGravity;
      }
    else
      {
        if (window_prompting & YNegative)
!       FRAME_X_OUTPUT (f)->win_gravity = SouthWestGravity;
        else
!       FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity;
      }
  
!   FRAME_X_OUTPUT (f)->size_hint_flags = window_prompting;
  
    return window_prompting;
  }
--- 3858,3887 ----
        /* It takes both for some WM:s to place it where we want */
        window_prompting = USPosition | PPosition;
        x_fullscreen_adjust (f, &width, &height, &top, &left);
!       FRAME_COLS (f) = width;
!       FRAME_LINES (f) = height;
!       FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width);
!       FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height);
!       f->left_pos = left;
!       f->top_pos = top;
      }
  
    if (window_prompting & XNegative)
      {
        if (window_prompting & YNegative)
!       f->win_gravity = SouthEastGravity;
        else
!       f->win_gravity = NorthEastGravity;
      }
    else
      {
        if (window_prompting & YNegative)
!       f->win_gravity = SouthWestGravity;
        else
!       f->win_gravity = NorthWestGravity;
      }
  
!   f->size_hint_flags = window_prompting;
  
    return window_prompting;
  }
Index: frame.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/frame.h,v
retrieving revision 1.101
diff -c -r1.101 frame.h
*** frame.h     31 Mar 2003 20:34:17 -0000      1.101
--- frame.h     14 May 2003 21:52:11 -0000
***************
*** 81,88 ****
    PIX_TYPE foreground_pixel;
  };
  
- #define FRAME_INTERNAL_BORDER_WIDTH(f) 0
- 
  #endif /* ! HAVE_X_WINDOWS */
  
  
--- 81,86 ----
***************
*** 238,251 ****
    /* Cost of deleting n lines on this frame */
    int *delete_n_lines_cost;
  
!   /* Size of this frame, in units of characters.  */
!   EMACS_INT height;
!   EMACS_INT width;
!   EMACS_INT window_width;
!   EMACS_INT window_height;
  
!   /* New height and width for pending size change.  0 if no change pending.  
*/
!   int new_height, new_width;
  
    /* The output method says how the contents of this frame
       are displayed.  It could be using termcap, or using an X window.  */
--- 236,282 ----
    /* Cost of deleting n lines on this frame */
    int *delete_n_lines_cost;
  
!   /* Size of this frame, excluding fringes, scroll bars etc.,
!      in units of canonical characters.  */
!   EMACS_INT text_lines, text_cols;
! 
!   /* Total size of this frame (i.e. its native window), in units of
!      canonical characters.  */
!   EMACS_INT total_lines, total_cols;
! 
!   /* New text height and width for pending size change.
!      0 if no change pending.  */
!   int new_text_lines, new_text_cols;
! 
!   /* Pixel position of the frame window (x and y offsets in root window).  */
!   int left_pos, top_pos;
! 
!   /* Size of the frame window in pixels.  */
!   int pixel_height, pixel_width;
! 
!   /* These many pixels are the difference between the outer window (i.e. the
!      left and top of the window manager decoration) and FRAME_X_WINDOW. */
!   int x_pixels_diff, y_pixels_diff;
! 
!   /* This is the gravity value for the specified window position.  */
!   int win_gravity;
! 
!   /* The geometry flags for this window.  */
!   int size_hint_flags;
! 
!   /* Border width of the frame window as known by the (X) window system.  */
!   int border_width;
! 
!   /* Width of the internal border.  This is a line of background color
!      just inside the window's border.  When the frame is selected,
!      a highlighting is displayed inside the internal border.  */
!   int internal_border_width;
! 
!   /* Canonical X unit.  Width of default font, in pixels.  */
!   int column_width;
  
!   /* Canonical Y unit.  Height of a line, in pixels.  */
!   int line_height;
  
    /* The output method says how the contents of this frame
       are displayed.  It could be using termcap, or using an X window.  */
***************
*** 265,270 ****
--- 296,311 ----
    }
    output_data;
  
+   /* Total width of fringes reserved for drawing truncation bitmaps,
+      continuation bitmaps and alike.  The width is in canonical char
+      units of the frame.  This must currently be the case because window
+      sizes aren't pixel values.  If it weren't the case, we wouldn't be
+      able to split windows horizontally nicely.  */
+   int fringe_cols;
+ 
+   /* The extra width (in pixels) currently allotted for fringes.  */
+   int left_fringe_width, right_fringe_width;
+ 
  #ifdef MULTI_KBOARD
    /* A pointer to the kboard structure associated with this frame.
       For termcap frames, this points to initial_kboard.  For X frames,
***************
*** 272,277 ****
--- 313,321 ----
    struct kboard *kboard;
  #endif
  
+   /* See FULLSCREEN_ enum below */
+   int want_fullscreen;
+ 
    /* Number of lines of menu bar.  */
    int menu_bar_lines;
  
***************
*** 377,388 ****
       for lines beyond a certain vpos.  This is the vpos.  */
    int scroll_bottom_vpos;
  
!   /* Width of the scroll bar, in pixels and in characters.
!      scroll_bar_cols tracks scroll_bar_pixel_width if the latter is positive;
!      a zero value in scroll_bar_pixel_width means to compute the actual width
!      on the fly, using scroll_bar_cols and the current font width.  */
!   int scroll_bar_pixel_width;
!   int scroll_bar_cols;
  
    /* The baud rate that was used to calculate costs for this frame.  */
    int cost_calculation_baud_rate;
--- 421,437 ----
       for lines beyond a certain vpos.  This is the vpos.  */
    int scroll_bottom_vpos;
  
!   /* Configured width of the scroll bar, in pixels and in characters.
!      config_scroll_bar_cols tracks config_scroll_bar_width if the
!      latter is positive; a zero value in config_scroll_bar_width means
!      to compute the actual width on the fly, using config_scroll_bar_cols
!      and the current font width.  */
!   int config_scroll_bar_width;
!   int config_scroll_bar_cols;
! 
!   /* The size of the extra width currently allotted for vertical
!      scroll bars in this frame, in pixels.  */
!   int scroll_bar_actual_width;
  
    /* The baud rate that was used to calculate costs for this frame.  */
    int cost_calculation_baud_rate;
***************
*** 451,466 ****
  /* Nonzero if frame F contains a minibuffer window.
     (If this is 0, F must use some other minibuffer window.)  */
  #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
- #define FRAME_HEIGHT(f) (f)->height
  
! /* Width of frame F, measured in character columns,
     not including scroll bars if any.  */
! #define FRAME_WIDTH(f) (f)->width
  
  /* Number of lines of frame F used for menu bar.
     This is relevant on terminal frames and on
     X Windows when not using the X toolkit.
!    These lines are counted in FRAME_HEIGHT.  */
  #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
  
  /* Nonzero if this frame should display a tool bar
--- 500,525 ----
  /* Nonzero if frame F contains a minibuffer window.
     (If this is 0, F must use some other minibuffer window.)  */
  #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
  
! /* Pixel height of frame F, including non-toolkit menu bar and
!    non-toolkit tool bar lines.  */
! #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
! 
! /* Pixel width of frame F.  */
! #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
! 
! /* Height of frame F, measured in canonical lines, including
!    non-toolkit menu bar and non-toolkit tool bar lines.  */
! #define FRAME_LINES(f) (f)->text_lines
! 
! /* Width of frame F, measured in canonical character columns,
     not including scroll bars if any.  */
! #define FRAME_COLS(f) (f)->text_cols
  
  /* Number of lines of frame F used for menu bar.
     This is relevant on terminal frames and on
     X Windows when not using the X toolkit.
!    These lines are counted in FRAME_LINES.  */
  #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
  
  /* Nonzero if this frame should display a tool bar
***************
*** 512,520 ****
     but not yet really put into effect.  This can be true temporarily
     when an X event comes in at a bad time.  */
  #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
- /* When a size change is pending, these are the requested new sizes.  */
- #define FRAME_NEW_HEIGHT(f) (f)->new_height
- #define FRAME_NEW_WIDTH(f) (f)->new_width
  
  /* The minibuffer window of frame F, if it has one; otherwise nil.  */
  #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
--- 571,576 ----
***************
*** 551,610 ****
  /* Width that a scroll bar in frame F should have, if there is one.
     Measured in pixels.
     If scroll bars are turned off, this is still nonzero.  */
! #define FRAME_SCROLL_BAR_PIXEL_WIDTH(f) ((f)->scroll_bar_pixel_width)
  
  /* Width that a scroll bar in frame F should have, if there is one.
     Measured in columns (characters).
     If scroll bars are turned off, this is still nonzero.  */
! #define FRAME_SCROLL_BAR_COLS(f) ((f)->scroll_bar_cols)
  
  /* Width of a scroll bar in frame F, measured in columns (characters),
     but only if scroll bars are on the left.  If scroll bars are on
     the right in this frame, or there are no scroll bars, value is 0.  */
  
! #define FRAME_LEFT_SCROLL_BAR_WIDTH(f)                        \
       (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)      \
!       ? FRAME_SCROLL_BAR_COLS (f)                     \
        : 0)
  
  /* Width of a scroll bar in frame F, measured in columns (characters),
     but only if scroll bars are on the right.  If scroll bars are on
     the left in this frame, or there are no scroll bars, value is 0.  */
  
! #define FRAME_RIGHT_SCROLL_BAR_WIDTH(f)                       \
       (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)     \
!       ? FRAME_SCROLL_BAR_COLS (f)                     \
        : 0)
  
! /* Width of a scroll bar in frame F, measured in columns (characters).  */
! #define FRAME_SCROLL_BAR_WIDTH(f) \
!      (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
!       ? FRAME_SCROLL_BAR_COLS (f) \
        : 0)
  
  /* Total width of frame F, in columns (characters),
     including the width used by scroll bars if any.  */
! #define FRAME_WINDOW_WIDTH(f) ((f)->window_width)
  
  /* Set the width of frame F to VAL.
     VAL is the width of a full-frame window,
!    not including scroll bars.  */
! #define SET_FRAME_WIDTH(f, val)                                               
\
!      ((f)->width = (val),                                             \
!       (f)->window_width = FRAME_WINDOW_WIDTH_ARG (f, (f)->width))
  
  /* Given a value WIDTH for frame F's nominal width,
!    return the value that FRAME_WINDOW_WIDTH should have.  */
! #define FRAME_WINDOW_WIDTH_ARG(f, width)      \
       ((width)                                 \
!       + FRAME_SCROLL_BAR_WIDTH (f)            \
        + FRAME_FRINGE_COLS (f))
  
  /* Maximum + 1 legitimate value for FRAME_CURSOR_X.  */
  #define FRAME_CURSOR_X_LIMIT(f) \
!      (FRAME_WIDTH (f) + FRAME_LEFT_SCROLL_BAR_WIDTH (f))
  
  /* Nonzero if frame F has scroll bars.  */
  #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
  
  #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
--- 607,693 ----
  /* Width that a scroll bar in frame F should have, if there is one.
     Measured in pixels.
     If scroll bars are turned off, this is still nonzero.  */
! #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
  
  /* Width that a scroll bar in frame F should have, if there is one.
     Measured in columns (characters).
     If scroll bars are turned off, this is still nonzero.  */
! #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
  
  /* Width of a scroll bar in frame F, measured in columns (characters),
     but only if scroll bars are on the left.  If scroll bars are on
     the right in this frame, or there are no scroll bars, value is 0.  */
  
! #define FRAME_LEFT_SCROLL_BAR_COLS(f)                 \
       (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)      \
!       ? FRAME_CONFIG_SCROLL_BAR_COLS (f)              \
        : 0)
  
+ /* Width of a left scroll bar in frame F, measured in pixels */
+ 
+ #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f)                                   
\
+   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)                         \
+    ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))      \
+    : 0)
+ 
  /* Width of a scroll bar in frame F, measured in columns (characters),
     but only if scroll bars are on the right.  If scroll bars are on
     the left in this frame, or there are no scroll bars, value is 0.  */
  
! #define FRAME_RIGHT_SCROLL_BAR_COLS(f)                        \
       (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)     \
!       ? FRAME_CONFIG_SCROLL_BAR_COLS (f)              \
        : 0)
  
! /* Width of a right scroll bar area in frame F, measured in pixels */
! 
! #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f)                                  
\
!   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)                                
\
!    ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))      \
!    : 0)
! 
! /* Actual width of a scroll bar in frame F, measured in columns.  */
! 
! #define FRAME_SCROLL_BAR_COLS(f)                      \
!      (FRAME_HAS_VERTICAL_SCROLL_BARS (f)              \
!       ? FRAME_CONFIG_SCROLL_BAR_COLS (f)              \
        : 0)
  
+ /* Actual width of a scroll bar area in frame F, measured in pixels.  */
+ 
+ #define FRAME_SCROLL_BAR_AREA_WIDTH(f)                                        
\
+   (FRAME_HAS_VERTICAL_SCROLL_BARS (f)                                 \
+    ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))      \
+    : 0)
+ 
  /* Total width of frame F, in columns (characters),
     including the width used by scroll bars if any.  */
! 
! #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
  
  /* Set the width of frame F to VAL.
     VAL is the width of a full-frame window,
!    not including scroll bars and fringes.  */
! 
! #define SET_FRAME_COLS(f, val)                                                
\
!      (FRAME_COLS (f) = (val),                                         \
!       (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
  
  /* Given a value WIDTH for frame F's nominal width,
!    return the value that FRAME_TOTAL_COLS should have.  */
! 
! #define FRAME_TOTAL_COLS_ARG(f, width)                \
       ((width)                                 \
!       + FRAME_SCROLL_BAR_COLS (f)             \
        + FRAME_FRINGE_COLS (f))
  
  /* Maximum + 1 legitimate value for FRAME_CURSOR_X.  */
+ 
  #define FRAME_CURSOR_X_LIMIT(f) \
!      (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
  
  /* Nonzero if frame F has scroll bars.  */
+ 
  #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
  
  #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
***************
*** 624,630 ****
     width of the frame by 4 because multi-byte form may require at most
     4-byte for a character.  */
  
! #define FRAME_MESSAGE_BUF_SIZE(f) (((int) (f)->width) * 4)
  
  /* Emacs's redisplay code could become confused if a frame's
     visibility changes at arbitrary times.  For example, if a frame is
--- 707,713 ----
     width of the frame by 4 because multi-byte form may require at most
     4-byte for a character.  */
  
! #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
  
  /* Emacs's redisplay code could become confused if a frame's
     visibility changes at arbitrary times.  For example, if a frame is
***************
*** 711,738 ****
  enum text_cursor_kinds get_specified_cursor_type P_ ((Lisp_Object, int *));
  enum text_cursor_kinds get_window_cursor_type P_ ((struct window *, int *, 
int *));
  
- /* Device-independent scroll bar stuff.  */
- 
- /* Return the starting column (zero-based) of the vertical scroll bar
-    for window W.  The column before this one is the last column we can
-    use for text.  If the window touches the right edge of the frame,
-    we have extra space allocated for it.  Otherwise, the scroll bar
-    takes over the window's rightmost columns.  */
- 
- #define WINDOW_VERTICAL_SCROLL_BAR_COLUMN(w) \
-   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (XFRAME (WINDOW_FRAME (w))) ? \
-     (((XINT ((w)->left) + XINT ((w)->width)) \
-       < FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) \
-      ? (XINT ((w)->left) + XINT ((w)->width) \
-        - FRAME_SCROLL_BAR_COLS (XFRAME (WINDOW_FRAME (w)))) \
-      : FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) \
-   : XINT ((w)->left))
- 
- /* Return the height in lines of the vertical scroll bar in w.  If the
-    window has a mode line, don't make the scroll bar extend that far.  */
- 
- #define WINDOW_VERTICAL_SCROLL_BAR_HEIGHT(w) (window_internal_height (w))
- 
  /* The currently selected frame.  */
  
  extern Lisp_Object selected_frame;
--- 794,799 ----
***************
*** 751,790 ****
                        Display-related Macros
   ***********************************************************************/
  
! /* Canonical y-unit on frame F.  This value currently equals the line
!    height of the frame.  Terminal specific header files are expected
!    to define the macro FRAME_LINE_HEIGHT.  */
! 
! #define CANON_Y_UNIT(F) \
!      (FRAME_WINDOW_P (F) ? FRAME_LINE_HEIGHT (F) : 1)
! 
! /* Canonical x-unit on frame F.  This is currently equal to the width
!    of the default font of F.  Terminal specific headers are expected
!    to define the macro FRAME_DEFAULT_FONT_WIDTH.  */
  
- #define CANON_X_UNIT(F) \
-      (FRAME_WINDOW_P (F) ? FRAME_DEFAULT_FONT_WIDTH (F) : 1)
  
  /* Pixel width of areas used to display truncation marks, continuation
     marks, overlay arrows.  This is 0 for terminal frames.  */
  
  #ifdef HAVE_WINDOW_SYSTEM
  
! #define FRAME_FRINGE_COLS(F) \
!      (FRAME_WINDOW_P (F) ? FRAME_X_FRINGE_COLS (F) : 0)
! #define FRAME_FRINGE_WIDTH(F) \
!      (FRAME_WINDOW_P (F) ? FRAME_X_FRINGE_WIDTH (F) : 0)
! #define FRAME_LEFT_FRINGE_WIDTH(F) \
!      (FRAME_WINDOW_P (F) ? FRAME_X_LEFT_FRINGE_WIDTH (F) : 0)
! #define FRAME_RIGHT_FRINGE_WIDTH(F) \
!      (FRAME_WINDOW_P (F) ? FRAME_X_RIGHT_FRINGE_WIDTH (F) : 0)
  
  #else /* not HAVE_WINDOW_SYSTEM */
  
- #define FRAME_FRINGE_WIDTH(F) 0
  #define FRAME_FRINGE_COLS(F)  0
  #define FRAME_LEFT_FRINGE_WIDTH(F)  0
  #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
  
  #endif /* not HAVE_WINDOW_SYSTEM */
  
--- 812,864 ----
                        Display-related Macros
   ***********************************************************************/
  
! /* Canonical y-unit on frame F.  
!    This value currently equals the line height of the frame (which is
!    the height of the default font of F).  */
! 
! #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
! 
! /* Canonical x-unit on frame F. 
!    This value currently equals the width of the default font of F.  */
! 
! #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
  
  
  /* Pixel width of areas used to display truncation marks, continuation
     marks, overlay arrows.  This is 0 for terminal frames.  */
  
  #ifdef HAVE_WINDOW_SYSTEM
  
! /* Total width of fringes reserved for drawing truncation bitmaps,
!    continuation bitmaps and alike.  The width is in canonical char
!    units of the frame.  This must currently be the case because window
!    sizes aren't pixel values.  If it weren't the case, we wouldn't be
!    able to split windows horizontally nicely.  */
! 
! #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
! 
! /* Pixel-width of the left and right fringe.  */
! 
! #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
! #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
! 
! /* Total width of fringes in pixels.  */
! 
! #define FRAME_TOTAL_FRINGE_WIDTH(F) \
!   (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
! 
! 
! /* Pixel-width of internal border lines */
! 
! #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
  
  #else /* not HAVE_WINDOW_SYSTEM */
  
  #define FRAME_FRINGE_COLS(F)  0
+ #define FRAME_TOTAL_FRINGE_WIDTH(F)   0
  #define FRAME_LEFT_FRINGE_WIDTH(F)  0
  #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
+ #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
  
  #endif /* not HAVE_WINDOW_SYSTEM */
  
***************
*** 795,841 ****
            Conversion between canonical units and pixels
   ***********************************************************************/
  
! /* Canonical x-values are fractions of CANON_X_UNIT, canonical y-unit
!    are fractions of CANON_Y_UNIT of a frame.  Both are represented as
!    Lisp numbers, i.e. integers or floats.  */
  
  /* Convert canonical value X to pixels.  F is the frame whose
     canonical char width is to be used.  X must be a Lisp integer or
     float.  Value is a C integer.  */
  
! #define PIXEL_X_FROM_CANON_X(F, X)                    \
       (INTEGERP (X)                                    \
!       ? XINT (X) * CANON_X_UNIT (F)                   \
!       : (int) (XFLOAT_DATA (X) * CANON_X_UNIT (F)))
  
  /* Convert canonical value Y to pixels.  F is the frame whose
     canonical character height is to be used.  X must be a Lisp integer
     or float.  Value is a C integer.  */
  
! #define PIXEL_Y_FROM_CANON_Y(F, Y)                    \
       (INTEGERP (Y)                                    \
!       ? XINT (Y) * CANON_Y_UNIT (F)                   \
!       : (int) (XFLOAT_DATA (Y) * CANON_Y_UNIT (F)))
  
  /* Convert pixel-value X to canonical units.  F is the frame whose
     canonical character width is to be used.  X is a C integer.  Result
     is a Lisp float if X is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define CANON_X_FROM_PIXEL_X(F, X)                    \
!      ((X) % CANON_X_UNIT (F) != 0                     \
!       ? make_float ((double) (X) / CANON_X_UNIT (F))  \
!       : make_number ((X) / CANON_X_UNIT (F)))
  
  /* Convert pixel-value Y to canonical units.  F is the frame whose
     canonical character height is to be used.  Y is a C integer.
     Result is a Lisp float if Y is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define CANON_Y_FROM_PIXEL_Y(F, Y)                    \
!      ((Y) % CANON_Y_UNIT (F)                          \
!       ? make_float ((double) (Y) / CANON_Y_UNIT (F))  \
!       : make_number ((Y) / CANON_Y_UNIT (F)))
  
  
  /***********************************************************************
--- 869,970 ----
            Conversion between canonical units and pixels
   ***********************************************************************/
  
! /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
!    y-unit are fractions of FRAME_LINE_HEIGHT of a frame.  Both are
!    represented as Lisp numbers, i.e. integers or floats.  */
  
  /* Convert canonical value X to pixels.  F is the frame whose
     canonical char width is to be used.  X must be a Lisp integer or
     float.  Value is a C integer.  */
  
! #define FRAME_PIXEL_X_FROM_CANON_X(F, X)              \
       (INTEGERP (X)                                    \
!       ? XINT (X) * FRAME_COLUMN_WIDTH (F)             \
!       : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
  
  /* Convert canonical value Y to pixels.  F is the frame whose
     canonical character height is to be used.  X must be a Lisp integer
     or float.  Value is a C integer.  */
  
! #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y)              \
       (INTEGERP (Y)                                    \
!       ? XINT (Y) * FRAME_LINE_HEIGHT (F)              \
!       : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
  
  /* Convert pixel-value X to canonical units.  F is the frame whose
     canonical character width is to be used.  X is a C integer.  Result
     is a Lisp float if X is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define FRAME_CANON_X_FROM_PIXEL_X(F, X)                      \
!      ((X) % FRAME_COLUMN_WIDTH (F) != 0                               \
!       ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F))    \
!       : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
  
  /* Convert pixel-value Y to canonical units.  F is the frame whose
     canonical character height is to be used.  Y is a C integer.
     Result is a Lisp float if Y is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y)                      \
!      ((Y) % FRAME_LINE_HEIGHT (F)                             \
!       ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F))     \
!       : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
! 
! 
! 
! /* Manipulating pixel sizes and character sizes.
!    Knowledge of which factors affect the overall size of the window should
!    be hidden in these macros, if that's possible.
! 
!    Return the upper/left pixel position of the character cell on frame F
!    at ROW/COL.  */
! 
! #define FRAME_LINE_TO_PIXEL_Y(f, row) \
!   (FRAME_INTERNAL_BORDER_WIDTH (f)  \
!    + (row) * FRAME_LINE_HEIGHT (f))
! 
! #define FRAME_COL_TO_PIXEL_X(f, col) \
!   (FRAME_INTERNAL_BORDER_WIDTH (f) \
!    + (col) * FRAME_COLUMN_WIDTH (f))
! 
! /* Return the pixel width/height of frame F if it has
!    COLS columns/LINES rows.  */
! 
! #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
!   (FRAME_COL_TO_PIXEL_X (f, cols) \
!    + (f)->scroll_bar_actual_width \
!    + FRAME_TOTAL_FRINGE_WIDTH (f)      \
!    + FRAME_INTERNAL_BORDER_WIDTH (f))
! 
! #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
!   (FRAME_LINE_TO_PIXEL_Y (f, lines) \
!    + FRAME_INTERNAL_BORDER_WIDTH (f))
! 
! 
! /* Return the row/column (zero-based) of the character cell containing
!    the pixel on FRAME at Y/X.  */
! 
! #define FRAME_PIXEL_Y_TO_LINE(f, y) \
!   (((y) - FRAME_INTERNAL_BORDER_WIDTH (f))    \
!    / FRAME_LINE_HEIGHT (f))
! 
! #define FRAME_PIXEL_X_TO_COL(f, x) \
!   (((x) - FRAME_INTERNAL_BORDER_WIDTH (f))    \
!    / FRAME_COLUMN_WIDTH (f))
! 
! /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
!    frame F?  */
! 
! #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width)              \
!   (FRAME_PIXEL_X_TO_COL (f, ((width)                          \
!                            - FRAME_INTERNAL_BORDER_WIDTH (f)  \
!                            - FRAME_TOTAL_FRINGE_WIDTH (f)     \
!                            - (f)->scroll_bar_actual_width)))
! 
! #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
!   (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
!                             - FRAME_INTERNAL_BORDER_WIDTH (f))))
  
  
  /***********************************************************************
Index: gtkutil.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/gtkutil.c,v
retrieving revision 1.28
diff -c -r1.28 gtkutil.c
*** gtkutil.c   2 May 2003 12:20:16 -0000       1.28
--- gtkutil.c   14 May 2003 21:52:12 -0000
***************
*** 34,40 ****
  #include <gdk/gdkkeysyms.h>
  
  #define FRAME_TOTAL_PIXEL_HEIGHT(f) \
!   (PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f))
  
  
  
--- 34,40 ----
  #include <gdk/gdkkeysyms.h>
  
  #define FRAME_TOTAL_PIXEL_HEIGHT(f) \
!   (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT 
(f))
  
  
  
***************
*** 237,248 ****
  xg_set_geometry (f)
       FRAME_PTR f;
  {
!   if (f->output_data.x->size_hint_flags & USPosition)
    {
!     int left = f->output_data.x->left_pos;
!     int xneg = f->output_data.x->size_hint_flags & XNegative;
!     int top = f->output_data.x->top_pos;
!     int yneg = f->output_data.x->size_hint_flags & YNegative;
      char geom_str[32];
  
      if (xneg)
--- 237,248 ----
  xg_set_geometry (f)
       FRAME_PTR f;
  {
!   if (f->size_hint_flags & USPosition)
    {
!     int left = f->left_pos;
!     int xneg = f->size_hint_flags & XNegative;
!     int top = f->top_pos;
!     int yneg = f->size_hint_flags & YNegative;
      char geom_str[32];
  
      if (xneg)
***************
*** 251,257 ****
        top = -top;
  
      sprintf (geom_str, "=%dx%d%c%d%c%d",
!              PIXEL_WIDTH (f),
               FRAME_TOTAL_PIXEL_HEIGHT (f),
               (xneg ? '-' : '+'), left,
               (yneg ? '-' : '+'), top);
--- 251,257 ----
        top = -top;
  
      sprintf (geom_str, "=%dx%d%c%d%c%d",
!              FRAME_PIXEL_WIDTH (f),
               FRAME_TOTAL_PIXEL_HEIGHT (f),
               (xneg ? '-' : '+'), left,
               (yneg ? '-' : '+'), top);
***************
*** 273,279 ****
       int rows;
  {
    gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
!                      PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f));
  
    /* base_height is now changed.  */
    x_wm_set_size_hint (f, 0, 0);
--- 273,279 ----
       int rows;
  {
    gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
!                      FRAME_PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f));
  
    /* base_height is now changed.  */
    x_wm_set_size_hint (f, 0, 0);
***************
*** 317,328 ****
  {
    int mbheight = FRAME_MENUBAR_HEIGHT (f);
    int tbheight = FRAME_TOOLBAR_HEIGHT (f);
!   int rows = PIXEL_TO_CHAR_HEIGHT (f, pixelheight - mbheight - tbheight);
!   int columns = PIXEL_TO_CHAR_WIDTH (f, pixelwidth);
  
    if (FRAME_GTK_WIDGET (f)
!       && (columns != FRAME_WIDTH (f) || rows != FRAME_HEIGHT (f)
!           || pixelwidth != PIXEL_WIDTH (f) || pixelheight != PIXEL_HEIGHT 
(f)))
      {
        struct x_output *x = f->output_data.x;
        GtkAllocation all;
--- 317,329 ----
  {
    int mbheight = FRAME_MENUBAR_HEIGHT (f);
    int tbheight = FRAME_TOOLBAR_HEIGHT (f);
!   int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (pixelheight 
!                                                  - mbheight - tbheight));
!   int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth);
  
    if (FRAME_GTK_WIDGET (f)
!       && (columns != FRAME_COLS (f) || rows != FRAME_LINES (f)
!           || pixelwidth != FRAME_PIXEL_WIDTH (f) || pixelheight != 
FRAME_PIXEL_HEIGHT (f)))
      {
        struct x_output *x = f->output_data.x;
        GtkAllocation all;
***************
*** 349,355 ****
       int cols;
       int rows;
  {
!   int pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows)
      + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
    int pixelwidth;
  
--- 350,356 ----
       int cols;
       int rows;
  {
!   int pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows)
      + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
    int pixelwidth;
  
***************
*** 358,374 ****
       might end up with a frame width that is not a multiple of the
       frame's character width which is bad for vertically split
       windows.  */
!   f->output_data.x->vertical_scroll_bar_extra
!     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
!        ? 0
!        : (FRAME_SCROLL_BAR_COLS (f)
!           * FONT_WIDTH (f->output_data.x->font)));
  
    compute_fringe_widths (f, 0);
  
!   /* CHAR_TO_PIXEL_WIDTH uses vertical_scroll_bar_extra, so call it
       after calculating that value.  */
!   pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
  
    /* Must resize our top level widget.  Font size may have changed,
       but not rows/cols.  */
--- 359,372 ----
       might end up with a frame width that is not a multiple of the
       frame's character width which is bad for vertically split
       windows.  */
!   f->scroll_bar_actual_width
!     = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
  
    compute_fringe_widths (f, 0);
  
!   /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it
       after calculating that value.  */
!   pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
  
    /* Must resize our top level widget.  Font size may have changed,
       but not rows/cols.  */
***************
*** 511,519 ****
  
    gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE);
  
!   gtk_widget_set_size_request (wfixed,
!                                PIXEL_WIDTH (f),
!                                PIXEL_HEIGHT (f));
  
    gtk_container_add (GTK_CONTAINER (wtop), wvbox);
    gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0);
--- 509,515 ----
  
    gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE);
  
!   gtk_widget_set_size_request (wfixed, FRAME_PIXEL_WIDTH (f), 
FRAME_PIXEL_HEIGHT (f));
  
    gtk_container_add (GTK_CONTAINER (wtop), wvbox);
    gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0);
***************
*** 594,601 ****
    gtk_widget_modify_style (wfixed, style);
  
    /* GTK does not set any border, and they look bad with GTK.  */
!   f->output_data.x->border_width = 0;
!   f->output_data.x->internal_border_width = 0;
  
    UNBLOCK_INPUT;
  
--- 590,597 ----
    gtk_widget_modify_style (wfixed, style);
  
    /* GTK does not set any border, and they look bad with GTK.  */
!   f->border_width = 0;
!   f->internal_border_width = 0;
  
    UNBLOCK_INPUT;
  
***************
*** 621,627 ****
      gint hint_flags = 0;
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
!     int win_gravity = f->output_data.x->win_gravity;
  
      if (flags)
        {
--- 617,623 ----
      gint hint_flags = 0;
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
!     int win_gravity = f->win_gravity;
  
      if (flags)
        {
***************
*** 630,647 ****
          f->output_data.x->hint_flags = hint_flags;
        }
       else
!        flags = f->output_data.x->size_hint_flags;
  
      size_hints = f->output_data.x->size_hints;
      hint_flags = f->output_data.x->hint_flags;
  
      hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;
!     size_hints.width_inc = FONT_WIDTH (f->output_data.x->font);
!     size_hints.height_inc = f->output_data.x->line_height;
  
      hint_flags |= GDK_HINT_BASE_SIZE;
!     base_width = CHAR_TO_PIXEL_WIDTH (f, 0);
!     base_height = CHAR_TO_PIXEL_HEIGHT (f, 0)
        + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
  
      check_frame_size (f, &min_rows, &min_cols);
--- 626,643 ----
          f->output_data.x->hint_flags = hint_flags;
        }
       else
!        flags = f->size_hint_flags;
  
      size_hints = f->output_data.x->size_hints;
      hint_flags = f->output_data.x->hint_flags;
  
      hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;
!     size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
!     size_hints.height_inc = FRAME_LINE_HEIGHT (f);
  
      hint_flags |= GDK_HINT_BASE_SIZE;
!     base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
!     base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0)
        + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
  
      check_frame_size (f, &min_rows, &min_cols);
***************
*** 2298,2304 ****
  
    /* The height has changed, resize outer widget and set columns
       rows to what we had before adding the menu bar.  */
!   xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
  
    SET_FRAME_GARBAGED (f);
    UNBLOCK_INPUT;
--- 2294,2300 ----
  
    /* The height has changed, resize outer widget and set columns
       rows to what we had before adding the menu bar.  */
!   xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
  
    SET_FRAME_GARBAGED (f);
    UNBLOCK_INPUT;
***************
*** 2327,2333 ****
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before removing the menu bar.  */
!       xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
  
        SET_FRAME_GARBAGED (f);
        UNBLOCK_INPUT;
--- 2323,2329 ----
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before removing the menu bar.  */
!       xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
  
        SET_FRAME_GARBAGED (f);
        UNBLOCK_INPUT;
***************
*** 2735,2741 ****
        /* We do the same as for MOTIF in xterm.c, assume 30 chars per line
           rather than the real portion value.  This makes the thumb less likely
           to resize and that looks better.  */
!       portion = XFASTINT (XWINDOW (bar->window)->height) * 30;
        /* When the thumb is at the bottom, position == whole.
           So we need to increase `whole' to make space for the thumb.  */
        whole += portion;
--- 2731,2737 ----
        /* We do the same as for MOTIF in xterm.c, assume 30 chars per line
           rather than the real portion value.  This makes the thumb less likely
           to resize and that looks better.  */
!       portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30;
        /* When the thumb is at the bottom, position == whole.
           So we need to increase `whole' to make space for the thumb.  */
        whole += portion;
***************
*** 2757,2763 ****
        value = max (value, XG_SB_MIN);
  
        /* Assume all lines are of equal size.  */
!       new_step = size / max (1, FRAME_HEIGHT (f));
  
        if ((int) adj->page_size != size
            || (int) adj->step_increment != new_step)
--- 2753,2759 ----
        value = max (value, XG_SB_MIN);
  
        /* Assume all lines are of equal size.  */
!       new_step = size / max (1, FRAME_LINES (f));
  
        if ((int) adj->page_size != size
            || (int) adj->step_increment != new_step)
***************
*** 2857,2863 ****
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before detaching the tool bar.  */
!       xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
      }
  }
  
--- 2853,2859 ----
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before detaching the tool bar.  */
!       xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
      }
  }
  
***************
*** 2884,2890 ****
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before detaching the tool bar.  */
!       xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
      }
  }
  
--- 2880,2886 ----
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before detaching the tool bar.  */
!       xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
      }
  }
  
***************
*** 3029,3035 ****
  
    /* The height has changed, resize outer widget and set columns
       rows to what we had before adding the tool bar.  */
!   xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
  
    SET_FRAME_GARBAGED (f);
  }
--- 3025,3031 ----
  
    /* The height has changed, resize outer widget and set columns
       rows to what we had before adding the tool bar.  */
!   xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
  
    SET_FRAME_GARBAGED (f);
  }
***************
*** 3202,3208 ****
    if (old_req.height != new_req.height)
      {
        FRAME_TOOLBAR_HEIGHT (f) = new_req.height;
!       xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
      }
  
    if (icon_list) g_list_free (icon_list);
--- 3198,3204 ----
    if (old_req.height != new_req.height)
      {
        FRAME_TOOLBAR_HEIGHT (f) = new_req.height;
!       xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
      }
  
    if (icon_list) g_list_free (icon_list);
***************
*** 3227,3233 ****
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before removing the tool bar.  */
!       xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
  
        SET_FRAME_GARBAGED (f);
        UNBLOCK_INPUT;
--- 3223,3229 ----
  
        /* The height has changed, resize outer widget and set columns
           rows to what we had before removing the tool bar.  */
!       xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
  
        SET_FRAME_GARBAGED (f);
        UNBLOCK_INPUT;
Index: indent.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/indent.c,v
retrieving revision 1.155
diff -c -r1.155 indent.c
*** indent.c    29 Nov 2002 15:13:50 -0000      1.155
--- indent.c    14 May 2003 21:52:13 -0000
***************
*** 1159,1176 ****
  
        window_width - 1
         - (has_vertical_scroll_bars
!           ? FRAME_SCROLL_BAR_COLS (XFRAME (window->frame))
!           : (window_width + window_left != frame_width))
  
        where
!         window_width is XFASTINT (w->width),
!         window_left is XFASTINT (w->left),
          has_vertical_scroll_bars is
!           FRAME_HAS_VERTICAL_SCROLL_BARS (XFRAME (WINDOW_FRAME (window)))
!         and frame_width = FRAME_WIDTH (XFRAME (window->frame))
  
!    Or you can let window_internal_width do this all for you, and write:
!       window_internal_width (w) - 1
  
     The `-1' accounts for the continuation-line backslashes; the rest
     accounts for window borders if the window is split horizontally, and
--- 1159,1176 ----
  
        window_width - 1
         - (has_vertical_scroll_bars
!           ? WINDOW_CONFIG_SCROLL_BAR_COLS (window)
!           : (window_width + window_left != frame_cols))
  
        where
!         window_width is XFASTINT (w->total_cols),
!         window_left is XFASTINT (w->left_col),
          has_vertical_scroll_bars is
!           WINDOW_HAS_VERTICAL_SCROLL_BAR (window)
!         and frame_cols = FRAME_COLS (XFRAME (window->frame))
  
!    Or you can let window_box_text_cols do this all for you, and write:
!       window_box_text_cols (w) - 1
  
     The `-1' accounts for the continuation-line backslashes; the rest
     accounts for window borders if the window is split horizontally, and
***************
*** 1366,1372 ****
        {
          if (hscroll
              || (truncate_partial_width_windows
!                 && width + 1 < FRAME_WIDTH (XFRAME (WINDOW_FRAME (win))))
              || !NILP (current_buffer->truncate_lines))
            {
              /* Truncating: skip to newline, unless we are already past
--- 1366,1372 ----
        {
          if (hscroll
              || (truncate_partial_width_windows
!                 && width + 1 < FRAME_COLS (XFRAME (WINDOW_FRAME (win))))
              || !NILP (current_buffer->truncate_lines))
            {
              /* Truncating: skip to newline, unless we are already past
***************
*** 1834,1840 ****
       register int from, vtarget;
       struct window *w;
  {
!   int width = window_internal_width (w) - 1;
    int hscroll = XINT (w->hscroll);
    struct position pos;
    /* vpos is cumulative vertical position, changed as from is changed */
--- 1834,1842 ----
       register int from, vtarget;
       struct window *w;
  {
!   /* We don't need to make room for continuation marks (we have fringes now),
!      so hould we really subtract 1 here if FRAME_WINDOW_P ?  ++KFS  */
!   int width = window_box_text_cols (w) - 1;
    int hscroll = XINT (w->hscroll);
    struct position pos;
    /* vpos is cumulative vertical position, changed as from is changed */
Index: keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.743
diff -c -r1.743 keyboard.c
*** keyboard.c  14 May 2003 18:43:12 -0000      1.743
--- keyboard.c  14 May 2003 21:52:16 -0000
***************
*** 5115,5120 ****
--- 5115,5121 ----
            Lisp_Object posn;
            Lisp_Object string_info = Qnil;
            int row, column;
+           int wx, wy;
  
            /* Ignore mouse events that were made on frame that
               have been deleted.  */
***************
*** 5186,5192 ****
            /* Set `window' to the window under frame pixel coordinates
               event->x/event->y.  */
            window = window_from_coordinates (f, XINT (event->x),
!                                             XINT (event->y), &part, 0);
  
            if (!WINDOWP (window))
              {
--- 5187,5194 ----
            /* Set `window' to the window under frame pixel coordinates
               event->x/event->y.  */
            window = window_from_coordinates (f, XINT (event->x),
!                                             XINT (event->y),
!                                             &part, &wx, &wy, 0);
  
            if (!WINDOWP (window))
              {
***************
*** 5199,5209 ****
                   event->x/ event->y.  */
                struct window *w = XWINDOW (window);
  
-               /* Get window relative coordinates.  Original code
-                  `rounded' this to glyph boundaries.  */
-               int wx = FRAME_TO_WINDOW_PIXEL_X (w, XINT (event->x));
-               int wy = FRAME_TO_WINDOW_PIXEL_Y (w, XINT (event->y));
- 
                /* Set event coordinates to window-relative coordinates
                   for constructing the Lisp event below.  */
                XSETINT (event->x, wx);
--- 5201,5206 ----
***************
*** 5534,5540 ****
        pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
                               &column, &row, NULL, 1);
        window = window_from_coordinates (f, XINT (event->x),
!                                           XINT (event->y), &part, 0);
  
        if (!WINDOWP (window))
          {
--- 5531,5538 ----
        pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
                               &column, &row, NULL, 1);
        window = window_from_coordinates (f, XINT (event->x),
!                                           XINT (event->y),
!                                         &part, 0, 0, 0);
  
        if (!WINDOWP (window))
          {
***************
*** 5544,5551 ****
        else
          {
            int pixcolumn, pixrow;
!           column -= XINT (XWINDOW (window)->left);
!           row -= XINT (XWINDOW (window)->top);
            glyph_to_pixel_coords (XWINDOW(window), column, row,
                                     &pixcolumn, &pixrow);
            XSETINT (event->x, pixcolumn);
--- 5542,5549 ----
        else
          {
            int pixcolumn, pixrow;
!           column -= WINDOW_LEFT_EDGE_COL (XWINDOW (window));
!           row -= WINDOW_TOP_EDGE_LINE (XWINDOW (window));
            glyph_to_pixel_coords (XWINDOW(window), column, row,
                                     &pixcolumn, &pixrow);
            XSETINT (event->x, pixcolumn);
***************
*** 5598,5603 ****
--- 5596,5602 ----
        Lisp_Object window;
        Lisp_Object posn;
        Lisp_Object files;
+       int wx, wy;
  
        /* The frame_or_window field should be a cons of the frame in
           which the event occurred and a list of the filenames
***************
*** 5614,5620 ****
          return Qnil;
  
        window = window_from_coordinates (f, XINT (event->x),
!                                           XINT (event->y), &part, 0);
  
        if (!WINDOWP (window))
          {
--- 5613,5620 ----
          return Qnil;
  
        window = window_from_coordinates (f, XINT (event->x),
!                                           XINT (event->y),
!                                         &part, &wx, &wy, 0);
  
        if (!WINDOWP (window))
          {
***************
*** 5627,5636 ****
               event->x/ event->y.  */
            struct window *w = XWINDOW (window);
  
-           /* Get window relative coordinates.  */
-           int wx = FRAME_TO_WINDOW_PIXEL_X (w, XINT (event->x));
-           int wy = FRAME_TO_WINDOW_PIXEL_Y (w, XINT (event->y));
- 
            /* Set event coordinates to window-relative coordinates
               for constructing the Lisp event below.  */
            XSETINT (event->x, wx);
--- 5627,5632 ----
***************
*** 5745,5765 ****
        enum window_part area;
        Lisp_Object window;
        Lisp_Object posn;
  
        if (frame)
        /* It's in a frame; which window on that frame?  */
!       window = window_from_coordinates (frame, XINT (x), XINT (y), &area, 0);
        else
        window = Qnil;
  
        if (WINDOWP (window))
        {
          struct window *w = XWINDOW (window);
-         int wx, wy;
  
!         /* Get window relative coordinates.  */
!         wx = FRAME_TO_WINDOW_PIXEL_X (w, XINT (x));
!         wy = FRAME_TO_WINDOW_PIXEL_Y (w, XINT (y));
          XSETINT (x, wx);
          XSETINT (y, wy);
  
--- 5741,5760 ----
        enum window_part area;
        Lisp_Object window;
        Lisp_Object posn;
+       int wx, wy;
  
        if (frame)
        /* It's in a frame; which window on that frame?  */
!       window = window_from_coordinates (frame, XINT (x), XINT (y),
!                                         &area, &wx, &wy, 0);
        else
        window = Qnil;
  
        if (WINDOWP (window))
        {
          struct window *w = XWINDOW (window);
  
!         /* Set window relative coordinates.  */
          XSETINT (x, wx);
          XSETINT (y, wy);
  
***************
*** 7926,7932 ****
    register Lisp_Object name;
    int nlength;
    /* FIXME: Use the minibuffer's frame width.  */
!   int width = FRAME_WIDTH (SELECTED_FRAME ()) - 4;
    int idx = -1;
    int nobindings = 1;
    Lisp_Object rest, vector;
--- 7921,7927 ----
    register Lisp_Object name;
    int nlength;
    /* FIXME: Use the minibuffer's frame width.  */
!   int width = FRAME_COLS (SELECTED_FRAME ()) - 4;
    int idx = -1;
    int nobindings = 1;
    Lisp_Object rest, vector;
Index: lisp.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lisp.h,v
retrieving revision 1.454
diff -c -r1.454 lisp.h
*** lisp.h      14 May 2003 18:50:47 -0000      1.454
--- lisp.h      14 May 2003 21:52:17 -0000
***************
*** 2875,2880 ****
--- 2875,2915 ----
  extern int indented_beyond_p P_ ((int, int, double));
  extern void syms_of_indent P_ ((void));
  
+ <<<<<<< lisp.h
+ /* defined in window.c */
+ extern Lisp_Object Qwindowp, Qwindow_live_p;
+ extern Lisp_Object Vwindow_list;
+ EXFUN (Fwindow_end, 2);
+ EXFUN (Fselected_window, 0);
+ EXFUN (Fnext_window, 3);
+ EXFUN (Fdelete_window, 1);
+ EXFUN (Fselect_window, 1);
+ EXFUN (Fset_window_buffer, 3);
+ EXFUN (Fwindow_buffer, 1);
+ EXFUN (Fget_buffer_window, 2);
+ EXFUN (Fsave_window_excursion, UNEVALLED);
+ EXFUN (Fsplit_window, 3);
+ EXFUN (Fset_window_configuration, 1);
+ EXFUN (Fcurrent_window_configuration, 1);
+ extern int compare_window_configurations P_ ((Lisp_Object, Lisp_Object, int));
+ EXFUN (Fcoordinates_in_window_p, 2);
+ EXFUN (Fwindow_at, 3);
+ EXFUN (Fpos_visible_in_window_p, 3);
+ extern void mark_window_cursors_off P_ ((struct window *));
+ extern int window_internal_height P_ ((struct window *));
+ extern int window_box_text_cols P_ ((struct window *));
+ EXFUN (Frecenter, 1);
+ EXFUN (Fscroll_other_window, 1);
+ EXFUN (Fset_window_start, 3);
+ extern void temp_output_buffer_show P_ ((Lisp_Object));
+ extern void replace_buffer_in_all_windows P_ ((Lisp_Object));
+ extern void init_window_once P_ ((void));
+ extern void init_window P_ ((void));
+ extern void syms_of_window P_ ((void));
+ extern void keys_of_window P_ ((void));
+ 
+ =======
+ >>>>>>> 1.454
  /* defined in frame.c */
  extern Lisp_Object Qvisible;
  extern void store_frame_param P_ ((struct frame *, Lisp_Object, Lisp_Object));
Index: macfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macfns.c,v
retrieving revision 1.23
diff -c -r1.23 macfns.c
*** macfns.c    1 Apr 2003 01:09:13 -0000       1.23
--- macfns.c    14 May 2003 21:52:19 -0000
***************
*** 610,615 ****
--- 610,619 ----
    LocalToGlobal (&pt);
    SetPort (oldport);
  
+   /* MAC has no frame pixel diff.  */
+   f->x_pixels_diff = 0;
+   f->y_pixels_diff = 0;
+ 
    *xptr = pt.h;
    *yptr = pt.v;
  }
***************
*** 1896,1902 ****
  {
    f->output_data.mac->border_pixel = pix;
  
!   if (FRAME_MAC_WINDOW (f) != 0 && f->output_data.mac->border_width > 0)
      {
        if (FRAME_VISIBLE_P (f))
          redraw_frame (f);
--- 1900,1906 ----
  {
    f->output_data.mac->border_pixel = pix;
  
!   if (FRAME_MAC_WINDOW (f) != 0 && f->border_width > 0)
      {
        if (FRAME_VISIBLE_P (f))
          redraw_frame (f);
***************
*** 2049,2055 ****
        /* Adjust the frame size so that the client (text) dimensions
         remain the same.  This depends on FRAME_EXTERNAL_MENU_BAR being
         set correctly.  */
!       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
        do_pending_window_change (0);
      }
    adjust_glyphs (f);
--- 2053,2059 ----
        /* Adjust the frame size so that the client (text) dimensions
         remain the same.  This depends on FRAME_EXTERNAL_MENU_BAR being
         set correctly.  */
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
        do_pending_window_change (0);
      }
    adjust_glyphs (f);
***************
*** 2087,2093 ****
  
    /* Don't resize the tool-bar to more than we have room for.  */
    root_window = FRAME_ROOT_WINDOW (f);
!   root_height = XINT (XWINDOW (root_window)->height);
    if (root_height - delta < 1)
      {
        delta = root_height - 1;
--- 2091,2097 ----
  
    /* Don't resize the tool-bar to more than we have room for.  */
    root_window = FRAME_ROOT_WINDOW (f);
!   root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
    if (root_height - delta < 1)
      {
        delta = root_height - 1;
***************
*** 2118,2125 ****
    if (delta < 0)
      {
        int height = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int width = PIXEL_WIDTH (f);
!       int y = nlines * CANON_Y_UNIT (f);
  
        BLOCK_INPUT;
        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
--- 2122,2129 ----
    if (delta < 0)
      {
        int height = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int width = FRAME_PIXEL_WIDTH (f);
!       int y = nlines * FRAME_LINE_HEIGHT (f);
  
        BLOCK_INPUT;
        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
***************
*** 2292,2311 ****
  {
    /* Imitate X without X Toolkit */
  
!   int wid = FONT_WIDTH (f->output_data.mac->font);
  
  #ifdef MAC_OSX
!   FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 16;  /* Aqua scroll bars.  */
!   FRAME_SCROLL_BAR_COLS (f) = (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) +
!                              wid - 1) / wid;
  #else /* not MAC_OSX */
    /* Make the actual width at least 14 pixels and a multiple of a
       character width.  */
!   FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
  
    /* Use all of that space (aside from required margins) for the
       scroll bar.  */
!   FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
  #endif /* not MAC_OSX */
  }
  
--- 2296,2315 ----
  {
    /* Imitate X without X Toolkit */
  
!   int wid = FRAME_COLUMN_WIDTH (f);
  
  #ifdef MAC_OSX
!   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 16;  /* Aqua scroll bars.  */
!   FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
!                                     wid - 1) / wid;
  #else /* not MAC_OSX */
    /* Make the actual width at least 14 pixels and a multiple of a
       character width.  */
!   FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
  
    /* Use all of that space (aside from required margins) for the
       scroll bar.  */
!   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 0;
  #endif /* not MAC_OSX */
  }
  
***************
*** 2507,2515 ****
      strcpy (f->namebuf, str);
    }
  
!   SetRect (&r, f->output_data.mac->left_pos, f->output_data.mac->top_pos,
!            f->output_data.mac->left_pos + PIXEL_WIDTH (f),
!            f->output_data.mac->top_pos + PIXEL_HEIGHT (f));
    FRAME_MAC_WINDOW (f)
      = NewCWindow (NULL, &r, "\p", 1, zoomDocProc, (WindowPtr) -1, 1, (long) 
f->output_data.mac);
  
--- 2511,2519 ----
      strcpy (f->namebuf, str);
    }
  
!   SetRect (&r, f->left_pos, f->top_pos,
!            f->left_pos + FRAME_PIXEL_WIDTH (f),
!            f->top_pos + FRAME_PIXEL_HEIGHT (f));
    FRAME_MAC_WINDOW (f)
      = NewCWindow (NULL, &r, "\p", 1, zoomDocProc, (WindowPtr) -1, 1, (long) 
f->output_data.mac);
  
***************
*** 2597,2603 ****
       Note that many default values are used.  */
  
    /* Normal video */
!   gc_values.font = f->output_data.mac->font;
    gc_values.foreground = FRAME_FOREGROUND_PIXEL (f);
    gc_values.background = FRAME_BACKGROUND_PIXEL (f);
    f->output_data.mac->normal_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
--- 2601,2607 ----
       Note that many default values are used.  */
  
    /* Normal video */
!   gc_values.font = FRAME_FONT (f);
    gc_values.foreground = FRAME_FOREGROUND_PIXEL (f);
    gc_values.background = FRAME_BACKGROUND_PIXEL (f);
    f->output_data.mac->normal_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
***************
*** 2881,2887 ****
       tool-bar height don't change the frame size. This is done so that
       users can create tall Emacs frames without having to guess how
       tall the tool-bar will get. */
!   f->height += FRAME_TOOL_BAR_LINES (f);
  
    /* mac_window (f, window_prompting, minibuffer_only); */
    make_mac_frame (f);
--- 2885,2891 ----
       tool-bar height don't change the frame size. This is done so that
       users can create tall Emacs frames without having to guess how
       tall the tool-bar will get. */
!   FRAME_LINES (f) += FRAME_TOOL_BAR_LINES (f);
  
    /* mac_window (f, window_prompting, minibuffer_only); */
    make_mac_frame (f);
***************
*** 2908,2921 ****
    x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
                       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
  
!   /* Dimensions, especially f->height, must be done via change_frame_size.
       Change will not be effected unless different from the current
!      f->height.  */
!   width = f->width;
!   height = f->height;
  
!   f->height = 0;
!   SET_FRAME_WIDTH (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Set up faces after all frame parameters are known.  */
--- 2912,2925 ----
    x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
                       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
  
!   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
       Change will not be effected unless different from the current
!      FRAME_LINES (f).  */
!   width = FRAME_COLS (f);
!   height = FRAME_LINES (f);
  
!   FRAME_LINES (f) = 0;
!   SET_FRAME_COLS (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Set up faces after all frame parameters are known.  */
***************
*** 3265,3292 ****
  x_pixel_width (f)
       register struct frame *f;
  {
!   return PIXEL_WIDTH (f);
  }
  
  int
  x_pixel_height (f)
       register struct frame *f;
  {
!   return PIXEL_HEIGHT (f);
  }
  
  int
  x_char_width (f)
       register struct frame *f;
  {
!   return FONT_WIDTH (f->output_data.mac->font);
  }
  
  int
  x_char_height (f)
       register struct frame *f;
  {
!   return f->output_data.mac->line_height;
  }
  
  int
--- 3269,3296 ----
  x_pixel_width (f)
       register struct frame *f;
  {
!   return FRAME_PIXEL_WIDTH (f);
  }
  
  int
  x_pixel_height (f)
       register struct frame *f;
  {
!   return FRAME_PIXEL_HEIGHT (f);
  }
  
  int
  x_char_width (f)
       register struct frame *f;
  {
!   return FRAME_COLUMN_WIDTH (f);
  }
  
  int
  x_char_height (f)
       register struct frame *f;
  {
!   return FRAME_LINE_HEIGHT (f);
  }
  
  int
***************
*** 8150,8156 ****
  #if 0
    f->output_data.w32->icon_bitmap = -1;
  #endif
!   f->output_data.w32->fontset = -1;
    f->icon_name = Qnil;
  
  #ifdef MULTI_KBOARD
--- 8154,8160 ----
  #if 0
    f->output_data.w32->icon_bitmap = -1;
  #endif
!   FRAME_FONTSET (f) = -1;
    f->icon_name = Qnil;
  
  #ifdef MULTI_KBOARD
***************
*** 8295,8307 ****
    x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
  
!   /* Dimensions, especially f->height, must be done via change_frame_size.
       Change will not be effected unless different from the current
!      f->height.  */
!   width = f->width;
!   height = f->height;
!   f->height = 0;
!   SET_FRAME_WIDTH (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Add `tooltip' frame parameter's default value. */
--- 8299,8311 ----
    x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
  
!   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
       Change will not be effected unless different from the current
!      FRAME_LINES (f).  */
!   width = FRAME_COLS (f);
!   height = FRAME_LINES (f);
!   FRAME_LINES (f) = 0;
!   SET_FRAME_COLS (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Add `tooltip' frame parameter's default value. */
***************
*** 8411,8417 ****
          BLOCK_INPUT;
          compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
          XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                      root_x, root_y - PIXEL_HEIGHT (f));
          UNBLOCK_INPUT;
  #endif /* MAC_TODO */
          goto start_timer;
--- 8415,8421 ----
          BLOCK_INPUT;
          compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
          XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                      root_x, root_y - FRAME_PIXEL_HEIGHT (f));
          UNBLOCK_INPUT;
  #endif /* MAC_TODO */
          goto start_timer;
***************
*** 8447,8461 ****
       columns x 40 lines.  If someone wants to show a larger tip, he
       will loose.  I don't think this is a realistic case.  */
    w = XWINDOW (FRAME_ROOT_WINDOW (f));
!   w->left = w->top = make_number (0);
!   w->width = make_number (80);
!   w->height = make_number (40);
    adjust_glyphs (f);
    w->pseudo_window_p = 1;
  
    /* Display the tooltip text in a temporary buffer.  */
    buffer = Fget_buffer_create (build_string (" *tip*"));
!   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer);
    old_buffer = current_buffer;
    set_buffer_internal_1 (XBUFFER (buffer));
    Ferase_buffer ();
--- 8451,8465 ----
       columns x 40 lines.  If someone wants to show a larger tip, he
       will loose.  I don't think this is a realistic case.  */
    w = XWINDOW (FRAME_ROOT_WINDOW (f));
!   w->left_col = w->top_line = make_number (0);
!   w->total_cols = make_number (80);
!   w->total_lines = make_number (40);
    adjust_glyphs (f);
    w->pseudo_window_p = 1;
  
    /* Display the tooltip text in a temporary buffer.  */
    buffer = Fget_buffer_create (build_string (" *tip*"));
!   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
    old_buffer = current_buffer;
    set_buffer_internal_1 (XBUFFER (buffer));
    Ferase_buffer ();
Index: macmenu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macmenu.c,v
retrieving revision 1.9
diff -c -r1.9 macmenu.c
*** macmenu.c   4 Feb 2003 14:03:12 -0000       1.9
--- macmenu.c   14 May 2003 21:52:19 -0000
***************
*** 732,741 ****
          CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
  
!         xpos = (FONT_WIDTH (FRAME_FONT (f))
!                 * XFASTINT (XWINDOW (window)->left));
!         ypos = (FRAME_LINE_HEIGHT (f)
!                 * XFASTINT (XWINDOW (window)->top));
        }
        else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
--- 732,739 ----
          CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
  
!         xpos = WINDOW_LEFT_EDGE_X (XWINDOW (window));
!         ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
        }
        else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
Index: macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.43
diff -c -r1.43 macterm.c
*** macterm.c   25 Apr 2003 04:32:25 -0000      1.43
--- macterm.c   14 May 2003 21:52:21 -0000
***************
*** 306,313 ****
  static void x_frame_rehighlight P_ ((struct x_display_info *));
  static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
!                              GC, int));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
--- 306,312 ----
  static void x_frame_rehighlight P_ ((struct x_display_info *));
  static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
***************
*** 1273,1279 ****
        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                  0, y, width, height, 0);
        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                 f->output_data.mac->pixel_width - width, y,
                  width, height, 0);
  
        UNBLOCK_INPUT;
--- 1272,1278 ----
        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                  0, y, width, height, 0);
        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                 FRAME_PIXEL_WIDTH (f) - width, y,
                  width, height, 0);
  
        UNBLOCK_INPUT;
***************
*** 1300,1306 ****
    struct face *face = p->face;
  
    /* Must clip because of partially visible lines.  */
!   x_clip_to_row (w, row, gc, 1);
  
    if (p->bx >= 0)
      {
--- 1299,1305 ----
    struct face *face = p->face;
  
    /* Must clip because of partially visible lines.  */
!   x_clip_to_row (w, row, gc);
  
    if (p->bx >= 0)
      {
***************
*** 2352,2360 ****
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += FRAME_X_RIGHT_FRINGE_WIDTH (s->f);
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
!       last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
      }
  
    /* The glyph that may have a right box line.  */
--- 2351,2360 ----
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (s->w);
!       if (s->area != RIGHT_MARGIN_AREA
!         || WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
!       last_x += WINDOW_RIGHT_FRINGE_WIDTH (s->w);
      }
  
    /* The glyph that may have a right box line.  */
***************
*** 2744,2750 ****
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (CANON_X_UNIT (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
--- 2744,2750 ----
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (FRAME_COLUMN_WIDTH (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
***************
*** 3147,3154 ****
       without mode lines.  Include in this box the left and right
       fringes of W.  */
    window_box (w, -1, &x, &y, &width, &height);
-   width += FRAME_X_FRINGE_WIDTH (f);
-   x -= FRAME_X_LEFT_FRINGE_WIDTH (f);
  
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->current_y);
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->desired_y);
--- 3147,3152 ----
***************
*** 3591,3605 ****
  {
    Lisp_Object window;
  
!   window = window_from_coordinates (f, x, y, 0, 0);
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
-       frame_to_window_pixel_xy (w, &x, &y);
- 
        for (; r < end && r->enabled_p; ++r)
        if (r->y <= y && r->y + r->height > y)
          {
--- 3589,3602 ----
  {
    Lisp_Object window;
  
!   window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
! 
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        for (; r < end && r->enabled_p; ++r)
        if (r->y <= y && r->y + r->height > y)
          {
***************
*** 3614,3620 ****
            if (x < r->x)
              {
                /* x is to the left of the first glyph in the row.  */
!               rect->left = XINT (w->left);
                rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
                return 1;
              }
--- 3611,3620 ----
            if (x < r->x)
              {
                /* x is to the left of the first glyph in the row.  */
!               /* Shouldn't this be a pixel value?
!                  WINDOW_LEFT_EDGE_X (w) seems to be the right value.
!                  ++KFS */
!               rect->left = WINDOW_LEFT_EDGE_COL (w);
                rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
                return 1;
              }
***************
*** 3630,3636 ****
  
            /* x is to the right of the last glyph in the row.  */
            rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
!           rect->right = XINT (w->left) + XINT (w->width);
            return 1;
          }
      }
--- 3630,3639 ----
  
            /* x is to the right of the last glyph in the row.  */
            rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
!           /* Shouldn't this be a pixel value?  
!              WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
!              ++KFS */
!           rect->right = WINDOW_RIGHT_EDGE_COL (w);
            return 1;
          }
      }
***************
*** 3652,3658 ****
        int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
        int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
  
!       /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
         round down even for negative values.  */
        if (gx < 0)
        gx -= width - 1;
--- 3655,3661 ----
        int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
        int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
  
!       /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
         round down even for negative values.  */
        if (gx < 0)
        gx -= width - 1;
***************
*** 3938,3972 ****
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width, disp_top, disp_height;
!   int window_x, window_y, window_width, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
    top = window_y;
  #ifdef MAC_OSX
    width = 16;
  #else
!   width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
  #endif
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     left = XINT (w->left) + XINT (w->width) - FRAME_SCROLL_BAR_COLS (f);
!   else
!     left = XFASTINT (w->left);
!   left *= CANON_X_UNIT (f);
!   left += FRAME_INTERNAL_BORDER_WIDTH (f);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0)
!     sb_width = FRAME_SCROLL_BAR_PIXEL_WIDTH (f);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
--- 3941,3970 ----
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width, disp_top, disp_height;
!   int window_y, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, 0, &window_y, 0, &window_height);
    top = window_y;
  #ifdef MAC_OSX
    width = 16;
  #else
!   width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
  #endif
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   left = WINDOW_SCROLL_BAR_AREA_X (w);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) > 0)
!     sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
***************
*** 3979,3991 ****
        disp_top = -1;
        disp_height++;
      }
!   else if (disp_top == PIXEL_HEIGHT (f) - 16)
      {
        disp_top++;
        disp_height--;
      }
  
!   if (sb_left + sb_width == PIXEL_WIDTH (f))
      sb_left++;
  
    /* Does the scroll bar exist yet?  */
--- 3977,3989 ----
        disp_top = -1;
        disp_height++;
      }
!   else if (disp_top == FRAME_PIXEL_HEIGHT (f) - 16)
      {
        disp_top++;
        disp_height--;
      }
  
!   if (sb_left + sb_width == FRAME_PIXEL_WIDTH (f))
      sb_left++;
  
    /* Does the scroll bar exist yet?  */
***************
*** 4021,4032 ****
             wide as the area reserved for it .  This makes sure a
             previous mode line display is cleared after C-x 2 C-x 1, for
             example.  */
!         int area_width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
          XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                      left, top, area_width, height, 0);
  
  #if 0
!           if (sb_left + sb_width >= PIXEL_WIDTH (f))
              XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                        sb_left - 1, top, 1, height, 0);
  #endif
--- 4019,4030 ----
             wide as the area reserved for it .  This makes sure a
             previous mode line display is cleared after C-x 2 C-x 1, for
             example.  */
!         int area_width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
          XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                      left, top, area_width, height, 0);
  
  #if 0
!           if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
              XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                        sb_left - 1, top, 1, height, 0);
  #endif
***************
*** 4369,4393 ****
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
-    WHOLE_LINE_P non-zero means include the areas used for truncation
-    mark display and alike in the clipping rectangle.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc, whole_line_p)
       struct window *w;
       struct glyph_row *row;
       GC gc;
-      int whole_line_p;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    Rect clip_rect;
!   int window_x, window_y, window_width, window_height;
  
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
  
    clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
--- 4367,4388 ----
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc)
       struct window *w;
       struct glyph_row *row;
       GC gc;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    Rect clip_rect;
!   int window_y, window_width;
  
!   window_box (w, -1, 0, &window_y, &window_width, 0);
  
    clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
***************
*** 4395,4408 ****
    clip_rect.right = clip_rect.left + window_width;
    clip_rect.bottom = clip_rect.top + row->visible_height;
  
-   /* If clipping to the whole line, including trunc marks, extend
-      the rectangle to the left and increase its width.  */
-   if (whole_line_p)
-     {
-       clip_rect.left -= FRAME_X_LEFT_FRINGE_WIDTH (f);
-       clip_rect.right += FRAME_X_FRINGE_WIDTH (f);
-     }
- 
    mac_set_clip_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 
&clip_rect);
  }
  
--- 4390,4395 ----
***************
*** 4442,4448 ****
    wd = cursor_glyph->pixel_width - 1;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (CANON_X_UNIT (f), wd);
  
    /* The foreground of cursor_gc is typically the same as the normal
       background color, which can cause the cursor box to be invisible.  */
--- 4429,4435 ----
    wd = cursor_glyph->pixel_width - 1;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (FRAME_COLUMN_WIDTH (f), wd);
  
    /* The foreground of cursor_gc is typically the same as the normal
       background color, which can cause the cursor box to be invisible.  */
***************
*** 4455,4461 ****
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc, 0);
    mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
    mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f));
  }
--- 4442,4448 ----
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc);
    mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
    mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f));
  }
***************
*** 4511,4517 ****
        width = FRAME_CURSOR_WIDTH (f);
  
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
!       x_clip_to_row (w, row, gc, 0);
        XFillRectangle (dpy, window, gc,
                      x,
                      WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
--- 4498,4504 ----
        width = FRAME_CURSOR_WIDTH (f);
  
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
!       x_clip_to_row (w, row, gc);
        XFillRectangle (dpy, window, gc,
                      x,
                      WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
***************
*** 4685,4720 ****
    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
    FRAME_FONTSET (f) = -1;
  
    /* Compute the scroll bar width in character columns.  */
!   if (f->scroll_bar_pixel_width > 0)
      {
!       int wid = FONT_WIDTH (FRAME_FONT (f));
!       f->scroll_bar_cols = (f->scroll_bar_pixel_width + wid-1) / wid;
      }
    else
      {
!       int wid = FONT_WIDTH (FRAME_FONT (f));
!       f->scroll_bar_cols = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_MAC_WINDOW (f) != 0)
      {
        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
!               f->output_data.mac->font);
        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->reverse_gc,
!               f->output_data.mac->font);
        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc,
!               f->output_data.mac->font);
  
-       frame_update_line_height (f);
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!         x_set_window_size (f, 0, f->width, f->height);
      }
-   else
-     /* If we are setting a new frame's font for the first time,
-        there are no faces yet, so this font's height is the line height.  */
-     f->output_data.mac->line_height = FONT_HEIGHT (FRAME_FONT (f));
  
    return build_string (fontp->full_name);
  }
--- 4672,4708 ----
    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
    FRAME_FONTSET (f) = -1;
  
+   FRAME_COLUMN_WIDTH (f) = FONT_WIDTH (FRAME_FONT (f));
+   FRAME_LINE_HEIGHT (f) = FONT_HEIGHT (FRAME_FONT (f));
+ 
+   compute_fringe_widths (f, 1);
+ 
    /* Compute the scroll bar width in character columns.  */
!   if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f) 
!       = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
      }
    else
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_MAC_WINDOW (f) != 0)
      {
        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
!               FRAME_FONT (f));
        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->reverse_gc,
!               FRAME_FONT (f));
        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc,
!               FRAME_FONT (f));
  
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!         x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
      }
  
    return build_string (fontp->full_name);
  }
***************
*** 4776,4782 ****
       struct frame *f;
  {
    Point pt;
!   int flags = f->output_data.mac->size_hint_flags;
  
    pt.h = pt.v = 0;
  
--- 4764,4770 ----
       struct frame *f;
  {
    Point pt;
!   int flags = f->size_hint_flags;
  
    pt.h = pt.v = 0;
  
***************
*** 4810,4829 ****
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->output_data.mac->left_pos = (FRAME_MAC_DISPLAY_INFO (f)->width
!                             - 2 * f->output_data.mac->border_width - pt.h
!                             - PIXEL_WIDTH (f)
!                             + f->output_data.mac->left_pos);
    /* NTEMACS_TODO: Subtract menubar height?  */
    if (flags & YNegative)
!     f->output_data.mac->top_pos = (FRAME_MAC_DISPLAY_INFO (f)->height
!                            - 2 * f->output_data.mac->border_width - pt.v
!                            - PIXEL_HEIGHT (f)
!                            + f->output_data.mac->top_pos);
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->output_data.mac->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
--- 4798,4817 ----
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->left_pos = (FRAME_MAC_DISPLAY_INFO (f)->width
!                  - 2 * f->border_width - pt.h
!                  - FRAME_PIXEL_WIDTH (f)
!                  + f->left_pos);
    /* NTEMACS_TODO: Subtract menubar height?  */
    if (flags & YNegative)
!     f->top_pos = (FRAME_MAC_DISPLAY_INFO (f)->height
!                 - 2 * f->border_width - pt.v
!                 - FRAME_PIXEL_HEIGHT (f)
!                 + f->top_pos);
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
***************
*** 4842,4863 ****
  
    if (change_gravity > 0)
      {
!       f->output_data.mac->top_pos = yoff;
!       f->output_data.mac->left_pos = xoff;
!       f->output_data.mac->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->output_data.mac->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->output_data.mac->size_hint_flags |= YNegative;
!       f->output_data.mac->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->output_data.mac->left_pos;
!   modified_top = f->output_data.mac->top_pos;
  
    MoveWindow (f->output_data.mac->mWP, modified_left + 6,
              modified_top + 42, false);
--- 4830,4851 ----
  
    if (change_gravity > 0)
      {
!       f->top_pos = yoff;
!       f->left_pos = xoff;
!       f->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->size_hint_flags |= YNegative;
!       f->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->left_pos;
!   modified_top = f->top_pos;
  
    MoveWindow (f->output_data.mac->mWP, modified_left + 6,
              modified_top + 42, false);
***************
*** 4881,4897 ****
    BLOCK_INPUT;
  
    check_frame_size (f, &rows, &cols);
!   f->output_data.mac->vertical_scroll_bar_extra
!     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
!        ? 0
!        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.mac->font)));
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
  
!   f->output_data.mac->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
--- 4869,4883 ----
    BLOCK_INPUT;
  
    check_frame_size (f, &rows, &cols);
!   f->scroll_bar_actual_width
!     = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
  
!   f->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
***************
*** 4910,4917 ****
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   PIXEL_WIDTH (f) = pixelwidth;
!   PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
--- 4896,4903 ----
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   FRAME_PIXEL_WIDTH (f) = pixelwidth;
!   FRAME_PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
***************
*** 4944,4957 ****
  {
    int pix_x, pix_y;
  
!   pix_x = CHAR_TO_PIXEL_COL (f, x) + FONT_WIDTH  (f->output_data.mac->font) / 
2;
!   pix_y = CHAR_TO_PIXEL_ROW (f, y) + f->output_data.mac->line_height / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > PIXEL_WIDTH (f)) pix_x = PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > PIXEL_HEIGHT (f)) pix_y = PIXEL_HEIGHT (f);
  
    x_set_mouse_pixel_position (f, pix_x, pix_y);
  }
--- 4930,4943 ----
  {
    int pix_x, pix_y;
  
!   pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
!   pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
  
    x_set_mouse_pixel_position (f, pix_x, pix_y);
  }
***************
*** 5050,5057 ****
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.mac->asked_for_visible)
!       x_set_offset (f, f->output_data.mac->left_pos,
!                     f->output_data.mac->top_pos, 0);
  
        f->output_data.mac->asked_for_visible = 1;
  
--- 5036,5042 ----
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.mac->asked_for_visible)
!       x_set_offset (f, f->left_pos, f->top_pos, 0);
  
        f->output_data.mac->asked_for_visible = 1;
  
***************
*** 5228,5235 ****
    /* Setting PMaxSize caused various problems.  */
    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
  
!   size_hints.x = f->output_data.x->left_pos;
!   size_hints.y = f->output_data.x->top_pos;
  
  #ifdef USE_X_TOOLKIT
    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
--- 5213,5220 ----
    /* Setting PMaxSize caused various problems.  */
    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
  
!   size_hints.x = f->left_pos;
!   size_hints.y = f->top_pos;
  
  #ifdef USE_X_TOOLKIT
    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
***************
*** 5238,5253 ****
    size_hints.height = widget_height;
    size_hints.width = widget_width;
  #else /* not USE_X_TOOLKIT */
!   size_hints.height = PIXEL_HEIGHT (f);
!   size_hints.width = PIXEL_WIDTH (f);
  #endif /* not USE_X_TOOLKIT */
  
!   size_hints.width_inc = FONT_WIDTH (f->output_data.x->font);
!   size_hints.height_inc = f->output_data.x->line_height;
    size_hints.max_width
!     = FRAME_X_DISPLAY_INFO (f)->width - CHAR_TO_PIXEL_WIDTH (f, 0);
    size_hints.max_height
!     = FRAME_X_DISPLAY_INFO (f)->height - CHAR_TO_PIXEL_HEIGHT (f, 0);
  
    /* Calculate the base and minimum sizes.
  
--- 5223,5238 ----
    size_hints.height = widget_height;
    size_hints.width = widget_width;
  #else /* not USE_X_TOOLKIT */
!   size_hints.height = FRAME_PIXEL_HEIGHT (f);
!   size_hints.width = FRAME_PIXEL_WIDTH (f);
  #endif /* not USE_X_TOOLKIT */
  
!   size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
!   size_hints.height_inc = FRAME_LINE_HEIGHT (f);
    size_hints.max_width
!     = FRAME_X_DISPLAY_INFO (f)->width - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
    size_hints.max_height
!     = FRAME_X_DISPLAY_INFO (f)->height - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 
0);
  
    /* Calculate the base and minimum sizes.
  
***************
*** 5258,5265 ****
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
  
!     base_width = CHAR_TO_PIXEL_WIDTH (f, 0);
!     base_height = CHAR_TO_PIXEL_HEIGHT (f, 0);
  
      check_frame_size (f, &min_rows, &min_cols);
  
--- 5243,5250 ----
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
  
!     base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
!     base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
  
      check_frame_size (f, &min_rows, &min_cols);
  
***************
*** 5334,5340 ****
  #endif
  
  #ifdef PWinGravity
!   size_hints.win_gravity = f->output_data.x->win_gravity;
    size_hints.flags |= PWinGravity;
  
    if (user_position)
--- 5319,5325 ----
  #endif
  
  #ifdef PWinGravity
!   size_hints.win_gravity = f->win_gravity;
    size_hints.flags |= PWinGravity;
  
    if (user_position)
***************
*** 7016,7023 ****
    /* see if it really changed size */
    if (grow_size != 0)
      {
!       rows = PIXEL_TO_CHAR_HEIGHT (f, HiWord (grow_size));
!       columns = PIXEL_TO_CHAR_WIDTH (f, LoWord (grow_size));
  
        x_set_window_size (f, 0, columns, rows);
      }
--- 7001,7008 ----
    /* see if it really changed size */
    if (grow_size != 0)
      {
!       rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, HiWord (grow_size));
!       columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, LoWord (grow_size));
  
        x_set_window_size (f, 0, columns, rows);
      }
***************
*** 7069,7075 ****
          InsetRect (&zoom_rect, 8, 4);  /* not too tight */
  
          zoom_rect.right = zoom_rect.left
!         + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
  
          SetWindowStandardState (w, &zoom_rect);
        }
--- 7054,7060 ----
          InsetRect (&zoom_rect, 8, 4);  /* not too tight */
  
          zoom_rect.right = zoom_rect.left
!         + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
  
          SetWindowStandardState (w, &zoom_rect);
        }
***************
*** 7091,7097 ****
        InsetRect (&zoom_rect, 8, 4);  /* not too tight */
  
        zoom_rect.right = zoom_rect.left
!       + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
  
        (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState
        = zoom_rect;
--- 7076,7082 ----
        InsetRect (&zoom_rect, 8, 4);  /* not too tight */
  
        zoom_rect.right = zoom_rect.left
!       + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
  
        (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState
        = zoom_rect;
***************
*** 7106,7113 ****
  #else
    port_rect = w->portRect;
  #endif
!   rows = PIXEL_TO_CHAR_HEIGHT (f, port_rect.bottom - port_rect.top);
!   columns = PIXEL_TO_CHAR_WIDTH (f, port_rect.right - port_rect.left);
    x_set_window_size (mwp->mFP, 0, columns, rows);
  
    SetPort (save_port);
--- 7091,7098 ----
  #else
    port_rect = w->portRect;
  #endif
!   rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - 
port_rect.top);
!   columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - 
port_rect.left);
    x_set_window_size (mwp->mFP, 0, columns, rows);
  
    SetPort (save_port);
***************
*** 8256,8262 ****
  
    mwp->fontset = -1;
  
!   SizeWindow (mwp->mWP, mwp->pixel_width, mwp->pixel_height, false);
    ShowWindow (mwp->mWP);
  
  }
--- 8241,8247 ----
  
    mwp->fontset = -1;
  
!   SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), 
false);
    ShowWindow (mwp->mWP);
  
  }
***************
*** 8277,8299 ****
    f->output_data.mac->mouse_pixel = 0xff00ff;
    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
  
!   f->output_data.mac->fontset = -1;
    f->output_data.mac->scroll_bar_foreground_pixel = -1;
    f->output_data.mac->scroll_bar_background_pixel = -1;
-   f->output_data.mac->left_pos = 4;
-   f->output_data.mac->top_pos = 4;
-   f->output_data.mac->border_width = 0;
    f->output_data.mac->explicit_parent = 0;
  
!   f->output_data.mac->internal_border_width = 0;
  
    f->output_method = output_mac;
  
    f->auto_raise = 1;
    f->auto_lower = 1;
  
!   f->new_width = 0;
!   f->new_height = 0;
  }
  
  void
--- 8262,8284 ----
    f->output_data.mac->mouse_pixel = 0xff00ff;
    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
  
!   FRAME_FONTSET (f) = -1;
    f->output_data.mac->scroll_bar_foreground_pixel = -1;
    f->output_data.mac->scroll_bar_background_pixel = -1;
    f->output_data.mac->explicit_parent = 0;
+   f->left_pos = 4;
+   f->top_pos = 4;
+   f->border_width = 0;
  
!   f->internal_border_width = 0;
  
    f->output_method = output_mac;
  
    f->auto_raise = 1;
    f->auto_lower = 1;
  
!   f->new_text_cols = 0;
!   f->new_text_lines = 0;
  }
  
  void
***************
*** 8307,8320 ****
    f->output_data.mac = (struct mac_output *)
      xmalloc (sizeof (struct mac_output));
    bzero (f->output_data.mac, sizeof (struct mac_output));
!   f->output_data.mac->fontset = -1;
    f->output_data.mac->scroll_bar_foreground_pixel = -1;
    f->output_data.mac->scroll_bar_background_pixel = -1;
  
    XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
  
!   f->width = 96;
!   f->height = 4;
  
    make_mac_frame (f);
  
--- 8292,8305 ----
    f->output_data.mac = (struct mac_output *)
      xmalloc (sizeof (struct mac_output));
    bzero (f->output_data.mac, sizeof (struct mac_output));
!   FRAME_FONTSET (f) = -1;
    f->output_data.mac->scroll_bar_foreground_pixel = -1;
    f->output_data.mac->scroll_bar_background_pixel = -1;
  
    XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
  
!   FRAME_COLS (f) = 96;
!   FRAME_LINES (f) = 4;
  
    make_mac_frame (f);
  
Index: macterm.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.h,v
retrieving revision 1.8
diff -c -r1.8 macterm.h
*** macterm.h   1 Apr 2003 01:09:13 -0000       1.8
--- macterm.h   14 May 2003 21:52:22 -0000
***************
*** 297,325 ****
    int size_computed_faces;
  #endif
  
-   /* Position of the Mac window (x and y offsets in global coordinates).  */
-   int left_pos;
-   int top_pos;
- 
-   /* Border width of the W32 window as known by the window system.  */
-   int border_width;
- 
-   /* Size of the W32 window in pixels.  */
-   int pixel_height, pixel_width;
- 
-   /* Height of a line, in pixels.  */
-   int line_height;
- 
    /* Here are the Graphics Contexts for the default font.  */
    GC normal_gc;                               /* Normal video */
    GC reverse_gc;                      /* Reverse video */
    GC cursor_gc;                               /* cursor drawing */
  
-   /* Width of the internal border.  This is a line of background color
-      just inside the window's border.  When the frame is selected,
-      a highlighting is displayed inside the internal border.  */
-   int internal_border_width;
- 
    /* The window used for this frame.
       May be zero while the frame object is being created
       and the window has not yet been created.  */
--- 297,307 ----
***************
*** 381,402 ****
    DWORD dwStyle;
  #endif
  
-   /* The size of the extra width currently allotted for vertical
-      scroll bars, in pixels.  */
-   int vertical_scroll_bar_extra;
- 
-   /* The extra width currently allotted for the areas in which
-      truncation marks, continuation marks, and overlay arrows are
-      displayed.  */
-   int left_fringe_width, right_fringe_width;
-   int fringe_cols, fringes_extra;
- 
-   /* This is the gravity value for the specified window position.  */
-   int win_gravity;
- 
-   /* The geometry flags for this window.  */
-   int size_hint_flags;
- 
    /* This is the Emacs structure for the display this frame is on.  */
    /* struct w32_display_info *display_info; */
  
--- 363,368 ----
***************
*** 429,445 ****
    /* The background for which the above relief GCs were set up.
       They are changed only when a different background is involved.  */
    unsigned long relief_background;
- 
-   /* See enum below */
-   int want_fullscreen;
- 
-   /* This many pixels are the difference between the outer window (i.e. the
-      left of the window manager decoration) and FRAME_X_WINDOW. */
-   int x_pixels_diff;
- 
-   /* This many pixels are the difference between the outer window (i.e. the
-      top of the window manager titlebar) and FRAME_X_WINDOW. */
-   int y_pixels_diff;
  };
  
  typedef struct mac_output mac_output;
--- 395,400 ----
***************
*** 457,469 ****
  #define FRAME_FONT(f) ((f)->output_data.mac->font)
  #define FRAME_FONTSET(f) ((f)->output_data.mac->fontset)
  
- #undef FRAME_INTERNAL_BORDER_WIDTH
- #define FRAME_INTERNAL_BORDER_WIDTH(f) \
-      ((f)->output_data.mac->internal_border_width)
- #define FRAME_LINE_HEIGHT(f) ((f)->output_data.mac->line_height)
- /* Width of the default font of frame F.  Must be defined by each
-    terminal specific header.  */
- #define FRAME_DEFAULT_FONT_WIDTH(F)   FONT_WIDTH (FRAME_FONT (F))
  #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.mac->baseline_offset)
  
  /* This gives the w32_display_info structure for the display F is on.  */
--- 412,417 ----
***************
*** 477,486 ****
  /* This is the 'font_info *' which frame F has.  */
  #define FRAME_MAC_FONT_TABLE(f) (FRAME_MAC_DISPLAY_INFO (f)->font_table)
  
- /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}.  */
- #define PIXEL_WIDTH(f) ((f)->output_data.mac->pixel_width)
- #define PIXEL_HEIGHT(f) ((f)->output_data.mac->pixel_height)
- 
  /* Value is the smallest width of any character in any font on frame F.  */
  
  #define FRAME_SMALLEST_CHAR_WIDTH(F) \
--- 425,430 ----
***************
*** 496,520 ****
  #define FRAME_X_IMAGE_CACHE(F) FRAME_MAC_DISPLAY_INFO ((F))->image_cache
  
  
- /* Total width of fringes reserved for drawing truncation bitmaps,
-    continuation bitmaps and alike.  The width is in canonical char
-    units of the frame.  This must currently be the case because window
-    sizes aren't pixel values.  If it weren't the case, we wouldn't be
-    able to split windows horizontally nicely.  */
- 
- #define FRAME_X_FRINGE_COLS(F)        ((F)->output_data.mac->fringe_cols)
- 
- /* Total width of fringes in pixels.  */
- 
- #define FRAME_X_FRINGE_WIDTH(F) ((F)->output_data.mac->fringes_extra)
- 
- /* Pixel-width of the left and right fringe.  */
- 
- #define FRAME_X_LEFT_FRINGE_WIDTH(F) ((F)->output_data.mac->left_fringe_width)
- #define FRAME_X_RIGHT_FRINGE_WIDTH(F) 
((F)->output_data.mac->right_fringe_width)
- 
- 
- 
  /* Mac-specific scroll bar stuff.  */
  
  /* We represent scroll bars as lisp vectors.  This allows us to place
--- 440,445 ----
***************
*** 647,697 ****
     text from glomming up against the scroll bar */
  #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
  
- 
- /* Manipulating pixel sizes and character sizes.
-    Knowledge of which factors affect the overall size of the window should
-    be hidden in these macros, if that's possible.
- 
-    Return the upper/left pixel position of the character cell on frame F
-    at ROW/COL.  */
- #define CHAR_TO_PIXEL_ROW(f, row) \
-   ((f)->output_data.mac->internal_border_width \
-    + (row) * (f)->output_data.mac->line_height)
- #define CHAR_TO_PIXEL_COL(f, col) \
-   ((f)->output_data.mac->internal_border_width \
-    + (col) * FONT_WIDTH ((f)->output_data.mac->font))
- 
- /* Return the pixel width/height of frame F if it has
-    WIDTH columns/HEIGHT rows.  */
- #define CHAR_TO_PIXEL_WIDTH(f, width) \
-   (CHAR_TO_PIXEL_COL (f, width) \
-    + (f)->output_data.mac->vertical_scroll_bar_extra \
-    + (f)->output_data.mac->fringes_extra \
-    + (f)->output_data.mac->internal_border_width)
- #define CHAR_TO_PIXEL_HEIGHT(f, height) \
-   (CHAR_TO_PIXEL_ROW (f, height) \
-    + (f)->output_data.mac->internal_border_width)
- 
- 
- /* Return the row/column (zero-based) of the character cell containing
-    the pixel on FRAME at ROW/COL.  */
- #define PIXEL_TO_CHAR_ROW(f, row) \
-   (((row) - (f)->output_data.mac->internal_border_width) \
-    / (f)->output_data.mac->line_height)
- #define PIXEL_TO_CHAR_COL(f, col) \
-   (((col) - (f)->output_data.mac->internal_border_width) \
-    / FONT_WIDTH ((f)->output_data.mac->font))
- 
- /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
-    frame F?  */
- #define PIXEL_TO_CHAR_WIDTH(f, width) \
-   (PIXEL_TO_CHAR_COL (f, ((width) \
-                         - (f)->output_data.mac->internal_border_width \
-                         - (f)->output_data.mac->fringes_extra \
-                         - (f)->output_data.mac->vertical_scroll_bar_extra)))
- #define PIXEL_TO_CHAR_HEIGHT(f, height) \
-   (PIXEL_TO_CHAR_ROW (f, ((height) \
-                         - (f)->output_data.mac->internal_border_width)))
  
  struct frame * check_x_frame (Lisp_Object);
  
--- 572,577 ----
Index: minibuf.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/minibuf.c,v
retrieving revision 1.255
diff -c -r1.255 minibuf.c
*** minibuf.c   11 Apr 2003 02:06:15 -0000      1.255
--- minibuf.c   14 May 2003 21:52:22 -0000
***************
*** 159,165 ****
         init_window_once.  That window doesn't have a buffer.  */
        buffer = XWINDOW (minibuf_window)->buffer;
        if (BUFFERP (buffer))
!       Fset_window_buffer (sf->minibuffer_window, buffer);
        minibuf_window = sf->minibuffer_window;
      }
  
--- 159,165 ----
         init_window_once.  That window doesn't have a buffer.  */
        buffer = XWINDOW (minibuf_window)->buffer;
        if (BUFFERP (buffer))
!       Fset_window_buffer (sf->minibuffer_window, buffer, Qnil);
        minibuf_window = sf->minibuffer_window;
      }
  
***************
*** 584,590 ****
    Vminibuf_scroll_window = selected_window;
    if (minibuf_level == 1 || !EQ (minibuf_window, selected_window))
      minibuf_selected_window = selected_window;
!   Fset_window_buffer (minibuf_window, Fcurrent_buffer ());
    Fselect_window (minibuf_window);
    XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0);
  
--- 584,590 ----
    Vminibuf_scroll_window = selected_window;
    if (minibuf_level == 1 || !EQ (minibuf_window, selected_window))
      minibuf_selected_window = selected_window;
!   Fset_window_buffer (minibuf_window, Fcurrent_buffer (), Qnil);
    Fselect_window (minibuf_window);
    XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0);
  
Index: msdos.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/msdos.c,v
retrieving revision 1.182
diff -c -r1.182 msdos.c
*** msdos.c     21 Mar 2003 22:56:52 -0000      1.182
--- msdos.c     14 May 2003 21:52:24 -0000
***************
*** 1260,1267 ****
        row->mouse_face_p = hl > 0;
        if (hl > 0)
        {
!         int vpos = row->y + WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w);
!         int kstart = start_hpos + WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X (w);
          int nglyphs = end_hpos - start_hpos;
          int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
          int start_offset = offset;
--- 1260,1267 ----
        row->mouse_face_p = hl > 0;
        if (hl > 0)
        {
!         int vpos = row->y + WINDOW_TOP_EDGE_Y (w);
!         int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w);
          int nglyphs = end_hpos - start_hpos;
          int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
          int start_offset = offset;
***************
*** 1303,1310 ****
          /* IT_write_glyphs writes at cursor position, so we need to
             temporarily move cursor coordinates to the beginning of
             the highlight region.  */
!         new_pos_X = start_hpos + WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X (w);
!         new_pos_Y = row->y + WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w);
  
          if (termscript)
            fprintf (termscript, "<MH- %d-%d:%d>",
--- 1303,1310 ----
          /* IT_write_glyphs writes at cursor position, so we need to
             temporarily move cursor coordinates to the beginning of
             the highlight region.  */
!         new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w);
!         new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w);
  
          if (termscript)
            fprintf (termscript, "<MH- %d-%d:%d>",
***************
*** 1433,1440 ****
        Lisp_Object help, map;
  
        /* Find the glyph under X.  */
!       glyph = row->glyphs[TEXT_AREA]
!       + x - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f);
        end = glyph + row->used[TEXT_AREA];
        if (glyph < end
          && STRINGP (glyph->object)
--- 1433,1442 ----
        Lisp_Object help, map;
  
        /* Find the glyph under X.  */
!       glyph = (row->glyphs[TEXT_AREA]
!              + x
!              /* Does MS-DOG really support scroll-bars??  ++KFS */
!              - WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w));
        end = glyph + row->used[TEXT_AREA];
        if (glyph < end
          && STRINGP (glyph->object)
***************
*** 1492,1498 ****
      }
  
    /* Which window is that in?  */
!   window = window_from_coordinates (f, x, y, &part, 0);
  
    /* If we were displaying active text in another window, clear that.  */
    if (! EQ (window, dpyinfo->mouse_face_window))
--- 1494,1500 ----
      }
  
    /* Which window is that in?  */
!   window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
  
    /* If we were displaying active text in another window, clear that.  */
    if (! EQ (window, dpyinfo->mouse_face_window))
***************
*** 1504,1511 ****
  
    /* Convert to window-relative coordinates.  */
    w = XWINDOW (window);
-   x -= WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X (w);
-   y -= WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w);
  
    if (part == ON_MODE_LINE || part == ON_HEADER_LINE)
      {
--- 1506,1511 ----
***************
*** 1513,1520 ****
        IT_note_mode_line_highlight (w, x, part == ON_MODE_LINE);
        return;
      }
!   else
!     IT_set_mouse_pointer (0);
  
    /* Are we in a window whose display is up to date?
       And verify the buffer's text has not changed.  */
--- 1513,1520 ----
        IT_note_mode_line_highlight (w, x, part == ON_MODE_LINE);
        return;
      }
! 
!   IT_set_mouse_pointer (0);
  
    /* Are we in a window whose display is up to date?
       And verify the buffer's text has not changed.  */
***************
*** 1881,1887 ****
    /* If we are in the echo area, put the cursor at the
       end of the echo area message.  */
    if (!update_cursor_pos
!       && XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top) <= new_pos_Y)
      {
        int tem_X = current_pos_X, dummy;
  
--- 1881,1887 ----
    /* If we are in the echo area, put the cursor at the
       end of the echo area message.  */
    if (!update_cursor_pos
!       && WINDOW_TOP_EDGE_LINE (XWINDOW (FRAME_MINIBUF_WINDOW (f))) <= 
new_pos_Y)
      {
        int tem_X = current_pos_X, dummy;
  
***************
*** 2548,2554 ****
        if (colors[1] >= 0 && colors[1] < 16)
          the_only_x_display.background_pixel = colors[1];
      }
-   the_only_x_display.line_height = 1;
    the_only_x_display.font = (XFontStruct *)1;   /* must *not* be zero */
    the_only_x_display.display_info.mouse_face_mouse_frame = NULL;
    the_only_x_display.display_info.mouse_face_deferred_gc = 0;
--- 2548,2553 ----
***************
*** 3383,3389 ****
              mouse_window = window_from_coordinates (SELECTED_FRAME(),
                                                      mouse_last_x,
                                                      mouse_last_y,
!                                                     0, 0);
              /* A window will be selected only when it is not
                 selected now, and the last mouse movement event was
                 not in it.  A minibuffer window will be selected iff
--- 3382,3388 ----
              mouse_window = window_from_coordinates (SELECTED_FRAME(),
                                                      mouse_last_x,
                                                      mouse_last_y,
!                                                     0, 0, 0, 0);
              /* A window will be selected only when it is not
                 selected now, and the last mouse movement event was
                 not in it.  A minibuffer window will be selected iff
***************
*** 4011,4023 ****
  int
  x_pixel_width (struct frame *f)
  {
!   return FRAME_WIDTH (f);
  }
  
  int
  x_pixel_height (struct frame *f)
  {
!   return FRAME_HEIGHT (f);
  }
  #endif /* !HAVE_X_WINDOWS */
  
--- 4010,4022 ----
  int
  x_pixel_width (struct frame *f)
  {
!   return FRAME_COLS (f);
  }
  
  int
  x_pixel_height (struct frame *f)
  {
!   return FRAME_LINES (f);
  }
  #endif /* !HAVE_X_WINDOWS */
  
Index: msdos.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/msdos.h,v
retrieving revision 1.26
diff -c -r1.26 msdos.h
*** msdos.h     21 Mar 2003 22:56:52 -0000      1.26
--- msdos.h     14 May 2003 21:52:24 -0000
***************
*** 90,98 ****
  /* This is a cut-down version of the one in xterm.h, which see.  */
  struct x_output
  {
-   int left_pos;                       /* used in xmenu_show (xmenu.c) */
-   int top_pos;                        /* ditto */
-   int line_height;            /* used in x-popup-menu (xmenu.c) */
    PIX_TYPE background_pixel;  /* used in xfaces.c and lots of other places */
    PIX_TYPE foreground_pixel;  /* ditto */
    XFontStruct *font;          /* used in x-popup-menu (xmenu.c) */
--- 90,95 ----
***************
*** 108,116 ****
  #define FRAME_BACKGROUND_PIXEL(f) (the_only_x_display.background_pixel)
  #define FRAME_FONT(f) (the_only_x_display.font)
  #define FRAME_X_DISPLAY_INFO(f) (&the_only_x_display.display_info)
- #define FRAME_LINE_HEIGHT(f) (the_only_x_display.line_height)
- 
- #define FRAME_INTERNAL_BORDER_WIDTH(f) (0)
  
  /* Prototypes.  */
  
--- 105,110 ----
***************
*** 129,136 ****
  #define x_destroy_bitmap(p1,p2)
  #define load_pixmap(p1,p2,p3,p4) (0)
  #define XGetGeometry(p1,p2,p3,p4,p5,p6,p7,p8,p9)
! #define DisplayWidth(p1,p2) (SELECTED_FRAME()->width)
! #define DisplayHeight(p1,p2) (SELECTED_FRAME()->height)
  #define XMenuSetAEQ (void)
  #define XMenuSetFreeze (void)
  #define XMenuRecompute (void)
--- 123,130 ----
  #define x_destroy_bitmap(p1,p2)
  #define load_pixmap(p1,p2,p3,p4) (0)
  #define XGetGeometry(p1,p2,p3,p4,p5,p6,p7,p8,p9)
! #define DisplayWidth(p1,p2) (SELECTED_FRAME()->text_cols)
! #define DisplayHeight(p1,p2) (SELECTED_FRAME()->text_lines)
  #define XMenuSetAEQ (void)
  #define XMenuSetFreeze (void)
  #define XMenuRecompute (void)
Index: scroll.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/scroll.c,v
retrieving revision 1.28
diff -c -r1.28 scroll.c
*** scroll.c    4 Feb 2003 14:03:13 -0000       1.28
--- scroll.c    14 May 2003 21:52:24 -0000
***************
*** 96,102 ****
       int free_at_end;
  {
    register int i, j;
!   int frame_height = FRAME_HEIGHT (frame);
    register struct matrix_elt *p, *p1;
    register int cost, cost1;
  
--- 96,102 ----
       int free_at_end;
  {
    register int i, j;
!   int frame_lines = FRAME_LINES (frame);
    register struct matrix_elt *p, *p1;
    register int cost, cost1;
  
***************
*** 105,122 ****
       at the i'th line of the lines we are considering,
       where I is origin 1 (as it is below).  */
    int *first_insert_cost
!     = &FRAME_INSERT_COST (frame)[frame_height - 1 - lines_moved];
    int *first_delete_cost
!     = &FRAME_DELETE_COST (frame)[frame_height - 1 - lines_moved];
    int *next_insert_cost
!     = &FRAME_INSERTN_COST (frame)[frame_height - 1 - lines_moved];
    int *next_delete_cost
!     = &FRAME_DELETEN_COST (frame)[frame_height - 1 - lines_moved];
  
    /* Discourage long scrolls on fast lines.
       Don't scroll nearly a full frame height unless it saves
       at least 1/4 second.  */
!   int extra_cost = baud_rate / (10 * 4 * FRAME_HEIGHT (frame));
  
    if (baud_rate <= 0)
      extra_cost = 1;
--- 105,122 ----
       at the i'th line of the lines we are considering,
       where I is origin 1 (as it is below).  */
    int *first_insert_cost
!     = &FRAME_INSERT_COST (frame)[frame_lines - 1 - lines_moved];
    int *first_delete_cost
!     = &FRAME_DELETE_COST (frame)[frame_lines - 1 - lines_moved];
    int *next_insert_cost
!     = &FRAME_INSERTN_COST (frame)[frame_lines - 1 - lines_moved];
    int *next_delete_cost
!     = &FRAME_DELETEN_COST (frame)[frame_lines - 1 - lines_moved];
  
    /* Discourage long scrolls on fast lines.
       Don't scroll nearly a full frame height unless it saves
       at least 1/4 second.  */
!   int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame));
  
    if (baud_rate <= 0)
      extra_cost = 1;
***************
*** 438,464 ****
       int free_at_end;
  {
    register int i, j;
!   int frame_height = FRAME_HEIGHT (frame);
    register struct matrix_elt *p, *p1;
    register int cost, cost1, delta;
  
    /* first_insert_cost[-I] is the cost of doing the first insert-line
       at a position I lines above the bottom line in the scroll window. */
    int *first_insert_cost
!     = &FRAME_INSERT_COST (frame)[frame_height - 1];
    int *first_delete_cost
!     = &FRAME_DELETE_COST (frame)[frame_height - 1];
    int *next_insert_cost
!     = &FRAME_INSERTN_COST (frame)[frame_height - 1];
    int *next_delete_cost
!     = &FRAME_DELETEN_COST (frame)[frame_height - 1];
  
    int scroll_overhead;
  
    /* Discourage long scrolls on fast lines.
       Don't scroll nearly a full frame height unless it saves
       at least 1/4 second.  */
!   int extra_cost = baud_rate / (10 * 4 * FRAME_HEIGHT (frame));
  
    if (baud_rate <= 0)
      extra_cost = 1;
--- 438,464 ----
       int free_at_end;
  {
    register int i, j;
!   int frame_lines = FRAME_LINES (frame);
    register struct matrix_elt *p, *p1;
    register int cost, cost1, delta;
  
    /* first_insert_cost[-I] is the cost of doing the first insert-line
       at a position I lines above the bottom line in the scroll window. */
    int *first_insert_cost
!     = &FRAME_INSERT_COST (frame)[frame_lines - 1];
    int *first_delete_cost
!     = &FRAME_DELETE_COST (frame)[frame_lines - 1];
    int *next_insert_cost
!     = &FRAME_INSERTN_COST (frame)[frame_lines - 1];
    int *next_delete_cost
!     = &FRAME_DELETEN_COST (frame)[frame_lines - 1];
  
    int scroll_overhead;
  
    /* Discourage long scrolls on fast lines.
       Don't scroll nearly a full frame height unless it saves
       at least 1/4 second.  */
!   int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame));
  
    if (baud_rate <= 0)
      extra_cost = 1;
***************
*** 909,915 ****
       will not be involved in actual motion.  */
    int limit = to;
    int offset;
!   int height = FRAME_HEIGHT (frame);
  
    if (amount == 0)
      return 0;
--- 909,915 ----
       will not be involved in actual motion.  */
    int limit = to;
    int offset;
!   int height = FRAME_LINES (frame);
  
    if (amount == 0)
      return 0;
***************
*** 947,957 ****
       register int *ov, *mf;
  {
    register int i;
!   register int frame_height = FRAME_HEIGHT (frame);
    register int insert_overhead = ov1 * 10;
    register int next_insert_cost = ovn * 10;
  
!   for (i = frame_height-1; i >= 0; i--)
      {
        mf[i] = next_insert_cost / 10;
        next_insert_cost += pfn;
--- 947,957 ----
       register int *ov, *mf;
  {
    register int i;
!   register int frame_lines = FRAME_LINES (frame);
    register int insert_overhead = ov1 * 10;
    register int next_insert_cost = ovn * 10;
  
!   for (i = frame_lines-1; i >= 0; i--)
      {
        mf[i] = next_insert_cost / 10;
        next_insert_cost += pfn;
***************
*** 1000,1011 ****
     only) and those that must repeatedly insert one line.
  
     The cost to insert N lines at line L is
!           [tt.t_ILov  + (frame_height + 1 - L) * tt.t_ILpf] +
!       N * [tt.t_ILnov + (frame_height + 1 - L) * tt.t_ILnpf]
  
     ILov represents the basic insert line overhead.  ILpf is the padding
     required to allow the terminal time to move a line: insertion at line
!    L changes (frame_height + 1 - L) lines.
  
     The first bracketed expression above is the overhead; the second is
     the multiply factor.  Both are dependent only on the position at
--- 1000,1011 ----
     only) and those that must repeatedly insert one line.
  
     The cost to insert N lines at line L is
!           [tt.t_ILov  + (frame_lines + 1 - L) * tt.t_ILpf] +
!       N * [tt.t_ILnov + (frame_lines + 1 - L) * tt.t_ILnpf]
  
     ILov represents the basic insert line overhead.  ILpf is the padding
     required to allow the terminal time to move a line: insertion at line
!    L changes (frame_lines + 1 - L) lines.
  
     The first bracketed expression above is the overhead; the second is
     the multiply factor.  Both are dependent only on the position at
***************
*** 1035,1061 ****
      {
        FRAME_INSERT_COST (frame) =
        (int *) xrealloc (FRAME_INSERT_COST (frame),
!                         FRAME_HEIGHT (frame) * sizeof (int));
        FRAME_DELETEN_COST (frame) =
        (int *) xrealloc (FRAME_DELETEN_COST (frame),
!                         FRAME_HEIGHT (frame) * sizeof (int));
        FRAME_INSERTN_COST (frame) =
        (int *) xrealloc (FRAME_INSERTN_COST (frame),
!                         FRAME_HEIGHT (frame) * sizeof (int));
        FRAME_DELETE_COST (frame) =
        (int *) xrealloc (FRAME_DELETE_COST (frame),
!                         FRAME_HEIGHT (frame) * sizeof (int));
      }
    else
      {
        FRAME_INSERT_COST (frame) =
!       (int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int));
        FRAME_DELETEN_COST (frame) =
!       (int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int));
        FRAME_INSERTN_COST (frame) =
!       (int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int));
        FRAME_DELETE_COST (frame) =
!       (int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int));
      }
  
    ins_del_costs (frame,
--- 1035,1061 ----
      {
        FRAME_INSERT_COST (frame) =
        (int *) xrealloc (FRAME_INSERT_COST (frame),
!                         FRAME_LINES (frame) * sizeof (int));
        FRAME_DELETEN_COST (frame) =
        (int *) xrealloc (FRAME_DELETEN_COST (frame),
!                         FRAME_LINES (frame) * sizeof (int));
        FRAME_INSERTN_COST (frame) =
        (int *) xrealloc (FRAME_INSERTN_COST (frame),
!                         FRAME_LINES (frame) * sizeof (int));
        FRAME_DELETE_COST (frame) =
        (int *) xrealloc (FRAME_DELETE_COST (frame),
!                         FRAME_LINES (frame) * sizeof (int));
      }
    else
      {
        FRAME_INSERT_COST (frame) =
!       (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
        FRAME_DELETEN_COST (frame) =
!       (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
        FRAME_INSERTN_COST (frame) =
!       (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
        FRAME_DELETE_COST (frame) =
!       (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
      }
  
    ins_del_costs (frame,
Index: sunfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/sunfns.c,v
retrieving revision 1.24
diff -c -r1.24 sunfns.c
*** sunfns.c    4 Feb 2003 14:03:13 -0000       1.24
--- sunfns.c    14 May 2003 21:52:24 -0000
***************
*** 454,461 ****
  
    CHECK_GFX (Qnil);
  
!   xpos = CtoSX (WINDOW_LEFT_MARGIN (XWINDOW (window)) + XINT(X_Position));
!   ypos = CtoSY (XWINDOW(window)->top  + XINT(Y_Position));
  #ifdef  Menu_Base_Kludge
    {static Lisp_Object symbol[2];
     symbol[0] = Fintern (sm_kludge_string, Qnil);
--- 454,463 ----
  
    CHECK_GFX (Qnil);
  
!   xpos = CtoSX (WINDOW_LEFT_EDGE_COL (XWINDOW (window))
!               + WINDOW_LEFT_SCROLL_BAR_COLS (XWINDOW (window))
!               + XINT(X_Position));
!   ypos = CtoSY (WINDOW_TOP_EDGE_LINE (XWINDOW(window)) + XINT(Y_Position));
  #ifdef  Menu_Base_Kludge
    {static Lisp_Object symbol[2];
     symbol[0] = Fintern (sm_kludge_string, Qnil);
Index: sysdep.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/sysdep.c,v
retrieving revision 1.248
diff -c -r1.248 sysdep.c
*** sysdep.c    4 Feb 2003 14:03:13 -0000       1.248
--- sysdep.c    14 May 2003 21:52:25 -0000
***************
*** 1814,1823 ****
      return;
  #endif
    sf = SELECTED_FRAME ();
!   cursor_to (FRAME_HEIGHT (sf) - 1, 0);
!   clear_end_of_line (FRAME_WIDTH (sf));
    /* clear_end_of_line may move the cursor */
!   cursor_to (FRAME_HEIGHT (sf) - 1, 0);
  #if defined (IBMR2AIX) && defined (AIXHFT)
    {
      /* HFT devices normally use ^J as a LF/CR.  We forced it to
--- 1814,1823 ----
      return;
  #endif
    sf = SELECTED_FRAME ();
!   cursor_to (FRAME_LINES (sf) - 1, 0);
!   clear_end_of_line (FRAME_COLS (sf));
    /* clear_end_of_line may move the cursor */
!   cursor_to (FRAME_LINES (sf) - 1, 0);
  #if defined (IBMR2AIX) && defined (AIXHFT)
    {
      /* HFT devices normally use ^J as a LF/CR.  We forced it to
Index: term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/term.c,v
retrieving revision 1.145
diff -c -r1.145 term.c
*** term.c      21 Mar 2003 13:51:06 -0000      1.145
--- term.c      14 May 2003 21:52:26 -0000
***************
*** 66,79 ****
  static void tty_hide_cursor P_ ((void));
  
  #define OUTPUT(a) \
!      tputs (a, (int) (FRAME_HEIGHT (XFRAME (selected_frame)) - curY), cmputc)
  #define OUTPUT1(a) tputs (a, 1, cmputc)
  #define OUTPUTL(a, lines) tputs (a, lines, cmputc)
  
  #define OUTPUT_IF(a)                                                  \
       do {                                                             \
         if (a)                                                         \
!          tputs (a, (int) (FRAME_HEIGHT (XFRAME (selected_frame))      \
                          - curY), cmputc);                             \
       } while (0)
  
--- 66,79 ----
  static void tty_hide_cursor P_ ((void));
  
  #define OUTPUT(a) \
!      tputs (a, (int) (FRAME_LINES (XFRAME (selected_frame)) - curY), cmputc)
  #define OUTPUT1(a) tputs (a, 1, cmputc)
  #define OUTPUTL(a, lines) tputs (a, lines, cmputc)
  
  #define OUTPUT_IF(a)                                                  \
       do {                                                             \
         if (a)                                                         \
!          tputs (a, (int) (FRAME_LINES (XFRAME (selected_frame))       \
                          - curY), cmputc);                             \
       } while (0)
  
***************
*** 363,373 ****
  
  /* The largest frame width in any call to calculate_costs.  */
  
! int max_frame_width;
  
  /* The largest frame height in any call to calculate_costs.  */
  
! int max_frame_height;
  
  static int costs_set;   /* Nonzero if costs have been calculated. */
  
--- 363,373 ----
  
  /* The largest frame width in any call to calculate_costs.  */
  
! int max_frame_cols;
  
  /* The largest frame height in any call to calculate_costs.  */
  
! int max_frame_lines;
  
  static int costs_set;   /* Nonzero if costs have been calculated. */
  
***************
*** 378,384 ****
     This is the number of lines, from the top of frame downwards,
     which can participate in insert-line/delete-line operations.
  
!    Effectively it excludes the bottom frame_height - specified_window_size
     lines from those operations.  */
  
  int specified_window;
--- 378,384 ----
     This is the number of lines, from the top of frame downwards,
     which can participate in insert-line/delete-line operations.
  
!    Effectively it excludes the bottom frame_lines - specified_window_size
     lines from those operations.  */
  
  int specified_window;
***************
*** 504,510 ****
  {
    if (FRAME_TERMCAP_P (updating_frame))
      {
!       specified_window = size ? size : FRAME_HEIGHT (updating_frame);
        if (scroll_region_ok)
        set_scroll_region (0, specified_window);
      }
--- 504,510 ----
  {
    if (FRAME_TERMCAP_P (updating_frame))
      {
!       specified_window = size ? size : FRAME_LINES (updating_frame);
        if (scroll_region_ok)
        set_scroll_region (0, specified_window);
      }
***************
*** 523,533 ****
      buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1);
    else if (TS_set_scroll_region_1)
      buf = tparam (TS_set_scroll_region_1, 0, 0,
!                 FRAME_HEIGHT (sf), start,
!                 FRAME_HEIGHT (sf) - stop,
!                 FRAME_HEIGHT (sf));
    else
!     buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (sf));
  
    OUTPUT (buf);
    xfree (buf);
--- 523,533 ----
      buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1);
    else if (TS_set_scroll_region_1)
      buf = tparam (TS_set_scroll_region_1, 0, 0,
!                 FRAME_LINES (sf), start,
!                 FRAME_LINES (sf) - stop,
!                 FRAME_LINES (sf));
    else
!     buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_COLS (sf));
  
    OUTPUT (buf);
    xfree (buf);
***************
*** 701,710 ****
      }
    else
      {
!       for (i = curY; i < FRAME_HEIGHT (XFRAME (selected_frame)); i++)
        {
          cursor_to (i, 0);
!         clear_end_of_line (FRAME_WIDTH (XFRAME (selected_frame)));
        }
      }
  }
--- 701,710 ----
      }
    else
      {
!       for (i = curY; i < FRAME_LINES (XFRAME (selected_frame)); i++)
        {
          cursor_to (i, 0);
!         clear_end_of_line (FRAME_COLS (XFRAME (selected_frame)));
        }
      }
  }
***************
*** 773,780 ****
        turn_off_insert ();
  
        /* Do not write in last row last col with Auto-wrap on. */
!       if (AutoWrap && curY == FRAME_HEIGHT (sf) - 1
!         && first_unused_hpos == FRAME_WIDTH (sf))
        first_unused_hpos--;
  
        for (i = curX; i < first_unused_hpos; i++)
--- 773,780 ----
        turn_off_insert ();
  
        /* Do not write in last row last col with Auto-wrap on. */
!       if (AutoWrap && curY == FRAME_LINES (sf) - 1
!         && first_unused_hpos == FRAME_COLS (sf))
        first_unused_hpos--;
  
        for (i = curX; i < first_unused_hpos; i++)
***************
*** 921,928 ****
       since that would scroll the whole frame on some terminals.  */
  
    if (AutoWrap
!       && curY + 1 == FRAME_HEIGHT (sf)
!       && (curX + len) == FRAME_WIDTH (sf))
      len --;
    if (len <= 0)
      return;
--- 921,928 ----
       since that would scroll the whole frame on some terminals.  */
  
    if (AutoWrap
!       && curY + 1 == FRAME_LINES (sf)
!       && (curX + len) == FRAME_COLS (sf))
      len --;
    if (len <= 0)
      return;
***************
*** 1153,1159 ****
       as there will be a matching inslines later that will flush them. */
    if (scroll_region_ok && vpos + i >= specified_window)
      return;
!   if (!memory_below_frame && vpos + i >= FRAME_HEIGHT (sf))
      return;
  
    if (multi)
--- 1153,1159 ----
       as there will be a matching inslines later that will flush them. */
    if (scroll_region_ok && vpos + i >= specified_window)
      return;
!   if (!memory_below_frame && vpos + i >= FRAME_LINES (sf))
      return;
  
    if (multi)
***************
*** 1188,1194 ****
  
    if (!scroll_region_ok && memory_below_frame && n < 0)
      {
!       cursor_to (FRAME_HEIGHT (sf) + n, 0);
        clear_to_end ();
      }
  }
--- 1188,1194 ----
  
    if (!scroll_region_ok && memory_below_frame && n < 0)
      {
!       cursor_to (FRAME_LINES (sf) + n, 0);
        clear_to_end ();
      }
  }
***************
*** 1238,1248 ****
  #ifndef old
  /* char_ins_del_cost[n] is cost of inserting N characters.
     char_ins_del_cost[-n] is cost of deleting N characters.
!    The length of this vector is based on max_frame_width.  */
  
  int *char_ins_del_vector;
  
! #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH ((f))])
  #endif
  
  /* ARGSUSED */
--- 1238,1248 ----
  #ifndef old
  /* char_ins_del_cost[n] is cost of inserting N characters.
     char_ins_del_cost[-n] is cost of deleting N characters.
!    The length of this vector is based on max_frame_cols.  */
  
  int *char_ins_del_vector;
  
! #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_COLS ((f))])
  #endif
  
  /* ARGSUSED */
***************
*** 1295,1301 ****
  
    /* Delete costs are at negative offsets */
    p = &char_ins_del_cost (frame)[0];
!   for (i = FRAME_WIDTH (frame); --i >= 0;)
      *--p = (del_startup_cost += del_cost_per_char);
  
    /* Doing nothing is free */
--- 1295,1301 ----
  
    /* Delete costs are at negative offsets */
    p = &char_ins_del_cost (frame)[0];
!   for (i = FRAME_COLS (frame); --i >= 0;)
      *--p = (del_startup_cost += del_cost_per_char);
  
    /* Doing nothing is free */
***************
*** 1303,1309 ****
    *p++ = 0;
  
    /* Insert costs are at positive offsets */
!   for (i = FRAME_WIDTH (frame); --i >= 0;)
      *p++ = (ins_startup_cost += ins_cost_per_char);
  }
  
--- 1303,1309 ----
    *p++ = 0;
  
    /* Insert costs are at positive offsets */
!   for (i = FRAME_COLS (frame); --i >= 0;)
      *p++ = (ins_startup_cost += ins_cost_per_char);
  }
  
***************
*** 1325,1332 ****
       char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
       X turns off char_ins_del_ok. */
  
!   max_frame_height = max (max_frame_height, FRAME_HEIGHT (frame));
!   max_frame_width = max (max_frame_width, FRAME_WIDTH (frame));
  
    costs_set = 1;
  
--- 1325,1332 ----
       char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
       X turns off char_ins_del_ok. */
  
!   max_frame_lines = max (max_frame_lines, FRAME_LINES (frame));
!   max_frame_cols = max (max_frame_cols, FRAME_COLS (frame));
  
    costs_set = 1;
  
***************
*** 1334,1347 ****
      char_ins_del_vector
        = (int *) xrealloc (char_ins_del_vector,
                          (sizeof (int)
!                          + 2 * max_frame_width * sizeof (int)));
    else
      char_ins_del_vector
        = (int *) xmalloc (sizeof (int)
!                        + 2 * max_frame_width * sizeof (int));
  
    bzero (char_ins_del_vector, (sizeof (int)
!                              + 2 * max_frame_width * sizeof (int)));
  
    if (f && (!TS_ins_line && !TS_del_line))
      do_line_insertion_deletion_costs (frame,
--- 1334,1347 ----
      char_ins_del_vector
        = (int *) xrealloc (char_ins_del_vector,
                          (sizeof (int)
!                          + 2 * max_frame_cols * sizeof (int)));
    else
      char_ins_del_vector
        = (int *) xmalloc (sizeof (int)
!                        + 2 * max_frame_cols * sizeof (int));
  
    bzero (char_ins_del_vector, (sizeof (int)
!                              + 2 * max_frame_cols * sizeof (int)));
  
    if (f && (!TS_ins_line && !TS_del_line))
      do_line_insertion_deletion_costs (frame,
***************
*** 1360,1366 ****
    if (TS_repeat && per_line_cost (TS_repeat) * baud_rate < 9000)
      RPov = string_cost (TS_repeat);
    else
!     RPov = FRAME_WIDTH (frame) * 2;
  
    cmcostinit ();              /* set up cursor motion costs */
  }
--- 1360,1366 ----
    if (TS_repeat && per_line_cost (TS_repeat) * baud_rate < 9000)
      RPov = string_cost (TS_repeat);
    else
!     RPov = FRAME_COLS (frame) * 2;
  
    cmcostinit ();              /* set up cursor motion costs */
  }
***************
*** 2174,2182 ****
    if (area == 0)
      abort ();
  
!   FrameRows = FRAME_HEIGHT (sf);
!   FrameCols = FRAME_WIDTH (sf);
!   specified_window = FRAME_HEIGHT (sf);
  
    delete_in_insert_mode = 1;
  
--- 2174,2182 ----
    if (area == 0)
      abort ();
  
!   FrameRows = FRAME_LINES (sf);
!   FrameCols = FRAME_COLS (sf);
!   specified_window = FRAME_LINES (sf);
  
    delete_in_insert_mode = 1;
  
***************
*** 2356,2376 ****
    {
      int height, width;
      get_frame_size (&width, &height);
!     FRAME_WIDTH (sf) = width;
!     FRAME_HEIGHT (sf) = height;
    }
  
!   if (FRAME_WIDTH (sf) <= 0)
!     SET_FRAME_WIDTH (sf, tgetnum ("co"));
    else
      /* Keep width and external_width consistent */
!     SET_FRAME_WIDTH (sf, FRAME_WIDTH (sf));
!   if (FRAME_HEIGHT (sf) <= 0)
!     FRAME_HEIGHT (sf) = tgetnum ("li");
  
!   if (FRAME_HEIGHT (sf) < 3 || FRAME_WIDTH (sf) < 3)
      fatal ("Screen size %dx%d is too small",
!          FRAME_HEIGHT (sf), FRAME_WIDTH (sf));
  
    min_padding_speed = tgetnum ("pb");
    TabWidth = tgetnum ("tw");
--- 2356,2376 ----
    {
      int height, width;
      get_frame_size (&width, &height);
!     FRAME_COLS (sf) = width;
!     FRAME_LINES (sf) = height;
    }
  
!   if (FRAME_COLS (sf) <= 0)
!     SET_FRAME_COLS (sf, tgetnum ("co"));
    else
      /* Keep width and external_width consistent */
!     SET_FRAME_COLS (sf, FRAME_COLS (sf));
!   if (FRAME_LINES (sf) <= 0)
!     FRAME_LINES (sf) = tgetnum ("li");
  
!   if (FRAME_LINES (sf) < 3 || FRAME_COLS (sf) < 3)
      fatal ("Screen size %dx%d is too small",
!          FRAME_LINES (sf), FRAME_COLS (sf));
  
    min_padding_speed = tgetnum ("pb");
    TabWidth = tgetnum ("tw");
***************
*** 2493,2501 ****
        }
      }
  
!   FrameRows = FRAME_HEIGHT (sf);
!   FrameCols = FRAME_WIDTH (sf);
!   specified_window = FRAME_HEIGHT (sf);
  
    if (Wcm_init () == -1)      /* can't do cursor motion */
  #ifdef VMS
--- 2493,2501 ----
        }
      }
  
!   FrameRows = FRAME_LINES (sf);
!   FrameCols = FRAME_COLS (sf);
!   specified_window = FRAME_LINES (sf);
  
    if (Wcm_init () == -1)      /* can't do cursor motion */
  #ifdef VMS
***************
*** 2524,2531 ****
           terminal_type);
  # endif /* TERMINFO */
  #endif /*VMS */
!   if (FRAME_HEIGHT (sf) <= 0
!       || FRAME_WIDTH (sf) <= 0)
      fatal ("The frame size has not been specified");
  
    delete_in_insert_mode
--- 2524,2531 ----
           terminal_type);
  # endif /* TERMINFO */
  #endif /*VMS */
!   if (FRAME_LINES (sf) <= 0
!       || FRAME_COLS (sf) <= 0)
      fatal ("The frame size has not been specified");
  
    delete_in_insert_mode
Index: w32console.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32console.c,v
retrieving revision 1.35
diff -c -r1.35 w32console.c
*** w32console.c        21 Mar 2003 22:56:52 -0000      1.35
--- w32console.c        14 May 2003 21:52:26 -0000
***************
*** 121,128 ****
  {
    struct frame * f = PICK_FRAME ();
  
!   clear_end_of_line (FRAME_WIDTH (f) - 1);
!   ins_del_lines (cursor_coords.Y, FRAME_HEIGHT (f) - cursor_coords.Y - 1);
  }
  
  /* Clear the frame.  */
--- 121,128 ----
  {
    struct frame * f = PICK_FRAME ();
  
!   clear_end_of_line (FRAME_COLS (f) - 1);
!   ins_del_lines (cursor_coords.Y, FRAME_LINES (f) - cursor_coords.Y - 1);
  }
  
  /* Clear the frame.  */
***************
*** 138,144 ****
    GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info);
  
    /* Remember that the screen buffer might be wider than the window.  */
!   n = FRAME_HEIGHT (f) * info.dwSize.X;
    dest.X = dest.Y = 0;
  
    FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r);
--- 138,144 ----
    GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info);
  
    /* Remember that the screen buffer might be wider than the window.  */
!   n = FRAME_LINES (f) * info.dwSize.X;
    dest.X = dest.Y = 0;
  
    FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r);
***************
*** 180,196 ****
    if (n < 0)
      {
        scroll.Top = vpos - n;
!       scroll.Bottom = FRAME_HEIGHT (f);
        dest.Y = vpos;
      }
    else
      {
        scroll.Top = vpos;
!       scroll.Bottom = FRAME_HEIGHT (f) - n;
        dest.Y = vpos + n;
      }
    scroll.Left = 0;
!   scroll.Right = FRAME_WIDTH (f);
  
    dest.X = 0;
  
--- 180,196 ----
    if (n < 0)
      {
        scroll.Top = vpos - n;
!       scroll.Bottom = FRAME_LINES (f);
        dest.Y = vpos;
      }
    else
      {
        scroll.Top = vpos;
!       scroll.Bottom = FRAME_LINES (f) - n;
        dest.Y = vpos + n;
      }
    scroll.Left = 0;
!   scroll.Right = FRAME_COLS (f);
  
    dest.X = 0;
  
***************
*** 213,219 ****
          for (i = scroll.Bottom; i < dest.Y; i++)
              {
              move_cursor (i, 0);
!             clear_end_of_line (FRAME_WIDTH (f));
              }
          }
      }
--- 213,219 ----
          for (i = scroll.Bottom; i < dest.Y; i++)
              {
              move_cursor (i, 0);
!             clear_end_of_line (FRAME_COLS (f));
              }
          }
      }
***************
*** 226,232 ****
          for (i = nb; i < scroll.Top; i++)
              {
              move_cursor (i, 0);
!             clear_end_of_line (FRAME_WIDTH (f));
              }
          }
      }
--- 226,232 ----
          for (i = nb; i < scroll.Top; i++)
              {
              move_cursor (i, 0);
!             clear_end_of_line (FRAME_COLS (f));
              }
          }
      }
***************
*** 256,267 ****
    if (direction == LEFT)
      {
        scroll.Left = cursor_coords.X + dist;
!       scroll.Right = FRAME_WIDTH (f) - 1;
      }
    else
      {
        scroll.Left = cursor_coords.X;
!       scroll.Right = FRAME_WIDTH (f) - dist - 1;
      }
  
    dest.X = cursor_coords.X;
--- 256,267 ----
    if (direction == LEFT)
      {
        scroll.Left = cursor_coords.X + dist;
!       scroll.Right = FRAME_COLS (f) - 1;
      }
    else
      {
        scroll.Left = cursor_coords.X;
!       scroll.Right = FRAME_COLS (f) - dist - 1;
      }
  
    dest.X = cursor_coords.X;
***************
*** 661,676 ****
  
    if (w32_use_full_screen_buffer)
      {
!       FRAME_HEIGHT (SELECTED_FRAME ()) = info.dwSize.Y;       /* lines per 
page */
!       SET_FRAME_WIDTH (SELECTED_FRAME (), info.dwSize.X);  /* characters per 
line */
      }
    else
      {
        /* Lines per page.  Use buffer coords instead of buffer size.  */
!       FRAME_HEIGHT (SELECTED_FRAME ()) = 1 + info.srWindow.Bottom -
        info.srWindow.Top;
        /* Characters per line.  Use buffer coords instead of buffer size.  */
!       SET_FRAME_WIDTH (SELECTED_FRAME (), 1 + info.srWindow.Right -
                       info.srWindow.Left);
      }
  
--- 661,676 ----
  
    if (w32_use_full_screen_buffer)
      {
!       FRAME_LINES (SELECTED_FRAME ()) = info.dwSize.Y;        /* lines per 
page */
!       SET_FRAME_COLS (SELECTED_FRAME (), info.dwSize.X);  /* characters per 
line */
      }
    else
      {
        /* Lines per page.  Use buffer coords instead of buffer size.  */
!       FRAME_LINES (SELECTED_FRAME ()) = 1 + info.srWindow.Bottom -
        info.srWindow.Top;
        /* Characters per line.  Use buffer coords instead of buffer size.  */
!       SET_FRAME_COLS (SELECTED_FRAME (), 1 + info.srWindow.Right -
                       info.srWindow.Left);
      }
  
Index: w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.215
diff -c -r1.215 w32fns.c
*** w32fns.c    31 Mar 2003 21:16:55 -0000      1.215
--- w32fns.c    14 May 2003 21:52:30 -0000
***************
*** 655,662 ****
    ClientToScreen (FRAME_W32_WINDOW(f), &pt);
  
    /* Remember x_pixels_diff and y_pixels_diff.  */
!   f->output_data.w32->x_pixels_diff = pt.x - rect.left;
!   f->output_data.w32->y_pixels_diff = pt.y - rect.top;
  
    *xptr = pt.x;
    *yptr = pt.y;
--- 655,662 ----
    ClientToScreen (FRAME_W32_WINDOW(f), &pt);
  
    /* Remember x_pixels_diff and y_pixels_diff.  */
!   f->x_pixels_diff = pt.x - rect.left;
!   f->y_pixels_diff = pt.y - rect.top;
  
    *xptr = pt.x;
    *yptr = pt.y;
***************
*** 1769,1775 ****
  
    f->output_data.w32->border_pixel = pix;
  
!   if (FRAME_W32_WINDOW (f) != 0 && f->output_data.w32->border_width > 0)
      {
        if (FRAME_VISIBLE_P (f))
          redraw_frame (f);
--- 1769,1775 ----
  
    f->output_data.w32->border_pixel = pix;
  
!   if (FRAME_W32_WINDOW (f) != 0 && f->border_width > 0)
      {
        if (FRAME_VISIBLE_P (f))
          redraw_frame (f);
***************
*** 1918,1924 ****
        /* Adjust the frame size so that the client (text) dimensions
         remain the same.  This depends on FRAME_EXTERNAL_MENU_BAR being
         set correctly.  */
!       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
        do_pending_window_change (0);
      }
    adjust_glyphs (f);
--- 1918,1924 ----
        /* Adjust the frame size so that the client (text) dimensions
         remain the same.  This depends on FRAME_EXTERNAL_MENU_BAR being
         set correctly.  */
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
        do_pending_window_change (0);
      }
    adjust_glyphs (f);
***************
*** 1956,1962 ****
  
    /* Don't resize the tool-bar to more than we have room for.  */
    root_window = FRAME_ROOT_WINDOW (f);
!   root_height = XINT (XWINDOW (root_window)->height);
    if (root_height - delta < 1)
      {
        delta = root_height - 1;
--- 1956,1962 ----
  
    /* Don't resize the tool-bar to more than we have room for.  */
    root_window = FRAME_ROOT_WINDOW (f);
!   root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
    if (root_height - delta < 1)
      {
        delta = root_height - 1;
***************
*** 1987,1994 ****
    if (delta < 0)
      {
        int height = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int width = PIXEL_WIDTH (f);
!       int y = nlines * CANON_Y_UNIT (f);
  
        BLOCK_INPUT;
        {
--- 1987,1994 ----
    if (delta < 0)
      {
        int height = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int width = FRAME_PIXEL_WIDTH (f);
!       int y = nlines * FRAME_LINE_HEIGHT (f);
  
        BLOCK_INPUT;
        {
***************
*** 2134,2144 ****
  void x_set_scroll_bar_default_width (f)
       struct frame *f;
  {
!   int wid = FONT_WIDTH (f->output_data.w32->font);
  
!   FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
!   FRAME_SCROLL_BAR_COLS (f) = (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) +
!                              wid - 1) / wid;
  }
  
  
--- 2134,2144 ----
  void x_set_scroll_bar_default_width (f)
       struct frame *f;
  {
!   int wid = FRAME_COLUMN_WIDTH (f);
  
!   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
!   FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
!                                     wid - 1) / wid;
  }
  
  
***************
*** 2231,2238 ****
    RECT rect;
  
    rect.left = rect.top = 0;
!   rect.right = PIXEL_WIDTH (f);
!   rect.bottom = PIXEL_HEIGHT (f);
  
    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
                    FRAME_EXTERNAL_MENU_BAR (f));
--- 2231,2238 ----
    RECT rect;
  
    rect.left = rect.top = 0;
!   rect.right = FRAME_PIXEL_WIDTH (f);
!   rect.bottom = FRAME_PIXEL_HEIGHT (f);
  
    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
                    FRAME_EXTERNAL_MENU_BAR (f));
***************
*** 2248,2255 ****
      = CreateWindow (EMACS_CLASS,
                    f->namebuf,
                    f->output_data.w32->dwStyle | WS_CLIPCHILDREN,
!                   f->output_data.w32->left_pos,
!                   f->output_data.w32->top_pos,
                    rect.right - rect.left,
                    rect.bottom - rect.top,
                    NULL,
--- 2248,2255 ----
      = CreateWindow (EMACS_CLASS,
                    f->namebuf,
                    f->output_data.w32->dwStyle | WS_CLIPCHILDREN,
!                   f->left_pos,
!                   f->top_pos,
                    rect.right - rect.left,
                    rect.bottom - rect.top,
                    NULL,
***************
*** 2259,2268 ****
  
    if (hwnd)
      {
!       SetWindowLong (hwnd, WND_FONTWIDTH_INDEX, FONT_WIDTH 
(f->output_data.w32->font));
!       SetWindowLong (hwnd, WND_LINEHEIGHT_INDEX, 
f->output_data.w32->line_height);
!       SetWindowLong (hwnd, WND_BORDER_INDEX, 
f->output_data.w32->internal_border_width);
!       SetWindowLong (hwnd, WND_SCROLLBAR_INDEX, 
f->output_data.w32->vertical_scroll_bar_extra);
        SetWindowLong (hwnd, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL (f));
  
        /* Enable drag-n-drop.  */
--- 2259,2268 ----
  
    if (hwnd)
      {
!       SetWindowLong (hwnd, WND_FONTWIDTH_INDEX, FRAME_COLUMN_WIDTH (f));
!       SetWindowLong (hwnd, WND_LINEHEIGHT_INDEX, FRAME_LINE_HEIGHT (f));
!       SetWindowLong (hwnd, WND_BORDER_INDEX, FRAME_INTERNAL_BORDER_WIDTH (f));
!       SetWindowLong (hwnd, WND_SCROLLBAR_INDEX, f->scroll_bar_actual_width);
        SetWindowLong (hwnd, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL (f));
  
        /* Enable drag-n-drop.  */
***************
*** 4014,4021 ****
    RECT rect;
  
    rect.left = rect.top = 0;
!   rect.right = PIXEL_WIDTH (f);
!   rect.bottom = PIXEL_HEIGHT (f);
  
    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
                    FRAME_EXTERNAL_MENU_BAR (f));
--- 4014,4021 ----
    RECT rect;
  
    rect.left = rect.top = 0;
!   rect.right = FRAME_PIXEL_WIDTH (f);
!   rect.bottom = FRAME_PIXEL_HEIGHT (f);
  
    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
                    FRAME_EXTERNAL_MENU_BAR (f));
***************
*** 4024,4031 ****
      = CreateWindow (EMACS_CLASS,
                    f->namebuf,
                    f->output_data.w32->dwStyle,
!                   f->output_data.w32->left_pos,
!                   f->output_data.w32->top_pos,
                    rect.right - rect.left,
                    rect.bottom - rect.top,
                    FRAME_W32_WINDOW (SELECTED_FRAME ()), /* owner */
--- 4024,4031 ----
      = CreateWindow (EMACS_CLASS,
                    f->namebuf,
                    f->output_data.w32->dwStyle,
!                   f->left_pos,
!                   f->top_pos,
                    rect.right - rect.left,
                    rect.bottom - rect.top,
                    FRAME_W32_WINDOW (SELECTED_FRAME ()), /* owner */
***************
*** 4035,4043 ****
  
    if (tip_window)
      {
!       SetWindowLong (tip_window, WND_FONTWIDTH_INDEX, FONT_WIDTH 
(f->output_data.w32->font));
!       SetWindowLong (tip_window, WND_LINEHEIGHT_INDEX, 
f->output_data.w32->line_height);
!       SetWindowLong (tip_window, WND_BORDER_INDEX, 
f->output_data.w32->internal_border_width);
        SetWindowLong (tip_window, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL 
(f));
  
        /* Tip frames have no scrollbars.  */
--- 4035,4043 ----
  
    if (tip_window)
      {
!       SetWindowLong (tip_window, WND_FONTWIDTH_INDEX, FRAME_COLUMN_WIDTH (f));
!       SetWindowLong (tip_window, WND_LINEHEIGHT_INDEX, FRAME_LINE_HEIGHT (f));
!       SetWindowLong (tip_window, WND_BORDER_INDEX, 
FRAME_INTERNAL_BORDER_WIDTH (f));
        SetWindowLong (tip_window, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL 
(f));
  
        /* Tip frames have no scrollbars.  */
***************
*** 4154,4160 ****
       Note that many default values are used.  */
  
    /* Normal video */
!   gc_values.font = f->output_data.w32->font;
  
    /* Cursor has cursor-color background, background-color foreground.  */
    gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
--- 4154,4160 ----
       Note that many default values are used.  */
  
    /* Normal video */
!   gc_values.font = FRAME_FONT (f);
  
    /* Cursor has cursor-color background, background-color foreground.  */
    gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
***************
*** 4286,4292 ****
    FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
  
    /* By default, make scrollbars the system standard width. */
!   f->scroll_bar_pixel_width = GetSystemMetrics (SM_CXVSCROLL);
  
    f->output_method = output_w32;
    f->output_data.w32 =
--- 4286,4292 ----
    FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
  
    /* By default, make scrollbars the system standard width. */
!   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
  
    f->output_method = output_w32;
    f->output_data.w32 =
***************
*** 4466,4479 ****
    x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
                       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
  
!   /* Dimensions, especially f->height, must be done via change_frame_size.
       Change will not be effected unless different from the current
!      f->height.  */
!   width = f->width;
!   height = f->height;
  
!   f->height = 0;
!   SET_FRAME_WIDTH (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Tell the server what size and position, etc, we want, and how
--- 4466,4479 ----
    x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
                       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
  
!   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
       Change will not be effected unless different from the current
!      FRAME_LINES (f).  */
!   width = FRAME_COLS (f);
!   height = FRAME_LINES (f);
  
!   FRAME_LINES (f) = 0;
!   SET_FRAME_COLS (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Tell the server what size and position, etc, we want, and how
***************
*** 6658,6685 ****
  x_pixel_width (f)
       register struct frame *f;
  {
!   return PIXEL_WIDTH (f);
  }
  
  int
  x_pixel_height (f)
       register struct frame *f;
  {
!   return PIXEL_HEIGHT (f);
  }
  
  int
  x_char_width (f)
       register struct frame *f;
  {
!   return FONT_WIDTH (f->output_data.w32->font);
  }
  
  int
  x_char_height (f)
       register struct frame *f;
  {
!   return f->output_data.w32->line_height;
  }
  
  int
--- 6658,6685 ----
  x_pixel_width (f)
       register struct frame *f;
  {
!   return FRAME_PIXEL_WIDTH (f);
  }
  
  int
  x_pixel_height (f)
       register struct frame *f;
  {
!   return FRAME_PIXEL_HEIGHT (f);
  }
  
  int
  x_char_width (f)
       register struct frame *f;
  {
!   return FRAME_COLUMN_WIDTH (f);
  }
  
  int
  x_char_height (f)
       register struct frame *f;
  {
!   return FRAME_LINE_HEIGHT (f);
  }
  
  int
***************
*** 7244,7251 ****
        int height = img->height + 2 * img->vmargin;
  
        if (NILP (pixels))
!       size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
!                     make_float ((double) height / CANON_Y_UNIT (f)));
        else
        size = Fcons (make_number (width), make_number (height));
      }
--- 7244,7251 ----
        int height = img->height + 2 * img->vmargin;
  
        if (NILP (pixels))
!       size = Fcons (make_float ((double) width / FRAME_COLUMN_WIDTH (f)),
!                     make_float ((double) height / FRAME_LINE_HEIGHT (f)));
        else
        size = Fcons (make_number (width), make_number (height));
      }
***************
*** 12731,12737 ****
    XSETFRAME (frame, f);
  
    buffer = Fget_buffer_create (build_string (" *tip*"));
!   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer);
    old_buffer = current_buffer;
    set_buffer_internal_1 (XBUFFER (buffer));
    current_buffer->truncate_lines = Qnil;
--- 12731,12737 ----
    XSETFRAME (frame, f);
  
    buffer = Fget_buffer_create (build_string (" *tip*"));
!   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
    old_buffer = current_buffer;
    set_buffer_internal_1 (XBUFFER (buffer));
    current_buffer->truncate_lines = Qnil;
***************
*** 12858,12867 ****
    window_prompting = x_figure_window_size (f, parms, 0);
  
    /* No fringes on tip frame.  */
!   f->output_data.w32->fringes_extra = 0;
!   f->output_data.w32->fringe_cols = 0;
!   f->output_data.w32->left_fringe_width = 0;
!   f->output_data.w32->right_fringe_width = 0;
  
    BLOCK_INPUT;
    my_create_tip_window (f);
--- 12858,12866 ----
    window_prompting = x_figure_window_size (f, parms, 0);
  
    /* No fringes on tip frame.  */
!   f->fringe_cols = 0;
!   f->left_fringe_width = 0;
!   f->right_fringe_width = 0;
  
    BLOCK_INPUT;
    my_create_tip_window (f);
***************
*** 12876,12888 ****
    x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
  
!   /* Dimensions, especially f->height, must be done via change_frame_size.
       Change will not be effected unless different from the current
!      f->height.  */
!   width = f->width;
!   height = f->height;
!   f->height = 0;
!   SET_FRAME_WIDTH (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Add `tooltip' frame parameter's default value. */
--- 12875,12887 ----
    x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
  
!   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
       Change will not be effected unless different from the current
!      FRAME_LINES (f).  */
!   width = FRAME_COLS (f);
!   height = FRAME_LINES (f);
!   FRAME_LINES (f) = 0;
!   SET_FRAME_COLS (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Add `tooltip' frame parameter's default value. */
***************
*** 13071,13078 ****
            }
  
          BLOCK_INPUT;
!         compute_tip_xy (f, parms, dx, dy, PIXEL_WIDTH (f),
!                         PIXEL_HEIGHT (f), &root_x, &root_y);
  
          /* Put tooltip in topmost group and in position.  */
          SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOPMOST,
--- 13070,13077 ----
            }
  
          BLOCK_INPUT;
!         compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
!                         FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
  
          /* Put tooltip in topmost group and in position.  */
          SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOPMOST,
***************
*** 13120,13126 ****
  
    /* Set up the frame's root window.  */
    w = XWINDOW (FRAME_ROOT_WINDOW (f));
!   w->left = w->top = make_number (0);
  
    if (CONSP (Vx_max_tooltip_size)
        && INTEGERP (XCAR (Vx_max_tooltip_size))
--- 13119,13125 ----
  
    /* Set up the frame's root window.  */
    w = XWINDOW (FRAME_ROOT_WINDOW (f));
!   w->left_col = w->top_line = make_number (0);
  
    if (CONSP (Vx_max_tooltip_size)
        && INTEGERP (XCAR (Vx_max_tooltip_size))
***************
*** 13128,13143 ****
        && INTEGERP (XCDR (Vx_max_tooltip_size))
        && XINT (XCDR (Vx_max_tooltip_size)) > 0)
      {
!       w->width = XCAR (Vx_max_tooltip_size);
!       w->height = XCDR (Vx_max_tooltip_size);
      }
    else
      {
!       w->width = make_number (80);
!       w->height = make_number (40);
      }
  
!   f->window_width = XINT (w->width);
    adjust_glyphs (f);
    w->pseudo_window_p = 1;
  
--- 13127,13142 ----
        && INTEGERP (XCDR (Vx_max_tooltip_size))
        && XINT (XCDR (Vx_max_tooltip_size)) > 0)
      {
!       w->total_cols = XCAR (Vx_max_tooltip_size);
!       w->total_lines = XCDR (Vx_max_tooltip_size);
      }
    else
      {
!       w->total_cols = make_number (80);
!       w->total_lines = make_number (40);
      }
  
!   FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
    adjust_glyphs (f);
    w->pseudo_window_p = 1;
  
Index: w32menu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32menu.c,v
retrieving revision 1.63
diff -c -r1.63 w32menu.c
*** w32menu.c   4 Feb 2003 14:03:15 -0000       1.63
--- w32menu.c   14 May 2003 21:52:31 -0000
***************
*** 725,734 ****
          CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
  
!         xpos = (FONT_WIDTH (FRAME_FONT (f))
!                 * XFASTINT (XWINDOW (window)->left));
!         ypos = (FRAME_LINE_HEIGHT (f)
!                 * XFASTINT (XWINDOW (window)->top));
        }
        else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
--- 725,732 ----
          CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
  
!         xpos = WINDOW_LEFT_EDGE_X (XWINDOW (window));
!         ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
        }
        else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
***************
*** 1601,1607 ****
      /* Force the window size to be recomputed so that the frame's text
         area remains the same, if menubar has just been created.  */
      if (old_widget == NULL)
!       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
    }
  
    UNBLOCK_INPUT;
--- 1599,1605 ----
      /* Force the window size to be recomputed so that the frame's text
         area remains the same, if menubar has just been created.  */
      if (old_widget == NULL)
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
    }
  
    UNBLOCK_INPUT;
Index: w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.188
diff -c -r1.188 w32term.c
*** w32term.c   4 Apr 2003 21:15:53 -0000       1.188
--- w32term.c   14 May 2003 21:52:32 -0000
***************
*** 256,263 ****
  static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
! static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
!                                  HDC, int));
  
  static Lisp_Object Qvendor_specific_keysyms;
  
--- 256,262 ----
  static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
! static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, HDC));
  
  static Lisp_Object Qvendor_specific_keysyms;
  
***************
*** 653,659 ****
        {
        HDC hdc = get_frame_dc (f);
        w32_clear_area (f, hdc, 0, y, width, height);
!       w32_clear_area (f, hdc, f->output_data.w32->pixel_width - width,
                        y, width, height);
        release_frame_dc (f, hdc);
        }
--- 652,658 ----
        {
        HDC hdc = get_frame_dc (f);
        w32_clear_area (f, hdc, 0, y, width, height);
!       w32_clear_area (f, hdc, FRAME_PIXEL_WIDTH (f) - width,
                        y, width, height);
        release_frame_dc (f, hdc);
        }
***************
*** 680,686 ****
    hdc = get_frame_dc (f);
  
    /* Must clip because of partially visible lines.  */
!   w32_clip_to_row (w, row, hdc, 1);
  
    if (p->bx >= 0)
      {
--- 679,685 ----
    hdc = get_frame_dc (f);
  
    /* Must clip because of partially visible lines.  */
!   w32_clip_to_row (w, row, hdc);
  
    if (p->bx >= 0)
      {
***************
*** 1834,1842 ****
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += FRAME_X_RIGHT_FRINGE_WIDTH (s->f);
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
!       last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
      }
  
    /* The glyph that may have a right box line.  */
--- 1833,1842 ----
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (s->w);
!       if (s->area != RIGHT_MARGIN_AREA
!         || WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
!       last_x += WINDOW_RIGHT_FRINGE_WIDTH (s->w);
      }
  
    /* The glyph that may have a right box line.  */
***************
*** 2258,2264 ****
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (CANON_X_UNIT (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
--- 2258,2264 ----
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (FRAME_COLUMN_WIDTH (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
***************
*** 2603,2610 ****
       without mode lines.  Include in this box the left and right
       fringes of W.  */
    window_box (w, -1, &x, &y, &width, &height);
-   width += FRAME_X_FRINGE_WIDTH (f);
-   x -= FRAME_X_LEFT_FRINGE_WIDTH (f);
  
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->current_y);
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->desired_y);
--- 2603,2608 ----
***************
*** 3072,3086 ****
  {
    Lisp_Object window;
  
!   window = window_from_coordinates (f, x, y, 0, 0);
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
-       frame_to_window_pixel_xy (w, &x, &y);
- 
        for (; r < end && r->enabled_p; ++r)
        if (r->y <= y && r->y + r->height > y)
          {
--- 3070,3083 ----
  {
    Lisp_Object window;
  
!   window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
! 
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        for (; r < end && r->enabled_p; ++r)
        if (r->y <= y && r->y + r->height > y)
          {
***************
*** 3095,3101 ****
            if (x < r->x)
              {
                /* x is to the left of the first glyph in the row.  */
!               rect->left = XINT (w->left);
                rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
                return 1;
              }
--- 3092,3101 ----
            if (x < r->x)
              {
                /* x is to the left of the first glyph in the row.  */
!               /* Shouldn't this be a pixel value?
!                  WINDOW_LEFT_EDGE_X (w) seems to be the right value.
!                  ++KFS */
!               rect->left = WINDOW_LEFT_EDGE_COL (w);
                rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
                return 1;
              }
***************
*** 3111,3117 ****
  
            /* x is to the right of the last glyph in the row.  */
            rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
!           rect->right = XINT (w->left) + XINT (w->width);
            return 1;
          }
      }
--- 3111,3120 ----
  
            /* x is to the right of the last glyph in the row.  */
            rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
!           /* Shouldn't this be a pixel value?  
!              WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
!              ++KFS */
!           rect->right = WINDOW_RIGHT_EDGE_COL (w);
            return 1;
          }
      }
***************
*** 3131,3137 ****
        int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
        int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
  
!       /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
         round down even for negative values.  */
        if (gx < 0)
        gx -= width - 1;
--- 3134,3140 ----
        int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
        int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
  
!       /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
         round down even for negative values.  */
        if (gx < 0)
        gx -= width - 1;
***************
*** 3572,3602 ****
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
!   int window_x, window_y, window_width, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
    top  = window_y;
!   width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     left = XINT (w->left) + XINT (w->width) - FRAME_SCROLL_BAR_COLS (f);
!   else
!     left = XFASTINT (w->left);
!   left *= CANON_X_UNIT (f);
!   left += FRAME_INTERNAL_BORDER_WIDTH (f);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0)
!     sb_width = FRAME_SCROLL_BAR_PIXEL_WIDTH (f);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
--- 3575,3600 ----
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
!   int window_y, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, 0, &window_y, 0, &window_height);
    top  = window_y;
!   width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   left = WINDOW_SCROLL_BAR_AREA_X (w);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) > 0)
!     sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
***************
*** 4248,4254 ****
                  int x = LOWORD (msg.msg.lParam);
                  int y = HIWORD (msg.msg.lParam);
  
!                 window = window_from_coordinates (f, x, y, 0, 0);
  
                  /* Window will be selected only when it is not
                     selected now and last mouse movement event was
--- 4246,4252 ----
                  int x = LOWORD (msg.msg.lParam);
                  int y = HIWORD (msg.msg.lParam);
  
!                 window = window_from_coordinates (f, x, y, 0, 0, 0, 0);
  
                  /* Window will be selected only when it is not
                     selected now and last mouse movement event was
***************
*** 4333,4345 ****
  
                  /* Is this in the tool-bar?  */
                  if (WINDOWP (f->tool_bar_window)
!                     && XFASTINT (XWINDOW (f->tool_bar_window)->height))
                    {
                      Lisp_Object window;
                    int x = XFASTINT (emacs_event.x);
                    int y = XFASTINT (emacs_event.y);
  
!                     window = window_from_coordinates (f, x, y, 0, 1);
  
                      if (EQ (window, f->tool_bar_window))
                        {
--- 4331,4343 ----
  
                  /* Is this in the tool-bar?  */
                  if (WINDOWP (f->tool_bar_window)
!                     && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
                    {
                      Lisp_Object window;
                    int x = XFASTINT (emacs_event.x);
                    int y = XFASTINT (emacs_event.y);
  
!                     window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
  
                      if (EQ (window, f->tool_bar_window))
                        {
***************
*** 4439,4447 ****
          if (f)
            {
              x_check_fullscreen_move(f);
!             if (f->output_data.w32->want_fullscreen & FULLSCREEN_WAIT)
!               f->output_data.w32->want_fullscreen &=
!                 ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
            }
          check_visibility = 1;
          break;
--- 4437,4444 ----
          if (f)
            {
              x_check_fullscreen_move(f);
!             if (f->want_fullscreen & FULLSCREEN_WAIT)
!               f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
            }
          check_visibility = 1;
          break;
***************
*** 4462,4469 ****
              int x, y;
  
              x_real_positions (f, &x, &y);
!             f->output_data.w32->left_pos = x;
!             f->output_data.w32->top_pos = y;
            }
  
          check_visibility = 1;
--- 4459,4466 ----
              int x, y;
  
              x_real_positions (f, &x, &y);
!             f->left_pos = x;
!             f->top_pos = y;
            }
  
          check_visibility = 1;
***************
*** 4535,4542 ****
                           when the Window is iconified, with 3000,3000
                           as the co-ords. */
                        x_real_positions (f, &x, &y);
!                       f->output_data.w32->left_pos = x;
!                       f->output_data.w32->top_pos = y;
  
                      bufp->kind = DEICONIFY_EVENT;
                      XSETFRAME (bufp->frame_or_window, f);
--- 4532,4539 ----
                           when the Window is iconified, with 3000,3000
                           as the co-ords. */
                        x_real_positions (f, &x, &y);
!                       f->left_pos = x;
!                       f->top_pos = y;
  
                      bufp->kind = DEICONIFY_EVENT;
                      XSETFRAME (bufp->frame_or_window, f);
***************
*** 4568,4575 ****
              height = rect.bottom - rect.top;
              width = rect.right - rect.left;
  
!             rows = PIXEL_TO_CHAR_HEIGHT (f, height);
!             columns = PIXEL_TO_CHAR_WIDTH (f, width);
  
              /* TODO: Clip size to the screen dimensions.  */
  
--- 4565,4572 ----
              height = rect.bottom - rect.top;
              width = rect.right - rect.left;
  
!             rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
!             columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
  
              /* TODO: Clip size to the screen dimensions.  */
  
***************
*** 4577,4593 ****
                 not changed, the font size may have changed, so we need
                 to check the pixel dimensions as well.  */
  
!             if (columns != f->width
!                 || rows != f->height
!                 || width != f->output_data.w32->pixel_width
!                 || height != f->output_data.w32->pixel_height)
                {
                  change_frame_size (f, rows, columns, 0, 1, 0);
                  SET_FRAME_GARBAGED (f);
                  cancel_mouse_face (f);
!                 f->output_data.w32->pixel_width = width;
!                 f->output_data.w32->pixel_height = height;
!                 f->output_data.w32->win_gravity = NorthWestGravity;
                }
            }
  
--- 4574,4590 ----
                 not changed, the font size may have changed, so we need
                 to check the pixel dimensions as well.  */
  
!             if (columns != FRAME_COLS (f)
!                 || rows != FRAME_LINES (f)
!                 || width != FRAME_PIXEL_WIDTH (f)
!                 || height != FRAME_PIXEL_HEIGHT (f))
                {
                  change_frame_size (f, rows, columns, 0, 1, 0);
                  SET_FRAME_GARBAGED (f);
                  cancel_mouse_face (f);
!                 FRAME_PIXEL_WIDTH (f) = width;
!                 FRAME_PIXEL_HEIGHT (f) = height;
!                 f->win_gravity = NorthWestGravity;
                }
            }
  
***************
*** 4868,4892 ****
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
-    WHOLE_LINE_P non-zero means include the areas used for truncation
-    mark display and alike in the clipping rectangle.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! w32_clip_to_row (w, row, hdc, whole_line_p)
       struct window *w;
       struct glyph_row *row;
       HDC hdc;
-      int whole_line_p;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    RECT clip_rect;
!   int window_x, window_y, window_width, window_height;
  
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
  
    clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
--- 4865,4886 ----
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! w32_clip_to_row (w, row, hdc)
       struct window *w;
       struct glyph_row *row;
       HDC hdc;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    RECT clip_rect;
!   int window_y, window_width;
  
!   window_box (w, -1, 0, &window_y, &window_width, 0);
  
    clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
***************
*** 4894,4907 ****
    clip_rect.right = clip_rect.left + window_width;
    clip_rect.bottom = clip_rect.top + row->visible_height;
  
-   /* If clipping to the whole line, including trunc marks, extend
-      the rectangle to the left and increase its width.  */
-   if (whole_line_p)
-     {
-       clip_rect.left -= FRAME_X_LEFT_FRINGE_WIDTH (f);
-       clip_rect.right += FRAME_X_FRINGE_WIDTH (f);
-     }
- 
    w32_set_clip_rectangle (hdc, &clip_rect);
  }
  
--- 4888,4893 ----
***************
*** 4940,4952 ****
    wd = cursor_glyph->pixel_width;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (CANON_X_UNIT (f), wd);
    w->phys_cursor_width = wd;
  
    rect.right = rect.left + wd;
    hdc = get_frame_dc (f);
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   w32_clip_to_row (w, row, hdc, 0);
    FrameRect (hdc, &rect, hb);
    DeleteObject (hb);
    w32_set_clip_rectangle (hdc, NULL);
--- 4926,4938 ----
    wd = cursor_glyph->pixel_width;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (FRAME_COLUMN_WIDTH (f), wd);
    w->phys_cursor_width = wd;
  
    rect.right = rect.left + wd;
    hdc = get_frame_dc (f);
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   w32_clip_to_row (w, row, hdc);
    FrameRect (hdc, &rect, hb);
    DeleteObject (hb);
    w32_set_clip_rectangle (hdc, NULL);
***************
*** 5012,5018 ****
  
  
        hdc = get_frame_dc (f);
!       w32_clip_to_row (w, row, hdc, 0);
  
        if (kind == BAR_CURSOR)
        {
--- 4998,5004 ----
  
  
        hdc = get_frame_dc (f);
!       w32_clip_to_row (w, row, hdc);
  
        if (kind == BAR_CURSOR)
        {
***************
*** 5241,5269 ****
    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
    FRAME_FONTSET (f) = -1;
  
    /* Compute the scroll bar width in character columns.  */
!   if (f->scroll_bar_pixel_width > 0)
      {
!       int wid = FONT_WIDTH (FRAME_FONT (f));
!       f->scroll_bar_cols = (f->scroll_bar_pixel_width + wid-1) / wid;
      }
    else
      {
!       int wid = FONT_WIDTH (FRAME_FONT (f));
!       f->scroll_bar_cols = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_W32_WINDOW (f) != 0)
      {
-       frame_update_line_height (f);
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!         x_set_window_size (f, 0, f->width, f->height);
      }
-   else
-     /* If we are setting a new frame's font for the first time,
-        there are no faces yet, so this font's height is the line height.  */
-     f->output_data.w32->line_height = FONT_HEIGHT (FRAME_FONT (f));
  
    return build_string (fontp->full_name);
  }
--- 5227,5256 ----
    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
    FRAME_FONTSET (f) = -1;
  
+   FRAME_COLUMN_WIDTH (f) = FONT_WIDTH (FRAME_FONT (f));
+   FRAME_LINE_HEIGHT (f) = FONT_HEIGHT (FRAME_FONT (f));
+ 
+   compute_fringe_widths (f, 1);
+ 
    /* Compute the scroll bar width in character columns.  */
!   if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f)
!       = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
      }
    else
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_W32_WINDOW (f) != 0)
      {
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!         x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
      }
  
    return build_string (fontp->full_name);
  }
***************
*** 5325,5331 ****
       struct frame *f;
  {
    POINT pt;
!   int flags = f->output_data.w32->size_hint_flags;
  
    pt.x = pt.y = 0;
  
--- 5312,5318 ----
       struct frame *f;
  {
    POINT pt;
!   int flags = f->size_hint_flags;
  
    pt.x = pt.y = 0;
  
***************
*** 5357,5376 ****
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->output_data.w32->left_pos = (FRAME_W32_DISPLAY_INFO (f)->width
!                             - 2 * f->output_data.w32->border_width - pt.x
!                             - PIXEL_WIDTH (f)
!                             + f->output_data.w32->left_pos);
  
    if (flags & YNegative)
!     f->output_data.w32->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height
!                            - 2 * f->output_data.w32->border_width - pt.y
!                            - PIXEL_HEIGHT (f)
!                            + f->output_data.w32->top_pos);
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->output_data.w32->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
--- 5344,5363 ----
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->left_pos = (FRAME_W32_DISPLAY_INFO (f)->width
!                  - 2 * f->border_width - pt.x
!                  - FRAME_PIXEL_WIDTH (f)
!                  + f->left_pos);
  
    if (flags & YNegative)
!     f->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height
!                 - 2 * f->border_width - pt.y
!                 - FRAME_PIXEL_HEIGHT (f)
!                 + f->top_pos);
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
***************
*** 5389,5410 ****
  
    if (change_gravity > 0)
      {
!       f->output_data.w32->top_pos = yoff;
!       f->output_data.w32->left_pos = xoff;
!       f->output_data.w32->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->output_data.w32->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->output_data.w32->size_hint_flags |= YNegative;
!       f->output_data.w32->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->output_data.w32->left_pos;
!   modified_top = f->output_data.w32->top_pos;
  
    my_set_window_pos (FRAME_W32_WINDOW (f),
                     NULL,
--- 5376,5397 ----
  
    if (change_gravity > 0)
      {
!       f->top_pos = yoff;
!       f->left_pos = xoff;
!       f->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->size_hint_flags |= YNegative;
!       f->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->left_pos;
!   modified_top = f->top_pos;
  
    my_set_window_pos (FRAME_W32_WINDOW (f),
                     NULL,
***************
*** 5421,5432 ****
  x_check_fullscreen (f)
       struct frame *f;
  {
!   if (f->output_data.w32->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
  
!       x_real_positions (f, &f->output_data.w32->left_pos,
!                         &f->output_data.w32->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
  
--- 5408,5418 ----
  x_check_fullscreen (f)
       struct frame *f;
  {
!   if (f->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
  
!       x_real_positions (f, &f->left_pos, &f->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
  
***************
*** 5434,5447 ****
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
           x_check_fullscreen_move. */
!       if (f->width != width || f->height != height)
          {
            change_frame_size (f, height, width, 0, 1, 0);
            SET_FRAME_GARBAGED (f);
            cancel_mouse_face (f);
  
            /* Wait for the change of frame size to occur */
!           f->output_data.w32->want_fullscreen |= FULLSCREEN_WAIT;
          }
      }
  }
--- 5420,5433 ----
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
           x_check_fullscreen_move. */
!       if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
          {
            change_frame_size (f, height, width, 0, 1, 0);
            SET_FRAME_GARBAGED (f);
            cancel_mouse_face (f);
  
            /* Wait for the change of frame size to occur */
!           f->want_fullscreen |= FULLSCREEN_WAIT;
          }
      }
  }
***************
*** 5456,5477 ****
  x_check_fullscreen_move (f)
       struct frame *f;
  {
!   if (f->output_data.w32->want_fullscreen & FULLSCREEN_MOVE_WAIT)
    {
!     int expect_top = f->output_data.w32->top_pos;
!     int expect_left = f->output_data.w32->left_pos;
  
!     if (f->output_data.w32->want_fullscreen & FULLSCREEN_HEIGHT)
        expect_top = 0;
!     if (f->output_data.w32->want_fullscreen & FULLSCREEN_WIDTH)
        expect_left = 0;
  
!     if (expect_top != f->output_data.w32->top_pos
!         || expect_left != f->output_data.w32->left_pos)
        x_set_offset (f, expect_left, expect_top, 1);
  
      /* Just do this once */
!     f->output_data.w32->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
    }
  }
  
--- 5442,5463 ----
  x_check_fullscreen_move (f)
       struct frame *f;
  {
!   if (f->want_fullscreen & FULLSCREEN_MOVE_WAIT)
    {
!     int expect_top = f->top_pos;
!     int expect_left = f->left_pos;
  
!     if (f->want_fullscreen & FULLSCREEN_HEIGHT)
        expect_top = 0;
!     if (f->want_fullscreen & FULLSCREEN_WIDTH)
        expect_left = 0;
  
!     if (expect_top != f->top_pos
!         || expect_left != f->left_pos)
        x_set_offset (f, expect_left, expect_top, 1);
  
      /* Just do this once */
!     f->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
    }
  }
  
***************
*** 5492,5508 ****
    BLOCK_INPUT;
  
    check_frame_size (f, &rows, &cols);
!   f->output_data.w32->vertical_scroll_bar_extra
!     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
!        ? 0
!        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.w32->font)));
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
  
!   f->output_data.w32->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    {
--- 5478,5492 ----
    BLOCK_INPUT;
  
    check_frame_size (f, &rows, &cols);
!   f->scroll_bar_actual_width
!     = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
  
!   f->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    {
***************
*** 5537,5544 ****
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   PIXEL_WIDTH (f) = pixelwidth;
!   PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
--- 5521,5528 ----
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   FRAME_PIXEL_WIDTH (f) = pixelwidth;
!   FRAME_PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
***************
*** 5569,5582 ****
  {
    int pix_x, pix_y;
  
!   pix_x = CHAR_TO_PIXEL_COL (f, x) + FONT_WIDTH  (f->output_data.w32->font) / 
2;
!   pix_y = CHAR_TO_PIXEL_ROW (f, y) + f->output_data.w32->line_height / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > PIXEL_WIDTH (f)) pix_x = PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > PIXEL_HEIGHT (f)) pix_y = PIXEL_HEIGHT (f);
  
    x_set_mouse_pixel_position (f, pix_x, pix_y);
  }
--- 5553,5566 ----
  {
    int pix_x, pix_y;
  
!   pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
!   pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
  
    x_set_mouse_pixel_position (f, pix_x, pix_y);
  }
***************
*** 5744,5750 ****
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.w32->asked_for_visible)
!       x_set_offset (f, f->output_data.w32->left_pos, 
f->output_data.w32->top_pos, 0);
  
        f->output_data.w32->asked_for_visible = 1;
  
--- 5728,5734 ----
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.w32->asked_for_visible)
!       x_set_offset (f, f->left_pos, f->top_pos, 0);
  
        f->output_data.w32->asked_for_visible = 1;
  
***************
*** 5932,5941 ****
  
    enter_crit ();
  
!   SetWindowLong (window, WND_FONTWIDTH_INDEX, FONT_WIDTH 
(f->output_data.w32->font));
!   SetWindowLong (window, WND_LINEHEIGHT_INDEX, 
f->output_data.w32->line_height);
!   SetWindowLong (window, WND_BORDER_INDEX, 
f->output_data.w32->internal_border_width);
!   SetWindowLong (window, WND_SCROLLBAR_INDEX, 
f->output_data.w32->vertical_scroll_bar_extra);
  
    leave_crit ();
  }
--- 5916,5925 ----
  
    enter_crit ();
  
!   SetWindowLong (window, WND_FONTWIDTH_INDEX, FRAME_COLUMN_WIDTH (f));
!   SetWindowLong (window, WND_LINEHEIGHT_INDEX, FRAME_LINE_HEIGHT (f));
!   SetWindowLong (window, WND_BORDER_INDEX, FRAME_INTERNAL_BORDER_WIDTH (f));
!   SetWindowLong (window, WND_SCROLLBAR_INDEX, f->scroll_bar_actual_width);
  
    leave_crit ();
  }
Index: w32term.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.h,v
retrieving revision 1.55
diff -c -r1.55 w32term.h
*** w32term.h   31 Mar 2003 20:35:43 -0000      1.55
--- w32term.h   14 May 2003 21:52:32 -0000
***************
*** 286,312 ****
    /* Original palette (used to deselect real palette after drawing) */
    HPALETTE old_palette;
  
-   /* Position of the W32 window (x and y offsets in root window).  */
-   int left_pos;
-   int top_pos;
- 
-   /* Border width of the W32 window as known by the window system.  */
-   int border_width;
- 
-   /* Size of the W32 window in pixels.  */
-   int pixel_height, pixel_width;
- 
-   /* Height of a line, in pixels.  */
-   int line_height;
- 
    /* Here are the Graphics Contexts for the default font.  */
    XGCValues *cursor_gc;                               /* cursor drawing */
  
-   /* Width of the internal border.  This is a line of background color
-      just inside the window's border.  When the frame is selected,
-      a highlighting is displayed inside the internal border.  */
-   int internal_border_width;
- 
    /* The window used for this frame.
       May be zero while the frame object is being created
       and the window has not yet been created.  */
--- 286,294 ----
***************
*** 364,385 ****
  
    DWORD dwStyle;
  
-   /* The size of the extra width currently allotted for vertical
-      scroll bars, in pixels.  */
-   int vertical_scroll_bar_extra;
- 
-   /* The extra width currently allotted for the areas in which
-      truncation marks, continuation marks, and overlay arrows are
-      displayed.  */
-   int left_fringe_width, right_fringe_width;
-   int fringe_cols, fringes_extra;
- 
-   /* This is the gravity value for the specified window position.  */
-   int win_gravity;
- 
-   /* The geometry flags for this window.  */
-   int size_hint_flags;
- 
    /* This is the Emacs structure for the display this frame is on.  */
    /* struct w32_display_info *display_info; */
  
--- 346,351 ----
***************
*** 412,428 ****
    /* The background for which the above relief GCs were set up.
       They are changed only when a different background is involved.  */
    unsigned long relief_background;
- 
-   /* See enum below */
-   int want_fullscreen;
- 
-   /* This many pixels are the difference between the outer window (i.e. the
-      left of the window manager decoration) and FRAME_W32_WINDOW. */
-   int x_pixels_diff;
- 
-   /* This many pixels are the difference between the outer window (i.e. the
-      top of the window manager titlebar) and FRAME_W32_WINDOW. */
-   int y_pixels_diff;
  };
  
  extern struct w32_output w32term_display;
--- 378,383 ----
***************
*** 438,448 ****
  #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
  #define FRAME_FONT(f) ((f)->output_data.w32->font)
  #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset)
- #define FRAME_INTERNAL_BORDER_WIDTH(f) 
((f)->output_data.w32->internal_border_width)
- #define FRAME_LINE_HEIGHT(f) ((f)->output_data.w32->line_height)
- /* Width of the default font of frame F.  Must be defined by each
-    terminal specific header.  */
- #define FRAME_DEFAULT_FONT_WIDTH(F)   FONT_WIDTH (FRAME_FONT (F))
  #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
  
  /* This gives the w32_display_info structure for the display F is on.  */
--- 393,398 ----
***************
*** 455,464 ****
  /* This is the 'font_info *' which frame F has.  */
  #define FRAME_W32_FONT_TABLE(f) (FRAME_W32_DISPLAY_INFO (f)->font_table)
  
- /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}.  */
- #define PIXEL_WIDTH(f) ((f)->output_data.w32->pixel_width)
- #define PIXEL_HEIGHT(f) ((f)->output_data.w32->pixel_height)
- 
  /* Value is the smallest width of any character in any font on frame F.  */
  
  #define FRAME_SMALLEST_CHAR_WIDTH(F) \
--- 405,410 ----
***************
*** 474,498 ****
  #define FRAME_X_IMAGE_CACHE(F) FRAME_W32_DISPLAY_INFO ((F))->image_cache
  
  
- /* Total width of fringes reserved for drawing truncation bitmaps,
-    continuation bitmaps and alike.  The width is in canonical char
-    units of the frame.  This must currently be the case because window
-    sizes aren't pixel values.  If it weren't the case, we wouldn't be
-    able to split windows horizontally nicely.  */
- 
- #define FRAME_X_FRINGE_COLS(F)        ((F)->output_data.w32->fringe_cols)
- 
- /* Total width of fringes in pixels.  */
- 
- #define FRAME_X_FRINGE_WIDTH(F) ((F)->output_data.w32->fringes_extra)
- 
- /* Pixel-width of the left and right fringe.  */
- 
- #define FRAME_X_LEFT_FRINGE_WIDTH(F) ((F)->output_data.w32->left_fringe_width)
- #define FRAME_X_RIGHT_FRINGE_WIDTH(F) 
((F)->output_data.w32->right_fringe_width)
- 
- 
- 
  /* W32-specific scroll bar stuff.  */
  
  /* We represent scroll bars as lisp vectors.  This allows us to place
--- 420,425 ----
***************
*** 627,678 ****
  /* Trimming off a few pixels from each side prevents
     text from glomming up against the scroll bar */
  #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
- 
- 
- /* Manipulating pixel sizes and character sizes.
-    Knowledge of which factors affect the overall size of the window should
-    be hidden in these macros, if that's possible.
- 
-    Return the upper/left pixel position of the character cell on frame F
-    at ROW/COL.  */
- #define CHAR_TO_PIXEL_ROW(f, row) \
-   ((f)->output_data.w32->internal_border_width \
-    + (row) * (f)->output_data.w32->line_height)
- #define CHAR_TO_PIXEL_COL(f, col) \
-   ((f)->output_data.w32->internal_border_width \
-    + (col) * FONT_WIDTH ((f)->output_data.w32->font))
- 
- /* Return the pixel width/height of frame F if it has
-    WIDTH columns/HEIGHT rows.  */
- #define CHAR_TO_PIXEL_WIDTH(f, width) \
-   (CHAR_TO_PIXEL_COL (f, width) \
-    + (f)->output_data.w32->vertical_scroll_bar_extra \
-    + (f)->output_data.w32->fringes_extra \
-    + (f)->output_data.w32->internal_border_width)
- #define CHAR_TO_PIXEL_HEIGHT(f, height) \
-   (CHAR_TO_PIXEL_ROW (f, height) \
-    + (f)->output_data.w32->internal_border_width)
- 
- 
- /* Return the row/column (zero-based) of the character cell containing
-    the pixel on FRAME at ROW/COL.  */
- #define PIXEL_TO_CHAR_ROW(f, row) \
-   (((row) - (f)->output_data.w32->internal_border_width) \
-    / (f)->output_data.w32->line_height)
- #define PIXEL_TO_CHAR_COL(f, col) \
-   (((col) - (f)->output_data.w32->internal_border_width) \
-    / FONT_WIDTH ((f)->output_data.w32->font))
- 
- /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
-    frame F?  */
- #define PIXEL_TO_CHAR_WIDTH(f, width) \
-   (PIXEL_TO_CHAR_COL (f, ((width) \
-                         - (f)->output_data.w32->internal_border_width \
-                         - (f)->output_data.w32->fringes_extra \
-                         - (f)->output_data.w32->vertical_scroll_bar_extra)))
- #define PIXEL_TO_CHAR_HEIGHT(f, height) \
-   (PIXEL_TO_CHAR_ROW (f, ((height) \
-                         - (f)->output_data.w32->internal_border_width)))
  
  
  extern void w32_fill_rect ();
--- 554,559 ----
Index: widget.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/widget.c,v
retrieving revision 1.68
diff -c -r1.68 widget.c
*** widget.c    12 Mar 2003 12:12:25 -0000      1.68
--- widget.c    14 May 2003 21:52:33 -0000
***************
*** 183,190 ****
       int* pixel_height;
  {
    struct frame* f = ew->emacs_frame.frame;
!   *pixel_width = FONT_WIDTH (f->output_data.x->font);
!   *pixel_height = f->output_data.x->line_height;
  }
  
  static void
--- 183,190 ----
       int* pixel_height;
  {
    struct frame* f = ew->emacs_frame.frame;
!   *pixel_width = FRAME_COLUMN_WIDTH (f);
!   *pixel_height = FRAME_LINE_HEIGHT (f);
  }
  
  static void
***************
*** 196,203 ****
       int* char_height;
  {
    struct frame* f = ew->emacs_frame.frame;
!   *char_width = PIXEL_TO_CHAR_WIDTH (f, (int) pixel_width);
!   *char_height = PIXEL_TO_CHAR_HEIGHT (f, (int) pixel_height);
  }
  
  static void
--- 196,203 ----
       int* char_height;
  {
    struct frame* f = ew->emacs_frame.frame;
!   *char_width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, (int) pixel_width);
!   *char_height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (int) pixel_height);
  }
  
  static void
***************
*** 209,216 ****
       Dimension* pixel_height;
  {
    struct frame* f = ew->emacs_frame.frame;
!   *pixel_width = CHAR_TO_PIXEL_WIDTH (f, char_width);
!   *pixel_height = CHAR_TO_PIXEL_HEIGHT (f, char_height);
  }
  
  static void
--- 209,216 ----
       Dimension* pixel_height;
  {
    struct frame* f = ew->emacs_frame.frame;
!   *pixel_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, char_width);
!   *pixel_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, char_height);
  }
  
  static void
***************
*** 305,312 ****
     */
  
    /* Hairily merged geometry */
!   unsigned int w = ew->emacs_frame.frame->width;
!   unsigned int h = ew->emacs_frame.frame->height;
  
    Widget wmshell = get_wm_shell ((Widget) ew);
    /* Each Emacs shell is now independent and top-level.  */
--- 305,312 ----
     */
  
    /* Hairily merged geometry */
!   unsigned int w = FRAME_COLS (ew->emacs_frame.frame);
!   unsigned int h = FRAME_LINES (ew->emacs_frame.frame);
  
    Widget wmshell = get_wm_shell ((Widget) ew);
    /* Each Emacs shell is now independent and top-level.  */
***************
*** 420,426 ****
      }
  #endif /* 0 */
    {
!     struct frame* frame = ew->emacs_frame.frame;
      Dimension pixel_width, pixel_height;
  
      /* Take into account the size of the scrollbar.  Always use the
--- 420,426 ----
      }
  #endif /* 0 */
    {
!     struct frame *f = ew->emacs_frame.frame;
      Dimension pixel_width, pixel_height;
  
      /* Take into account the size of the scrollbar.  Always use the
***************
*** 428,445 ****
         might end up with a frame width that is not a multiple of the
         frame's character width which is bad for vertically split
         windows.  */
!     frame->output_data.x->vertical_scroll_bar_extra
!       = (!FRAME_HAS_VERTICAL_SCROLL_BARS (frame)
!        ? 0
!        : (FRAME_SCROLL_BAR_COLS (frame)
!           * FONT_WIDTH (frame->output_data.x->font)));
  
!     compute_fringe_widths (frame, 0);
  
  #if 0 /* This can run Lisp code, and it is dangerous to give
         out the frame to Lisp code before it officially exists.
         This is handled in Fx_create_frame so not needed here.  */
!     change_frame_size (frame, h, w, 1, 0, 0);
  #endif
      char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height);
      ew->core.width = pixel_width;
--- 428,442 ----
         might end up with a frame width that is not a multiple of the
         frame's character width which is bad for vertically split
         windows.  */
!     f->scroll_bar_actual_width
!       = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
  
!     compute_fringe_widths (f, 0);
  
  #if 0 /* This can run Lisp code, and it is dangerous to give
         out the frame to Lisp code before it officially exists.
         This is handled in Fx_create_frame so not needed here.  */
!     change_frame_size (f, h, w, 1, 0, 0);
  #endif
      char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height);
      ew->core.width = pixel_width;
***************
*** 645,654 ****
  update_various_frame_slots (ew)
       EmacsFrame ew;
  {
!   struct x_output *x = ew->emacs_frame.frame->output_data.x;
!   x->pixel_height = ew->core.height + x->menubar_height;
!   x->pixel_width = ew->core.width;
!   x->internal_border_width = ew->emacs_frame.internal_border_width;
  
  }
  
--- 642,652 ----
  update_various_frame_slots (ew)
       EmacsFrame ew;
  {
!   struct frame *f = ew->emacs_frame.frame;
!   struct x_output *x = f->output_data.x;
!   FRAME_PIXEL_HEIGHT (f) = ew->core.height + x->menubar_height;
!   FRAME_PIXEL_WIDTH (f) = ew->core.width;
!   f->internal_border_width = ew->emacs_frame.internal_border_width;
  
  }
  
***************
*** 656,666 ****
  update_from_various_frame_slots (ew)
       EmacsFrame ew;
  {
!   struct x_output *x = ew->emacs_frame.frame->output_data.x;
!   ew->core.height = x->pixel_height - x->menubar_height;
!   ew->core.width = x->pixel_width;
    ew->core.background_pixel = x->background_pixel;
!   ew->emacs_frame.internal_border_width = x->internal_border_width;
    ew->emacs_frame.font = x->font;
    ew->emacs_frame.foreground_pixel = x->foreground_pixel;
    ew->emacs_frame.cursor_color = x->cursor_pixel;
--- 654,665 ----
  update_from_various_frame_slots (ew)
       EmacsFrame ew;
  {
!   struct frame *f = ew->emacs_frame.frame;
!   struct x_output *x = f->output_data.x;
!   ew->core.height = FRAME_PIXEL_HEIGHT (f) - x->menubar_height;
!   ew->core.width = FRAME_PIXEL_WIDTH (f);
    ew->core.background_pixel = x->background_pixel;
!   ew->emacs_frame.internal_border_width = f->internal_border_width;
    ew->emacs_frame.font = x->font;
    ew->emacs_frame.foreground_pixel = x->foreground_pixel;
    ew->emacs_frame.cursor_color = x->cursor_pixel;
***************
*** 717,723 ****
    }
  
  /* Update the font field in frame */
!   ew->emacs_frame.frame->output_data.x->font = ew->emacs_frame.font;
  #endif
  
    update_from_various_frame_slots (ew);
--- 716,722 ----
    }
  
  /* Update the font field in frame */
!   FRAME_FONT (ew->emacs_frame.frame) = ew->emacs_frame.font;
  #endif
  
    update_from_various_frame_slots (ew);
***************
*** 910,919 ****
    if (columns < 3) columns = 3;  /* no way buddy */
  
    check_frame_size (f, &rows, &columns);
!   f->output_data.x->vertical_scroll_bar_extra
!     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
!        ? 0
!        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));
  
    compute_fringe_widths (f, 0);
  
--- 909,916 ----
    if (columns < 3) columns = 3;  /* no way buddy */
  
    check_frame_size (f, &rows, &columns);
!   f->scroll_bar_actual_width
!     = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
  
    compute_fringe_widths (f, 0);
  
***************
*** 923,929 ****
    /* Something is really strange here wrt to the border width:
       Apparently, XtNwidth and XtNheight include the border, so we have
       to add it here.  But the XtNborderWidth set for the widgets has
!      no similarity to what f->output_data.x->border_width is set to.  */
    XtVaGetValues (widget, XtNborderWidth, &border_width, NULL);
    pixel_height += 2 * border_width;
    pixel_width += 2 * border_width;
--- 920,926 ----
    /* Something is really strange here wrt to the border width:
       Apparently, XtNwidth and XtNheight include the border, so we have
       to add it here.  But the XtNborderWidth set for the widgets has
!      no similarity to what f->border_width is set to.  */
    XtVaGetValues (widget, XtNborderWidth, &border_width, NULL);
    pixel_height += 2 * border_width;
    pixel_width += 2 * border_width;
***************
*** 1017,1022 ****
    EmacsFrame ew = (EmacsFrame) widget;
    FRAME_PTR f = ew->emacs_frame.frame;
  
!   ew->emacs_frame.internal_border_width
!     = f->output_data.x->internal_border_width;
  }
--- 1014,1018 ----
    EmacsFrame ew = (EmacsFrame) widget;
    FRAME_PTR f = ew->emacs_frame.frame;
  
!   ew->emacs_frame.internal_border_width = f->internal_border_width;
  }
Index: window.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/window.c,v
retrieving revision 1.438
diff -c -r1.438 window.c
*** window.c    31 Mar 2003 20:35:51 -0000      1.438
--- window.c    14 May 2003 21:52:34 -0000
***************
*** 243,255 ****
  
    p = allocate_window ();
    XSETFASTINT (p->sequence_number, ++sequence_number);
!   XSETFASTINT (p->left, 0);
!   XSETFASTINT (p->top, 0);
!   XSETFASTINT (p->height, 0);
!   XSETFASTINT (p->width, 0);
    XSETFASTINT (p->hscroll, 0);
    XSETFASTINT (p->min_hscroll, 0);
!   p->orig_top = p->orig_height = Qnil;
    p->start = Fmake_marker ();
    p->pointm = Fmake_marker ();
    XSETFASTINT (p->use_time, 0);
--- 243,255 ----
  
    p = allocate_window ();
    XSETFASTINT (p->sequence_number, ++sequence_number);
!   XSETFASTINT (p->left_col, 0);
!   XSETFASTINT (p->top_line, 0);
!   XSETFASTINT (p->total_lines, 0);
!   XSETFASTINT (p->total_cols, 0);
    XSETFASTINT (p->hscroll, 0);
    XSETFASTINT (p->min_hscroll, 0);
!   p->orig_top_line = p->orig_total_lines = Qnil;
    p->start = Fmake_marker ();
    p->pointm = Fmake_marker ();
    XSETFASTINT (p->use_time, 0);
***************
*** 273,278 ****
--- 273,285 ----
    p->frozen_window_start_p = 0;
    p->height_fixed_p = 0;
    p->last_cursor_off_p = p->cursor_off_p = 0;
+   p->left_margin_cols = Qnil;
+   p->right_margin_cols = Qnil;
+   p->left_fringe_width = Qnil;
+   p->right_fringe_width = Qnil;
+   p->fringes_outside_margins = Qnil;
+   p->scroll_bar_width = Qnil;
+   p->vertical_scroll_bar_type = Qt;
  
    Vwindow_list = Qnil;
    return val;
***************
*** 399,405 ****
       (window)
       Lisp_Object window;
  {
!   return decode_window (window)->height;
  }
  
  DEFUN ("window-width", Fwindow_width, Swindow_width, 0, 1, 0,
--- 406,412 ----
       (window)
       Lisp_Object window;
  {
!   return decode_window (window)->total_lines;
  }
  
  DEFUN ("window-width", Fwindow_width, Swindow_width, 0, 1, 0,
***************
*** 410,416 ****
       (window)
       Lisp_Object window;
  {
!   return make_number (window_internal_width (decode_window (window)));
  }
  
  DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
--- 417,423 ----
       (window)
       Lisp_Object window;
  {
!   return make_number (window_box_text_cols (decode_window (window)));
  }
  
  DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
***************
*** 483,493 ****
  {
    register struct window *w = decode_window (window);
  
!   return Fcons (w->left, Fcons (w->top,
!            Fcons (make_number (WINDOW_RIGHT_EDGE (w)),
!                 Fcons (make_number (XFASTINT (w->top)
!                                     + XFASTINT (w->height)),
!                        Qnil))));
  }
  
  /* Test if the character at column *X, row *Y is within window W.
--- 490,500 ----
  {
    register struct window *w = decode_window (window);
  
!   return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w)),
!        Fcons (make_number (WINDOW_TOP_EDGE_LINE (w)),
!        Fcons (make_number (WINDOW_RIGHT_EDGE_COL (w)),
!        Fcons (make_number (WINDOW_BOTTOM_EDGE_LINE (w)),
!               Qnil))));
  }
  
  /* Test if the character at column *X, row *Y is within window W.
***************
*** 514,531 ****
       register struct window *w;
       register int *x, *y;
  {
-   /* Let's make this a global enum later, instead of using numbers
-      everywhere.  */
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    int left_x, right_x, top_y, bottom_y;
    enum window_part part;
!   int ux = CANON_X_UNIT (f);
!   int x0 = XFASTINT (w->left) * ux;
!   int x1 = x0 + XFASTINT (w->width) * ux;
    /* The width of the area where the vertical line can be dragged.
       (Between mode lines for instance.  */
    int grabbable_width = ux;
!   int lmargin_width = 0, rmargin_width = 0;
  
    if (*x < x0 || *x >= x1)
      return ON_NOTHING;
--- 521,536 ----
       register struct window *w;
       register int *x, *y;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    int left_x, right_x, top_y, bottom_y;
    enum window_part part;
!   int ux = FRAME_COLUMN_WIDTH (f);
!   int x0 = WINDOW_LEFT_EDGE_X (w);
!   int x1 = WINDOW_RIGHT_EDGE_X (w);
    /* The width of the area where the vertical line can be dragged.
       (Between mode lines for instance.  */
    int grabbable_width = ux;
!   int lmargin_width, rmargin_width, text_left, text_right;
  
    if (*x < x0 || *x >= x1)
      return ON_NOTHING;
***************
*** 535,554 ****
    if (w->pseudo_window_p)
      {
        left_x = 0;
!       right_x = XFASTINT (w->width) * CANON_X_UNIT (f) - 1;
!       top_y = WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w);
!       bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w);
      }
    else
      {
!       left_x = (WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X (w)
!               - FRAME_INTERNAL_BORDER_WIDTH_SAFE (f));
!       right_x = WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X (w) - 1;
!       top_y = (WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w)
!              - FRAME_INTERNAL_BORDER_WIDTH_SAFE (f));
!       bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w);
      }
  
    /* On the mode line or header line?  If it's near the start of
       the mode or header line of window that's has a horizontal
       sibling, say it's on the vertical line.  That's to be able
--- 540,561 ----
    if (w->pseudo_window_p)
      {
        left_x = 0;
!       right_x = WINDOW_TOTAL_WIDTH (w) - 1;
!       top_y = WINDOW_TOP_EDGE_Y (w);
!       bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
      }
    else
      {
!       left_x = WINDOW_BOX_LEFT_EDGE_X (w);
!       right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1;
!       top_y = WINDOW_TOP_EDGE_Y (w);
!       bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
      }
  
+   /* Outside any interesting row?  */
+   if (*y < top_y || *y >= bottom_y)
+     return ON_NOTHING;
+ 
    /* On the mode line or header line?  If it's near the start of
       the mode or header line of window that's has a horizontal
       sibling, say it's on the vertical line.  That's to be able
***************
*** 559,688 ****
        && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)
        && *y < bottom_y)
      {
        /* We're somewhere on the mode line.  We consider the place
         between mode lines of horizontally adjacent mode lines
         as the vertical border.    If scroll bars on the left,
         return the right window.  */
!       part = ON_MODE_LINE;
! 
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
        {
!         if (abs (*x - x0) < grabbable_width)
!           part = ON_VERTICAL_BORDER;
        }
!       else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < grabbable_width)
!       part = ON_VERTICAL_BORDER;
!     }
!   else if (WINDOW_WANTS_HEADER_LINE_P (w)
!          && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)
!          && *y >= top_y)
!     {
!       part = ON_HEADER_LINE;
! 
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
        {
!         if (abs (*x - x0) < grabbable_width)
!           part = ON_VERTICAL_BORDER;
        }
!       else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < grabbable_width)
!       part = ON_VERTICAL_BORDER;
      }
!   /* Outside anything interesting?  */
!   else if (*y < top_y
!          || *y >= bottom_y
!          || *x < (left_x
!                   - FRAME_LEFT_FRINGE_WIDTH (f)
!                   - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux)
!          || *x > (right_x
!                   + FRAME_RIGHT_FRINGE_WIDTH (f)
!                   + FRAME_RIGHT_SCROLL_BAR_WIDTH (f) * ux))
      {
!       part = ON_NOTHING;
      }
!   else if (FRAME_WINDOW_P (f))
      {
        if (!w->pseudo_window_p
!         && !FRAME_HAS_VERTICAL_SCROLL_BARS (f)
          && !WINDOW_RIGHTMOST_P (w)
!         && (abs (*x - right_x - FRAME_RIGHT_FRINGE_WIDTH (f)) < 
grabbable_width))
!       {
!         part = ON_VERTICAL_BORDER;
!       }
!       else if (*x < left_x || *x > right_x)
!       {
!         /* Other lines than the mode line don't include fringes and
!            scroll bars on the left.  */
! 
!         /* Convert X and Y to window-relative pixel coordinates.  */
!         *x -= left_x;
!         *y -= top_y;
!         part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE;
!       }
!       else
!       {
!         lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
!         rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
!         /* You can never be on a margin area if its width is zero.  */
!         if (lmargin_width
!             && *x <= window_box_right (w, LEFT_MARGIN_AREA))
!           part = ON_LEFT_MARGIN;
!         else if (rmargin_width
!                  && *x >= window_box_left (w, RIGHT_MARGIN_AREA))
!           part = ON_RIGHT_MARGIN;
!         else
!           {
!             part = ON_TEXT;
!             *x -= left_x;
!             *y -= top_y;
!           }
!       }
      }
    else
      {
        /* Need to say "*x > right_x" rather than >=, since on character
         terminals, the vertical line's x coordinate is right_x.  */
!       if (*x < left_x || *x > right_x)
!       {
!         /* Other lines than the mode line don't include fringes and
!            scroll bars on the left.  */
! 
!         /* Convert X and Y to window-relative pixel coordinates.  */
!         *x -= left_x;
!         *y -= top_y;
!         part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE;
!       }
!       /* Here, too, "*x > right_x" is because of character terminals.  */
!       else if (!w->pseudo_window_p
!              && !WINDOW_RIGHTMOST_P (w)
!              && *x > right_x - ux)
        {
          /* On the border on the right side of the window?  Assume that
             this area begins at RIGHT_X minus a canonical char width.  */
!         part = ON_VERTICAL_BORDER;
!       }
!       else
!       {
!         lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
!         rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
!         /* You can never be on a margin area if its width is zero.
!            This is especially important for character terminals.  */
!         if (lmargin_width
!             && *x <= window_box_right (w, LEFT_MARGIN_AREA))
!           part = ON_LEFT_MARGIN;
!         else if (rmargin_width
!                  && *x >= window_box_left (w, RIGHT_MARGIN_AREA))
!           part = ON_RIGHT_MARGIN;
!         else
!           {
!             part = ON_TEXT;
!             /* Convert X and Y to window-relative pixel coordinates.  */
!             *x -= left_x;
!             *y -= top_y;
!           }
        }
      }
  
!   return part;
  }
  
  
--- 566,665 ----
        && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)
        && *y < bottom_y)
      {
+       part = ON_MODE_LINE;
+ 
+     header_vertical_border_check:
        /* We're somewhere on the mode line.  We consider the place
         between mode lines of horizontally adjacent mode lines
         as the vertical border.    If scroll bars on the left,
         return the right window.  */
!       if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
!         || WINDOW_RIGHTMOST_P (w))
        {
!         if (!WINDOW_LEFTMOST_P (w) && abs (*x - x0) < grabbable_width)
!           return ON_VERTICAL_BORDER;
        }
!       else 
        {
!         if (abs (*x - x1) < grabbable_width)
!           return ON_VERTICAL_BORDER;
        }
! 
!       return part;
      }
! 
!   if (WINDOW_WANTS_HEADER_LINE_P (w)
!       && *y >= top_y
!       && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w))
      {
!       part = ON_HEADER_LINE;
!       goto header_vertical_border_check;
      }
! 
!   /* Outside any interesting column?  */
!   if (*x < left_x || *x > right_x)
!     return ON_NOTHING;
! 
!   lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
!   rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
!   
!   text_left = window_box_left (w, TEXT_AREA);
!   text_right = text_left + window_box_width (w, TEXT_AREA);
! 
!   if (FRAME_WINDOW_P (f))
      {
        if (!w->pseudo_window_p
!         && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
          && !WINDOW_RIGHTMOST_P (w)
!         && (abs (*x - right_x) < grabbable_width))
!       return ON_VERTICAL_BORDER;
      }
    else
      {
        /* Need to say "*x > right_x" rather than >=, since on character
         terminals, the vertical line's x coordinate is right_x.  */
!       if (!w->pseudo_window_p
!         && !WINDOW_RIGHTMOST_P (w)
!         && *x > right_x - ux)
        {
          /* On the border on the right side of the window?  Assume that
             this area begins at RIGHT_X minus a canonical char width.  */
!         return ON_VERTICAL_BORDER;
        }
      }
  
!   if (*x < text_left)
!     {
!       if (lmargin_width > 0
!         && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!             ? (*x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w))
!             : (*x < left_x + lmargin_width)))
!       return ON_LEFT_MARGIN;
! 
!       /* Convert X and Y to window-relative pixel coordinates.  */
!       *x -= left_x;
!       *y -= top_y;
!       return ON_LEFT_FRINGE;
!     }
! 
!   if (*x >= text_right)
!     {
!       if (rmargin_width > 0
!         && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!             ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w))
!             : (*x >= right_x - rmargin_width)))
!       return ON_RIGHT_MARGIN;
! 
!       /* Convert X and Y to window-relative pixel coordinates.  */
!       *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w);
!       *y -= top_y;
!       return ON_RIGHT_FRINGE;
!     }
! 
!   /* Everything special ruled out - must be on text area */
!   *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w);
!   *y -= top_y;
!   return ON_TEXT;
  }
  
  
***************
*** 719,726 ****
    ly = Fcdr (coordinates);
    CHECK_NUMBER_OR_FLOAT (lx);
    CHECK_NUMBER_OR_FLOAT (ly);
!   x = PIXEL_X_FROM_CANON_X (f, lx);
!   y = PIXEL_Y_FROM_CANON_Y (f, ly);
  
    switch (coordinates_in_window (w, &x, &y))
      {
--- 696,703 ----
    ly = Fcdr (coordinates);
    CHECK_NUMBER_OR_FLOAT (lx);
    CHECK_NUMBER_OR_FLOAT (ly);
!   x = FRAME_PIXEL_X_FROM_CANON_X (f, lx);
!   y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly);
  
    switch (coordinates_in_window (w, &x, &y))
      {
***************
*** 730,737 ****
      case ON_TEXT:
        /* X and Y are now window relative pixel coordinates.  Convert
         them to canonical char units before returning them.  */
!       return Fcons (CANON_X_FROM_PIXEL_X (f, x),
!                   CANON_Y_FROM_PIXEL_Y (f, y));
  
      case ON_MODE_LINE:
        return Qmode_line;
--- 707,714 ----
      case ON_TEXT:
        /* X and Y are now window relative pixel coordinates.  Convert
         them to canonical char units before returning them.  */
!       return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x),
!                   FRAME_CANON_Y_FROM_PIXEL_Y (f, y));
  
      case ON_MODE_LINE:
        return Qmode_line;
***************
*** 798,805 ****
  
  
  /* Find the window containing frame-relative pixel position X/Y and
!    return it as a Lisp_Object.  If X, Y is on one of the window's 
!    special `window_part' elements, set *PART to the id of that element.
     If there is no window under X, Y return nil and leave *PART
     unmodified.  TOOL_BAR_P non-zero means detect tool-bar windows.
  
--- 775,786 ----
  
  
  /* Find the window containing frame-relative pixel position X/Y and
!    return it as a Lisp_Object.
! 
!    If X, Y is on one of the window's special `window_part' elements,
!    set *PART to the id of that element, and return X and Y converted
!    to window relative coordinates in WX and WY.
! 
     If there is no window under X, Y return nil and leave *PART
     unmodified.  TOOL_BAR_P non-zero means detect tool-bar windows.
  
***************
*** 813,822 ****
     case.  */
  
  Lisp_Object
! window_from_coordinates (f, x, y, part, tool_bar_p)
       struct frame *f;
       int x, y;
       enum window_part *part;
       int tool_bar_p;
  {
    Lisp_Object window;
--- 794,804 ----
     case.  */
  
  Lisp_Object
! window_from_coordinates (f, x, y, part, wx, wy, tool_bar_p)
       struct frame *f;
       int x, y;
       enum window_part *part;
+      int *wx, *wy;
       int tool_bar_p;
  {
    Lisp_Object window;
***************
*** 835,841 ****
    if (NILP (window)
        && tool_bar_p
        && WINDOWP (f->tool_bar_window)
!       && XINT (XWINDOW (f->tool_bar_window)->height) > 0
        && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)
          != ON_NOTHING))
      {
--- 817,823 ----
    if (NILP (window)
        && tool_bar_p
        && WINDOWP (f->tool_bar_window)
!       && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0
        && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)
          != ON_NOTHING))
      {
***************
*** 843,848 ****
--- 825,833 ----
        window = f->tool_bar_window;
      }
  
+   if (wx) *wx = x;
+   if (wy) *wy = y;
+ 
    return window;
  }
  
***************
*** 866,874 ****
    CHECK_NUMBER_OR_FLOAT (y);
  
    return window_from_coordinates (f,
!                                 PIXEL_X_FROM_CANON_X (f, x),
!                                 PIXEL_Y_FROM_CANON_Y (f, y),
!                                 0, 0);
  }
  
  DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
--- 851,859 ----
    CHECK_NUMBER_OR_FLOAT (y);
  
    return window_from_coordinates (f,
!                                 FRAME_PIXEL_X_FROM_CANON_X (f, x),
!                                 FRAME_PIXEL_Y_FROM_CANON_Y (f, y),
!                                 0, 0, 0, 0);
  }
  
  DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
***************
*** 1168,1177 ****
    if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame))))
      FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement;
  
!   p->left = o->left;
!   p->top = o->top;
!   p->width = o->width;
!   p->height = o->height;
    p->desired_matrix = p->current_matrix = 0;
    p->vscroll = 0;
    bzero (&p->cursor, sizeof (p->cursor));
--- 1153,1162 ----
    if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame))))
      FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement;
  
!   p->left_col = o->left_col;
!   p->top_line = o->top_line;
!   p->total_cols = o->total_cols;
!   p->total_lines = o->total_lines;
    p->desired_matrix = p->current_matrix = 0;
    p->vscroll = 0;
    bzero (&p->cursor, sizeof (p->cursor));
***************
*** 1185,1191 ****
    XSETFASTINT (p->window_end_pos, 0);
    p->window_end_valid = Qnil;
    p->frozen_window_start_p = 0;
!   p->orig_top = p->orig_height = Qnil;
  
    p->next = tem = o->next;
    if (!NILP (tem))
--- 1170,1176 ----
    XSETFASTINT (p->window_end_pos, 0);
    p->window_end_valid = Qnil;
    p->frozen_window_start_p = 0;
!   p->orig_top_line = p->orig_total_lines = Qnil;
  
    p->next = tem = o->next;
    if (!NILP (tem))
***************
*** 1344,1361 ****
         set_window_{height,width} will re-position the sibling's
         children.  */
        sib = p->next;
!       XWINDOW (sib)->top = p->top;
!       XWINDOW (sib)->left = p->left;
      }
  
    /* Stretch that sibling.  */
    if (!NILP (par->vchild))
      set_window_height (sib,
!                      XFASTINT (XWINDOW (sib)->height) + XFASTINT (p->height),
                       1);
    if (!NILP (par->hchild))
      set_window_width (sib,
!                     XFASTINT (XWINDOW (sib)->width) + XFASTINT (p->width),
                      1);
  
    /* If parent now has only one child,
--- 1329,1346 ----
         set_window_{height,width} will re-position the sibling's
         children.  */
        sib = p->next;
!       XWINDOW (sib)->top_line = p->top_line;
!       XWINDOW (sib)->left_col = p->left_col;
      }
  
    /* Stretch that sibling.  */
    if (!NILP (par->vchild))
      set_window_height (sib,
!                      XFASTINT (XWINDOW (sib)->total_lines) + XFASTINT 
(p->total_lines),
                       1);
    if (!NILP (par->hchild))
      set_window_width (sib,
!                     XFASTINT (XWINDOW (sib)->total_cols) + XFASTINT 
(p->total_cols),
                      1);
  
    /* If parent now has only one child,
***************
*** 1891,1897 ****
                       display there.  */
                    Lisp_Object buffer;
                    buffer = Fother_buffer (obj, Qnil, w->frame);
!                   Fset_window_buffer (window, buffer);
                    if (EQ (window, selected_window))
                      Fset_buffer (w->buffer);
                  }
--- 1876,1882 ----
                       display there.  */
                    Lisp_Object buffer;
                    buffer = Fother_buffer (obj, Qnil, w->frame);
!                   Fset_window_buffer (window, buffer, Qnil);
                    if (EQ (window, selected_window))
                      Fset_buffer (w->buffer);
                  }
***************
*** 1911,1918 ****
              else
                {
                  struct window *b = XWINDOW (best_window);
!                 if (XFASTINT (w->height) * XFASTINT (w->width)
!                     > XFASTINT (b->height) * XFASTINT (b->width))
                    best_window = window;
                }
            }
--- 1896,1903 ----
              else
                {
                  struct window *b = XWINDOW (best_window);
!                 if (XFASTINT (w->total_lines) * XFASTINT (w->total_cols)
!                     > XFASTINT (b->total_lines) * XFASTINT (b->total_cols))
                    best_window = window;
                }
            }
***************
*** 1955,1961 ****
                  {
                    /* Otherwise show a different buffer in the window.  */
                    w->dedicated = Qnil;
!                   Fset_window_buffer (window, buffer);
                    if (EQ (window, selected_window))
                      Fset_buffer (w->buffer);
                  }
--- 1940,1946 ----
                  {
                    /* Otherwise show a different buffer in the window.  */
                    w->dedicated = Qnil;
!                   Fset_window_buffer (window, buffer, Qnil);
                    if (EQ (window, selected_window))
                      Fset_buffer (w->buffer);
                  }
***************
*** 2060,2066 ****
    w = XWINDOW (window);
  
    startpos = marker_position (w->start);
!   top = XFASTINT (w->top) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
  
    if (MINI_WINDOW_P (w) && top > 0)
      error ("Can't expand minibuffer to full frame");
--- 2045,2051 ----
    w = XWINDOW (window);
  
    startpos = marker_position (w->start);
!   top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME 
(w)));
  
    if (MINI_WINDOW_P (w) && top > 0)
      error ("Can't expand minibuffer to full frame");
***************
*** 2072,2078 ****
       on the frame.  But don't try to do this if the window start is
       outside the visible portion (as might happen when the display is
       not current, due to typeahead).  */
!   new_top = XFASTINT (w->top) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
    if (new_top != top
        && startpos >= BUF_BEGV (XBUFFER (w->buffer))
        && startpos <= BUF_ZV (XBUFFER (w->buffer)))
--- 2057,2063 ----
       on the frame.  But don't try to do this if the window start is
       outside the visible portion (as might happen when the display is
       not current, due to typeahead).  */
!   new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME 
(w)));
    if (new_top != top
        && startpos >= BUF_BEGV (XBUFFER (w->buffer))
        && startpos <= BUF_ZV (XBUFFER (w->buffer)))
***************
*** 2427,2433 ****
      *fixed = fixed_p;
  
    if (fixed_p)
!     size = width_p ? XFASTINT (w->width) : XFASTINT (w->height);
    else
      size = window_min_size_1 (w, width_p);
  
--- 2412,2418 ----
      *fixed = fixed_p;
  
    if (fixed_p)
!     size = width_p ? XFASTINT (w->total_cols) : XFASTINT (w->total_lines);
    else
      size = window_min_size_1 (w, width_p);
  
***************
*** 2435,2440 ****
--- 2420,2462 ----
  }
  
  
+ /* Adjust the margins of window W if text area is too small.  
+    Return 1 if window width is ok after adjustment; 0 if window
+    is still too narrow.  */
+ 
+ static int
+ adjust_window_margins (w)
+      struct window *w;
+ {
+   int box_cols = (WINDOW_TOTAL_COLS (w)
+                 - WINDOW_FRINGE_COLS (w)
+                 - WINDOW_SCROLL_BAR_COLS (w));
+   int margin_cols = (WINDOW_LEFT_MARGIN_COLS (w)
+                    + WINDOW_RIGHT_MARGIN_COLS (w));
+ 
+   if (box_cols - margin_cols >= MIN_SAFE_WINDOW_WIDTH)
+     return 1;
+ 
+   if (margin_cols < 0 || box_cols < MIN_SAFE_WINDOW_WIDTH)
+     return 0;
+ 
+   /* Window's text area is too narrow, but reducing the window
+      margins will fix that.  */
+   margin_cols = box_cols - MIN_SAFE_WINDOW_WIDTH;
+   if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
+     {
+       if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
+       w->left_margin_cols = w->right_margin_cols
+         = make_number (margin_cols/2);
+       else
+       w->right_margin_cols = make_number (margin_cols);
+     }
+   else
+     w->left_margin_cols = make_number (margin_cols);
+   return 1;
+ }
+ 
+ 
  /* Set WINDOW's height or width to SIZE.  WIDTH_P non-zero means set
     WINDOW's width.  Resize WINDOW's children, if any, so that they
     keep their proportionate size relative to WINDOW.  Propagate
***************
*** 2452,2459 ****
    struct window *w = XWINDOW (window);
    struct window *c;
    Lisp_Object child, *forward, *sideward;
!   int old_size, min_size;
  
    if (nodelete_p == 2)
      nodelete_p = 0;
  
--- 2474,2483 ----
    struct window *w = XWINDOW (window);
    struct window *c;
    Lisp_Object child, *forward, *sideward;
!   int old_size, min_size, safe_min_size;
  
+   /* We test nodelete_p != 2 and nodelete_p != 1 below, so it
+      seems like it's too soon to do this here.  ++KFS.  */
    if (nodelete_p == 2)
      nodelete_p = 0;
  
***************
*** 2465,2477 ****
       Preserve it as long as that is at all possible.  */
    if (width_p)
      {
!       old_size = XINT (w->width);
        min_size = window_min_width;
      }
    else
      {
!       old_size = XINT (w->height);
        min_size = window_min_height;
      }
  
    if (old_size < min_size && nodelete_p != 2)
--- 2489,2507 ----
       Preserve it as long as that is at all possible.  */
    if (width_p)
      {
!       old_size = WINDOW_TOTAL_COLS (w);
        min_size = window_min_width;
+       /* Ensure that there is room for the scroll bar and fringes!
+          We may reduce display margins though.  */
+       safe_min_size = (MIN_SAFE_WINDOW_WIDTH
+                      + WINDOW_FRINGE_COLS (w)
+                      + WINDOW_SCROLL_BAR_COLS (w));
      }
    else
      {
!       old_size = XINT (w->total_lines);
        min_size = window_min_height;
+       safe_min_size = MIN_SAFE_WINDOW_HEIGHT;
      }
  
    if (old_size < min_size && nodelete_p != 2)
***************
*** 2482,2490 ****
      {
        if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok))
        min_size = width_p ? MIN_SAFE_WINDOW_WIDTH : MIN_SAFE_WINDOW_HEIGHT;
!       else
!       min_size = width_p ? window_min_width : window_min_height;
! 
        if (size < min_size)
        {
          delete_window (window);
--- 2512,2519 ----
      {
        if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok))
        min_size = width_p ? MIN_SAFE_WINDOW_WIDTH : MIN_SAFE_WINDOW_HEIGHT;
!       if (min_size < safe_min_size)
!       min_size = safe_min_size;
        if (size < min_size)
        {
          delete_window (window);
***************
*** 2502,2515 ****
      {
        sideward = &w->vchild;
        forward = &w->hchild;
!       w->width = make_number (size);
      }
    else
      {
        sideward = &w->hchild;
        forward = &w->vchild;
!       w->height = make_number (size);
!       w->orig_height = Qnil;
      }
  
    if (!NILP (*sideward))
--- 2531,2545 ----
      {
        sideward = &w->vchild;
        forward = &w->hchild;
!       w->total_cols = make_number (size);
!       adjust_window_margins (w);
      }
    else
      {
        sideward = &w->hchild;
        forward = &w->vchild;
!       w->total_lines = make_number (size);
!       w->orig_total_lines = Qnil;
      }
  
    if (!NILP (*sideward))
***************
*** 2518,2526 ****
        {
          c = XWINDOW (child);
          if (width_p)
!           c->left = w->left;
          else
!           c->top = w->top;
          size_window (child, size, width_p, nodelete_p);
        }
      }
--- 2548,2556 ----
        {
          c = XWINDOW (child);
          if (width_p)
!           c->left_col = w->left_col;
          else
!           c->top_line = w->top_line;
          size_window (child, size, width_p, nodelete_p);
        }
      }
***************
*** 2538,2544 ****
          int child_size;
  
          c = XWINDOW (child);
!         child_size = width_p ? XINT (c->width) : XINT (c->height);
          total += child_size;
  
          if (window_fixed_size_p (c, width_p, 0))
--- 2568,2574 ----
          int child_size;
  
          c = XWINDOW (child);
!         child_size = width_p ? XINT (c->total_cols) : XINT (c->total_lines);
          total += child_size;
  
          if (window_fixed_size_p (c, width_p, 0))
***************
*** 2560,2581 ****
        extra = (size - total) - n * each;
  
        /* Compute new children heights and edge positions.  */
!       first_pos = width_p ? XINT (w->left) : XINT (w->top);
        last_pos = first_pos;
        for (child = *forward; !NILP (child); child = c->next)
        {
          int new_size, old_size;
  
          c = XWINDOW (child);
!         old_size = width_p ? XFASTINT (c->width) : XFASTINT (c->height);
          new_size = old_size;
  
          /* The top or left edge position of this child equals the
             bottom or right edge of its predecessor.  */
          if (width_p)
!           c->left = make_number (last_pos);
          else
!           c->top = make_number (last_pos);
  
          /* If this child can be resized, do it.  */
          if (resize_fixed_p || !window_fixed_size_p (c, width_p, 0))
--- 2590,2611 ----
        extra = (size - total) - n * each;
  
        /* Compute new children heights and edge positions.  */
!       first_pos = width_p ? XINT (w->left_col) : XINT (w->top_line);
        last_pos = first_pos;
        for (child = *forward; !NILP (child); child = c->next)
        {
          int new_size, old_size;
  
          c = XWINDOW (child);
!         old_size = width_p ? XFASTINT (c->total_cols) : XFASTINT 
(c->total_lines);
          new_size = old_size;
  
          /* The top or left edge position of this child equals the
             bottom or right edge of its predecessor.  */
          if (width_p)
!           c->left_col = make_number (last_pos);
          else
!           c->top_line = make_number (last_pos);
  
          /* If this child can be resized, do it.  */
          if (resize_fixed_p || !window_fixed_size_p (c, width_p, 0))
***************
*** 2603,2609 ****
          {
            int child_size;
            c = XWINDOW (child);
!           child_size = width_p ? XINT (c->width) : XINT (c->height);
            size_window (child, child_size, width_p, 2);
          }
      }
--- 2633,2639 ----
          {
            int child_size;
            c = XWINDOW (child);
!           child_size = width_p ? XINT (c->total_cols) : XINT (c->total_lines);
            size_window (child, child_size, width_p, 2);
          }
      }
***************
*** 2647,2659 ****
  {
    struct window *w = XWINDOW (window);
  
!   XSETFASTINT (w->top, XFASTINT (w->top) + n);
!   XSETFASTINT (w->height, XFASTINT (w->height) - n);
  
!   if (INTEGERP (w->orig_top))
!     XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
!   if (INTEGERP (w->orig_height))
!     XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
  
    /* Handle just the top child in a vertical split.  */
    if (!NILP (w->vchild))
--- 2677,2689 ----
  {
    struct window *w = XWINDOW (window);
  
!   XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
!   XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
  
!   if (INTEGERP (w->orig_top_line))
!     XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
!   if (INTEGERP (w->orig_total_lines))
!     XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
  
    /* Handle just the top child in a vertical split.  */
    if (!NILP (w->vchild))
***************
*** 2681,2692 ****
  
  /* Make WINDOW display BUFFER as its contents.  RUN_HOOKS_P non-zero
     means it's allowed to run hooks.  See make_frame for a case where
!    it's not allowed.  */
  
  void
! set_window_buffer (window, buffer, run_hooks_p)
       Lisp_Object window, buffer;
!      int run_hooks_p;
  {
    struct window *w = XWINDOW (window);
    struct buffer *b = XBUFFER (buffer);
--- 2711,2724 ----
  
  /* Make WINDOW display BUFFER as its contents.  RUN_HOOKS_P non-zero
     means it's allowed to run hooks.  See make_frame for a case where
!    it's not allowed.  KEEP_MARGINS_P non-zero means that the current
!    margins, fringes, and scroll-bar settings of the window are not
!    reset from the buffer's local settings.  */
  
  void
! set_window_buffer (window, buffer, run_hooks_p, keep_margins_p)
       Lisp_Object window, buffer;
!      int run_hooks_p, keep_margins_p;
  {
    struct window *w = XWINDOW (window);
    struct buffer *b = XBUFFER (buffer);
***************
*** 2731,2738 ****
        Fset_buffer (buffer);
      }
  
!   /* Set left and right marginal area width from buffer.  */
!   Fset_window_margins (window, b->left_margin_width, b->right_margin_width);
  
    if (run_hooks_p)
      {
--- 2763,2787 ----
        Fset_buffer (buffer);
      }
  
!   if (!keep_margins_p)
!     {
!       /* Set left and right marginal area width etc. from buffer.  */
! 
!       /* This may call adjust_window_margins three times, so 
!        temporarily disable window margins.  */
!       w->left_margin_cols = w->right_margin_cols = Qnil;
! 
!       Fset_window_fringes (window,
!                          b->left_fringe_width, b->right_fringe_width,
!                          b->fringes_outside_margins);
! 
!       Fset_window_scroll_bars (window,
!                              b->scroll_bar_width,
!                              b->vertical_scroll_bar_type, Qnil);
! 
!       Fset_window_margins (window,
!                          b->left_margin_cols, b->right_margin_cols);
!     }
  
    if (run_hooks_p)
      {
***************
*** 2749,2758 ****
  }
  
  
! DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 2, 0,
         doc: /* Make WINDOW display BUFFER as its contents.
! BUFFER can be a buffer or buffer name.  */)
!      (window, buffer)
       register Lisp_Object window, buffer;
  {
    register Lisp_Object tem;
--- 2798,2811 ----
  }
  
  
! DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
         doc: /* Make WINDOW display BUFFER as its contents.
! BUFFER can be a buffer or buffer name.  
! Optional third arg KEEP_MARGINS non-nil means that WINDOW's current
! display margins, fringe widths, and scroll bar settings are maintained;
! the default is to reset these from BUFFER's local settings or the frame
! defaults.  */)
!      (window, buffer, keep_margins)
       register Lisp_Object window, buffer;
  {
    register Lisp_Object tem;
***************
*** 2778,2784 ****
        unshow_buffer (w);
      }
  
!   set_window_buffer (window, buffer, 1);
    return Qnil;
  }
  
--- 2831,2837 ----
        unshow_buffer (w);
      }
  
!   set_window_buffer (window, buffer, 1, !NILP (keep_margins));
    return Qnil;
  }
  
***************
*** 3050,3056 ****
    if (pop_up_frames || last_nonminibuf_frame == 0)
      {
        window = Fframe_selected_window (call0 (Vpop_up_frame_function));
!       Fset_window_buffer (window, buffer);
        return display_buffer_1 (window);
      }
  
--- 3103,3109 ----
    if (pop_up_frames || last_nonminibuf_frame == 0)
      {
        window = Fframe_selected_window (call0 (Vpop_up_frame_function));
!       Fset_window_buffer (window, buffer, Qnil);
        return display_buffer_1 (window);
      }
  
***************
*** 3139,3152 ****
          if (!NILP (other)
              && !NILP (Veven_window_heights)
              /* Check that OTHER and WINDOW are vertically arrayed.  */
!             && !EQ (XWINDOW (other)->top, XWINDOW (window)->top)
!             && (XFASTINT (XWINDOW (other)->height)
!                 > XFASTINT (XWINDOW (window)->height)))
            {
!             int total = (XFASTINT (XWINDOW (other)->height)
!                          + XFASTINT (XWINDOW (window)->height));
              enlarge_window (upper,
!                             total / 2 - XFASTINT (XWINDOW (upper)->height),
                              0, 0);
            }
        }
--- 3192,3205 ----
          if (!NILP (other)
              && !NILP (Veven_window_heights)
              /* Check that OTHER and WINDOW are vertically arrayed.  */
!             && !EQ (XWINDOW (other)->top_line, XWINDOW (window)->top_line)
!             && (XFASTINT (XWINDOW (other)->total_lines)
!                 > XFASTINT (XWINDOW (window)->total_lines)))
            {
!             int total = (XFASTINT (XWINDOW (other)->total_lines)
!                          + XFASTINT (XWINDOW (window)->total_lines));
              enlarge_window (upper,
!                             total / 2 - XFASTINT (XWINDOW 
(upper)->total_lines),
                              0, 0);
            }
        }
***************
*** 3154,3160 ****
    else
      window = Fget_lru_window (Qnil);
  
!   Fset_window_buffer (window, buffer);
    return display_buffer_1 (window);
  }
  
--- 3207,3213 ----
    else
      window = Fget_lru_window (Qnil);
  
!   Fset_window_buffer (window, buffer, Qnil);
    return display_buffer_1 (window);
  }
  
***************
*** 3284,3292 ****
           the usable space in columns by two.
           We round up, since the left-hand window may include
           a dividing line, while the right-hand may not.  */
!       size_int = (XFASTINT (o->width) + 1) >> 1;
        else
!       size_int = XFASTINT (o->height) >> 1;
      }
    else
      {
--- 3337,3345 ----
           the usable space in columns by two.
           We round up, since the left-hand window may include
           a dividing line, while the right-hand may not.  */
!       size_int = (XFASTINT (o->total_cols) + 1) >> 1;
        else
!       size_int = XFASTINT (o->total_lines) >> 1;
      }
    else
      {
***************
*** 3305,3313 ****
      {
        if (size_int < window_min_height)
        error ("Window height %d too small (after splitting)", size_int);
!       if (size_int + window_min_height > XFASTINT (o->height))
        error ("Window height %d too small (after splitting)",
!              XFASTINT (o->height) - size_int);
        if (NILP (o->parent)
          || NILP (XWINDOW (o->parent)->vchild))
        {
--- 3358,3366 ----
      {
        if (size_int < window_min_height)
        error ("Window height %d too small (after splitting)", size_int);
!       if (size_int + window_min_height > XFASTINT (o->total_lines))
        error ("Window height %d too small (after splitting)",
!              XFASTINT (o->total_lines) - size_int);
        if (NILP (o->parent)
          || NILP (XWINDOW (o->parent)->vchild))
        {
***************
*** 3321,3329 ****
        if (size_int < window_min_width)
        error ("Window width %d too small (after splitting)", size_int);
  
!       if (size_int + window_min_width > XFASTINT (o->width))
        error ("Window width %d too small (after splitting)",
!              XFASTINT (o->width) - size_int);
        if (NILP (o->parent)
          || NILP (XWINDOW (o->parent)->hchild))
        {
--- 3374,3382 ----
        if (size_int < window_min_width)
        error ("Window width %d too small (after splitting)", size_int);
  
!       if (size_int + window_min_width > XFASTINT (o->total_cols))
        error ("Window width %d too small (after splitting)",
!              XFASTINT (o->total_cols) - size_int);
        if (NILP (o->parent)
          || NILP (XWINDOW (o->parent)->hchild))
        {
***************
*** 3353,3380 ****
    p->window_end_valid = Qnil;
    bzero (&p->last_cursor, sizeof p->last_cursor);
  
    /* Apportion the available frame space among the two new windows */
  
    if (!NILP (horflag))
      {
!       p->height = o->height;
!       p->top = o->top;
!       XSETFASTINT (p->width, XFASTINT (o->width) - size_int);
!       XSETFASTINT (o->width, size_int);
!       XSETFASTINT (p->left, XFASTINT (o->left) + size_int);
      }
    else
      {
!       p->left = o->left;
!       p->width = o->width;
!       XSETFASTINT (p->height, XFASTINT (o->height) - size_int);
!       XSETFASTINT (o->height, size_int);
!       XSETFASTINT (p->top, XFASTINT (o->top) + size_int);
      }
  
    /* Adjust glyph matrices.  */
    adjust_glyphs (fo);
!   Fset_window_buffer (new, o->buffer);
    return new;
  }
  
--- 3406,3446 ----
    p->window_end_valid = Qnil;
    bzero (&p->last_cursor, sizeof p->last_cursor);
  
+   /* Duplicate special geometry settings.  */
+ 
+   p->left_margin_cols = o->left_margin_cols;
+   p->right_margin_cols = o->right_margin_cols;
+   p->left_fringe_width = o->left_fringe_width;
+   p->right_fringe_width = o->right_fringe_width;
+   p->fringes_outside_margins = o->fringes_outside_margins;
+   p->scroll_bar_width = o->scroll_bar_width;
+   p->vertical_scroll_bar_type = o->vertical_scroll_bar_type;
+ 
    /* Apportion the available frame space among the two new windows */
  
    if (!NILP (horflag))
      {
!       p->total_lines = o->total_lines;
!       p->top_line = o->top_line;
!       XSETFASTINT (p->total_cols, XFASTINT (o->total_cols) - size_int);
!       XSETFASTINT (o->total_cols, size_int);
!       XSETFASTINT (p->left_col, XFASTINT (o->left_col) + size_int);
!       adjust_window_margins (p);
!       adjust_window_margins (o);
      }
    else
      {
!       p->left_col = o->left_col;
!       p->total_cols = o->total_cols;
!       XSETFASTINT (p->total_lines, XFASTINT (o->total_lines) - size_int);
!       XSETFASTINT (o->total_lines, size_int);
!       XSETFASTINT (p->top_line, XFASTINT (o->top_line) + size_int);
      }
  
    /* Adjust glyph matrices.  */
    adjust_glyphs (fo);
! 
!   Fset_window_buffer (new, o->buffer, Qt);
    return new;
  }
  
***************
*** 3425,3431 ****
       Lisp_Object window;
  {
    register struct window *p = XWINDOW (window);
!   return XFASTINT (p->height);
  }
  
  int
--- 3491,3497 ----
       Lisp_Object window;
  {
    register struct window *p = XWINDOW (window);
!   return WINDOW_TOTAL_LINES (p);
  }
  
  int
***************
*** 3433,3447 ****
       Lisp_Object window;
  {
    register struct window *p = XWINDOW (window);
!   return XFASTINT (p->width);
  }
  
  
  #define CURBEG(w) \
!   *(widthflag ? &(XWINDOW (w)->left) : &(XWINDOW (w)->top))
  
  #define CURSIZE(w) \
!   *(widthflag ? &(XWINDOW (w)->width) : &(XWINDOW (w)->height))
  
  
  /* Enlarge WINDOW by DELTA.  WIDTHFLAG non-zero means
--- 3499,3513 ----
       Lisp_Object window;
  {
    register struct window *p = XWINDOW (window);
!   return WINDOW_TOTAL_COLS (p);
  }
  
  
  #define CURBEG(w) \
!   *(widthflag ? &(XWINDOW (w)->left_col) : &(XWINDOW (w)->top_line))
  
  #define CURSIZE(w) \
!   *(widthflag ? &(XWINDOW (w)->total_cols) : &(XWINDOW (w)->total_lines))
  
  
  /* Enlarge WINDOW by DELTA.  WIDTHFLAG non-zero means
***************
*** 3772,3786 ****
    windows_or_buffers_changed++;
    FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w))) = 1;
  
!   old_height = XFASTINT (w->height);
!   XSETFASTINT (w->height, height);
  
    if (!NILP (w->hchild))
      {
        for (child = w->hchild; !NILP (child); child = c->next)
        {
          c = XWINDOW (child);
!         c->top = w->top;
          shrink_window_lowest_first (c, height);
        }
      }
--- 3838,3852 ----
    windows_or_buffers_changed++;
    FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w))) = 1;
  
!   old_height = XFASTINT (w->total_lines);
!   XSETFASTINT (w->total_lines, height);
  
    if (!NILP (w->hchild))
      {
        for (child = w->hchild; !NILP (child); child = c->next)
        {
          c = XWINDOW (child);
!         c->top_line = w->top_line;
          shrink_window_lowest_first (c, height);
        }
      }
***************
*** 3804,3826 ****
          int this_one;
  
          c = XWINDOW (child);
!         this_one = XFASTINT (c->height) - MIN_SAFE_WINDOW_HEIGHT;
  
          if (this_one > delta)
            this_one = delta;
  
!         shrink_window_lowest_first (c, XFASTINT (c->height) - this_one);
          delta -= this_one;
        }
  
        /* Compute new positions.  */
!       last_top = XINT (w->top);
        for (child = w->vchild; !NILP (child); child = c->next)
        {
          c = XWINDOW (child);
!         c->top = make_number (last_top);
!         shrink_window_lowest_first (c, XFASTINT (c->height));
!         last_top += XFASTINT (c->height);
        }
      }
  }
--- 3870,3892 ----
          int this_one;
  
          c = XWINDOW (child);
!         this_one = XFASTINT (c->total_lines) - MIN_SAFE_WINDOW_HEIGHT;
  
          if (this_one > delta)
            this_one = delta;
  
!         shrink_window_lowest_first (c, XFASTINT (c->total_lines) - this_one);
          delta -= this_one;
        }
  
        /* Compute new positions.  */
!       last_top = XINT (w->top_line);
        for (child = w->vchild; !NILP (child); child = c->next)
        {
          c = XWINDOW (child);
!         c->top_line = make_number (last_top);
!         shrink_window_lowest_first (c, XFASTINT (c->total_lines));
!         last_top += XFASTINT (c->total_lines);
        }
      }
  }
***************
*** 3829,3843 ****
  /* Save, restore, or check positions and sizes in the window tree
     rooted at W.  ACTION says what to do.
  
!    If ACTION is CHECK_ORIG_SIZES, check if orig_top and orig_height
!    members are valid for all windows in the window tree.  Value is
!    non-zero if they are valid.
  
     If ACTION is SAVE_ORIG_SIZES, save members top and height in
!    orig_top and orig_height for all windows in the tree.
  
!    If ACTION is RESTORE_ORIG_SIZES, restore top and height from
!    values stored in orig_top and orig_height for all windows.  */
  
  static int
  save_restore_orig_size (w, action)
--- 3895,3909 ----
  /* Save, restore, or check positions and sizes in the window tree
     rooted at W.  ACTION says what to do.
  
!    If ACTION is CHECK_ORIG_SIZES, check if orig_top_line and
!    orig_total_lines members are valid for all windows in the window
!    tree.  Value is non-zero if they are valid.
  
     If ACTION is SAVE_ORIG_SIZES, save members top and height in
!    orig_top_line and orig_total_lines for all windows in the tree.
  
!    If ACTION is RESTORE_ORIG_SIZES, restore top and height from values
!    stored in orig_top_line and orig_total_lines for all windows.  */
  
  static int
  save_restore_orig_size (w, action)
***************
*** 3862,3883 ****
        switch (action)
        {
        case CHECK_ORIG_SIZES:
!         if (!INTEGERP (w->orig_top) || !INTEGERP (w->orig_height))
            return 0;
          break;
  
        case SAVE_ORIG_SIZES:
!         w->orig_top = w->top;
!         w->orig_height = w->height;
            XSETFASTINT (w->last_modified, 0);
            XSETFASTINT (w->last_overlay_modified, 0);
          break;
  
        case RESTORE_ORIG_SIZES:
!         xassert (INTEGERP (w->orig_top) && INTEGERP (w->orig_height));
!         w->top = w->orig_top;
!         w->height = w->orig_height;
!         w->orig_height = w->orig_top = Qnil;
            XSETFASTINT (w->last_modified, 0);
            XSETFASTINT (w->last_overlay_modified, 0);
          break;
--- 3928,3949 ----
        switch (action)
        {
        case CHECK_ORIG_SIZES:
!         if (!INTEGERP (w->orig_top_line) || !INTEGERP (w->orig_total_lines))
            return 0;
          break;
  
        case SAVE_ORIG_SIZES:
!         w->orig_top_line = w->top_line;
!         w->orig_total_lines = w->total_lines;
            XSETFASTINT (w->last_modified, 0);
            XSETFASTINT (w->last_overlay_modified, 0);
          break;
  
        case RESTORE_ORIG_SIZES:
!         xassert (INTEGERP (w->orig_top_line) && INTEGERP 
(w->orig_total_lines));
!         w->top_line = w->orig_top_line;
!         w->total_lines = w->orig_total_lines;
!         w->orig_total_lines = w->orig_top_line = Qnil;
            XSETFASTINT (w->last_modified, 0);
            XSETFASTINT (w->last_overlay_modified, 0);
          break;
***************
*** 3917,3926 ****
    if (delta)
      {
        int min_height = window_min_size (root, 0, 0, 0);
!       if (XFASTINT (root->height) - delta < min_height)
        /* Note that the root window may already be smaller than
           min_height.  */
!       delta = max (0, XFASTINT (root->height) - min_height);
      }
  
    if (delta)
--- 3983,3992 ----
    if (delta)
      {
        int min_height = window_min_size (root, 0, 0, 0);
!       if (XFASTINT (root->total_lines) - delta < min_height)
        /* Note that the root window may already be smaller than
           min_height.  */
!       delta = max (0, XFASTINT (root->total_lines) - min_height);
      }
  
    if (delta)
***************
*** 3930,3940 ****
        save_restore_orig_size (root, SAVE_ORIG_SIZES);
  
        /* Shrink other windows.  */
!       shrink_window_lowest_first (root, XFASTINT (root->height) - delta);
  
        /* Grow the mini-window.  */
!       w->top = make_number (XFASTINT (root->top) + XFASTINT (root->height));
!       w->height = make_number (XFASTINT (w->height) + delta);
        XSETFASTINT (w->last_modified, 0);
        XSETFASTINT (w->last_overlay_modified, 0);
  
--- 3996,4006 ----
        save_restore_orig_size (root, SAVE_ORIG_SIZES);
  
        /* Shrink other windows.  */
!       shrink_window_lowest_first (root, XFASTINT (root->total_lines) - delta);
  
        /* Grow the mini-window.  */
!       w->top_line = make_number (XFASTINT (root->top_line) + XFASTINT 
(root->total_lines));
!       w->total_lines = make_number (XFASTINT (w->total_lines) + delta);
        XSETFASTINT (w->last_modified, 0);
        XSETFASTINT (w->last_overlay_modified, 0);
  
***************
*** 3962,3974 ****
        FRAME_WINDOW_SIZES_CHANGED (f) = 1;
        windows_or_buffers_changed = 1;
      }
!   else if (XFASTINT (w->height) > 1)
      {
        /* Distribute the additional lines of the mini-window
         among the other windows.  */
        Lisp_Object window;
        XSETWINDOW (window, w);
!       enlarge_window (window, 1 - XFASTINT (w->height), 0, 0);
      }
  }
  
--- 4028,4040 ----
        FRAME_WINDOW_SIZES_CHANGED (f) = 1;
        windows_or_buffers_changed = 1;
      }
!   else if (XFASTINT (w->total_lines) > 1)
      {
        /* Distribute the additional lines of the mini-window
         among the other windows.  */
        Lisp_Object window;
        XSETWINDOW (window, w);
!       enlarge_window (window, 1 - XFASTINT (w->total_lines), 0, 0);
      }
  }
  
***************
*** 4003,4009 ****
  window_internal_height (w)
       struct window *w;
  {
!   int ht = XFASTINT (w->height);
  
    if (!MINI_WINDOW_P (w))
      {
--- 4069,4075 ----
  window_internal_height (w)
       struct window *w;
  {
!   int ht = XFASTINT (w->total_lines);
  
    if (!MINI_WINDOW_P (w))
      {
***************
*** 4028,4051 ****
     separating W from the sibling to its right.  */
  
  int
! window_internal_width (w)
       struct window *w;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
!   int width = XINT (w->width);
  
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
      /* Scroll bars occupy a few columns.  */
!     width -= FRAME_SCROLL_BAR_COLS (f);
!   else if (!WINDOW_RIGHTMOST_P (w) && !WINDOW_FULL_WIDTH_P (w))
      /* The column of `|' characters separating side-by-side windows
         occupies one column only.  */
      width -= 1;
  
-   /* On window-systems, areas to the left and right of the window
-      are used as fringes.  */
    if (FRAME_WINDOW_P (f))
!     width -= FRAME_FRINGE_COLS (f);
  
    return width;
  }
--- 4094,4120 ----
     separating W from the sibling to its right.  */
  
  int
! window_box_text_cols (w)
       struct window *w;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
!   int width = XINT (w->total_cols);
  
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
      /* Scroll bars occupy a few columns.  */
!     width -= WINDOW_CONFIG_SCROLL_BAR_COLS (w);
!   else if (!FRAME_WINDOW_P (f)
!          && !WINDOW_RIGHTMOST_P (w) && !WINDOW_FULL_WIDTH_P (w))
      /* The column of `|' characters separating side-by-side windows
         occupies one column only.  */
      width -= 1;
  
    if (FRAME_WINDOW_P (f))
!     /* On window-systems, fringes and display margins cannot be
!        used for normal text.  */
!     width -= (WINDOW_FRINGE_COLS (w)
!             + WINDOW_LEFT_MARGIN_COLS (w)
!             + WINDOW_RIGHT_MARGIN_COLS (w));
  
    return width;
  }
***************
*** 4150,4156 ****
    if (whole)
      {
        int screen_full = (window_box_height (w)
!                        - next_screen_context_lines * CANON_Y_UNIT (it.f));
        int dy = n * screen_full;
  
        /* Note that move_it_vertically always moves the iterator to the
--- 4219,4225 ----
    if (whole)
      {
        int screen_full = (window_box_height (w)
!                        - next_screen_context_lines * FRAME_LINE_HEIGHT 
(it.f));
        int dy = n * screen_full;
  
        /* Note that move_it_vertically always moves the iterator to the
***************
*** 4247,4254 ****
      {
        /* Move PT out of scroll margins.  */
        this_scroll_margin = max (0, scroll_margin);
!       this_scroll_margin = min (this_scroll_margin, XFASTINT (w->height) / 4);
!       this_scroll_margin *= CANON_Y_UNIT (it.f);
  
        if (n > 0)
        {
--- 4316,4323 ----
      {
        /* Move PT out of scroll margins.  */
        this_scroll_margin = max (0, scroll_margin);
!       this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) 
/ 4);
!       this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
  
        if (n > 0)
        {
***************
*** 4325,4331 ****
  
    posit = *compute_motion (startpos, 0, 0, 0,
                           PT, ht, 0,
!                          window_internal_width (w), XINT (w->hscroll),
                           0, w);
    original_vpos = posit.vpos;
  
--- 4394,4400 ----
  
    posit = *compute_motion (startpos, 0, 0, 0,
                           PT, ht, 0,
!                          window_box_text_cols (w), XINT (w->hscroll),
                           0, w);
    original_vpos = posit.vpos;
  
***************
*** 4362,4369 ****
        if (this_scroll_margin < 0)
        this_scroll_margin = 0;
  
!       if (XINT (w->height) < 4 * scroll_margin)
!       this_scroll_margin = XINT (w->height) / 4;
  
        set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
        w->start_at_line_beg = bolp;
--- 4431,4438 ----
        if (this_scroll_margin < 0)
        this_scroll_margin = 0;
  
!       if (XINT (w->total_lines) < 4 * scroll_margin)
!       this_scroll_margin = XINT (w->total_lines) / 4;
  
        set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
        w->start_at_line_beg = bolp;
***************
*** 4613,4619 ****
    struct window *w = XWINDOW (selected_window);
  
    if (NILP (arg))
!     XSETFASTINT (arg, window_internal_width (w) - 2);
    else
      arg = Fprefix_numeric_value (arg);
  
--- 4682,4688 ----
    struct window *w = XWINDOW (selected_window);
  
    if (NILP (arg))
!     XSETFASTINT (arg, window_box_text_cols (w) - 2);
    else
      arg = Fprefix_numeric_value (arg);
  
***************
*** 4643,4649 ****
    struct window *w = XWINDOW (selected_window);
  
    if (NILP (arg))
!     XSETFASTINT (arg, window_internal_width (w) - 2);
    else
      arg = Fprefix_numeric_value (arg);
  
--- 4712,4718 ----
    struct window *w = XWINDOW (selected_window);
  
    if (NILP (arg))
!     XSETFASTINT (arg, window_box_text_cols (w) - 2);
    else
      arg = Fprefix_numeric_value (arg);
  
***************
*** 4717,4723 ****
    /* Add in empty lines at the bottom of the window.  */
    if (bottom_y < height)
      {
!       int uy = CANON_Y_UNIT (it.f);
        it.vpos += (height - bottom_y + uy - 1) / uy;
      }
  
--- 4786,4792 ----
    /* Add in empty lines at the bottom of the window.  */
    if (bottom_y < height)
      {
!       int uy = FRAME_LINE_HEIGHT (it.f);
        it.vpos += (height - bottom_y + uy - 1) / uy;
      }
  
***************
*** 4809,4815 ****
          /* If we can't move down NLINES lines because we hit
             the end of the buffer, count in some empty lines.  */
          if (it.vpos < nlines)
!           y1 += (nlines - it.vpos) * CANON_Y_UNIT (it.f);
  
          h = window_box_height (w) - (y1 - y0);
  
--- 4878,4884 ----
          /* If we can't move down NLINES lines because we hit
             the end of the buffer, count in some empty lines.  */
          if (it.vpos < nlines)
!           y1 += (nlines - it.vpos) * FRAME_LINE_HEIGHT (it.f);
  
          h = window_box_height (w) - (y1 - y0);
  
***************
*** 4867,4873 ****
  {
    struct window *w = decode_window (window);
    int pixel_height = window_box_height (w);
!   int line_height = pixel_height / CANON_Y_UNIT (XFRAME (w->frame));
    return make_number (line_height);
  }
  
--- 4936,4942 ----
  {
    struct window *w = decode_window (window);
    int pixel_height = window_box_height (w);
!   int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame));
    return make_number (line_height);
  }
  
***************
*** 4926,4932 ****
    {
      EMACS_INT size_from_Lisp_Vector_struct;
      struct Lisp_Vector *next_from_Lisp_Vector_struct;
!     Lisp_Object frame_width, frame_height, frame_menu_bar_lines;
      Lisp_Object frame_tool_bar_lines;
      Lisp_Object selected_frame;
      Lisp_Object current_window;
--- 4995,5001 ----
    {
      EMACS_INT size_from_Lisp_Vector_struct;
      struct Lisp_Vector *next_from_Lisp_Vector_struct;
!     Lisp_Object frame_cols, frame_lines, frame_menu_bar_lines;
      Lisp_Object frame_tool_bar_lines;
      Lisp_Object selected_frame;
      Lisp_Object current_window;
***************
*** 4952,4965 ****
  
    Lisp_Object window;
    Lisp_Object buffer, start, pointm, mark;
!   Lisp_Object left, top, width, height, hscroll, min_hscroll;
    Lisp_Object parent, prev;
    Lisp_Object start_at_line_beg;
    Lisp_Object display_table;
!   Lisp_Object orig_top, orig_height;
  };
  
! #define SAVED_WINDOW_VECTOR_SIZE 17 /* Arg to Fmake_vector */
  
  #define SAVED_WINDOW_N(swv,n) \
    ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
--- 5021,5038 ----
  
    Lisp_Object window;
    Lisp_Object buffer, start, pointm, mark;
!   Lisp_Object left_col, top_line, total_cols, total_lines;
!   Lisp_Object hscroll, min_hscroll;
    Lisp_Object parent, prev;
    Lisp_Object start_at_line_beg;
    Lisp_Object display_table;
!   Lisp_Object orig_top_line, orig_total_lines;
!   Lisp_Object left_margin_cols, right_margin_cols;
!   Lisp_Object left_fringe_width, right_fringe_width, fringes_outside_margins;
!   Lisp_Object scroll_bar_width, vertical_scroll_bar_type;
  };
  
! #define SAVED_WINDOW_VECTOR_SIZE 24 /* Arg to Fmake_vector */
  
  #define SAVED_WINDOW_N(swv,n) \
    ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
***************
*** 5043,5050 ****
         made, we change the frame to the size specified in the
         configuration, restore the configuration, and then resize it
         back.  We keep track of the prevailing height in these variables.  */
!       int previous_frame_height = FRAME_HEIGHT (f);
!       int previous_frame_width =  FRAME_WIDTH  (f);
        int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
        int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f);
  
--- 5116,5123 ----
         made, we change the frame to the size specified in the
         configuration, restore the configuration, and then resize it
         back.  We keep track of the prevailing height in these variables.  */
!       int previous_frame_lines = FRAME_LINES (f);
!       int previous_frame_cols =  FRAME_COLS  (f);
        int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
        int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f);
  
***************
*** 5052,5061 ****
         if it runs during this.  */
        BLOCK_INPUT;
  
!       if (XFASTINT (data->frame_height) != previous_frame_height
!         || XFASTINT (data->frame_width) != previous_frame_width)
!       change_frame_size (f, XFASTINT (data->frame_height),
!                          XFASTINT (data->frame_width), 0, 0, 0);
  #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
        if (XFASTINT (data->frame_menu_bar_lines)
          != previous_frame_menu_bar_lines)
--- 5125,5134 ----
         if it runs during this.  */
        BLOCK_INPUT;
  
!       if (XFASTINT (data->frame_lines) != previous_frame_lines
!         || XFASTINT (data->frame_cols) != previous_frame_cols)
!       change_frame_size (f, XFASTINT (data->frame_lines),
!                          XFASTINT (data->frame_cols), 0, 0, 0);
  #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
        if (XFASTINT (data->frame_menu_bar_lines)
          != previous_frame_menu_bar_lines)
***************
*** 5130,5136 ****
              w->prev = Qnil;
              if (!NILP (w->parent))
                {
!                 if (EQ (p->width, XWINDOW (w->parent)->width))
                    {
                      XWINDOW (w->parent)->vchild = p->window;
                      XWINDOW (w->parent)->hchild = Qnil;
--- 5203,5209 ----
              w->prev = Qnil;
              if (!NILP (w->parent))
                {
!                 if (EQ (p->total_cols, XWINDOW (w->parent)->total_cols))
                    {
                      XWINDOW (w->parent)->vchild = p->window;
                      XWINDOW (w->parent)->hchild = Qnil;
***************
*** 5145,5161 ****
  
          /* If we squirreled away the buffer in the window's height,
             restore it now.  */
!         if (BUFFERP (w->height))
!           w->buffer = w->height;
!         w->left = p->left;
!         w->top = p->top;
!         w->width = p->width;
!         w->height = p->height;
          w->hscroll = p->hscroll;
          w->min_hscroll = p->min_hscroll;
          w->display_table = p->display_table;
!         w->orig_top = p->orig_top;
!         w->orig_height = p->orig_height;
          XSETFASTINT (w->last_modified, 0);
          XSETFASTINT (w->last_overlay_modified, 0);
  
--- 5218,5241 ----
  
          /* If we squirreled away the buffer in the window's height,
             restore it now.  */
!         if (BUFFERP (w->total_lines))
!           w->buffer = w->total_lines;
!         w->left_col = p->left_col;
!         w->top_line = p->top_line;
!         w->total_cols = p->total_cols;
!         w->total_lines = p->total_lines;
          w->hscroll = p->hscroll;
          w->min_hscroll = p->min_hscroll;
          w->display_table = p->display_table;
!         w->orig_top_line = p->orig_top_line;
!         w->orig_total_lines = p->orig_total_lines;
!         w->left_margin_cols = p->left_margin_cols;
!         w->right_margin_cols = p->right_margin_cols;
!         w->left_fringe_width = p->left_fringe_width;
!         w->right_fringe_width = p->right_fringe_width;
!         w->fringes_outside_margins = p->fringes_outside_margins;
!         w->scroll_bar_width = p->scroll_bar_width;
!         w->vertical_scroll_bar_type = p->vertical_scroll_bar_type;
          XSETFASTINT (w->last_modified, 0);
          XSETFASTINT (w->last_overlay_modified, 0);
  
***************
*** 5237,5245 ****
  #endif
  
        /* Set the screen height to the value it had before this function.  */
!       if (previous_frame_height != FRAME_HEIGHT (f)
!         || previous_frame_width != FRAME_WIDTH (f))
!       change_frame_size (f, previous_frame_height, previous_frame_width,
                           0, 0, 0);
  #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
        if (previous_frame_menu_bar_lines != FRAME_MENU_BAR_LINES (f))
--- 5317,5325 ----
  #endif
  
        /* Set the screen height to the value it had before this function.  */
!       if (previous_frame_lines != FRAME_LINES (f)
!         || previous_frame_cols != FRAME_COLS (f))
!       change_frame_size (f, previous_frame_lines, previous_frame_cols,
                           0, 0, 0);
  #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
        if (previous_frame_menu_bar_lines != FRAME_MENU_BAR_LINES (f))
***************
*** 5310,5316 ****
    if (!NILP (w->hchild))
      delete_all_subwindows (XWINDOW (w->hchild));
  
!   w->height = w->buffer;       /* See Fset_window_configuration for excuse.  
*/
  
    if (!NILP (w->buffer))
      unshow_buffer (w);
--- 5390,5396 ----
    if (!NILP (w->hchild))
      delete_all_subwindows (XWINDOW (w->hchild));
  
!   w->total_lines = w->buffer;       /* See Fset_window_configuration for 
excuse.  */
  
    if (!NILP (w->buffer))
      unshow_buffer (w);
***************
*** 5408,5422 ****
        XSETFASTINT (w->temslot, i++);
        p->window = window;
        p->buffer = w->buffer;
!       p->left = w->left;
!       p->top = w->top;
!       p->width = w->width;
!       p->height = w->height;
        p->hscroll = w->hscroll;
        p->min_hscroll = w->min_hscroll;
        p->display_table = w->display_table;
!       p->orig_top = w->orig_top;
!       p->orig_height = w->orig_height;
        if (!NILP (w->buffer))
        {
          /* Save w's value of point in the window configuration.
--- 5488,5509 ----
        XSETFASTINT (w->temslot, i++);
        p->window = window;
        p->buffer = w->buffer;
!       p->left_col = w->left_col;
!       p->top_line = w->top_line;
!       p->total_cols = w->total_cols;
!       p->total_lines = w->total_lines;
        p->hscroll = w->hscroll;
        p->min_hscroll = w->min_hscroll;
        p->display_table = w->display_table;
!       p->orig_top_line = w->orig_top_line;
!       p->orig_total_lines = w->orig_total_lines;
!       p->left_margin_cols = w->left_margin_cols;
!       p->right_margin_cols = w->right_margin_cols;
!       p->left_fringe_width = w->left_fringe_width;
!       p->right_fringe_width = w->right_fringe_width;
!       p->fringes_outside_margins = w->fringes_outside_margins;
!       p->scroll_bar_width = w->scroll_bar_width;
!       p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
        if (!NILP (w->buffer))
        {
          /* Save w's value of point in the window configuration.
***************
*** 5494,5501 ****
    vec = allocate_other_vector (VECSIZE (struct save_window_data));
    data = (struct save_window_data *)vec;
  
!   XSETFASTINT (data->frame_width, FRAME_WIDTH (f));
!   XSETFASTINT (data->frame_height, FRAME_HEIGHT (f));
    XSETFASTINT (data->frame_menu_bar_lines, FRAME_MENU_BAR_LINES (f));
    XSETFASTINT (data->frame_tool_bar_lines, FRAME_TOOL_BAR_LINES (f));
    data->selected_frame = selected_frame;
--- 5581,5588 ----
    vec = allocate_other_vector (VECSIZE (struct save_window_data));
    data = (struct save_window_data *)vec;
  
!   XSETFASTINT (data->frame_cols, FRAME_COLS (f));
!   XSETFASTINT (data->frame_lines, FRAME_LINES (f));
    XSETFASTINT (data->frame_menu_bar_lines, FRAME_MENU_BAR_LINES (f));
    XSETFASTINT (data->frame_tool_bar_lines, FRAME_TOOL_BAR_LINES (f));
    data->selected_frame = selected_frame;
***************
*** 5556,5561 ****
--- 5643,5652 ----
  {
    struct window *w = decode_window (window);
  
+   /* TODO: It doesn't make sense to use FLOATs here, since
+      the rest of the code assumes they are integers.
+      So don't allow floats!  ++KFS */
+ 
    if (!NILP (left))
      CHECK_NUMBER_OR_FLOAT (left);
    if (!NILP (right))
***************
*** 5575,5585 ****
    if (INTEGERP (right) && XFASTINT (right) == 0)
      right = Qnil;
  
!   w->left_margin_width = left;
!   w->right_margin_width = right;
  
-   ++windows_or_buffers_changed;
-   adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
    return Qnil;
  }
  
--- 5666,5683 ----
    if (INTEGERP (right) && XFASTINT (right) == 0)
      right = Qnil;
  
!   if (!EQ (w->left_margin_cols, left)
!       || !EQ (w->right_margin_cols, right))
!     {
!       w->left_margin_cols = left;
!       w->right_margin_cols = right;
! 
!       adjust_window_margins (w);
! 
!       ++windows_or_buffers_changed;
!       adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
!     }
  
    return Qnil;
  }
  
***************
*** 5595,5601 ****
       Lisp_Object window;
  {
    struct window *w = decode_window (window);
!   return Fcons (w->left_margin_width, w->right_margin_width);
  }
  
  
--- 5693,5826 ----
       Lisp_Object window;
  {
    struct window *w = decode_window (window);
!   return Fcons (w->left_margin_cols, w->right_margin_cols);
! }
! 
! 
! 
! /***********************************************************************
!                           Fringes
!  ***********************************************************************/
! 
! DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes,
!        2, 4, 0,
!        doc: /* Set width of fringes of window WINDOW.
! 
! If window is nil, set fringes of the currently selected window.
! Second parameter LEFT-WIDTH specifies the number of pixels to reserve
! for the left fringe.  Third parameter RIGHT-WIDTH does the same for
! the right fringe.  Fourth parameter OUTSIDE-MARGINS non-nil specifies 
! that fringes are drawn outside of the display margins; by default, fringes
! are drawn between display marginal areas and the text area.
! A nil width parameter means to use the frame's corresponding fringe width.  
*/)
!      (window, left, right, outside_margins)
!      Lisp_Object window, left, right, outside_margins;
! {
!   struct window *w = decode_window (window);
! 
!   if (!NILP (left))
!     CHECK_NUMBER (left);
!   if (!NILP (right))
!     CHECK_NUMBER (right);
! 
!   if (!EQ (w->left_fringe_width, left)
!       || !EQ (w->right_fringe_width, right)
!       || !EQ (w->fringes_outside_margins, outside_margins))
!     {
!       w->left_fringe_width = left;
!       w->right_fringe_width = right;
!       w->fringes_outside_margins = outside_margins;
! 
!       adjust_window_margins (w);
! 
!       clear_glyph_matrix (w->current_matrix);
!       w->window_end_valid = Qnil;
! 
!       ++windows_or_buffers_changed;
!       adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
!     }
! 
!   return Qnil;
! }
! 
! 
! DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes,
!        0, 1, 0,
!        doc: /* Get width of fringes of window WINDOW.
! If WINDOW is omitted or nil, use the currently selected window.
! Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS).
! If a window specific fringe width is not set, its width will be returned
! as nil.  */)
!      (window)
!      Lisp_Object window;
! {
!   struct window *w = decode_window (window);
!   return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)),
!               Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)),
!                      Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) ?
!                              Qt : Qnil), Qnil)));
! }
! 
! 
! 
! /***********************************************************************
!                           Scroll bars
!  ***********************************************************************/
! 
! DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, 
Sset_window_scroll_bars,
!        2, 4, 0,
!        doc: /* Set width and type of scroll bars of window WINDOW.
! If window is nil, set scroll bars of the currently selected window.
! Second parameter WIDTH specifies the pixel width for the scroll bar;
! this is automatically adjusted to a multiple of the frame column width.
! Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
! bar: left, right, or nil.
! A width of nil and type of t means to use the frame's corresponding value.  
*/)
!      (window, width, vertical_type, horisontal_type)
!      Lisp_Object window, width, vertical_type, horisontal_type;
! {
!   struct window *w = decode_window (window);
! 
!   if (!NILP (width))
!     CHECK_NUMBER (width);
! 
!   if (XINT (width) == 0)
!     vertical_type = Qnil;
! 
!   if (!EQ (w->scroll_bar_width, width)
!       || !EQ (w->vertical_scroll_bar_type, vertical_type))
!     {
!       w->scroll_bar_width = width;
!       w->vertical_scroll_bar_type = vertical_type;
! 
!       adjust_window_margins (w);
! 
!       clear_glyph_matrix (w->current_matrix);
!       w->window_end_valid = Qnil;
! 
!       ++windows_or_buffers_changed;
!       adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
!     }
! 
!   return Qnil;
! }
! 
! 
! DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars,
!        0, 1, 0,
!        doc: /* Get width and type of scroll bars of window WINDOW.
! If WINDOW is omitted or nil, use the currently selected window.
! Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORISONTAL-TYPE).  */)
!      (window)
!      Lisp_Object window;
! {
!   struct window *w = decode_window (window);
!   return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
!                             ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
!                             : WINDOW_SCROLL_BAR_AREA_WIDTH (w))),
!               Fcons (make_number (WINDOW_SCROLL_BAR_COLS (w)),
!                      Fcons (w->vertical_scroll_bar_type,
!                             Fcons (Qnil, Qnil))));
  }
  
  
***************
*** 5623,5629 ****
    f = XFRAME (w->frame);
  
    if (FRAME_WINDOW_P (f))
!     result = CANON_Y_FROM_PIXEL_Y (f, -w->vscroll);
    else
      result = make_number (0);
    return result;
--- 5848,5854 ----
    f = XFRAME (w->frame);
  
    if (FRAME_WINDOW_P (f))
!     result = FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll);
    else
      result = make_number (0);
    return result;
***************
*** 5654,5660 ****
      {
        int old_dy = w->vscroll;
  
!       w->vscroll = - CANON_Y_UNIT (f) * XFLOATINT (vscroll);
        w->vscroll = min (w->vscroll, 0);
  
        /* Adjust glyph matrix of the frame if the virtual display
--- 5879,5885 ----
      {
        int old_dy = w->vscroll;
  
!       w->vscroll = - FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll);
        w->vscroll = min (w->vscroll, 0);
  
        /* Adjust glyph matrix of the frame if the virtual display
***************
*** 5773,5781 ****
    sw1 = XVECTOR (d1->saved_windows);
    sw2 = XVECTOR (d2->saved_windows);
  
!   if (! EQ (d1->frame_width, d2->frame_width))
      return 0;
!   if (! EQ (d1->frame_height, d2->frame_height))
      return 0;
    if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines))
      return 0;
--- 5998,6006 ----
    sw1 = XVECTOR (d1->saved_windows);
    sw2 = XVECTOR (d2->saved_windows);
  
!   if (! EQ (d1->frame_cols, d2->frame_cols))
      return 0;
!   if (! EQ (d1->frame_lines, d2->frame_lines))
      return 0;
    if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines))
      return 0;
***************
*** 5827,5839 ****
        /* Verify that the corresponding windows do match.  */
        if (! EQ (p1->buffer, p2->buffer))
        return 0;
!       if (! EQ (p1->left, p2->left))
        return 0;
!       if (! EQ (p1->top, p2->top))
        return 0;
!       if (! EQ (p1->width, p2->width))
        return 0;
!       if (! EQ (p1->height, p2->height))
        return 0;
        if (! EQ (p1->display_table, p2->display_table))
        return 0;
--- 6052,6064 ----
        /* Verify that the corresponding windows do match.  */
        if (! EQ (p1->buffer, p2->buffer))
        return 0;
!       if (! EQ (p1->left_col, p2->left_col))
        return 0;
!       if (! EQ (p1->top_line, p2->top_line))
        return 0;
!       if (! EQ (p1->total_cols, p2->total_cols))
        return 0;
!       if (! EQ (p1->total_lines, p2->total_lines))
        return 0;
        if (! EQ (p1->display_table, p2->display_table))
        return 0;
***************
*** 5856,5861 ****
--- 6081,6100 ----
          if (NILP (Fequal (p1->mark, p2->mark)))
            return 0;
        }
+       if (! EQ (p1->left_margin_cols, p2->left_margin_cols))
+       return 0;
+       if (! EQ (p1->right_margin_cols, p2->right_margin_cols))
+       return 0;
+       if (! EQ (p1->left_fringe_width, p2->left_fringe_width))
+       return 0;
+       if (! EQ (p1->right_fringe_width, p2->right_fringe_width))
+       return 0;
+       if (! EQ (p1->fringes_outside_margins, p2->fringes_outside_margins))
+       return 0;
+       if (! EQ (p1->scroll_bar_width, p2->scroll_bar_width))
+       return 0;
+       if (! EQ (p1->vertical_scroll_bar_type, p2->vertical_scroll_bar_type))
+       return 0;
      }
  
    return 1;
***************
*** 6154,6159 ****
--- 6393,6402 ----
    defsubr (&Ssave_window_excursion);
    defsubr (&Sset_window_margins);
    defsubr (&Swindow_margins);
+   defsubr (&Sset_window_fringes);
+   defsubr (&Swindow_fringes);
+   defsubr (&Sset_window_scroll_bars);
+   defsubr (&Swindow_scroll_bars);
    defsubr (&Swindow_vscroll);
    defsubr (&Sset_window_vscroll);
    defsubr (&Scompare_window_configurations);
Index: window.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/window.h,v
retrieving revision 1.54
diff -c -r1.54 window.h
*** window.h    14 May 2003 18:50:47 -0000      1.54
--- window.h    14 May 2003 21:52:34 -0000
***************
*** 24,29 ****
--- 24,31 ----
  
  #include "dispextern.h"
  
+ extern Lisp_Object Qleft, Qright;
+ 
  /* Windows are allocated as if they were vectors, but then the
  Lisp data type is changed to Lisp_Window.  They are garbage
  collected along with the vectors.
***************
*** 108,118 ****
      Lisp_Object parent;
      /* The upper left corner coordinates of this window,
         as integers relative to upper left corner of frame = 0, 0 */
!     Lisp_Object left;
!     Lisp_Object top;
      /* The size of the window */
!     Lisp_Object height;
!     Lisp_Object width;
      /* The buffer displayed in this window */
      /* Of the fields vchild, hchild and buffer, only one is non-nil.  */
      Lisp_Object buffer;
--- 110,120 ----
      Lisp_Object parent;
      /* The upper left corner coordinates of this window,
         as integers relative to upper left corner of frame = 0, 0 */
!     Lisp_Object left_col;
!     Lisp_Object top_line;
      /* The size of the window */
!     Lisp_Object total_lines;
!     Lisp_Object total_cols;
      /* The buffer displayed in this window */
      /* Of the fields vchild, hchild and buffer, only one is non-nil.  */
      Lisp_Object buffer;
***************
*** 160,167 ****
  
      /* Width of left and right marginal areas.  A value of nil means
         no margin.  */
!     Lisp_Object left_margin_width;
!     Lisp_Object right_margin_width;
  
  /* The rest are currently not used or only half used */
      /* Frame coords of mark as of last time display completed */
--- 162,183 ----
  
      /* Width of left and right marginal areas.  A value of nil means
         no margin.  */
!     Lisp_Object left_margin_cols, right_margin_cols;
! 
!     /* Width of left and right fringes.
!        A value of nil or t means use frame values.  */
!     Lisp_Object left_fringe_width, right_fringe_width;
! 
!   /* Non-nil means fringes are drawn outside display margins;
!      othersize draw them between margin areas and text.  */
!     Lisp_Object fringes_outside_margins;
! 
!     /* Pixel width of scroll bars.
!        A value of nil or t means use frame values.  */
!     Lisp_Object scroll_bar_width;
!     /* Type of vertical scroll bar.  A value of nil means
!        no scroll bar.  A value of t means use frame value.  */
!     Lisp_Object vertical_scroll_bar_type;
  
  /* The rest are currently not used or only half used */
      /* Frame coords of mark as of last time display completed */
***************
*** 211,217 ****
  
      /* Original window height and top before mini-window was
         enlarged. */
!     Lisp_Object orig_height, orig_top;
  
      /* No Lisp data may follow below this point without changing
         mark_object in alloc.c.  The member current_matrix must be the
--- 227,233 ----
  
      /* Original window height and top before mini-window was
         enlarged. */
!     Lisp_Object orig_total_lines, orig_top_line;
  
      /* No Lisp data may follow below this point without changing
         mark_object in alloc.c.  The member current_matrix must be the
***************
*** 281,320 ****
  
  #define MINI_WINDOW_P(W)      (!NILP ((W)->mini_p))
  
! /* Return the window column at which the text in window W starts.
!    This is different from the `left' field because it does not include
!    a left-hand scroll bar if any.  */
! 
! #define WINDOW_LEFT_MARGIN(W) \
!      (XFASTINT ((W)->left) \
!       + FRAME_LEFT_SCROLL_BAR_WIDTH (XFRAME (WINDOW_FRAME (W))))
  
! /* Return the window column before which window W ends.
     This includes a right-hand scroll bar, if any.  */
  
! #define WINDOW_RIGHT_EDGE(W) \
!      (XFASTINT ((W)->left) + XFASTINT ((W)->width))
  
- /* Return the window column before which the text in window W ends.
-    This is different from WINDOW_RIGHT_EDGE because it does not include
-    a scroll bar or window-separating line on the right edge.  */
  
! #define WINDOW_RIGHT_MARGIN(W) \
!      (WINDOW_RIGHT_EDGE (W) \
!       - (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (XFRAME (WINDOW_FRAME (W))) \
!          ? FRAME_SCROLL_BAR_COLS (XFRAME (WINDOW_FRAME (W))) \
!          : 0))
  
  /* 1 if window W takes up the full width of its frame.  */
  
  #define WINDOW_FULL_WIDTH_P(W) \
!      (XFASTINT ((W)->width) == FRAME_WINDOW_WIDTH (XFRAME (WINDOW_FRAME (W))))
  
  /* 1 if window W's has no other windows to its right in its frame.  */
  
  #define WINDOW_RIGHTMOST_P(W) \
!      (WINDOW_RIGHT_EDGE (W) == FRAME_WINDOW_WIDTH (XFRAME (WINDOW_FRAME (W))))
  
  
  /* This is the window in which the terminal's cursor should
     be left when nothing is being done with it.  This must
--- 297,696 ----
  
  #define MINI_WINDOW_P(W)      (!NILP ((W)->mini_p))
  
! /* General window layout:
! 
!    LEFT_EDGE_COL         RIGHT_EDGE_COL
!    |                                  |
!    |                                  |
!    |  BOX_LEFT_EDGE_COL               |
!    |  |           BOX_RIGHT_EDGE_COL  |
!    |  |                            |  |
!    v  v                            v  v
!    <-><-><---><-----------><---><-><->
!     ^  ^   ^        ^        ^   ^  ^
!     |  |   |        |        |   |  |
!     |  |   |        |        |   |  +-- RIGHT_SCROLL_BAR_COLS
!     |  |   |        |        |   +----- RIGHT_FRINGE_WIDTH
!     |  |   |        |        +--------- RIGHT_MARGIN_COLS
!     |  |   |        |
!     |  |   |        +------------------ TEXT_AREA_COLS
!     |  |   |
!     |  |   +--------------------------- LEFT_MARGIN_COLS
!     |  +------------------------------- LEFT_FRINGE_WIDTH
!     +---------------------------------- LEFT_SCROLL_BAR_COLS
!     
! */
! 
! 
! /* A handy macro.  */
! 
! #define WINDOW_XFRAME(W) \
!   (XFRAME (WINDOW_FRAME ((W))))
! 
! /* Return the canonical column width of the frame of window W.  */
! 
! #define WINDOW_FRAME_COLUMN_WIDTH(W) \
!   (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
! 
! /* Return the canonical column width of the frame of window W.  */
! 
! #define WINDOW_FRAME_LINE_HEIGHT(W) \
!   (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
! 
! 
! /* Return the frame width in canonical column units.
!    This includes scroll bars and fringes.  */
! 
! #define WINDOW_TOTAL_COLS(W) \
!   (XFASTINT ((W)->total_cols))
! 
! /* Return the frame height in canonical line units.
!    This includes header and mode lines, if any.  */
  
! #define WINDOW_TOTAL_LINES(W) \
!   (XFASTINT ((W)->total_lines))
! 
! 
! /* Return the total pixel width of window W.  */
! 
! #define WINDOW_TOTAL_WIDTH(W) \
!   (WINDOW_TOTAL_COLS (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
! 
! /* Return the total pixel height of window W.  */
! 
! #define WINDOW_TOTAL_HEIGHT(W) \
!   (WINDOW_TOTAL_LINES (W) * WINDOW_FRAME_LINE_HEIGHT (W))
! 
! 
! /* Return the canonical frame column at which window W starts.
!    This includes a left-hand scroll bar, if any.  */
! 
! #define WINDOW_LEFT_EDGE_COL(W) \
!   (XFASTINT ((W)->left_col))
! 
! /* Return the canonical frame column before which window W ends.
     This includes a right-hand scroll bar, if any.  */
  
! #define WINDOW_RIGHT_EDGE_COL(W) \
!   (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
! 
! /* Return the canonical frame line at which window W starts.
!    This includes a header line, if any.  */
! 
! #define WINDOW_TOP_EDGE_LINE(W) \
!   (XFASTINT ((W)->top_line))
! 
! /* Return the canonical frame line before which window W ends.
!    This includes a mode line, if any.  */
! 
! #define WINDOW_BOTTOM_EDGE_LINE(W) \
!   (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
  
  
! /* Return the frame x-position at which window W starts.
!    This includes a left-hand scroll bar, if any.  */
! 
! #define WINDOW_LEFT_EDGE_X(W) \
!   (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
!    + WINDOW_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
! 
! /* Return the frame x- position before which window W ends.
!    This includes a right-hand scroll bar, if any.  */
! 
! #define WINDOW_RIGHT_EDGE_X(W) \
!   (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
!    + WINDOW_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
! 
! /* Return the frame y-position at which window W starts.
!    This includes a header line, if any.  */
! 
! #define WINDOW_TOP_EDGE_Y(W) \
!   (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
!    + WINDOW_TOP_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
! 
! /* Return the frame y-position before which window W ends.
!    This includes a mode line, if any.  */
! 
! #define WINDOW_BOTTOM_EDGE_Y(W) \
!   (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
!    + WINDOW_BOTTOM_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
! 
  
  /* 1 if window W takes up the full width of its frame.  */
  
  #define WINDOW_FULL_WIDTH_P(W) \
!   (WINDOW_TOTAL_COLS (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
! 
! /* 1 if window W's has no other windows to its left in its frame.  */
! 
! #define WINDOW_LEFTMOST_P(W) \
!   (WINDOW_LEFT_EDGE_COL (W) == 0)
  
  /* 1 if window W's has no other windows to its right in its frame.  */
  
  #define WINDOW_RIGHTMOST_P(W) \
!   (WINDOW_RIGHT_EDGE_COL (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
! 
! 
! /* Return the frame column at which the text (or left fringe) in
!    window W starts.  This is different from the `LEFT_EDGE' because it
!    does not include a left-hand scroll bar if any.  */
! 
! #define WINDOW_BOX_LEFT_EDGE_COL(W) \
!   (WINDOW_LEFT_EDGE_COL (W) \
!    + WINDOW_LEFT_SCROLL_BAR_COLS (W))
! 
! /* Return the window column before which the text in window W ends.
!    This is different from WINDOW_RIGHT_EDGE_COL because it does not
!    include a scroll bar or window-separating line on the right edge.  */
! 
! #define WINDOW_BOX_RIGHT_EDGE_COL(W) \
!   (WINDOW_RIGHT_EDGE_COL (W) \
!    - WINDOW_RIGHT_SCROLL_BAR_COLS (W))
! 
! 
! /* Return the frame position at which the text (or left fringe) in
!    window W starts.  This is different from the `LEFT_EDGE' because it
!    does not include a left-hand scroll bar if any.  */
! 
! #define WINDOW_BOX_LEFT_EDGE_X(W) \
!   (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
!    + WINDOW_BOX_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
! 
! /* Return the window column before which the text in window W ends.
!    This is different from WINDOW_RIGHT_EDGE_COL because it does not
!    include a scroll bar or window-separating line on the right edge.  */
! 
! #define WINDOW_BOX_RIGHT_EDGE_X(W) \
!   (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
!    + WINDOW_BOX_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
! 
! 
! /* Width of left margin area in columns.  */
! 
! #define WINDOW_LEFT_MARGIN_COLS(W)                    \
!   (NILP ((W)->left_margin_cols)                               \
!    ? 0                                                        \
!    : XINT ((W)->left_margin_cols))
! 
! /* Width of right marginal area in columns.  */
! 
! #define WINDOW_RIGHT_MARGIN_COLS(W)                   \
!   (NILP ((W)->right_margin_cols)                      \
!    ? 0                                                        \
!    : XINT ((W)->right_margin_cols))
! 
! /* Width of left margin area in pixels.  */
! 
! #define WINDOW_LEFT_MARGIN_WIDTH(W)                   \
!   (NILP ((W)->left_margin_cols)                               \
!    ? 0                                                        \
!    : (XINT ((W)->left_margin_cols)                    \
!       * WINDOW_FRAME_COLUMN_WIDTH (W)))
! 
! /* Width of right marginal area in pixels.  */
! 
! #define WINDOW_RIGHT_MARGIN_WIDTH(W)                  \
!   (NILP ((W)->right_margin_cols)                      \
!    ? 0                                                        \
!    : (XINT ((W)->right_margin_cols)                   \
!       * WINDOW_FRAME_COLUMN_WIDTH (W)))
! 
! /* Total width of fringes reserved for drawing truncation bitmaps,
!    continuation bitmaps and alike.  The width is in canonical char
!    units of the frame.  This must currently be the case because window
!    sizes aren't pixel values.  If it weren't the case, we wouldn't be
!    able to split windows horizontally nicely.  */
! 
! #define WINDOW_FRINGE_COLS(W)                         \
!   ((INTEGERP ((W)->left_fringe_width)                 \
!     || INTEGERP ((W)->right_fringe_width))            \
!    ? ((WINDOW_LEFT_FRINGE_WIDTH (W)                   \
!        + WINDOW_RIGHT_FRINGE_WIDTH (W)                        \
!        + WINDOW_FRAME_COLUMN_WIDTH (W) - 1)           \
!       / WINDOW_FRAME_COLUMN_WIDTH (W))                        \
!    : FRAME_FRINGE_COLS (WINDOW_XFRAME (W)))
! 
! /* Pixel-width of the left and right fringe.  */
! 
! #define WINDOW_LEFT_FRINGE_WIDTH(W)                   \
!   (INTEGERP ((W)->left_fringe_width)                  \
!    ? XFASTINT ((W)->left_fringe_width)                        \
!    : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
! 
! #define WINDOW_RIGHT_FRINGE_WIDTH(W)                  \
!   (INTEGERP ((W)->right_fringe_width)                 \
!    ? XFASTINT ((W)->right_fringe_width)                       \
!    : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
! 
! /* Total width of fringes in pixels.  */
! 
! #define WINDOW_TOTAL_FRINGE_WIDTH(W)          \
!   (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
! 
! /* Are fringes outside display margins in window W.  */
! 
! #define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
!   (!NILP ((W)->fringes_outside_margins))
! 
! /* Say whether scroll bars are currently enabled for window W,
!    and which side they are on.  */
! 
! #define WINDOW_VERTICAL_SCROLL_BAR_TYPE(w)            \
!   (EQ ((w)->vertical_scroll_bar_type, Qt)             \
!    ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (w))       \
!    : EQ ((w)->vertical_scroll_bar_type, Qleft)                \
!    ? vertical_scroll_bar_left                         \
!    : EQ ((w)->vertical_scroll_bar_type, Qright)               \
!    ? vertical_scroll_bar_right                                \
!    : vertical_scroll_bar_none)                                \
! 
! #define WINDOW_HAS_VERTICAL_SCROLL_BAR(w)             \
!   (EQ ((w)->vertical_scroll_bar_type, Qt)             \
!    ? FRAME_HAS_VERTICAL_SCROLL_BARS (WINDOW_XFRAME (w))       \
!    : !NILP ((w)->vertical_scroll_bar_type))
! 
! #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(w)             \
!   (EQ ((w)->vertical_scroll_bar_type, Qt)                     \
!    ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (WINDOW_XFRAME (w))       \
!    : EQ ((w)->vertical_scroll_bar_type, Qleft))
! 
! #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT(w)            \
!   (EQ ((w)->vertical_scroll_bar_type, Qt)                     \
!    ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (WINDOW_XFRAME (w))\
!    : EQ ((w)->vertical_scroll_bar_type, Qright))
! 
! /* Width that a scroll bar in window W should have, if there is one.
!    Measured in pixels.  If scroll bars are turned off, this is still
!    nonzero.  */
! 
! #define WINDOW_CONFIG_SCROLL_BAR_WIDTH(w)             \
!   (INTEGERP ((w)->scroll_bar_width)                   \
!    ? XFASTINT ((w)->scroll_bar_width)                 \
!    : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (w)))
! 
! /* Width that a scroll bar in window W should have, if there is one.
!    Measured in columns (characters).  If scroll bars are turned off,
!    this is still nonzero.  */
! 
! #define WINDOW_CONFIG_SCROLL_BAR_COLS(w)              \
!   (INTEGERP ((w)->scroll_bar_width)                   \
!    ? ((XFASTINT ((w)->scroll_bar_width)                       \
!        + WINDOW_FRAME_COLUMN_WIDTH (w) - 1)           \
!       / WINDOW_FRAME_COLUMN_WIDTH (w))                        \
!    : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (w)))
! 
! /* Width of a scroll bar in window W, measured in columns (characters),
!    but only if scroll bars are on the left.  If scroll bars are on
!    the right in this frame, or there are no scroll bars, value is 0.  */
! 
! #define WINDOW_LEFT_SCROLL_BAR_COLS(w)               \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
!    ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w))       \
!    : 0)
! 
! /* Width of a left scroll bar area in window W , measured in pixels.  */
! 
! #define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(w) \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
!    ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
!    : 0)
! 
! /* Width of a scroll bar in window W, measured in columns (characters),
!    but only if scroll bars are on the right.  If scroll bars are on
!    the left in this frame, or there are no scroll bars, value is 0.  */
! 
! #define WINDOW_RIGHT_SCROLL_BAR_COLS(w)               \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
!    ? WINDOW_CONFIG_SCROLL_BAR_COLS (w)                \
!    : 0)
! 
! /* Width of a left scroll bar area in window W , measured in pixels.  */
! 
! #define WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(w)                          \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)                                
 \
!    ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
!    : 0)
! 
! 
! /* Actual width of a scroll bar in window W, measured in columns.  */
! 
! #define WINDOW_SCROLL_BAR_COLS(w)            \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)        \
!    ? WINDOW_CONFIG_SCROLL_BAR_COLS (w)               \
!    : 0)
! 
! /* Width of a left scroll bar area in window W , measured in pixels.  */
! 
! #define WINDOW_SCROLL_BAR_AREA_WIDTH(w)                                       
 \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)                                 \
!    ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
!    : 0)
! 
! 
! /* Return the frame position where the scroll bar of window W starts.  */
! 
! #define WINDOW_SCROLL_BAR_AREA_X(W)           \
!   (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W)        \
!    ? WINDOW_BOX_RIGHT_EDGE_X (W)              \
!    : WINDOW_LEFT_EDGE_X (W))
! 
! 
! /* Height in pixels of the mode line.  May be zero if W doesn't have a
!    mode line.  */
! 
! #define WINDOW_MODE_LINE_HEIGHT(W)    \
!   (WINDOW_WANTS_MODELINE_P ((W))      \
!    ? CURRENT_MODE_LINE_HEIGHT (W)     \
!    : 0)
! 
! /* Height in pixels of the header line.  Zero if W doesn't have a header
!    line.  */
! 
! #define WINDOW_HEADER_LINE_HEIGHT(W)  \
!   (WINDOW_WANTS_HEADER_LINE_P ((W))   \
!    ? CURRENT_HEADER_LINE_HEIGHT (W)   \
!    : 0)
! 
! /* Pixel height of window W without mode line.  */
! 
! #define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W)     \
!   (WINDOW_TOTAL_HEIGHT ((W))                  \
!    - WINDOW_MODE_LINE_HEIGHT ((W)))
! 
! /* Pixel height of window W without mode and header line.  */
! 
! #define WINDOW_BOX_TEXT_HEIGHT(W)             \
!   (WINDOW_TOTAL_HEIGHT ((W))                  \
!    - WINDOW_MODE_LINE_HEIGHT ((W))            \
!    - WINDOW_HEADER_LINE_HEIGHT ((W)))
! 
! 
! /* Convert window W relative pixel X to frame pixel coordinates.  */
! 
! #define WINDOW_TO_FRAME_PIXEL_X(W, X)         \
!   ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
! 
! /* Convert window W relative pixel Y to frame pixel coordinates.  */
! 
! #define WINDOW_TO_FRAME_PIXEL_Y(W, Y)         \
!   ((Y) + WINDOW_TOP_EDGE_Y ((W)))
! 
! /* Convert frame relative pixel X to window relative pixel X.  */
! 
! #define FRAME_TO_WINDOW_PIXEL_X(W, X)         \
!   ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
! 
! /* Convert frame relative pixel Y to window relative pixel Y.  */
! 
! #define FRAME_TO_WINDOW_PIXEL_Y(W, Y)         \
!   ((Y) - WINDOW_TOP_EDGE_Y ((W)))
! 
! /* Convert a text area relative x-position in window W to frame X
!    pixel coordinates.  */
  
+ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)            \
+   (window_box_left ((W), TEXT_AREA) + (X))
  
  /* This is the window in which the terminal's cursor should
     be left when nothing is being done with it.  This must
***************
*** 368,374 ****
  EXFUN (Fnext_window, 3);
  EXFUN (Fselect_window, 1);
  EXFUN (Fdisplay_buffer, 3);
! EXFUN (Fset_window_buffer, 2);
  EXFUN (Fset_window_hscroll, 2);
  EXFUN (Fwindow_hscroll, 1);
  EXFUN (Fset_window_vscroll, 2);
--- 744,750 ----
  EXFUN (Fnext_window, 3);
  EXFUN (Fselect_window, 1);
  EXFUN (Fdisplay_buffer, 3);
! EXFUN (Fset_window_buffer, 3);
  EXFUN (Fset_window_hscroll, 2);
  EXFUN (Fwindow_hscroll, 1);
  EXFUN (Fset_window_vscroll, 2);
***************
*** 379,385 ****
  extern Lisp_Object make_window P_ ((void));
  extern void delete_window P_ ((Lisp_Object));
  extern Lisp_Object window_from_coordinates P_ ((struct frame *, int, int,
!                                               enum window_part *, int));
  EXFUN (Fwindow_dedicated_p, 1);
  extern int window_height P_ ((Lisp_Object));
  extern int window_width P_ ((Lisp_Object));
--- 755,762 ----
  extern Lisp_Object make_window P_ ((void));
  extern void delete_window P_ ((Lisp_Object));
  extern Lisp_Object window_from_coordinates P_ ((struct frame *, int, int,
!                                               enum window_part *,
!                                               int *, int*, int));
  EXFUN (Fwindow_dedicated_p, 1);
  extern int window_height P_ ((Lisp_Object));
  extern int window_width P_ ((Lisp_Object));
***************
*** 400,406 ****
     it's not allowed.  */
  
  void set_window_buffer P_ ((Lisp_Object window, Lisp_Object buffer,
!                           int run_hooks_p));
  
  /* Prompt to display in front of the minibuffer contents.  */
  
--- 777,783 ----
     it's not allowed.  */
  
  void set_window_buffer P_ ((Lisp_Object window, Lisp_Object buffer,
!                           int run_hooks_p, int keep_margins_p));
  
  /* Prompt to display in front of the minibuffer contents.  */
  
Index: xdisp.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v
retrieving revision 1.829
diff -c -r1.829 xdisp.c
*** xdisp.c     10 May 2003 16:27:35 -0000      1.829
--- xdisp.c     14 May 2003 21:52:40 -0000
***************
*** 424,431 ****
  
  /* Recenter the window whenever point gets within this many lines of
     the top or bottom of the window.  This value is translated into a
!    pixel value by multiplying it with CANON_Y_UNIT, which means that
!    there is really a fixed pixel height scroll margin.  */
  
  EMACS_INT scroll_margin;
  
--- 424,431 ----
  
  /* Recenter the window whenever point gets within this many lines of
     the top or bottom of the window.  This value is translated into a
!    pixel value by multiplying it with FRAME_LINE_HEIGHT, which means
!    that there is really a fixed pixel height scroll margin.  */
  
  EMACS_INT scroll_margin;
  
***************
*** 913,926 ****
       struct window *w;
  {
    struct frame *f = XFRAME (w->frame);
!   int height = XFASTINT (w->height) * CANON_Y_UNIT (f);
  
    if (WINDOW_WANTS_MODELINE_P (w))
      height -= CURRENT_MODE_LINE_HEIGHT (w);
    return height;
  }
  
- 
  /* Return the pixel width of display area AREA of window W.  AREA < 0
     means return the total width of W, not including fringes to
     the left and right of the window.  */
--- 913,925 ----
       struct window *w;
  {
    struct frame *f = XFRAME (w->frame);
!   int height = WINDOW_TOTAL_HEIGHT (w);
  
    if (WINDOW_WANTS_MODELINE_P (w))
      height -= CURRENT_MODE_LINE_HEIGHT (w);
    return height;
  }
  
  /* Return the pixel width of display area AREA of window W.  AREA < 0
     means return the total width of W, not including fringes to
     the left and right of the window.  */
***************
*** 930,958 ****
       struct window *w;
       int area;
  {
!   struct frame *f = XFRAME (w->frame);
!   int width = XFASTINT (w->width);
  
    if (!w->pseudo_window_p)
      {
!       width -= FRAME_SCROLL_BAR_WIDTH (f) + FRAME_FRINGE_COLS (f);
  
        if (area == TEXT_AREA)
        {
!         if (INTEGERP (w->left_margin_width))
!           width -= XFASTINT (w->left_margin_width);
!         if (INTEGERP (w->right_margin_width))
!           width -= XFASTINT (w->right_margin_width);
        }
        else if (area == LEFT_MARGIN_AREA)
!       width = (INTEGERP (w->left_margin_width)
!                ? XFASTINT (w->left_margin_width) : 0);
        else if (area == RIGHT_MARGIN_AREA)
!       width = (INTEGERP (w->right_margin_width)
!                ? XFASTINT (w->right_margin_width) : 0);
      }
  
!   return width * CANON_X_UNIT (f);
  }
  
  
--- 929,964 ----
       struct window *w;
       int area;
  {
!   int cols = XFASTINT (w->total_cols);
!   int pixels = 0;
  
    if (!w->pseudo_window_p)
      {
!       cols -= WINDOW_SCROLL_BAR_COLS (w);
  
        if (area == TEXT_AREA)
        {
!         if (INTEGERP (w->left_margin_cols))
!           cols -= XFASTINT (w->left_margin_cols);
!         if (INTEGERP (w->right_margin_cols))
!           cols -= XFASTINT (w->right_margin_cols);
!         pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w);
        }
        else if (area == LEFT_MARGIN_AREA)
!       {
!         cols = (INTEGERP (w->left_margin_cols)
!                  ? XFASTINT (w->left_margin_cols) : 0);
!         pixels = 0;
!       }
        else if (area == RIGHT_MARGIN_AREA)
!       {
!         cols = (INTEGERP (w->right_margin_cols)
!                  ? XFASTINT (w->right_margin_cols) : 0);
!         pixels = 0;
!       }
      }
  
!   return cols * WINDOW_FRAME_COLUMN_WIDTH (w) + pixels;
  }
  
  
***************
*** 964,970 ****
       struct window *w;
  {
    struct frame *f = XFRAME (w->frame);
!   int height = XFASTINT (w->height) * CANON_Y_UNIT (f);
  
    xassert (height >= 0);
  
--- 970,976 ----
       struct window *w;
  {
    struct frame *f = XFRAME (w->frame);
!   int height = WINDOW_TOTAL_HEIGHT (w);
  
    xassert (height >= 0);
  
***************
*** 1003,1008 ****
--- 1009,1059 ----
    return max (0, height);
  }
  
+ /* Return the window-relative coordinate of the left edge of display
+    area AREA of window W.  AREA < 0 means return the left edge of the
+    whole window, to the right of the left fringe of W.  */
+ 
+ INLINE int
+ window_box_left_offset (w, area)
+      struct window *w;
+      int area;
+ {
+   int x;
+ 
+   if (w->pseudo_window_p)
+     return 0;
+ 
+   x = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w);
+ 
+   if (area == TEXT_AREA)
+     x += (WINDOW_LEFT_FRINGE_WIDTH (w)
+         + window_box_width (w, LEFT_MARGIN_AREA));
+   else if (area == RIGHT_MARGIN_AREA)
+     x += (WINDOW_LEFT_FRINGE_WIDTH (w)
+         + window_box_width (w, LEFT_MARGIN_AREA)
+         + window_box_width (w, TEXT_AREA)
+         + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+            ? 0
+            : WINDOW_RIGHT_FRINGE_WIDTH (w)));
+   else if (area == LEFT_MARGIN_AREA
+          && WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
+     x += WINDOW_LEFT_FRINGE_WIDTH (w);
+ 
+   return x;
+ }
+ 
+ 
+ /* Return the window-relative coordinate of the right edge of display
+    area AREA of window W.  AREA < 0 means return the left edge of the
+    whole window, to the left of the right fringe of W.  */
+ 
+ INLINE int
+ window_box_right_offset (w, area)
+      struct window *w;
+      int area;
+ {
+   return window_box_left_offset (w, area) + window_box_width (w, area);
+ }
  
  /* Return the frame-relative coordinate of the left edge of display
     area AREA of window W.  AREA < 0 means return the left edge of the
***************
*** 1014,1032 ****
       int area;
  {
    struct frame *f = XFRAME (w->frame);
!   int x = FRAME_INTERNAL_BORDER_WIDTH_SAFE (f);
  
!   if (!w->pseudo_window_p)
!     {
!       x += (WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f)
!           + FRAME_LEFT_FRINGE_WIDTH (f));
  
!       if (area == TEXT_AREA)
!       x += window_box_width (w, LEFT_MARGIN_AREA);
!       else if (area == RIGHT_MARGIN_AREA)
!       x += (window_box_width (w, LEFT_MARGIN_AREA)
!             + window_box_width (w, TEXT_AREA));
!     }
  
    return x;
  }
--- 1065,1077 ----
       int area;
  {
    struct frame *f = XFRAME (w->frame);
!   int x;
  
!   if (w->pseudo_window_p)
!     return FRAME_INTERNAL_BORDER_WIDTH (f);
  
!   x = (WINDOW_LEFT_EDGE_X (w)
!        + window_box_left_offset (w, area));
  
    return x;
  }
***************
*** 1044,1050 ****
    return window_box_left (w, area) + window_box_width (w, area);
  }
  
- 
  /* Get the bounding box of the display area AREA of window W, without
     mode lines, in frame-relative coordinates.  AREA < 0 means the
     whole window, not including the left and right fringes of
--- 1089,1094 ----
***************
*** 1058,1072 ****
       int area;
       int *box_x, *box_y, *box_width, *box_height;
  {
!   struct frame *f = XFRAME (w->frame);
! 
!   *box_width = window_box_width (w, area);
!   *box_height = window_box_height (w);
!   *box_x = window_box_left (w, area);
!   *box_y = (FRAME_INTERNAL_BORDER_WIDTH_SAFE (f)
!           + XFASTINT (w->top) * CANON_Y_UNIT (f));
!   if (WINDOW_WANTS_HEADER_LINE_P (w))
!     *box_y += CURRENT_HEADER_LINE_HEIGHT (w);
  }
  
  
--- 1102,1119 ----
       int area;
       int *box_x, *box_y, *box_width, *box_height;
  {
!   if (box_width)
!     *box_width = window_box_width (w, area);
!   if (box_height)
!     *box_height = window_box_height (w);
!   if (box_x)
!     *box_x = window_box_left (w, area);
!   if (box_y)
!     {
!       *box_y = WINDOW_TOP_EDGE_Y (w);
!       if (WINDOW_WANTS_HEADER_LINE_P (w))
!       *box_y += CURRENT_HEADER_LINE_HEIGHT (w);
!     }
  }
  
  
***************
*** 1184,1190 ****
      {
        int top_y = it.current_y;
        int bottom_y = line_bottom_y (&it);
!       int window_top_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
  
        if (top_y < window_top_y)
        visible_p = bottom_y > window_top_y;
--- 1231,1237 ----
      {
        int top_y = it.current_y;
        int bottom_y = line_bottom_y (&it);
!       int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w);
  
        if (top_y < window_top_y)
        visible_p = bottom_y > window_top_y;
***************
*** 1421,1454 ****
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
         even for negative values.  */
        if (pix_x < 0)
!       pix_x -= FONT_WIDTH (FRAME_FONT (f)) - 1;
        if (pix_y < 0)
!       pix_y -= FRAME_X_OUTPUT(f)->line_height - 1;
  
!       pix_x = PIXEL_TO_CHAR_COL (f, pix_x);
!       pix_y = PIXEL_TO_CHAR_ROW (f, pix_y);
  
        if (bounds)
        STORE_NATIVE_RECT (*bounds,
!                          CHAR_TO_PIXEL_COL (f, pix_x),
!                          CHAR_TO_PIXEL_ROW (f, pix_y),
!                          FONT_WIDTH  (FRAME_FONT (f)) - 1,
!                          FRAME_X_OUTPUT (f)->line_height - 1);
  
        if (!noclip)
        {
          if (pix_x < 0)
            pix_x = 0;
!         else if (pix_x > FRAME_WINDOW_WIDTH (f))
!           pix_x = FRAME_WINDOW_WIDTH (f);
  
          if (pix_y < 0)
            pix_y = 0;
!         else if (pix_y > f->height)
!           pix_y = f->height;
        }
      }
  #endif
--- 1468,1501 ----
  #ifdef HAVE_WINDOW_SYSTEM
    if (FRAME_WINDOW_P (f))
      {
!       /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to round down
         even for negative values.  */
        if (pix_x < 0)
!       pix_x -= FRAME_COLUMN_WIDTH (f) - 1;
        if (pix_y < 0)
!       pix_y -= FRAME_LINE_HEIGHT (f) - 1;
  
!       pix_x = FRAME_PIXEL_X_TO_COL (f, pix_x);
!       pix_y = FRAME_PIXEL_Y_TO_LINE (f, pix_y);
  
        if (bounds)
        STORE_NATIVE_RECT (*bounds,
!                          FRAME_COL_TO_PIXEL_X (f, pix_x),
!                          FRAME_LINE_TO_PIXEL_Y (f, pix_y),
!                          FRAME_COLUMN_WIDTH (f) - 1,
!                          FRAME_LINE_HEIGHT (f) - 1);
  
        if (!noclip)
        {
          if (pix_x < 0)
            pix_x = 0;
!         else if (pix_x > FRAME_TOTAL_COLS (f))
!           pix_x = FRAME_TOTAL_COLS (f);
  
          if (pix_y < 0)
            pix_y = 0;
!         else if (pix_y > FRAME_LINES (f))
!           pix_y = FRAME_LINES (f);
        }
      }
  #endif
***************
*** 1530,1536 ****
  {
    struct glyph *glyph, *end;
    struct glyph_row *row = NULL;
!   int x0, i, left_area_width;
  
    /* Find row containing Y.  Give up if some row is not enabled.  */
    for (i = 0; i < w->current_matrix->nrows; ++i)
--- 1577,1583 ----
  {
    struct glyph *glyph, *end;
    struct glyph_row *row = NULL;
!   int x0, i;
  
    /* Find row containing Y.  Give up if some row is not enabled.  */
    for (i = 0; i < w->current_matrix->nrows; ++i)
***************
*** 1557,1577 ****
      }
    else
      {
!       left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
!       if (x < left_area_width)
        {
          *area = LEFT_MARGIN_AREA;
!         x0 = 0;
        }
!       else if (x < left_area_width + window_box_width (w, TEXT_AREA))
        {
          *area = TEXT_AREA;
!         x0 = row->x + left_area_width;
        }
        else
        {
          *area = RIGHT_MARGIN_AREA;
!         x0 = left_area_width + window_box_width (w, TEXT_AREA);
        }
      }
  
--- 1604,1623 ----
      }
    else
      {
!       if (x < window_box_left_offset (w, TEXT_AREA))
        {
          *area = LEFT_MARGIN_AREA;
!         x0 = window_box_left_offset (w, LEFT_MARGIN_AREA);
        }
!       else if (x < window_box_right_offset (w, TEXT_AREA))
        {
          *area = TEXT_AREA;
!         x0 = window_box_left_offset (w, TEXT_AREA);
        }
        else
        {
          *area = RIGHT_MARGIN_AREA;
!         x0 = window_box_left_offset (w, RIGHT_MARGIN_AREA);
        }
      }
  
***************
*** 1614,1625 ****
        /* A pseudo-window is always full-width, and starts at the
         left edge of the frame, plus a frame border.  */
        struct frame *f = XFRAME (w->frame);
!       *x -= FRAME_INTERNAL_BORDER_WIDTH_SAFE (f);
        *y = FRAME_TO_WINDOW_PIXEL_Y (w, *y);
      }
    else
      {
!       *x = FRAME_TO_WINDOW_PIXEL_X (w, *x);
        *y = FRAME_TO_WINDOW_PIXEL_Y (w, *y);
      }
  }
--- 1660,1671 ----
        /* A pseudo-window is always full-width, and starts at the
         left edge of the frame, plus a frame border.  */
        struct frame *f = XFRAME (w->frame);
!       *x -= FRAME_INTERNAL_BORDER_WIDTH (f);
        *y = FRAME_TO_WINDOW_PIXEL_Y (w, *y);
      }
    else
      {
!       *x -= WINDOW_LEFT_EDGE_X (w);
        *y = FRAME_TO_WINDOW_PIXEL_Y (w, *y);
      }
  }
***************
*** 1636,1655 ****
  
    if (s->row->full_width_p)
      {
!       /* Draw full-width.  X coordinates are relative to S->w->left.  */
!       int canon_x = CANON_X_UNIT (s->f);
! 
!       r.x = WINDOW_LEFT_MARGIN (s->w) * canon_x;
!       r.width = XFASTINT (s->w->width) * canon_x;
! 
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS (s->f))
!       {
!         int width = FRAME_SCROLL_BAR_WIDTH (s->f) * canon_x;
!         if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))
!           r.x -= width;
!       }
! 
!       r.x += FRAME_INTERNAL_BORDER_WIDTH (s->f);
  
        /* Unless displaying a mode or menu bar line, which are always
         fully visible, clip to the visible part of the row.  */
--- 1682,1690 ----
  
    if (s->row->full_width_p)
      {
!       /* Draw full-width.  X coordinates are relative to S->w->left_col.  */
!       r.x = WINDOW_LEFT_EDGE_X (s->w);
!       r.width = WINDOW_TOTAL_WIDTH (s->w);
  
        /* Unless displaying a mode or menu bar line, which are always
         fully visible, clip to the visible part of the row.  */
***************
*** 1661,1667 ****
    else
      {
        /* This is a text line that may be partially visible.  */
!       r.x = WINDOW_AREA_TO_FRAME_PIXEL_X (s->w, s->area, 0);
        r.width = window_box_width (s->w, s->area);
        r.height = s->row->visible_height;
      }
--- 1696,1702 ----
    else
      {
        /* This is a text line that may be partially visible.  */
!       r.x = window_box_left (s->w, s->area);
        r.width = window_box_width (s->w, s->area);
        r.height = s->row->visible_height;
      }
***************
*** 1671,1677 ****
       intentionally draws over other lines.  */
    if (s->for_overlaps_p)
      {
!       r.y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s->w);
        r.height = window_text_bottom_y (s->w) - r.y;
      }
    else
--- 1706,1712 ----
       intentionally draws over other lines.  */
    if (s->for_overlaps_p)
      {
!       r.y = WINDOW_HEADER_LINE_HEIGHT (s->w);
        r.height = window_text_bottom_y (s->w) - r.y;
      }
    else
***************
*** 1681,1687 ****
         partially visible lines at the top of a window.  */
        if (!s->row->full_width_p
          && MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (s->w, s->row))
!       r.y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s->w);
        else
        r.y = max (0, s->row->y);
  
--- 1716,1722 ----
         partially visible lines at the top of a window.  */
        if (!s->row->full_width_p
          && MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (s->w, s->row))
!       r.y = WINDOW_HEADER_LINE_HEIGHT (s->w);
        else
        r.y = max (0, s->row->y);
  
***************
*** 2087,2098 ****
      {
        /* Mode lines, menu bar in terminal frames.  */
        it->first_visible_x = 0;
!       it->last_visible_x = XFASTINT (w->width) * CANON_X_UNIT (it->f);
      }
    else
      {
        it->first_visible_x
!       = XFASTINT (it->w->hscroll) * CANON_X_UNIT (it->f);
        it->last_visible_x = (it->first_visible_x
                            + window_box_width (w, TEXT_AREA));
  
--- 2122,2133 ----
      {
        /* Mode lines, menu bar in terminal frames.  */
        it->first_visible_x = 0;
!       it->last_visible_x = WINDOW_TOTAL_WIDTH (w);
      }
    else
      {
        it->first_visible_x
!       = XFASTINT (it->w->hscroll) * FRAME_COLUMN_WIDTH (it->f);
        it->last_visible_x = (it->first_visible_x
                            + window_box_width (w, TEXT_AREA));
  
***************
*** 2109,2115 ****
        }
  
        it->header_line_p = WINDOW_WANTS_HEADER_LINE_P (w);
!       it->current_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w) + w->vscroll;
      }
  
    /* Leave room for a border glyph.  */
--- 2144,2150 ----
        }
  
        it->header_line_p = WINDOW_WANTS_HEADER_LINE_P (w);
!       it->current_y = WINDOW_HEADER_LINE_HEIGHT (w) + w->vscroll;
      }
  
    /* Leave room for a border glyph.  */
***************
*** 5796,5802 ****
    xassert (dy >= 0);
  
    /* Estimate how many newlines we must move back.  */
!   nlines = max (1, dy / CANON_Y_UNIT (it->f));
  
    /* Set the iterator's position that many lines back.  */
    while (nlines-- && IT_CHARPOS (*it) > BEGV)
--- 5831,5837 ----
    xassert (dy >= 0);
  
    /* Estimate how many newlines we must move back.  */
!   nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f));
  
    /* Set the iterator's position that many lines back.  */
    while (nlines-- && IT_CHARPOS (*it) > BEGV)
***************
*** 7107,7115 ****
      {
        struct it it;
        struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
!       int total_height = XFASTINT (root->height) + XFASTINT (w->height);
        int height, max_height;
!       int unit = CANON_Y_UNIT (f);
        struct text_pos start;
        struct buffer *old_current_buffer = NULL;
  
--- 7142,7150 ----
      {
        struct it it;
        struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
!       int total_height = WINDOW_TOTAL_LINES (root) + WINDOW_TOTAL_LINES (w);
        int height, max_height;
!       int unit = FRAME_LINE_HEIGHT (f);
        struct text_pos start;
        struct buffer *old_current_buffer = NULL;
  
***************
*** 7123,7129 ****
  
        /* Compute the max. number of lines specified by the user.  */
        if (FLOATP (Vmax_mini_window_height))
!       max_height = XFLOATINT (Vmax_mini_window_height) * FRAME_HEIGHT (f);
        else if (INTEGERP (Vmax_mini_window_height))
        max_height = XINT (Vmax_mini_window_height);
        else
--- 7158,7164 ----
  
        /* Compute the max. number of lines specified by the user.  */
        if (FLOATP (Vmax_mini_window_height))
!       max_height = XFLOATINT (Vmax_mini_window_height) * FRAME_LINES (f);
        else if (INTEGERP (Vmax_mini_window_height))
        max_height = XINT (Vmax_mini_window_height);
        else
***************
*** 7164,7208 ****
        {
          /* Let it grow only, until we display an empty message, in which
             case the window shrinks again.  */
!         if (height > XFASTINT (w->height))
            {
!             int old_height = XFASTINT (w->height);
              freeze_window_starts (f, 1);
!             grow_mini_window (w, height - XFASTINT (w->height));
!             window_height_changed_p = XFASTINT (w->height) != old_height;
            }
!         else if (height < XFASTINT (w->height)
                   && (exact_p || BEGV == ZV))
            {
!             int old_height = XFASTINT (w->height);
              freeze_window_starts (f, 0);
              shrink_mini_window (w);
!             window_height_changed_p = XFASTINT (w->height) != old_height;
            }
        }
        else
        {
          /* Always resize to exact size needed.  */
!         if (height > XFASTINT (w->height))
            {
!             int old_height = XFASTINT (w->height);
              freeze_window_starts (f, 1);
!             grow_mini_window (w, height - XFASTINT (w->height));
!             window_height_changed_p = XFASTINT (w->height) != old_height;
            }
!         else if (height < XFASTINT (w->height))
            {
!             int old_height = XFASTINT (w->height);
              freeze_window_starts (f, 0);
              shrink_mini_window (w);
  
              if (height)
                {
                  freeze_window_starts (f, 1);
!                 grow_mini_window (w, height - XFASTINT (w->height));
                }
  
!             window_height_changed_p = XFASTINT (w->height) != old_height;
            }
        }
  
--- 7199,7243 ----
        {
          /* Let it grow only, until we display an empty message, in which
             case the window shrinks again.  */
!         if (height > WINDOW_TOTAL_LINES (w))
            {
!             int old_height = WINDOW_TOTAL_LINES (w);
              freeze_window_starts (f, 1);
!             grow_mini_window (w, height - WINDOW_TOTAL_LINES (w));
!             window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height;
            }
!         else if (height < WINDOW_TOTAL_LINES (w)
                   && (exact_p || BEGV == ZV))
            {
!             int old_height = WINDOW_TOTAL_LINES (w);
              freeze_window_starts (f, 0);
              shrink_mini_window (w);
!             window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height;
            }
        }
        else
        {
          /* Always resize to exact size needed.  */
!         if (height > WINDOW_TOTAL_LINES (w))
            {
!             int old_height = WINDOW_TOTAL_LINES (w);
              freeze_window_starts (f, 1);
!             grow_mini_window (w, height - WINDOW_TOTAL_LINES (w));
!             window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height;
            }
!         else if (height < WINDOW_TOTAL_LINES (w))
            {
!             int old_height = WINDOW_TOTAL_LINES (w);
              freeze_window_starts (f, 0);
              shrink_mini_window (w);
  
              if (height)
                {
                  freeze_window_starts (f, 1);
!                 grow_mini_window (w, height - WINDOW_TOTAL_LINES (w));
                }
  
!             window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height;
            }
        }
  
***************
*** 8105,8111 ****
    int do_update = FRAME_EXTERNAL_TOOL_BAR(f);
  #else
    int do_update = WINDOWP (f->tool_bar_window)
!     && XFASTINT (XWINDOW (f->tool_bar_window)->height) > 0;
  #endif
  
    if (do_update)
--- 8140,8146 ----
    int do_update = FRAME_EXTERNAL_TOOL_BAR(f);
  #else
    int do_update = WINDOWP (f->tool_bar_window)
!     && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0;
  #endif
  
    if (do_update)
***************
*** 8438,8444 ****
       F->desired_tool_bar_string in the tool-bar window of frame F.  */
    init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
    it.first_visible_x = 0;
!   it.last_visible_x = FRAME_WINDOW_WIDTH (f) * CANON_X_UNIT (f);
    reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
  
    while (!ITERATOR_AT_END_P (&it))
--- 8473,8479 ----
       F->desired_tool_bar_string in the tool-bar window of frame F.  */
    init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
    it.first_visible_x = 0;
!   it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
    reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
  
    while (!ITERATOR_AT_END_P (&it))
***************
*** 8448,8454 ****
        display_tool_bar_line (&it);
      }
  
!   return (it.current_y + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
  }
  
  
--- 8483,8489 ----
        display_tool_bar_line (&it);
      }
  
!   return (it.current_y + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
  }
  
  
***************
*** 8470,8476 ****
  
    if (WINDOWP (f->tool_bar_window)
        || (w = XWINDOW (f->tool_bar_window),
!         XFASTINT (w->height) > 0))
      {
        update_tool_bar (f, 1);
        if (f->n_tool_bar_items)
--- 8505,8511 ----
  
    if (WINDOWP (f->tool_bar_window)
        || (w = XWINDOW (f->tool_bar_window),
!         WINDOW_TOTAL_LINES (w) > 0))
      {
        update_tool_bar (f, 1);
        if (f->n_tool_bar_items)
***************
*** 8508,8520 ****
       can turn off tool-bars by specifying tool-bar-lines zero.  */
    if (!WINDOWP (f->tool_bar_window)
        || (w = XWINDOW (f->tool_bar_window),
!           XFASTINT (w->height) == 0))
      return 0;
  
    /* Set up an iterator for the tool-bar window.  */
    init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
    it.first_visible_x = 0;
!   it.last_visible_x = FRAME_WINDOW_WIDTH (f) * CANON_X_UNIT (f);
    row = it.glyph_row;
  
    /* Build a string that represents the contents of the tool-bar.  */
--- 8543,8555 ----
       can turn off tool-bars by specifying tool-bar-lines zero.  */
    if (!WINDOWP (f->tool_bar_window)
        || (w = XWINDOW (f->tool_bar_window),
!           WINDOW_TOTAL_LINES (w) == 0))
      return 0;
  
    /* Set up an iterator for the tool-bar window.  */
    init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TOOL_BAR_FACE_ID);
    it.first_visible_x = 0;
!   it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
    row = it.glyph_row;
  
    /* Build a string that represents the contents of the tool-bar.  */
***************
*** 8541,8550 ****
  
        /* If there are blank lines at the end, except for a partially
         visible blank line at the end that is smaller than
!        CANON_Y_UNIT, change the tool-bar's height.  */
        row = it.glyph_row - 1;
        if (!row->displays_text_p
!         && row->height >= CANON_Y_UNIT (f))
        change_height_p = 1;
  
        /* If row displays tool-bar items, but is partially visible,
--- 8576,8585 ----
  
        /* If there are blank lines at the end, except for a partially
         visible blank line at the end that is smaller than
!        FRAME_LINE_HEIGHT, change the tool-bar's height.  */
        row = it.glyph_row - 1;
        if (!row->displays_text_p
!         && row->height >= FRAME_LINE_HEIGHT (f))
        change_height_p = 1;
  
        /* If row displays tool-bar items, but is partially visible,
***************
*** 8557,8567 ****
         frame parameter.  */
        if (change_height_p
          && (nlines = tool_bar_lines_needed (f),
!             nlines != XFASTINT (w->height)))
        {
          extern Lisp_Object Qtool_bar_lines;
          Lisp_Object frame;
!         int old_height = XFASTINT (w->height);
  
          XSETFRAME (frame, f);
          clear_glyph_matrix (w->desired_matrix);
--- 8592,8602 ----
         frame parameter.  */
        if (change_height_p
          && (nlines = tool_bar_lines_needed (f),
!             nlines != WINDOW_TOTAL_LINES (w)))
        {
          extern Lisp_Object Qtool_bar_lines;
          Lisp_Object frame;
!         int old_height = WINDOW_TOTAL_LINES (w);
  
          XSETFRAME (frame, f);
          clear_glyph_matrix (w->desired_matrix);
***************
*** 8569,8575 ****
                                    Fcons (Fcons (Qtool_bar_lines,
                                                  make_number (nlines)),
                                           Qnil));
!         if (XFASTINT (w->height) != old_height)
            fonts_changed_p = 1;
        }
      }
--- 8604,8610 ----
                                    Fcons (Fcons (Qtool_bar_lines,
                                                  make_number (nlines)),
                                           Qnil));
!         if (WINDOW_TOTAL_LINES (w) != old_height)
            fonts_changed_p = 1;
        }
      }
***************
*** 8782,8788 ****
    if (!NILP (enabled_p))
      {
        /* Compute the x-position of the glyph.  In front and past the
!        image is a space.  We include this is the highlighted area.  */
        row = MATRIX_ROW (w->current_matrix, vpos);
        for (i = x = 0; i < hpos; ++i)
        x += row->glyphs[TEXT_AREA][i].pixel_width;
--- 8817,8823 ----
    if (!NILP (enabled_p))
      {
        /* Compute the x-position of the glyph.  In front and past the
!        image is a space.  We include this in the highlighted area.  */
        row = MATRIX_ROW (w->current_matrix, vpos);
        for (i = x = 0; i < hpos; ++i)
        x += row->glyphs[TEXT_AREA][i].pixel_width;
***************
*** 8909,8949 ****
    p.bx = -1;
    if (left_p)
      {
!       if (p.wd > FRAME_X_LEFT_FRINGE_WIDTH (f))
!       p.wd = FRAME_X_LEFT_FRINGE_WIDTH (f);
!       p.x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
!            - p.wd
!            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - p.wd) / 2);
!       if (p.wd < FRAME_X_LEFT_FRINGE_WIDTH (f) || row->height > p.h)
        {
          /* If W has a vertical border to its left, don't draw over it.  */
!         int border = ((XFASTINT (w->left) > 0
!                        && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))
!                       ? 1 : 0);
!         p.bx = (window_box_left (w, -1)
!                 - FRAME_X_LEFT_FRINGE_WIDTH (f)
!                 + border);
!         p.nx = (FRAME_X_LEFT_FRINGE_WIDTH (f) - border);
        }
      }
    else
      {
!       if (p.wd > FRAME_X_RIGHT_FRINGE_WIDTH (f))
!       p.wd = FRAME_X_RIGHT_FRINGE_WIDTH (f);
!       p.x = (window_box_right (w, -1)
!            + (FRAME_X_RIGHT_FRINGE_WIDTH (f) - p.wd) / 2);
        /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
         the fringe.  */
!       if (p.wd < FRAME_X_RIGHT_FRINGE_WIDTH (f) || row->height > p.h)
        {
!         p.bx = window_box_right (w, -1);
!         p.nx = FRAME_X_RIGHT_FRINGE_WIDTH (f);
        }
      }
  
    if (p.bx >= 0)
      {
!       int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
  
        p.by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, row->y));
        p.ny = row->visible_height;
--- 8944,8989 ----
    p.bx = -1;
    if (left_p)
      {
!       int wd = WINDOW_LEFT_FRINGE_WIDTH (w);
!       int x = window_box_left (w, (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!                                  ? LEFT_MARGIN_AREA
!                                  : TEXT_AREA));
!       if (p.wd > wd)
!       p.wd = wd;
!       p.x = x - p.wd - (wd - p.wd) / 2;
! 
!       if (p.wd < wd || row->height > p.h)
        {
          /* If W has a vertical border to its left, don't draw over it.  */
!         wd -= ((!WINDOW_LEFTMOST_P (w)
!                 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
!                ? 1 : 0);
!         p.bx = x - wd;
!         p.nx = wd;
        }
      }
    else
      {
!       int x = window_box_right (w,
!                               (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!                                ? RIGHT_MARGIN_AREA
!                                : TEXT_AREA));
!       int wd = WINDOW_RIGHT_FRINGE_WIDTH (w);
!       if (p.wd > wd)
!       p.wd = wd;
!       p.x = x + (wd - p.wd) / 2;
        /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
         the fringe.  */
!       if (p.wd < wd || row->height > p.h)
        {
!         p.bx = x;
!         p.nx = wd;
        }
      }
  
    if (p.bx >= 0)
      {
!       int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
  
        p.by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, row->y));
        p.ny = row->visible_height;
***************
*** 8973,8979 ****
    if (row->visible_height <= 0)
      return;
  
!   if (FRAME_X_LEFT_FRINGE_WIDTH (f) != 0)
      {
        /* Decide which bitmap to draw in the left fringe.  */
        if (row->overlay_arrow_p)
--- 9013,9019 ----
    if (row->visible_height <= 0)
      return;
  
!   if (WINDOW_LEFT_FRINGE_WIDTH (w) != 0)
      {
        /* Decide which bitmap to draw in the left fringe.  */
        if (row->overlay_arrow_p)
***************
*** 8990,9003 ****
        draw_fringe_bitmap (w, row, bitmap, 1);
      }
  
!   if (FRAME_X_RIGHT_FRINGE_WIDTH (f) != 0)
      {
        /* Decide which bitmap to draw in the right fringe.  */
        if (row->truncated_on_right_p)
        bitmap = RIGHT_TRUNCATION_BITMAP;
        else if (row->continued_p)
        bitmap = CONTINUED_LINE_BITMAP;
!       else if (row->indicate_empty_line_p && FRAME_X_LEFT_FRINGE_WIDTH (f) == 
0)
        bitmap = ZV_LINE_BITMAP;
        else
        bitmap = NO_FRINGE_BITMAP;
--- 9030,9043 ----
        draw_fringe_bitmap (w, row, bitmap, 1);
      }
  
!   if (WINDOW_RIGHT_FRINGE_WIDTH (w) != 0)
      {
        /* Decide which bitmap to draw in the right fringe.  */
        if (row->truncated_on_right_p)
        bitmap = RIGHT_TRUNCATION_BITMAP;
        else if (row->continued_p)
        bitmap = CONTINUED_LINE_BITMAP;
!       else if (row->indicate_empty_line_p && WINDOW_LEFT_FRINGE_WIDTH (w) == 
0)
        bitmap = ZV_LINE_BITMAP;
        else
        bitmap = NO_FRINGE_BITMAP;
***************
*** 9014,9022 ****
       struct frame *f;
       int redraw;
  {
!   int o_left = FRAME_X_LEFT_FRINGE_WIDTH (f);
!   int o_right = FRAME_X_RIGHT_FRINGE_WIDTH (f);
!   int o_cols = FRAME_X_FRINGE_COLS (f);
  
    Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
    Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
--- 9054,9062 ----
       struct frame *f;
       int redraw;
  {
!   int o_left = FRAME_LEFT_FRINGE_WIDTH (f);
!   int o_right = FRAME_RIGHT_FRINGE_WIDTH (f);
!   int o_cols = FRAME_FRINGE_COLS (f);
  
    Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
    Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
***************
*** 9037,9043 ****
        int left_wid = left_fringe_width >= 0 ? left_fringe_width : 
-left_fringe_width;
        int right_wid = right_fringe_width >= 0 ? right_fringe_width : 
-right_fringe_width;
        int conf_wid = left_wid + right_wid;
!       int font_wid = FONT_WIDTH (FRAME_FONT (f));
        int cols = (left_wid + right_wid + font_wid-1) / font_wid;
        int real_wid = cols * font_wid;
        if (left_wid && right_wid)
--- 9077,9083 ----
        int left_wid = left_fringe_width >= 0 ? left_fringe_width : 
-left_fringe_width;
        int right_wid = right_fringe_width >= 0 ? right_fringe_width : 
-right_fringe_width;
        int conf_wid = left_wid + right_wid;
!       int font_wid = FRAME_COLUMN_WIDTH (f);
        int cols = (left_wid + right_wid + font_wid-1) / font_wid;
        int real_wid = cols * font_wid;
        if (left_wid && right_wid)
***************
*** 9045,9058 ****
          if (left_fringe_width < 0)
            {
              /* Left fringe width is fixed, adjust right fringe if necessary */
!             FRAME_X_LEFT_FRINGE_WIDTH (f) = left_wid;
!             FRAME_X_RIGHT_FRINGE_WIDTH (f) = real_wid - left_wid;
            }
          else if (right_fringe_width < 0)
            {
              /* Right fringe width is fixed, adjust left fringe if necessary */
!             FRAME_X_LEFT_FRINGE_WIDTH (f) = real_wid - right_wid;
!             FRAME_X_RIGHT_FRINGE_WIDTH (f) = right_wid;
            }
          else
            {
--- 9085,9098 ----
          if (left_fringe_width < 0)
            {
              /* Left fringe width is fixed, adjust right fringe if necessary */
!             FRAME_LEFT_FRINGE_WIDTH (f) = left_wid;
!             FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid - left_wid;
            }
          else if (right_fringe_width < 0)
            {
              /* Right fringe width is fixed, adjust left fringe if necessary */
!             FRAME_LEFT_FRINGE_WIDTH (f) = real_wid - right_wid;
!             FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid;
            }
          else
            {
***************
*** 9060,9094 ****
                 Note that we are doing integer arithmetic here, so don't
                 lose a pixel if the total width is an odd number.  */
              int fill = real_wid - conf_wid;
!             FRAME_X_LEFT_FRINGE_WIDTH (f) = left_wid + fill/2;
!             FRAME_X_RIGHT_FRINGE_WIDTH (f) = right_wid + fill - fill/2;
            }
        }
        else if (left_fringe_width)
        {
!         FRAME_X_LEFT_FRINGE_WIDTH (f) = real_wid;
!         FRAME_X_RIGHT_FRINGE_WIDTH (f) = 0;
        }
        else
        {
!         FRAME_X_LEFT_FRINGE_WIDTH (f) = 0;
!         FRAME_X_RIGHT_FRINGE_WIDTH (f) = real_wid;
        }
!       FRAME_X_FRINGE_COLS (f) = cols;
!       FRAME_X_FRINGE_WIDTH (f) = real_wid;
      }
    else
      {
!       FRAME_X_LEFT_FRINGE_WIDTH (f) = 0;
!       FRAME_X_RIGHT_FRINGE_WIDTH (f) = 0;
!       FRAME_X_FRINGE_COLS (f) = 0;
!       FRAME_X_FRINGE_WIDTH (f) = 0;
      }
  
    if (redraw && FRAME_VISIBLE_P (f))
!     if (o_left != FRAME_X_LEFT_FRINGE_WIDTH (f) ||
!       o_right != FRAME_X_RIGHT_FRINGE_WIDTH (f) ||
!       o_cols != FRAME_X_FRINGE_COLS (f))
        redraw_frame (f);
  }
  
--- 9100,9132 ----
                 Note that we are doing integer arithmetic here, so don't
                 lose a pixel if the total width is an odd number.  */
              int fill = real_wid - conf_wid;
!             FRAME_LEFT_FRINGE_WIDTH (f) = left_wid + fill/2;
!             FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid + fill - fill/2;
            }
        }
        else if (left_fringe_width)
        {
!         FRAME_LEFT_FRINGE_WIDTH (f) = real_wid;
!         FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
        }
        else
        {
!         FRAME_LEFT_FRINGE_WIDTH (f) = 0;
!         FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid;
        }
!       FRAME_FRINGE_COLS (f) = cols;
      }
    else
      {
!       FRAME_LEFT_FRINGE_WIDTH (f) = 0;
!       FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
!       FRAME_FRINGE_COLS (f) = 0;
      }
  
    if (redraw && FRAME_VISIBLE_P (f))
!     if (o_left != FRAME_LEFT_FRINGE_WIDTH (f) ||
!       o_right != FRAME_RIGHT_FRINGE_WIDTH (f) ||
!       o_cols != FRAME_FRINGE_COLS (f))
        redraw_frame (f);
  }
  
***************
*** 9146,9153 ****
        hscrolled_p |= hscroll_window_tree (w->vchild);
        else if (w->cursor.vpos >= 0)
        {
!         int h_margin, text_area_x, text_area_y;
!         int text_area_width, text_area_height;
          struct glyph_row *current_cursor_row
            = MATRIX_ROW (w->current_matrix, w->cursor.vpos);
          struct glyph_row *desired_cursor_row
--- 9184,9191 ----
        hscrolled_p |= hscroll_window_tree (w->vchild);
        else if (w->cursor.vpos >= 0)
        {
!         int h_margin;
!         int text_area_width;
          struct glyph_row *current_cursor_row
            = MATRIX_ROW (w->current_matrix, w->cursor.vpos);
          struct glyph_row *desired_cursor_row
***************
*** 9157,9167 ****
               ? desired_cursor_row
               : current_cursor_row);
  
!         window_box (w, TEXT_AREA, &text_area_x, &text_area_y,
!                     &text_area_width, &text_area_height);
  
          /* Scroll when cursor is inside this scroll margin.  */
!         h_margin = hscroll_margin * CANON_X_UNIT (XFRAME (w->frame));
  
          if ((XFASTINT (w->hscroll)
               && w->cursor.x <= h_margin)
--- 9195,9204 ----
               ? desired_cursor_row
               : current_cursor_row);
  
!         text_area_width = window_box_width (w, TEXT_AREA);
  
          /* Scroll when cursor is inside this scroll margin.  */
!         h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w);
  
          if ((XFASTINT (w->hscroll)
               && w->cursor.x <= h_margin)
***************
*** 9198,9204 ****
              /* Position cursor in window.  */
              if (!hscroll_relative_p && hscroll_step_abs == 0)
                hscroll = max (0, it.current_x - text_area_width / 2)
!                         / CANON_X_UNIT (it.f);
              else if (w->cursor.x >= text_area_width - h_margin)
                {
                  if (hscroll_relative_p)
--- 9235,9241 ----
              /* Position cursor in window.  */
              if (!hscroll_relative_p && hscroll_step_abs == 0)
                hscroll = max (0, it.current_x - text_area_width / 2)
!                         / FRAME_COLUMN_WIDTH (it.f);
              else if (w->cursor.x >= text_area_width - h_margin)
                {
                  if (hscroll_relative_p)
***************
*** 9206,9215 ****
                               - h_margin;
                  else
                    wanted_x = text_area_width
!                              - hscroll_step_abs * CANON_X_UNIT (it.f)
                               - h_margin;
                  hscroll
!                   = max (0, it.current_x - wanted_x) / CANON_X_UNIT (it.f);
                }
              else
                {
--- 9243,9252 ----
                               - h_margin;
                  else
                    wanted_x = text_area_width
!                              - hscroll_step_abs * FRAME_COLUMN_WIDTH (it.f)
                               - h_margin;
                  hscroll
!                   = max (0, it.current_x - wanted_x) / FRAME_COLUMN_WIDTH 
(it.f);
                }
              else
                {
***************
*** 9217,9226 ****
                    wanted_x = text_area_width * hscroll_step_rel
                               + h_margin;
                  else
!                   wanted_x = hscroll_step_abs * CANON_X_UNIT (it.f)
                               + h_margin;
                  hscroll
!                   = max (0, it.current_x - wanted_x) / CANON_X_UNIT (it.f);
                }
              hscroll = max (hscroll, XFASTINT (w->min_hscroll));
  
--- 9254,9263 ----
                    wanted_x = text_area_width * hscroll_step_rel
                               + h_margin;
                  else
!                   wanted_x = hscroll_step_abs * FRAME_COLUMN_WIDTH (it.f)
                               + h_margin;
                  hscroll
!                   = max (0, it.current_x - wanted_x) / FRAME_COLUMN_WIDTH 
(it.f);
                }
              hscroll = max (hscroll, XFASTINT (w->min_hscroll));
  
***************
*** 9869,9875 ****
               /* Make sure the cursor was last displayed
                  in this window.  Otherwise we have to reposition it.  */
               && 0 <= w->cursor.vpos
!              && XINT (w->height) > w->cursor.vpos)
        {
          if (!must_finish)
            {
--- 9906,9912 ----
               /* Make sure the cursor was last displayed
                  in this window.  Otherwise we have to reposition it.  */
               && 0 <= w->cursor.vpos
!              && WINDOW_TOTAL_LINES (w) > w->cursor.vpos)
        {
          if (!must_finish)
            {
***************
*** 10273,10279 ****
        w->window_end_valid = w->buffer;
  #if 0 /* This is incorrect with variable-height lines.  */
        xassert (XINT (w->window_end_vpos)
!              < (XINT (w->height)
                  - (WINDOW_WANTS_MODELINE_P (w) ? 1 : 0)));
  #endif
        w->update_mode_line = Qnil;
--- 10310,10316 ----
        w->window_end_valid = w->buffer;
  #if 0 /* This is incorrect with variable-height lines.  */
        xassert (XINT (w->window_end_vpos)
!              < (WINDOW_TOTAL_LINES (w)
                  - (WINDOW_WANTS_MODELINE_P (w) ? 1 : 0)));
  #endif
        w->update_mode_line = Qnil;
***************
*** 10736,10743 ****
       within this distance from the top or bottom of the window.  */
    if (scroll_margin > 0)
      {
!       this_scroll_margin = min (scroll_margin, XINT (w->height) / 4);
!       this_scroll_margin *= CANON_Y_UNIT (f);
      }
    else
      this_scroll_margin = 0;
--- 10773,10780 ----
       within this distance from the top or bottom of the window.  */
    if (scroll_margin > 0)
      {
!       this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
!       this_scroll_margin *= FRAME_LINE_HEIGHT (f);
      }
    else
      this_scroll_margin = 0;
***************
*** 10755,10761 ****
      scroll_max = 10;
    else
      scroll_max = 0;
!   scroll_max *= CANON_Y_UNIT (f);
  
    /* Decide whether we have to scroll down.  Start at the window end
       and move this_scroll_margin up to find the position of the scroll
--- 10792,10798 ----
      scroll_max = 10;
    else
      scroll_max = 0;
!   scroll_max *= FRAME_LINE_HEIGHT (f);
  
    /* Decide whether we have to scroll down.  Start at the window end
       and move this_scroll_margin up to find the position of the scroll
***************
*** 10806,10820 ****
        /* Set AMOUNT_TO_SCROLL to at least one line,
           and at most scroll_conservatively lines.  */
        amount_to_scroll
!         = min (max (dy, CANON_Y_UNIT (f)),
!                CANON_Y_UNIT (f) * scroll_conservatively);
        else if (scroll_step || temp_scroll_step)
        amount_to_scroll = scroll_max;
        else
        {
          aggressive = current_buffer->scroll_up_aggressively;
!         height = (WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w)
!                   - WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w));
          if (NUMBERP (aggressive))
            amount_to_scroll = XFLOATINT (aggressive) * height;
        }
--- 10843,10856 ----
        /* Set AMOUNT_TO_SCROLL to at least one line,
           and at most scroll_conservatively lines.  */
        amount_to_scroll
!         = min (max (dy, FRAME_LINE_HEIGHT (f)),
!                FRAME_LINE_HEIGHT (f) * scroll_conservatively);
        else if (scroll_step || temp_scroll_step)
        amount_to_scroll = scroll_max;
        else
        {
          aggressive = current_buffer->scroll_up_aggressively;
!         height = WINDOW_BOX_TEXT_HEIGHT (w);
          if (NUMBERP (aggressive))
            amount_to_scroll = XFLOATINT (aggressive) * height;
        }
***************
*** 10866,10879 ****
  
          if (scroll_conservatively)
            amount_to_scroll =
!             max (dy, CANON_Y_UNIT (f) * max (scroll_step, temp_scroll_step));
          else if (scroll_step || temp_scroll_step)
            amount_to_scroll = scroll_max;
          else
            {
              aggressive = current_buffer->scroll_down_aggressively;
!             height = (WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w)
!                       - WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w));
              if (NUMBERP (aggressive))
                amount_to_scroll = XFLOATINT (aggressive) * height;
            }
--- 10902,10914 ----
  
          if (scroll_conservatively)
            amount_to_scroll =
!             max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, 
temp_scroll_step));
          else if (scroll_step || temp_scroll_step)
            amount_to_scroll = scroll_max;
          else
            {
              aggressive = current_buffer->scroll_down_aggressively;
!             height = WINDOW_BOX_TEXT_HEIGHT (w);
              if (NUMBERP (aggressive))
                amount_to_scroll = XFLOATINT (aggressive) * height;
            }
***************
*** 10963,10969 ****
        /* If the line start is "too far" away from the window start,
           say it takes too much time to compute a new window start.  */
        if (CHARPOS (start_pos) - IT_CHARPOS (it)
!         < XFASTINT (w->height) * XFASTINT (w->width))
        {
          int min_distance, distance;
  
--- 10998,11004 ----
        /* If the line start is "too far" away from the window start,
           say it takes too much time to compute a new window start.  */
        if (CHARPOS (start_pos) - IT_CHARPOS (it)
!         < WINDOW_TOTAL_LINES (w) * WINDOW_TOTAL_COLS (w))
        {
          int min_distance, distance;
  
***************
*** 11081,11088 ****
        /* Scroll if point within this distance from the top or bottom
         of the window.  This is a pixel value.  */
        this_scroll_margin = max (0, scroll_margin);
!       this_scroll_margin = min (this_scroll_margin, XFASTINT (w->height) / 4);
!       this_scroll_margin *= CANON_Y_UNIT (f);
  
        /* Start with the row the cursor was displayed during the last
         not paused redisplay.  Give up if that row is not valid.  */
--- 11116,11123 ----
        /* Scroll if point within this distance from the top or bottom
         of the window.  This is a pixel value.  */
        this_scroll_margin = max (0, scroll_margin);
!       this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 
4);
!       this_scroll_margin *= FRAME_LINE_HEIGHT (f);
  
        /* Start with the row the cursor was displayed during the last
         not paused redisplay.  Give up if that row is not valid.  */
***************
*** 11942,11948 ****
    ;
   finish_scroll_bars:
  
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
      {
        /* Set the thumb's position and size.  */
        set_vertical_scroll_bar (w);
--- 11977,11983 ----
    ;
   finish_scroll_bars:
  
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
      {
        /* Set the thumb's position and size.  */
        set_vertical_scroll_bar (w);
***************
*** 12177,12183 ****
            (start_row + i)->enabled_p = 0;
  
          /* Re-compute Y positions.  */
!         min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
          max_y = it.last_visible_y;
          for (row = start_row + nrows_scrolled;
               row < bottom_row;
--- 12212,12218 ----
            (start_row + i)->enabled_p = 0;
  
          /* Re-compute Y positions.  */
!         min_y = WINDOW_HEADER_LINE_HEIGHT (w);
          max_y = it.last_visible_y;
          for (row = start_row + nrows_scrolled;
               row < bottom_row;
***************
*** 12292,12298 ****
        it.vpos = (MATRIX_ROW_VPOS (first_row_to_display, w->current_matrix)
                 - nrows_scrolled);
        it.current_y = (first_row_to_display->y - first_reusable_row->y
!                     + WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w));
  
        /* Display lines beginning with first_row_to_display in the
           desired matrix.  Set last_text_row to the last row displayed
--- 12327,12333 ----
        it.vpos = (MATRIX_ROW_VPOS (first_row_to_display, w->current_matrix)
                 - nrows_scrolled);
        it.current_y = (first_row_to_display->y - first_reusable_row->y
!                     + WINDOW_HEADER_LINE_HEIGHT (w));
  
        /* Display lines beginning with first_row_to_display in the
           desired matrix.  Set last_text_row to the last row displayed
***************
*** 12323,12329 ****
  
        /* Scroll the display.  */
        run.current_y = first_reusable_row->y;
!       run.desired_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
        run.height = it.last_visible_y - run.current_y;
        dy = run.current_y - run.desired_y;
  
--- 12358,12364 ----
  
        /* Scroll the display.  */
        run.current_y = first_reusable_row->y;
!       run.desired_y = WINDOW_HEADER_LINE_HEIGHT (w);
        run.height = it.last_visible_y - run.current_y;
        dy = run.current_y - run.desired_y;
  
***************
*** 12340,12346 ****
  
        /* Adjust Y positions of reused rows.  */
        bottom_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w);
!       min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
        max_y = it.last_visible_y;
        for (row = first_reusable_row; row < first_row_to_display; ++row)
        {
--- 12375,12381 ----
  
        /* Adjust Y positions of reused rows.  */
        bottom_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w);
!       min_y = WINDOW_HEADER_LINE_HEIGHT (w);
        max_y = it.last_visible_y;
        for (row = first_reusable_row; row < first_row_to_display; ++row)
        {
***************
*** 12592,12598 ****
       marginal areas (see build_frame_matrix).  */
    window_row = w->current_matrix->rows;
    window_row_end = window_row + w->current_matrix->nrows;
!   frame_row = f->current_matrix->rows + XFASTINT (w->top);
    while (window_row < window_row_end)
      {
        struct glyph *start = window_row->glyphs[LEFT_MARGIN_AREA];
--- 12627,12633 ----
       marginal areas (see build_frame_matrix).  */
    window_row = w->current_matrix->rows;
    window_row_end = window_row + w->current_matrix->nrows;
!   frame_row = f->current_matrix->rows + WINDOW_TOP_EDGE_LINE (w);
    while (window_row < window_row_end)
      {
        struct glyph *start = window_row->glyphs[LEFT_MARGIN_AREA];
***************
*** 13133,13141 ****
      int this_scroll_margin, cursor_height;
  
      this_scroll_margin = max (0, scroll_margin);
!     this_scroll_margin = min (this_scroll_margin,
!                             XFASTINT (w->height) / 4);
!     this_scroll_margin *= CANON_Y_UNIT (it.f);
      cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
  
      if ((w->cursor.y < this_scroll_margin
--- 13168,13175 ----
      int this_scroll_margin, cursor_height;
  
      this_scroll_margin = max (0, scroll_margin);
!     this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
!     this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
      cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
  
      if ((w->cursor.y < this_scroll_margin
***************
*** 13170,13177 ****
             lines to scroll by; dvpos < 0 means scroll up.  */
          int first_unchanged_at_end_vpos
            = MATRIX_ROW_VPOS (first_unchanged_at_end_row, w->current_matrix);
!         int from = XFASTINT (w->top) + first_unchanged_at_end_vpos;
!         int end = (XFASTINT (w->top)
                     + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0)
                     + window_internal_height (w));
  
--- 13204,13211 ----
             lines to scroll by; dvpos < 0 means scroll up.  */
          int first_unchanged_at_end_vpos
            = MATRIX_ROW_VPOS (first_unchanged_at_end_row, w->current_matrix);
!         int from = WINDOW_TOP_EDGE_LINE (w) + first_unchanged_at_end_vpos;
!         int end = (WINDOW_TOP_EDGE_LINE (w)
                     + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0)
                     + window_internal_height (w));
  
***************
*** 13861,13867 ****
        if (row->height == 0)
        {
          if (it->max_ascent + it->max_descent == 0)
!           it->max_descent = it->max_phys_descent = CANON_Y_UNIT (it->f);
          row->ascent = it->max_ascent;
          row->height = it->max_ascent + it->max_descent;
          row->phys_ascent = it->max_phys_ascent;
--- 13895,13901 ----
        if (row->height == 0)
        {
          if (it->max_ascent + it->max_descent == 0)
!           it->max_descent = it->max_phys_descent = FRAME_LINE_HEIGHT (it->f);
          row->ascent = it->max_ascent;
          row->height = it->max_ascent + it->max_descent;
          row->phys_ascent = it->max_phys_ascent;
***************
*** 13892,13899 ****
        /* Compute how much of the line is visible.  */
        row->visible_height = row->height;
  
!       min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (it->w);
!       max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (it->w);
  
        if (row->y < min_y)
        row->visible_height -= min_y - row->y;
--- 13926,13933 ----
        /* Compute how much of the line is visible.  */
        row->visible_height = row->height;
  
!       min_y = WINDOW_HEADER_LINE_HEIGHT (it->w);
!       max_y = WINDOW_BOX_HEIGHT_NO_MODE_LINE (it->w);
  
        if (row->y < min_y)
        row->visible_height -= min_y - row->y;
***************
*** 14649,14655 ****
    xassert (!FRAME_WINDOW_P (f));
    init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID);
    it.first_visible_x = 0;
!   it.last_visible_x = FRAME_WINDOW_WIDTH (f) * CANON_X_UNIT (f);
  #else /* not USE_X_TOOLKIT */
    if (FRAME_WINDOW_P (f))
      {
--- 14683,14689 ----
    xassert (!FRAME_WINDOW_P (f));
    init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID);
    it.first_visible_x = 0;
!   it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
  #else /* not USE_X_TOOLKIT */
    if (FRAME_WINDOW_P (f))
      {
***************
*** 14661,14667 ****
        init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
                     MENU_FACE_ID);
        it.first_visible_x = 0;
!       it.last_visible_x = FRAME_WINDOW_WIDTH (f) * CANON_X_UNIT (f);
      }
    else
      {
--- 14695,14701 ----
        init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
                     MENU_FACE_ID);
        it.first_visible_x = 0;
!       it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
      }
    else
      {
***************
*** 14670,14676 ****
        init_iterator (&it, w, -1, -1, f->desired_matrix->rows,
                     MENU_FACE_ID);
        it.first_visible_x = 0;
!       it.last_visible_x = FRAME_WIDTH (f);
      }
  #endif /* not USE_X_TOOLKIT */
  
--- 14704,14710 ----
        init_iterator (&it, w, -1, -1, f->desired_matrix->rows,
                     MENU_FACE_ID);
        it.first_visible_x = 0;
!       it.last_visible_x = FRAME_COLS (f);
      }
  #endif /* not USE_X_TOOLKIT */
  
***************
*** 15748,15754 ****
        int startpos_byte = marker_byte_position (w->start);
        int line, linepos, linepos_byte, topline;
        int nlines, junk;
!       int height = XFASTINT (w->height);
  
        /* If we decided that this buffer isn't suitable for line numbers,
           don't forget that too fast.  */
--- 15782,15788 ----
        int startpos_byte = marker_byte_position (w->start);
        int line, linepos, linepos_byte, topline;
        int nlines, junk;
!       int height = WINDOW_TOTAL_LINES (w);
  
        /* If we decided that this buffer isn't suitable for line numbers,
           don't forget that too fast.  */
***************
*** 17274,17303 ****
      {
        /* X is relative to the left edge of W, without scroll bars
         or fringes.  */
!       int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);
! 
!       x += window_left_x;
!       area_width = XFASTINT (w->width) * CANON_X_UNIT (f);
!       last_x = window_left_x + area_width;
! 
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
!       {
!         int width = FRAME_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f);
!         if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!           last_x += width;
!         else
!           x -= width;
!       }
! 
!       x += FRAME_INTERNAL_BORDER_WIDTH (f);
!       /* ++KFS: W32 and MAC versions had -= in next line (bug??)  */
!       last_x += FRAME_INTERNAL_BORDER_WIDTH (f);
      }
    else
      {
!       x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, area, x);
        area_width = window_box_width (w, area);
!       last_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, area, area_width);
      }
  
    /* Build a doubly-linked list of glyph_string structures between
--- 17308,17322 ----
      {
        /* X is relative to the left edge of W, without scroll bars
         or fringes.  */
!       x += WINDOW_LEFT_EDGE_X (w);
!       last_x = WINDOW_LEFT_EDGE_X (w) + WINDOW_TOTAL_WIDTH (w);
      }
    else
      {
!       int area_left = window_box_left (w, area);
!       x += area_left;
        area_width = window_box_width (w, area);
!       last_x = area_left + area_width;
      }
  
    /* Build a doubly-linked list of glyph_string structures between
***************
*** 17402,17439 ****
        int x0 = head ? head->x : x;
        int x1 = tail ? tail->x + tail->background_width : x;
  
!       x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
!       x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
! 
!       /* ++KFS: W32 and MAC versions had following test here:
!        if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)
!       */
! 
!       if (XFASTINT (w->left_margin_width) != 0)
!       {
!         int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
!         x0 -= left_area_width;
!         x1 -= left_area_width;
!       }
  
!       notice_overwritten_cursor (w, area, x0, x1,
                                 row->y, MATRIX_ROW_BOTTOM_Y (row));
      }
  
    /* Value is the x-position up to which drawn, relative to AREA of W.
       This doesn't include parts drawn because of overhangs.  */
!   x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached);
!   if (!row->full_width_p)
!     {
!       /* ++KFS: W32 and MAC versions only had this test here:
!        if (area > LEFT_MARGIN_AREA)
!       */
! 
!       if (area > LEFT_MARGIN_AREA && XFASTINT (w->left_margin_width) != 0)
!       x_reached -= window_box_width (w, LEFT_MARGIN_AREA);
!       if (area > TEXT_AREA)
!       x_reached -= window_box_width (w, TEXT_AREA);
!     }
  
    RELEASE_HDC (hdc, f);
  
--- 17421,17440 ----
        int x0 = head ? head->x : x;
        int x1 = tail ? tail->x + tail->background_width : x;
  
!       int text_left = window_box_left (w, TEXT_AREA);
!       x0 -= text_left;
!       x1 -= text_left;
  
!       notice_overwritten_cursor (w, TEXT_AREA, x0, x1,
                                 row->y, MATRIX_ROW_BOTTOM_Y (row));
      }
  
    /* Value is the x-position up to which drawn, relative to AREA of W.
       This doesn't include parts drawn because of overhangs.  */
!   if (row->full_width_p)
!     x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached);
!   else
!     x_reached -= window_box_left (w, area);
  
    RELEASE_HDC (hdc, f);
  
***************
*** 17701,17707 ****
    if (prop = Fplist_get (plist, QCwidth),
        NUMVAL (prop) > 0)
      /* Absolute width `:width WIDTH' specified and valid.  */
!     width = NUMVAL (prop) * CANON_X_UNIT (it->f);
    else if (prop = Fplist_get (plist, QCrelative_width),
           NUMVAL (prop) > 0)
      {
--- 17702,17708 ----
    if (prop = Fplist_get (plist, QCwidth),
        NUMVAL (prop) > 0)
      /* Absolute width `:width WIDTH' specified and valid.  */
!     width = NUMVAL (prop) * FRAME_COLUMN_WIDTH (it->f);
    else if (prop = Fplist_get (plist, QCrelative_width),
           NUMVAL (prop) > 0)
      {
***************
*** 17728,17742 ****
      }
    else if (prop = Fplist_get (plist, QCalign_to),
           NUMVAL (prop) > 0)
!     width = NUMVAL (prop) * CANON_X_UNIT (it->f) - it->current_x;
    else
      /* Nothing specified -> width defaults to canonical char width.  */
!     width = CANON_X_UNIT (it->f);
  
    /* Compute height.  */
    if (prop = Fplist_get (plist, QCheight),
        NUMVAL (prop) > 0)
!     height = NUMVAL (prop) * CANON_Y_UNIT (it->f);
    else if (prop = Fplist_get (plist, QCrelative_height),
           NUMVAL (prop) > 0)
      height = FONT_HEIGHT (font) * NUMVAL (prop);
--- 17729,17743 ----
      }
    else if (prop = Fplist_get (plist, QCalign_to),
           NUMVAL (prop) > 0)
!     width = NUMVAL (prop) * FRAME_COLUMN_WIDTH (it->f) - it->current_x;
    else
      /* Nothing specified -> width defaults to canonical char width.  */
!     width = FRAME_COLUMN_WIDTH (it->f);
  
    /* Compute height.  */
    if (prop = Fplist_get (plist, QCheight),
        NUMVAL (prop) > 0)
!     height = NUMVAL (prop) * FRAME_LINE_HEIGHT (it->f);
    else if (prop = Fplist_get (plist, QCrelative_height),
           NUMVAL (prop) > 0)
      height = FONT_HEIGHT (font) * NUMVAL (prop);
***************
*** 17963,17976 ****
        }
        else if (it->char_to_display == '\t')
        {
!         int tab_width = it->tab_width * CANON_X_UNIT (it->f);
          int x = it->current_x + it->continuation_lines_width;
          int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
  
          /* If the distance from the current position to the next tab
             stop is less than a canonical character width, use the
             tab stop after that.  */
!         if (next_tab_x - x < CANON_X_UNIT (it->f))
            next_tab_x += tab_width;
  
          it->pixel_width = next_tab_x - x;
--- 17964,17977 ----
        }
        else if (it->char_to_display == '\t')
        {
!         int tab_width = it->tab_width * FRAME_COLUMN_WIDTH (it->f);
          int x = it->current_x + it->continuation_lines_width;
          int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
  
          /* If the distance from the current position to the next tab
             stop is less than a canonical character width, use the
             tab stop after that.  */
!         if (next_tab_x - x < FRAME_COLUMN_WIDTH (it->f))
            next_tab_x += tab_width;
  
          it->pixel_width = next_tab_x - x;
***************
*** 18005,18011 ****
              int charset = CHAR_CHARSET (it->char_to_display);
  
              it->glyph_not_available_p = 1;
!             it->pixel_width = (FONT_WIDTH (FRAME_FONT (it->f))
                                 * CHARSET_WIDTH (charset));
              it->phys_ascent = FONT_BASE (font) + boff;
              it->phys_descent = FONT_DESCENT (font) - boff;
--- 18006,18012 ----
              int charset = CHAR_CHARSET (it->char_to_display);
  
              it->glyph_not_available_p = 1;
!             it->pixel_width = (FRAME_COLUMN_WIDTH (it->f)
                                 * CHARSET_WIDTH (charset));
              it->phys_ascent = FONT_BASE (font) + boff;
              it->phys_descent = FONT_DESCENT (font) - boff;
***************
*** 18461,18472 ****
    f = XFRAME (w->frame);
  
    if (updated_row->full_width_p)
!     {
!       max_x = XFASTINT (w->width) * CANON_X_UNIT (f);
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)
!         && !w->pseudo_window_p)
!       max_x += FRAME_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f);
!     }
    else
      max_x = window_box_width (w, updated_area);
    max_y = window_text_bottom_y (w);
--- 18462,18468 ----
    f = XFRAME (w->frame);
  
    if (updated_row->full_width_p)
!     max_x = WINDOW_TOTAL_WIDTH (w);
    else
      max_x = window_box_width (w, updated_area);
    max_y = window_text_bottom_y (w);
***************
*** 18499,18509 ****
      }
    else
      {
!       from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);
!       to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);
      }
  
!   min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
  
--- 18495,18506 ----
      }
    else
      {
!       int area_left = window_box_left (w, updated_area);
!       from_x += area_left;
!       to_x += area_left;
      }
  
!   min_y = WINDOW_HEADER_LINE_HEIGHT (w);
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
  
***************
*** 18789,18801 ****
  
    BLOCK_INPUT;
  
!   if (area == LEFT_MARGIN_AREA)
!     x = 0;
!   else if (area == TEXT_AREA)
!     x = row->x + window_box_width (w, LEFT_MARGIN_AREA);
!   else
!     x = (window_box_width (w, LEFT_MARGIN_AREA)
!        + window_box_width (w, TEXT_AREA));
  
    for (i = 0; i < row->used[area];)
      {
--- 18786,18794 ----
  
    BLOCK_INPUT;
  
!   x = window_box_left_offset (w, area);
!   if (area == TEXT_AREA)
!     x += row->x;
  
    for (i = 0; i < row->used[area];)
      {
***************
*** 18934,18940 ****
    if (w->phys_cursor_type == HOLLOW_BOX_CURSOR)
      {
        int x, y;
!       int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
  
        cursor_glyph = get_phys_cursor_glyph (w);
        if (cursor_glyph == NULL)
--- 18927,18933 ----
    if (w->phys_cursor_type == HOLLOW_BOX_CURSOR)
      {
        int x, y;
!       int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
  
        cursor_glyph = get_phys_cursor_glyph (w);
        if (cursor_glyph == NULL)
***************
*** 19600,19606 ****
      }
  
    /* Which window is that in?  */
!   window = window_from_coordinates (f, x, y, &part, 1);
  
    /* If we were displaying active text in another window, clear that.  */
    if (! EQ (window, dpyinfo->mouse_face_window))
--- 19593,19599 ----
      }
  
    /* Which window is that in?  */
!   window = window_from_coordinates (f, x, y, &part, 0, 0, 1);
  
    /* If we were displaying active text in another window, clear that.  */
    if (! EQ (window, dpyinfo->mouse_face_window))
***************
*** 20084,20096 ****
        /* Set START_X to the window-relative start position for drawing glyphs 
of
         AREA.  The first glyph of the text area can be partially visible.
         The first glyphs of other areas cannot.  */
!       if (area == LEFT_MARGIN_AREA)
!       start_x = 0;
!       else if (area == TEXT_AREA)
!       start_x = row->x + window_box_width (w, LEFT_MARGIN_AREA);
!       else
!       start_x = (window_box_width (w, LEFT_MARGIN_AREA)
!                  + window_box_width (w, TEXT_AREA));
        x = start_x;
  
        /* Find the first glyph that must be redrawn.  */
--- 20077,20085 ----
        /* Set START_X to the window-relative start position for drawing glyphs 
of
         AREA.  The first glyph of the text area can be partially visible.
         The first glyphs of other areas cannot.  */
!       start_x = window_box_left_offset (w, area);
!       if (area == TEXT_AREA)
!       start_x += row->x;
        x = start_x;
  
        /* Find the first glyph that must be redrawn.  */
***************
*** 20220,20240 ****
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
  
    /* Redraw borders between horizontally adjacent windows.  Don't
       do it for frames with vertical scroll bars because either the
       right scroll bar of a window, or the left scroll bar of its
       neighbor will suffice as a border.  */
    if (!WINDOW_RIGHTMOST_P (w)
!       && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))
      {
        int x0, x1, y0, y1;
  
        window_box_edges (w, -1, &x0, &y0, &x1, &y1);
-       x1 += FRAME_X_RIGHT_FRINGE_WIDTH (f);
        y1 -= 1;
  
        rif->draw_vertical_window_border (w, x1, y0, y1);
      }
  }
  
  
--- 20209,20242 ----
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
  
+   /* We could do better, if we knew what type of scroll-bar the adjacent
+      windows (on either side) have...  But we don't :-( 
+      However, I think this works ok.  ++KFS 2003-04-25 */
+ 
    /* Redraw borders between horizontally adjacent windows.  Don't
       do it for frames with vertical scroll bars because either the
       right scroll bar of a window, or the left scroll bar of its
       neighbor will suffice as a border.  */
    if (!WINDOW_RIGHTMOST_P (w)
!       && !WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      {
        int x0, x1, y0, y1;
  
        window_box_edges (w, -1, &x0, &y0, &x1, &y1);
        y1 -= 1;
  
        rif->draw_vertical_window_border (w, x1, y0, y1);
      }
+   else if (!WINDOW_LEFTMOST_P (w)
+          && !WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
+     {
+       int x0, x1, y0, y1;
+ 
+       window_box_edges (w, -1, &x0, &y0, &x1, &y1);
+       y1 -= 1;
+ 
+       rif->draw_vertical_window_border (w, x0, y0, y1);
+     }
  }
  
  
***************
*** 20269,20278 ****
      }
  
    /* Frame-relative pixel rectangle of W.  */
!   wr.x = XFASTINT (w->left) * CANON_X_UNIT (f);
!   wr.y = XFASTINT (w->top) * CANON_Y_UNIT (f);
!   wr.width = XFASTINT (w->width) * CANON_X_UNIT (f);
!   wr.height = XFASTINT (w->height) * CANON_Y_UNIT (f);
  
    if (x_intersect_rectangles (fr, &wr, &r))
      {
--- 20271,20280 ----
      }
  
    /* Frame-relative pixel rectangle of W.  */
!   wr.x = WINDOW_LEFT_EDGE_X (w);
!   wr.y = WINDOW_TOP_EDGE_Y (w);
!   wr.width = WINDOW_TOTAL_WIDTH (w);
!   wr.height = WINDOW_TOTAL_HEIGHT (w);
  
    if (x_intersect_rectangles (fr, &wr, &r))
      {
***************
*** 20447,20454 ****
    if (w == 0 || h == 0)
      {
        r.x = r.y = 0;
!       r.width = CANON_X_UNIT (f) * f->width;
!       r.height = CANON_Y_UNIT (f) * f->height;
      }
    else
      {
--- 20449,20456 ----
    if (w == 0 || h == 0)
      {
        r.x = r.y = 0;
!       r.width = FRAME_COLUMN_WIDTH (f) * FRAME_COLS (f);
!       r.height = FRAME_LINE_HEIGHT (f) * FRAME_LINES (f);
      }
    else
      {
***************
*** 21013,21027 ****
        struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (root_window)));
        int i;
  
!       XWINDOW (root_window)->top = make_number (FRAME_TOP_MARGIN (f));
        set_window_height (root_window,
!                        FRAME_HEIGHT (f) - 1 - FRAME_TOP_MARGIN (f),
                         0);
!       mini_w->top = make_number (FRAME_HEIGHT (f) - 1);
        set_window_height (minibuf_window, 1, 0);
  
!       XWINDOW (root_window)->width = make_number (FRAME_WIDTH (f));
!       mini_w->width = make_number (FRAME_WIDTH (f));
  
        scratch_glyph_row.glyphs[TEXT_AREA] = scratch_glyphs;
        scratch_glyph_row.glyphs[TEXT_AREA + 1]
--- 21015,21029 ----
        struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (root_window)));
        int i;
  
!       XWINDOW (root_window)->top_line = make_number (FRAME_TOP_MARGIN (f));
        set_window_height (root_window,
!                        FRAME_LINES (f) - 1 - FRAME_TOP_MARGIN (f),
                         0);
!       mini_w->top_line = make_number (FRAME_LINES (f) - 1);
        set_window_height (minibuf_window, 1, 0);
  
!       XWINDOW (root_window)->total_cols = make_number (FRAME_COLS (f));
!       mini_w->total_cols = make_number (FRAME_COLS (f));
  
        scratch_glyph_row.glyphs[TEXT_AREA] = scratch_glyphs;
        scratch_glyph_row.glyphs[TEXT_AREA + 1]
Index: xfaces.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xfaces.c,v
retrieving revision 1.274
diff -c -r1.274 xfaces.c
*** xfaces.c    9 Apr 2003 07:26:59 -0000       1.274
--- xfaces.c    14 May 2003 21:52:41 -0000
***************
*** 228,237 ****
  #define check_x check_w32
  #define x_list_fonts w32_list_fonts
  #define GCGraphicsExposures 0
- /* For historic reasons, FONT_WIDTH refers to average width on W32,
-    not maximum as on X. Redefine here. */
- #undef FONT_WIDTH
- #define FONT_WIDTH FONT_MAX_WIDTH
  #endif /* WINDOWSNT */
  
  #ifdef MAC_OS
--- 228,233 ----
***************
*** 1215,1244 ****
  
  
  /***********************************************************************
-                        Minimum font bounds
-  ***********************************************************************/
- 
- #ifdef HAVE_WINDOW_SYSTEM
- 
- /* Update the line_height of frame F.  Return non-zero if line height
-    changes.  */
- 
- int
- frame_update_line_height (f)
-      struct frame *f;
- {
-   int line_height, changed_p;
- 
-   line_height = FONT_HEIGHT (FRAME_FONT (f));
-   changed_p = line_height != FRAME_LINE_HEIGHT (f);
-   FRAME_LINE_HEIGHT (f) = line_height;
-   return changed_p;
- }
- 
- #endif /* HAVE_WINDOW_SYSTEM */
- 
- 
- /***********************************************************************
                                Fonts
   ***********************************************************************/
  
--- 1211,1216 ----
***************
*** 2963,2972 ****
                           ? NULL
                           : FACE_FROM_ID (f, face_id));
  
        if (face && face->font)
        size = FONT_WIDTH (face->font);
        else
!       size = FONT_WIDTH (FRAME_FONT (f));
  
        if (!NILP (width))
        size *= XINT (width);
--- 2935,2951 ----
                           ? NULL
                           : FACE_FROM_ID (f, face_id));
  
+ #ifdef WINDOWSNT
+ /* For historic reasons, FONT_WIDTH refers to average width on W32,
+    not maximum as on X.  Redefine here. */
+ #undef FONT_WIDTH
+ #define FONT_WIDTH FONT_MAX_WIDTH
+ #endif
+ 
        if (face && face->font)
        size = FONT_WIDTH (face->font);
        else
!       size = FONT_WIDTH (FRAME_FONT (f));  /* FRAME_COLUMN_WIDTH (f) */
  
        if (!NILP (width))
        size *= XINT (width);
Index: xfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xfns.c,v
retrieving revision 1.578
diff -c -r1.578 xfns.c
*** xfns.c      1 Apr 2003 10:04:38 -0000       1.578
--- xfns.c      14 May 2003 21:52:44 -0000
***************
*** 859,865 ****
  
                                   /* Child of win.  */
                                   &child);
!     }
  
        had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
      }
--- 859,865 ----
  
                                   /* Child of win.  */
                                   &child);
!       }
  
        had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
      }
***************
*** 870,879 ****
  
    if (had_errors) return;
  
!   f->output_data.x->x_pixels_diff = -win_x;
!   f->output_data.x->y_pixels_diff = -win_y;
!   f->output_data.x->x_pixels_outer_diff = -outer_x;
!   f->output_data.x->y_pixels_outer_diff = -outer_y;
  
    *xptr = real_x;
    *yptr = real_y;
--- 870,880 ----
  
    if (had_errors) return;
  
!   f->x_pixels_diff = -win_x;
!   f->y_pixels_diff = -win_y;
! 
!   FRAME_X_OUTPUT (f)->x_pixels_outer_diff = -outer_x;
!   FRAME_X_OUTPUT (f)->y_pixels_outer_diff = -outer_y;
  
    *xptr = real_x;
    *yptr = real_y;
***************
*** 1296,1302 ****
    unload_color (f, f->output_data.x->border_pixel);
    f->output_data.x->border_pixel = pix;
  
!   if (FRAME_X_WINDOW (f) != 0 && f->output_data.x->border_width > 0)
      {
        BLOCK_INPUT;
        XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
--- 1297,1303 ----
    unload_color (f, f->output_data.x->border_pixel);
    f->output_data.x->border_pixel = pix;
  
!   if (FRAME_X_WINDOW (f) != 0 && f->border_width > 0)
      {
        BLOCK_INPUT;
        XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
***************
*** 1519,1525 ****
  
    /* Don't resize the tool-bar to more than we have room for.  */
    root_window = FRAME_ROOT_WINDOW (f);
!   root_height = XINT (XWINDOW (root_window)->height);
    if (root_height - delta < 1)
      {
        delta = root_height - 1;
--- 1520,1526 ----
  
    /* Don't resize the tool-bar to more than we have room for.  */
    root_window = FRAME_ROOT_WINDOW (f);
!   root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
    if (root_height - delta < 1)
      {
        delta = root_height - 1;
***************
*** 1550,1557 ****
    if (delta < 0)
      {
        int height = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int width = PIXEL_WIDTH (f);
!       int y = nlines * CANON_Y_UNIT (f);
  
        BLOCK_INPUT;
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
--- 1551,1558 ----
    if (delta < 0)
      {
        int height = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int width = FRAME_PIXEL_WIDTH (f);
!       int y = nlines * FRAME_LINE_HEIGHT (f);
  
        BLOCK_INPUT;
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
***************
*** 1956,1976 ****
  x_set_scroll_bar_default_width (f)
       struct frame *f;
  {
!   int wid = FONT_WIDTH (f->output_data.x->font);
  
  #ifdef USE_TOOLKIT_SCROLL_BARS
    /* A minimum width of 14 doesn't look good for toolkit scroll bars.  */
    int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;
!   FRAME_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;
!   FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width;
  #else
    /* Make the actual width at least 14 pixels and a multiple of a
       character width.  */
!   FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
  
    /* Use all of that space (aside from required margins) for the
       scroll bar.  */
!   FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
  #endif
  }
  
--- 1957,1977 ----
  x_set_scroll_bar_default_width (f)
       struct frame *f;
  {
!   int wid = FRAME_COLUMN_WIDTH (f);
  
  #ifdef USE_TOOLKIT_SCROLL_BARS
    /* A minimum width of 14 doesn't look good for toolkit scroll bars.  */
    int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;
!   FRAME_CONFIG_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;
!   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = width;
  #else
    /* Make the actual width at least 14 pixels and a multiple of a
       character width.  */
!   FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
  
    /* Use all of that space (aside from required margins) for the
       scroll bar.  */
!   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 0;
  #endif
  }
  
***************
*** 2369,2376 ****
  
    area.width  = needed->width;
    area.height = needed->height;
!   area.x = PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
!   area.y = (PIXEL_HEIGHT (f) - area.height
            - FRAME_MENUBAR_HEIGHT (f)
            - FRAME_TOOLBAR_HEIGHT (f)
              - FRAME_INTERNAL_BORDER_WIDTH (f));
--- 2370,2377 ----
  
    area.width  = needed->width;
    area.height = needed->height;
!   area.x = FRAME_PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH 
(f);
!   area.y = (FRAME_PIXEL_HEIGHT (f) - area.height
            - FRAME_MENUBAR_HEIGHT (f)
            - FRAME_TOOLBAR_HEIGHT (f)
              - FRAME_INTERNAL_BORDER_WIDTH (f));
***************
*** 2448,2454 ****
    XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
    XtSetArg (al[ac], XtNinput, 1); ac++;
    XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
!   XtSetArg (al[ac], XtNborderWidth, f->output_data.x->border_width); ac++;
    XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
    XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
    XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
--- 2449,2455 ----
    XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
    XtSetArg (al[ac], XtNinput, 1); ac++;
    XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
!   XtSetArg (al[ac], XtNborderWidth, f->border_width); ac++;
    XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
    XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
    XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
***************
*** 2533,2541 ****
         is a user-specified or program-specified one.
         We pass that information later, in x_wm_set_size_hints.  */
      {
!       int left = f->output_data.x->left_pos;
        int xneg = window_prompting & XNegative;
!       int top = f->output_data.x->top_pos;
        int yneg = window_prompting & YNegative;
        if (xneg)
        left = -left;
--- 2534,2542 ----
         is a user-specified or program-specified one.
         We pass that information later, in x_wm_set_size_hints.  */
      {
!       int left = f->left_pos;
        int xneg = window_prompting & XNegative;
!       int top = f->top_pos;
        int yneg = window_prompting & YNegative;
        if (xneg)
        left = -left;
***************
*** 2544,2557 ****
  
        if (window_prompting & USPosition)
        sprintf (shell_position, "=%dx%d%c%d%c%d",
!                PIXEL_WIDTH (f) + extra_borders,
!                PIXEL_HEIGHT (f) + menubar_size + extra_borders,
                 (xneg ? '-' : '+'), left,
                 (yneg ? '-' : '+'), top);
        else
        sprintf (shell_position, "=%dx%d",
!                PIXEL_WIDTH (f) + extra_borders,
!                PIXEL_HEIGHT (f) + menubar_size + extra_borders);
      }
  
      len = strlen (shell_position) + 1;
--- 2545,2558 ----
  
        if (window_prompting & USPosition)
        sprintf (shell_position, "=%dx%d%c%d%c%d",
!                FRAME_PIXEL_WIDTH (f) + extra_borders,
!                FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders,
                 (xneg ? '-' : '+'), left,
                 (yneg ? '-' : '+'), top);
        else
        sprintf (shell_position, "=%dx%d",
!                FRAME_PIXEL_WIDTH (f) + extra_borders,
!                FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders);
      }
  
      len = strlen (shell_position) + 1;
***************
*** 2711,2720 ****
    FRAME_X_WINDOW (f)
      = XCreateWindow (FRAME_X_DISPLAY (f),
                     f->output_data.x->parent_desc,
!                    f->output_data.x->left_pos,
!                    f->output_data.x->top_pos,
!                    PIXEL_WIDTH (f), PIXEL_HEIGHT (f),
!                    f->output_data.x->border_width,
                     CopyFromParent, /* depth */
                     InputOutput, /* class */
                     FRAME_X_VISUAL (f),
--- 2712,2721 ----
    FRAME_X_WINDOW (f)
      = XCreateWindow (FRAME_X_DISPLAY (f),
                     f->output_data.x->parent_desc,
!                    f->left_pos,
!                    f->top_pos,
!                    FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f),
!                    f->border_width,
                     CopyFromParent, /* depth */
                     InputOutput, /* class */
                     FRAME_X_VISUAL (f),
***************
*** 2858,2864 ****
       Note that many default values are used.  */
  
    /* Normal video */
!   gc_values.font = f->output_data.x->font->fid;
    gc_values.foreground = f->output_data.x->foreground_pixel;
    gc_values.background = f->output_data.x->background_pixel;
    gc_values.line_width = 0;   /* Means 1 using fast algorithm.  */
--- 2859,2865 ----
       Note that many default values are used.  */
  
    /* Normal video */
!   gc_values.font = FRAME_FONT (f)->fid;
    gc_values.foreground = f->output_data.x->foreground_pixel;
    gc_values.background = f->output_data.x->background_pixel;
    gc_values.line_width = 0;   /* Means 1 using fast algorithm.  */
***************
*** 3064,3070 ****
    f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
    bzero (f->output_data.x, sizeof (struct x_output));
    f->output_data.x->icon_bitmap = -1;
!   f->output_data.x->fontset = -1;
    f->output_data.x->scroll_bar_foreground_pixel = -1;
    f->output_data.x->scroll_bar_background_pixel = -1;
  #ifdef USE_TOOLKIT_SCROLL_BARS
--- 3065,3071 ----
    f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
    bzero (f->output_data.x, sizeof (struct x_output));
    f->output_data.x->icon_bitmap = -1;
!   FRAME_FONTSET (f) = -1;
    f->output_data.x->scroll_bar_foreground_pixel = -1;
    f->output_data.x->scroll_bar_background_pixel = -1;
  #ifdef USE_TOOLKIT_SCROLL_BARS
***************
*** 3192,3198 ****
  #ifdef USE_LUCID
    /* Prevent lwlib/xlwmenu.c from crashing because of a bug
       whereby it fails to get any font.  */
!   xlwmenu_default_font = f->output_data.x->font;
  #endif
  
    x_default_parameter (f, parms, Qborder_width, make_number (2),
--- 3193,3199 ----
  #ifdef USE_LUCID
    /* Prevent lwlib/xlwmenu.c from crashing because of a bug
       whereby it fails to get any font.  */
!   xlwmenu_default_font = FRAME_FONT (f);
  #endif
  
    x_default_parameter (f, parms, Qborder_width, make_number (2),
***************
*** 3304,3317 ****
                       "scrollBarWidth", "ScrollBarWidth",
                       RES_TYPE_NUMBER);
  
!   /* Dimensions, especially f->height, must be done via change_frame_size.
       Change will not be effected unless different from the current
!      f->height.  */
!   width = f->width;
!   height = f->height;
  
!   f->height = 0;
!   SET_FRAME_WIDTH (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Set up faces after all frame parameters are known.  This call
--- 3305,3318 ----
                       "scrollBarWidth", "ScrollBarWidth",
                       RES_TYPE_NUMBER);
  
!   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
       Change will not be effected unless different from the current
!      FRAME_LINES (f).  */
!   width = FRAME_COLS (f);
!   height = FRAME_LINES (f);
  
!   SET_FRAME_COLS (f, 0);
!   FRAME_LINES (f) = 0;
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Set up faces after all frame parameters are known.  This call
***************
*** 3762,3789 ****
  x_pixel_width (f)
       register struct frame *f;
  {
!   return PIXEL_WIDTH (f);
  }
  
  int
  x_pixel_height (f)
       register struct frame *f;
  {
!   return PIXEL_HEIGHT (f);
  }
  
  int
  x_char_width (f)
       register struct frame *f;
  {
!   return FONT_WIDTH (f->output_data.x->font);
  }
  
  int
  x_char_height (f)
       register struct frame *f;
  {
!   return f->output_data.x->line_height;
  }
  
  int
--- 3763,3790 ----
  x_pixel_width (f)
       register struct frame *f;
  {
!   return FRAME_PIXEL_WIDTH (f);
  }
  
  int
  x_pixel_height (f)
       register struct frame *f;
  {
!   return FRAME_PIXEL_HEIGHT (f);
  }
  
  int
  x_char_width (f)
       register struct frame *f;
  {
!   return FRAME_COLUMN_WIDTH (f);
  }
  
  int
  x_char_height (f)
       register struct frame *f;
  {
!   return FRAME_LINE_HEIGHT (f);
  }
  
  int
***************
*** 4474,4481 ****
        int height = img->height + 2 * img->vmargin;
  
        if (NILP (pixels))
!       size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
!                     make_float ((double) height / CANON_Y_UNIT (f)));
        else
        size = Fcons (make_number (width), make_number (height));
      }
--- 4475,4482 ----
        int height = img->height + 2 * img->vmargin;
  
        if (NILP (pixels))
!       size = Fcons (make_float ((double) width / FRAME_COLUMN_WIDTH (f)),
!                     make_float ((double) height / FRAME_LINE_HEIGHT (f)));
        else
        size = Fcons (make_number (width), make_number (height));
      }
***************
*** 9631,9637 ****
    XSETFRAME (frame, f);
  
    buffer = Fget_buffer_create (build_string (" *tip*"));
!   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer);
    old_buffer = current_buffer;
    set_buffer_internal_1 (XBUFFER (buffer));
    current_buffer->truncate_lines = Qnil;
--- 9632,9638 ----
    XSETFRAME (frame, f);
  
    buffer = Fget_buffer_create (build_string (" *tip*"));
!   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
    old_buffer = current_buffer;
    set_buffer_internal_1 (XBUFFER (buffer));
    current_buffer->truncate_lines = Qnil;
***************
*** 9650,9656 ****
    f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
    bzero (f->output_data.x, sizeof (struct x_output));
    f->output_data.x->icon_bitmap = -1;
!   f->output_data.x->fontset = -1;
    f->output_data.x->scroll_bar_foreground_pixel = -1;
    f->output_data.x->scroll_bar_background_pixel = -1;
  #ifdef USE_TOOLKIT_SCROLL_BARS
--- 9651,9657 ----
    f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
    bzero (f->output_data.x, sizeof (struct x_output));
    f->output_data.x->icon_bitmap = -1;
!   FRAME_FONTSET (f) = -1;
    f->output_data.x->scroll_bar_foreground_pixel = -1;
    f->output_data.x->scroll_bar_background_pixel = -1;
  #ifdef USE_TOOLKIT_SCROLL_BARS
***************
*** 9831,9843 ****
    x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
  
!   /* Dimensions, especially f->height, must be done via change_frame_size.
       Change will not be effected unless different from the current
!      f->height.  */
!   width = f->width;
!   height = f->height;
!   f->height = 0;
!   SET_FRAME_WIDTH (f, 0);
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Add `tooltip' frame parameter's default value. */
--- 9832,9844 ----
    x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
  
!   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
       Change will not be effected unless different from the current
!      FRAME_LINES (f).  */
!   width = FRAME_COLS (f);
!   height = FRAME_LINES (f);
!   SET_FRAME_COLS (f, 0);
!   FRAME_LINES (f) = 0;
    change_frame_size (f, height, width, 1, 0, 0);
  
    /* Add `tooltip' frame parameter's default value. */
***************
*** 10026,10033 ****
            }
  
          BLOCK_INPUT;
!         compute_tip_xy (f, parms, dx, dy, PIXEL_WIDTH (f),
!                         PIXEL_HEIGHT (f), &root_x, &root_y);
          XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                       root_x, root_y);
          UNBLOCK_INPUT;
--- 10027,10034 ----
            }
  
          BLOCK_INPUT;
!         compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
!                         FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
          XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                       root_x, root_y);
          UNBLOCK_INPUT;
***************
*** 10062,10068 ****
  
    /* Set up the frame's root window.  */
    w = XWINDOW (FRAME_ROOT_WINDOW (f));
!   w->left = w->top = make_number (0);
  
    if (CONSP (Vx_max_tooltip_size)
        && INTEGERP (XCAR (Vx_max_tooltip_size))
--- 10063,10069 ----
  
    /* Set up the frame's root window.  */
    w = XWINDOW (FRAME_ROOT_WINDOW (f));
!   w->left_col = w->top_line = make_number (0);
  
    if (CONSP (Vx_max_tooltip_size)
        && INTEGERP (XCAR (Vx_max_tooltip_size))
***************
*** 10070,10085 ****
        && INTEGERP (XCDR (Vx_max_tooltip_size))
        && XINT (XCDR (Vx_max_tooltip_size)) > 0)
      {
!       w->width = XCAR (Vx_max_tooltip_size);
!       w->height = XCDR (Vx_max_tooltip_size);
      }
    else
      {
!       w->width = make_number (80);
!       w->height = make_number (40);
      }
  
!   f->window_width = XINT (w->width);
    adjust_glyphs (f);
    w->pseudo_window_p = 1;
  
--- 10071,10086 ----
        && INTEGERP (XCDR (Vx_max_tooltip_size))
        && XINT (XCDR (Vx_max_tooltip_size)) > 0)
      {
!       w->total_cols = XCAR (Vx_max_tooltip_size);
!       w->total_lines = XCDR (Vx_max_tooltip_size);
      }
    else
      {
!       w->total_cols = make_number (80);
!       w->total_lines = make_number (40);
      }
  
!   FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
    adjust_glyphs (f);
    w->pseudo_window_p = 1;
  
Index: xmenu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xmenu.c,v
retrieving revision 1.246
diff -c -r1.246 xmenu.c
*** xmenu.c     10 May 2003 16:14:35 -0000      1.246
--- xmenu.c     14 May 2003 21:52:45 -0000
***************
*** 709,718 ****
  
    /* xmenu_show expects window coordinates, not root window
       coordinates.  Translate.  */
!   *x -= f->output_data.x->left_pos
!     + FRAME_OUTER_TO_INNER_DIFF_X (f);
!   *y -= f->output_data.x->top_pos
!     + FRAME_OUTER_TO_INNER_DIFF_Y (f);
  }
  
  #endif /* HAVE_X_WINDOWS */
--- 709,716 ----
  
    /* xmenu_show expects window coordinates, not root window
       coordinates.  Translate.  */
!   *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
!   *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
  }
  
  #endif /* HAVE_X_WINDOWS */
***************
*** 861,870 ****
          CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
  
!         xpos = (FONT_WIDTH (FRAME_FONT (f))
!                 * XFASTINT (XWINDOW (window)->left));
!         ypos = (FRAME_LINE_HEIGHT (f)
!                 * XFASTINT (XWINDOW (window)->top));
        }
        else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
--- 859,866 ----
          CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
  
!         xpos = WINDOW_LEFT_EDGE_X (XWINDOW (window));
!         ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
        }
        else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
***************
*** 1779,1786 ****
    BLOCK_INPUT;
    /* Save the size of the frame because the pane widget doesn't accept
       to resize itself. So force it.  */
!   columns = f->width;
!   rows = f->height;
  
    /* Do the voodoo which means "I'm changing lots of things, don't try
       to refigure sizes until I'm done."  */
--- 1775,1782 ----
    BLOCK_INPUT;
    /* Save the size of the frame because the pane widget doesn't accept
       to resize itself. So force it.  */
!   columns = FRAME_COLS (f);
!   rows = FRAME_LINES (f);
  
    /* Do the voodoo which means "I'm changing lots of things, don't try
       to refigure sizes until I'm done."  */
***************
*** 2314,2321 ****
        pos_func = menu_position_func;
  
        /* Adjust coordinates to be root-window-relative.  */
!       x += f->output_data.x->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
!       y += f->output_data.x->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
  
        popup_x_y.x = x;
        popup_x_y.y = y;
--- 2310,2317 ----
        pos_func = menu_position_func;
  
        /* Adjust coordinates to be root-window-relative.  */
!       x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
!       y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
  
        popup_x_y.x = x;
        popup_x_y.y = y;
***************
*** 2402,2409 ****
    dummy.y = y;
  
    /* Adjust coordinates to be root-window-relative.  */
!   x += f->output_data.x->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
!   y += f->output_data.x->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
  
    dummy.x_root = x;
    dummy.y_root = y;
--- 2398,2405 ----
    dummy.y = y;
  
    /* Adjust coordinates to be root-window-relative.  */
!   x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
!   y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
  
    dummy.x_root = x;
    dummy.y_root = y;
***************
*** 3120,3127 ****
  #endif /* HAVE_X_WINDOWS */
  
    /* Adjust coordinates to be root-window-relative.  */
!   x += f->output_data.x->left_pos;
!   y += f->output_data.x->top_pos;
  
    /* Create all the necessary panes and their items.  */
    i = 0;
--- 3116,3123 ----
  #endif /* HAVE_X_WINDOWS */
  
    /* Adjust coordinates to be root-window-relative.  */
!   x += f->left_pos;
!   y += f->top_pos;
  
    /* Create all the necessary panes and their items.  */
    i = 0;
Index: xterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.c,v
retrieving revision 1.790
diff -c -r1.790 xterm.c
*** xterm.c     9 Apr 2003 16:44:45 -0000       1.790
--- xterm.c     14 May 2003 21:52:47 -0000
***************
*** 344,351 ****
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
  
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
!                              GC, int));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
--- 344,350 ----
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
  
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
***************
*** 673,679 ****
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    0, y, width, height, False);
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                   f->output_data.x->pixel_width - width,
                    y, width, height, False);
        UNBLOCK_INPUT;
      }
--- 672,678 ----
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    0, y, width, height, False);
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                   FRAME_PIXEL_WIDTH (f) - width,
                    y, width, height, False);
        UNBLOCK_INPUT;
      }
***************
*** 692,698 ****
    struct face *face = p->face;
  
    /* Must clip because of partially visible lines.  */
!   x_clip_to_row (w, row, gc, 1);
  
    if (p->bx >= 0)
      {
--- 691,697 ----
    struct face *face = p->face;
  
    /* Must clip because of partially visible lines.  */
!   x_clip_to_row (w, row, gc);
  
    if (p->bx >= 0)
      {
***************
*** 2076,2084 ****
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += FRAME_X_RIGHT_FRINGE_WIDTH (s->f);
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
!       last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
      }
  
    /* The glyph that may have a right box line.  */
--- 2075,2084 ----
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (s->w);
!       if (s->area != RIGHT_MARGIN_AREA
!         || WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
!       last_x += WINDOW_RIGHT_FRINGE_WIDTH (s->w);
      }
  
    /* The glyph that may have a right box line.  */
***************
*** 2466,2472 ****
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (CANON_X_UNIT (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
--- 2466,2472 ----
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (FRAME_COLUMN_WIDTH (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
***************
*** 2819,2830 ****
  
      {
        /* Get the height not including a menu bar widget.  */
!       int height = CHAR_TO_PIXEL_HEIGHT (f, FRAME_HEIGHT (f));
        /* Height of each line to flash.  */
        int flash_height = FRAME_LINE_HEIGHT (f);
        /* These will be the left and right margins of the rectangles.  */
        int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int flash_right = PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f);
  
        int width;
  
--- 2819,2830 ----
  
      {
        /* Get the height not including a menu bar widget.  */
!       int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
        /* Height of each line to flash.  */
        int flash_height = FRAME_LINE_HEIGHT (f);
        /* These will be the left and right margins of the rectangles.  */
        int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH 
(f);
  
        int width;
  
***************
*** 2852,2858 ****
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * CANON_Y_UNIT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
--- 2852,2858 ----
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
***************
*** 2906,2912 ****
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * CANON_Y_UNIT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
--- 2906,2912 ----
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
***************
*** 2998,3005 ****
       without mode lines.  Include in this box the left and right
       fringe of W.  */
    window_box (w, -1, &x, &y, &width, &height);
-   width += FRAME_X_FRINGE_WIDTH (f);
-   x -= FRAME_X_LEFT_FRINGE_WIDTH (f);
  
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->current_y);
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->desired_y);
--- 2998,3003 ----
***************
*** 3574,3588 ****
    Lisp_Object window;
    int found = 0;
  
!   window = window_from_coordinates (f, x, y, 0, 0);
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
-       frame_to_window_pixel_xy (w, &x, &y);
- 
        for (; !found && r < end && r->enabled_p; ++r)
        if (r->y >= y)
          {
--- 3572,3584 ----
    Lisp_Object window;
    int found = 0;
  
!   window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        for (; !found && r < end && r->enabled_p; ++r)
        if (r->y >= y)
          {
***************
*** 3802,3808 ****
                gx = win_x;
                gy = win_y;
  
!               /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
                   round down even for negative values.  */
                if (gx < 0)
                  gx -= width - 1;
--- 3798,3804 ----
                gx = win_x;
                gy = win_y;
  
!               /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
                   round down even for negative values.  */
                if (gx < 0)
                  gx -= width - 1;
***************
*** 4588,4594 ****
       its size, the update will often happen too late.
       If you don't believe it, check out revision 1.650 of xterm.c to see
       what hoops we were going through and the still poor behavior we got.  */
!   portion = XFASTINT (XWINDOW (bar->window)->height) * 30;
    /* When the thumb is at the bottom, position == whole.
       So we need to increase `whole' to make space for the thumb.  */
    whole += portion;
--- 4584,4590 ----
       its size, the update will often happen too late.
       If you don't believe it, check out revision 1.650 of xterm.c to see
       what hoops we were going through and the still poor behavior we got.  */
!   portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30;
    /* When the thumb is at the bottom, position == whole.
       So we need to increase `whole' to make space for the thumb.  */
    whole += portion;
***************
*** 4956,4992 ****
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
!   int window_x, window_y, window_width, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
    top = window_y;
!   width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     left = XINT (w->left) + XINT (w->width) - FRAME_SCROLL_BAR_COLS (f);
!   else
!     left = XFASTINT (w->left);
!   left *= CANON_X_UNIT (f);
!   left += FRAME_INTERNAL_BORDER_WIDTH (f);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0)
!     sb_width = FRAME_SCROLL_BAR_PIXEL_WIDTH (f);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
  #else
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
      sb_left = left + width - sb_width;
    else
      sb_left = left;
--- 4952,4983 ----
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
!   int window_y, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, 0, &window_y, 0, &window_height);
    top = window_y;
!   width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   left = WINDOW_SCROLL_BAR_AREA_X (w);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) > 0)
!     sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
  #else
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width;
    else
      sb_left = left;
***************
*** 5071,5081 ****
         previous mode line display is cleared after C-x 2 C-x 1, for
         example.  */
        {
!       int area_width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
        int rest = area_width - sb_width;
        if (rest > 0 && height > 0)
          {
!           if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
              x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                            left + area_width -  rest, top,
                            rest, height, False);
--- 5062,5072 ----
         previous mode line display is cleared after C-x 2 C-x 1, for
         example.  */
        {
!       int area_width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH 
(f);
        int rest = area_width - sb_width;
        if (rest > 0 && height > 0)
          {
!           if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
              x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                            left + area_width -  rest, top,
                            rest, height, False);
***************
*** 5862,5869 ****
  
              if (f)
                {
!                 f->output_data.x->left_pos = new_x;
!                 f->output_data.x->top_pos = new_y;
                }
            }
  #ifdef HACK_EDITRES
--- 5853,5860 ----
  
              if (f)
                {
!                 f->left_pos = new_x;
!                 f->top_pos = new_y;
                }
            }
  #ifdef HACK_EDITRES
***************
*** 5990,5997 ****
            int x, y;
            f->output_data.x->parent_desc = event.xreparent.parent;
            x_real_positions (f, &x, &y);
!           f->output_data.x->left_pos = x;
!           f->output_data.x->top_pos = y;
          }
        goto OTHER;
        break;
--- 5981,5988 ----
            int x, y;
            f->output_data.x->parent_desc = event.xreparent.parent;
            x_real_positions (f, &x, &y);
!           f->left_pos = x;
!           f->top_pos = y;
          }
        goto OTHER;
        break;
***************
*** 6010,6018 ****
                SET_FRAME_GARBAGED (f);
              }
            else
!             expose_frame (x_window_to_frame (dpyinfo,
!                                              event.xexpose.window),
!                           event.xexpose.x, event.xexpose.y,
                            event.xexpose.width, event.xexpose.height);
          }
        else
--- 6001,6008 ----
                SET_FRAME_GARBAGED (f);
              }
            else
!             expose_frame (f,
!                         event.xexpose.x, event.xexpose.y,
                            event.xexpose.width, event.xexpose.height);
          }
        else
***************
*** 6657,6663 ****
  
                  window = window_from_coordinates (f,
                                                    event.xmotion.x, 
event.xmotion.y,
!                                                   0, 0);
  
                  /* Window will be selected only when it is not selected now 
and
                     last mouse movement event was not in it.  Minibuffer window
--- 6647,6653 ----
  
                  window = window_from_coordinates (f,
                                                    event.xmotion.x, 
event.xmotion.y,
!                                                   0, 0, 0, 0);
  
                  /* Window will be selected only when it is not selected now 
and
                     last mouse movement event was not in it.  Minibuffer window
***************
*** 6728,6738 ****
               do this one, the right one will come later.
               The toolkit version doesn't seem to need this, but we
               need to reset it below.  */
!           int dont_resize =
!             ((f->output_data.x->want_fullscreen & FULLSCREEN_WAIT)
!              && FRAME_NEW_WIDTH (f) != 0);
!           int rows = PIXEL_TO_CHAR_HEIGHT (f, event.xconfigure.height);
!           int columns = PIXEL_TO_CHAR_WIDTH (f, event.xconfigure.width);
            if (dont_resize)
              goto OTHER;
  
--- 6718,6729 ----
               do this one, the right one will come later.
               The toolkit version doesn't seem to need this, but we
               need to reset it below.  */
!           int dont_resize 
!           = ((f->want_fullscreen & FULLSCREEN_WAIT)
!              && f->new_text_cols != 0);
!           int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, 
event.xconfigure.height);
!           int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, 
event.xconfigure.width);
! 
            if (dont_resize)
              goto OTHER;
  
***************
*** 6743,6752 ****
            /* Even if the number of character rows and columns has
               not changed, the font size may have changed, so we need
               to check the pixel dimensions as well.  */
!           if (columns != f->width
!               || rows != f->height
!               || event.xconfigure.width != f->output_data.x->pixel_width
!               || event.xconfigure.height != f->output_data.x->pixel_height)
              {
                change_frame_size (f, rows, columns, 0, 1, 0);
                SET_FRAME_GARBAGED (f);
--- 6734,6743 ----
            /* Even if the number of character rows and columns has
               not changed, the font size may have changed, so we need
               to check the pixel dimensions as well.  */
!           if (columns != FRAME_COLS (f)
!               || rows != FRAME_LINES (f)
!               || event.xconfigure.width != FRAME_PIXEL_WIDTH (f)
!               || event.xconfigure.height != FRAME_PIXEL_HEIGHT (f))
              {
                change_frame_size (f, rows, columns, 0, 1, 0);
                SET_FRAME_GARBAGED (f);
***************
*** 6755,6782 ****
  #endif /* not USE_GTK */
  #endif
  
!           f->output_data.x->pixel_width = event.xconfigure.width;
!           f->output_data.x->pixel_height = event.xconfigure.height;
  
  #ifdef USE_GTK
            /* GTK creates windows but doesn't map them.
               Only get real positions and check fullscreen when mapped. */
            if (FRAME_GTK_OUTER_WIDGET (f)
                && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f)))
-             {
  #endif
!           /* What we have now is the position of Emacs's own window.
!              Convert that to the position of the window manager window.  */
!           x_real_positions (f, &f->output_data.x->left_pos,
!                             &f->output_data.x->top_pos);
! 
!           x_check_fullscreen_move (f);
!           if (f->output_data.x->want_fullscreen & FULLSCREEN_WAIT)
!             f->output_data.x->want_fullscreen &=
!               ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
! #ifdef USE_GTK
              }
! #endif
  #ifdef HAVE_X_I18N
            if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea))
              xic_set_statusarea (f);
--- 6746,6770 ----
  #endif /* not USE_GTK */
  #endif
  
!           FRAME_PIXEL_WIDTH (f) = event.xconfigure.width;
!           FRAME_PIXEL_HEIGHT (f) = event.xconfigure.height;
  
  #ifdef USE_GTK
            /* GTK creates windows but doesn't map them.
               Only get real positions and check fullscreen when mapped. */
            if (FRAME_GTK_OUTER_WIDGET (f)
                && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f)))
  #endif
!             {
!             /* What we have now is the position of Emacs's own window.
!                Convert that to the position of the window manager window.  */
!             x_real_positions (f, &f->left_pos, &f->top_pos);
! 
!             x_check_fullscreen_move (f);
!             if (f->want_fullscreen & FULLSCREEN_WAIT)
!               f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
              }
! 
  #ifdef HAVE_X_I18N
            if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea))
              xic_set_statusarea (f);
***************
*** 6786,6792 ****
              {
                /* Since the WM decorations come below top_pos now,
                   we must put them below top_pos in the future.  */
!               f->output_data.x->win_gravity = NorthWestGravity;
                x_wm_set_size_hint (f, (long) 0, 0);
              }
          }
--- 6774,6780 ----
              {
                /* Since the WM decorations come below top_pos now,
                   we must put them below top_pos in the future.  */
!               f->win_gravity = NorthWestGravity;
                x_wm_set_size_hint (f, (long) 0, 0);
              }
          }
***************
*** 6814,6826 ****
            {
              /* Is this in the tool-bar?  */
              if (WINDOWP (f->tool_bar_window)
!                 && XFASTINT (XWINDOW (f->tool_bar_window)->height))
                {
                  Lisp_Object window;
                  int x = event.xbutton.x;
                  int y = event.xbutton.y;
  
!                 window = window_from_coordinates (f, x, y, 0, 1);
                  if (EQ (window, f->tool_bar_window))
                    {
                    if (event.xbutton.type == ButtonPress)
--- 6802,6814 ----
            {
              /* Is this in the tool-bar?  */
              if (WINDOWP (f->tool_bar_window)
!                 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
                {
                  Lisp_Object window;
                  int x = event.xbutton.x;
                  int y = event.xbutton.y;
  
!                 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
                  if (EQ (window, f->tool_bar_window))
                    {
                    if (event.xbutton.type == ButtonPress)
***************
*** 6903,6909 ****
              /* Verify the event is really within the menu bar
                 and not just sent to it due to grabbing.  */
              && event.xbutton.x >= 0
!             && event.xbutton.x < f->output_data.x->pixel_width
              && event.xbutton.y >= 0
              && event.xbutton.y < f->output_data.x->menubar_height
              && event.xbutton.same_screen)
--- 6891,6897 ----
              /* Verify the event is really within the menu bar
                 and not just sent to it due to grabbing.  */
              && event.xbutton.x >= 0
!             && event.xbutton.x < FRAME_PIXEL_WIDTH (f)
              && event.xbutton.y >= 0
              && event.xbutton.y < f->output_data.x->menubar_height
              && event.xbutton.same_screen)
***************
*** 7204,7228 ****
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
-    WHOLE_LINE_P non-zero means include the areas used for truncation
-    mark display and alike in the clipping rectangle.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc, whole_line_p)
       struct window *w;
       struct glyph_row *row;
       GC gc;
-      int whole_line_p;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    XRectangle clip_rect;
!   int window_x, window_y, window_width, window_height;
  
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
  
    clip_rect.x = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
--- 7192,7213 ----
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc)
       struct window *w;
       struct glyph_row *row;
       GC gc;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    XRectangle clip_rect;
!   int window_y, window_width;
  
!   window_box (w, -1, 0, &window_y, &window_width, 0);
  
    clip_rect.x = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
***************
*** 7230,7243 ****
    clip_rect.width = window_width;
    clip_rect.height = row->visible_height;
  
-   /* If clipping to the whole line, including trunc marks, extend
-      the rectangle to the left and increase its width.  */
-   if (whole_line_p)
-     {
-       clip_rect.x -= FRAME_X_LEFT_FRINGE_WIDTH (f);
-       clip_rect.width += FRAME_X_FRINGE_WIDTH (f);
-     }
- 
    XSetClipRectangles (FRAME_X_DISPLAY (f), gc, 0, 0, &clip_rect, 1, Unsorted);
  }
  
--- 7215,7220 ----
***************
*** 7277,7283 ****
    wd = cursor_glyph->pixel_width - 1;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (CANON_X_UNIT (f), wd);
    w->phys_cursor_width = wd;
  
    /* The foreground of cursor_gc is typically the same as the normal
--- 7254,7260 ----
    wd = cursor_glyph->pixel_width - 1;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (FRAME_COLUMN_WIDTH (f), wd);
    w->phys_cursor_width = wd;
  
    /* The foreground of cursor_gc is typically the same as the normal
***************
*** 7291,7297 ****
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc, 0);
    XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h);
    XSetClipMask (dpy, gc, None);
  }
--- 7268,7274 ----
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc);
    XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h);
    XSetClipMask (dpy, gc, None);
  }
***************
*** 7363,7369 ****
        width = min (cursor_glyph->pixel_width, width);
  
        w->phys_cursor_width = width;
!       x_clip_to_row (w, row, gc, 0);
  
        if (kind == BAR_CURSOR)
          XFillRectangle (dpy, window, gc,
--- 7340,7346 ----
        width = min (cursor_glyph->pixel_width, width);
  
        w->phys_cursor_width = width;
!       x_clip_to_row (w, row, gc);
  
        if (kind == BAR_CURSOR)
          XFillRectangle (dpy, window, gc,
***************
*** 7882,7927 ****
    if (!fontp)
      return Qnil;
  
!   f->output_data.x->font = (XFontStruct *) (fontp->font);
!   f->output_data.x->baseline_offset = fontp->baseline_offset;
!   f->output_data.x->fontset = -1;
  
    compute_fringe_widths (f, 1);
  
    /* Compute the scroll bar width in character columns.  */
!   if (f->scroll_bar_pixel_width > 0)
      {
!       int wid = FONT_WIDTH (f->output_data.x->font);
!       f->scroll_bar_cols = (f->scroll_bar_pixel_width + wid-1) / wid;
      }
    else
      {
!       int wid = FONT_WIDTH (f->output_data.x->font);
!       f->scroll_bar_cols = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_X_WINDOW (f) != 0)
      {
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
!               f->output_data.x->font->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
!               f->output_data.x->font->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
!               f->output_data.x->font->fid);
! 
!       frame_update_line_height (f);
  
        /* Don't change the size of a tip frame; there's no point in
         doing it because it's done in Fx_show_tip, and it leads to
         problems because the tip frame has no widget.  */
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!       x_set_window_size (f, 0, f->width, f->height);
      }
-   else
-     /* If we are setting a new frame's font for the first time,
-        there are no faces yet, so this font's height is the line height.  */
-     f->output_data.x->line_height = FONT_HEIGHT (f->output_data.x->font);
  
    return build_string (fontp->full_name);
  }
--- 7859,7902 ----
    if (!fontp)
      return Qnil;
  
!   FRAME_FONT (f) = (XFontStruct *) (fontp->font);
!   FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
!   FRAME_FONTSET (f) = -1;
! 
!   FRAME_COLUMN_WIDTH (f) = FONT_WIDTH (FRAME_FONT (f));
!   FRAME_LINE_HEIGHT (f) = FONT_HEIGHT (FRAME_FONT (f));
  
    compute_fringe_widths (f, 1);
  
    /* Compute the scroll bar width in character columns.  */
!   if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f)
!       = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
      }
    else
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_X_WINDOW (f) != 0)
      {
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
!               FRAME_FONT (f)->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
!               FRAME_FONT (f)->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
!               FRAME_FONT (f)->fid);
  
        /* Don't change the size of a tip frame; there's no point in
         doing it because it's done in Fx_show_tip, and it leads to
         problems because the tip frame has no widget.  */
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
      }
  
    return build_string (fontp->full_name);
  }
***************
*** 7942,7948 ****
    if (fontset < 0)
      return Qnil;
  
!   if (f->output_data.x->fontset == fontset)
      /* This fontset is already set in frame F.  There's nothing more
         to do.  */
      return fontset_name (fontset);
--- 7917,7923 ----
    if (fontset < 0)
      return Qnil;
  
!   if (FRAME_FONTSET (f) == fontset)
      /* This fontset is already set in frame F.  There's nothing more
         to do.  */
      return fontset_name (fontset);
***************
*** 7954,7960 ****
      return Qnil;
  
    /* Since x_new_font doesn't update any fontset information, do it now.  */
!   f->output_data.x->fontset = fontset;
  
  #ifdef HAVE_X_I18N
    if (FRAME_XIC (f)
--- 7929,7935 ----
      return Qnil;
  
    /* Since x_new_font doesn't update any fontset information, do it now.  */
!   FRAME_FONTSET (f) = fontset;
  
  #ifdef HAVE_X_I18N
    if (FRAME_XIC (f)
***************
*** 8185,8191 ****
  {
    Window child;
    int win_x = 0, win_y = 0;
!   int flags = f->output_data.x->size_hint_flags;
    int this_window;
  
    /* We have nothing to do if the current position
--- 8160,8166 ----
  {
    Window child;
    int win_x = 0, win_y = 0;
!   int flags = f->size_hint_flags;
    int this_window;
  
    /* We have nothing to do if the current position
***************
*** 8243,8255 ****
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->output_data.x->left_pos = (FRAME_X_DISPLAY_INFO (f)->width
!                                 - 2 * f->output_data.x->border_width - win_x
!                                 - PIXEL_WIDTH (f)
!                                 + f->output_data.x->left_pos);
  
    {
!     int height = PIXEL_HEIGHT (f);
  
  #if defined USE_X_TOOLKIT && defined USE_MOTIF
      /* Something is fishy here.  When using Motif, starting Emacs with
--- 8218,8230 ----
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->left_pos = (FRAME_X_DISPLAY_INFO (f)->width
!                  - 2 * f->border_width - win_x
!                  - FRAME_PIXEL_WIDTH (f)
!                  + f->left_pos);
  
    {
!     int height = FRAME_PIXEL_HEIGHT (f);
  
  #if defined USE_X_TOOLKIT && defined USE_MOTIF
      /* Something is fishy here.  When using Motif, starting Emacs with
***************
*** 8268,8284 ****
  #endif
  
    if (flags & YNegative)
!     f->output_data.x->top_pos = (FRAME_X_DISPLAY_INFO (f)->height
!                                - 2 * f->output_data.x->border_width
!                                - win_y
!                                - height
!                                + f->output_data.x->top_pos);
    }
  
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
--- 8243,8259 ----
  #endif
  
    if (flags & YNegative)
!     f->top_pos = (FRAME_X_DISPLAY_INFO (f)->height
!                 - 2 * f->border_width
!                 - win_y
!                 - height
!                 + f->top_pos);
    }
  
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
***************
*** 8297,8326 ****
  
    if (change_gravity > 0)
      {
!       f->output_data.x->top_pos = yoff;
!       f->output_data.x->left_pos = xoff;
!       f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->output_data.x->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->output_data.x->size_hint_flags |= YNegative;
!       f->output_data.x->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->output_data.x->left_pos;
!   modified_top = f->output_data.x->top_pos;
  #if 0 /* Running on psilocin (Debian), and displaying on the NCD X-terminal,
         this seems to be unnecessary and incorrect.  rms, 4/17/97.  */
    /* It is a mystery why we need to add the border_width here
       when the frame is already visible, but experiment says we do.  */
    if (change_gravity != 0)
      {
!       modified_left += f->output_data.x->border_width;
!       modified_top += f->output_data.x->border_width;
      }
  #endif
  
--- 8272,8301 ----
  
    if (change_gravity > 0)
      {
!       f->top_pos = yoff;
!       f->left_pos = xoff;
!       f->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->size_hint_flags |= YNegative;
!       f->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->left_pos;
!   modified_top = f->top_pos;
  #if 0 /* Running on psilocin (Debian), and displaying on the NCD X-terminal,
         this seems to be unnecessary and incorrect.  rms, 4/17/97.  */
    /* It is a mystery why we need to add the border_width here
       when the frame is already visible, but experiment says we do.  */
    if (change_gravity != 0)
      {
!       modified_left += f->border_width;
!       modified_top += f->border_width;
      }
  #endif
  
***************
*** 8335,8346 ****
  x_check_fullscreen (f)
       struct frame *f;
  {
!   if (f->output_data.x->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
  
!       x_real_positions (f, &f->output_data.x->left_pos,
!                         &f->output_data.x->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
  
--- 8310,8320 ----
  x_check_fullscreen (f)
       struct frame *f;
  {
!   if (f->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
  
!       x_real_positions (f, &f->left_pos, &f->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
  
***************
*** 8348,8361 ****
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
           x_check_fullscreen_move. */
!       if (f->width != width || f->height != height)
          {
            change_frame_size (f, height, width, 0, 1, 0);
            SET_FRAME_GARBAGED (f);
            cancel_mouse_face (f);
  
            /* Wait for the change of frame size to occur */
!           f->output_data.x->want_fullscreen |= FULLSCREEN_WAIT;
          }
      }
  }
--- 8322,8335 ----
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
           x_check_fullscreen_move. */
!       if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
          {
            change_frame_size (f, height, width, 0, 1, 0);
            SET_FRAME_GARBAGED (f);
            cancel_mouse_face (f);
  
            /* Wait for the change of frame size to occur */
!           f->want_fullscreen |= FULLSCREEN_WAIT;
          }
      }
  }
***************
*** 8370,8391 ****
  x_check_fullscreen_move (f)
       struct frame *f;
  {
!   if (f->output_data.x->want_fullscreen & FULLSCREEN_MOVE_WAIT)
    {
!     int expect_top = f->output_data.x->top_pos;
!     int expect_left = f->output_data.x->left_pos;
  
!     if (f->output_data.x->want_fullscreen & FULLSCREEN_HEIGHT)
        expect_top = 0;
!     if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
        expect_left = 0;
  
!     if (expect_top != f->output_data.x->top_pos
!         || expect_left != f->output_data.x->left_pos)
        x_set_offset (f, expect_left, expect_top, 1);
  
      /* Just do this once */
!     f->output_data.x->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
    }
  }
  
--- 8344,8364 ----
  x_check_fullscreen_move (f)
       struct frame *f;
  {
!   if (f->want_fullscreen & FULLSCREEN_MOVE_WAIT)
    {
!     int expect_top = f->top_pos;
!     int expect_left = f->left_pos;
  
!     if (f->want_fullscreen & FULLSCREEN_HEIGHT)
        expect_top = 0;
!     if (f->want_fullscreen & FULLSCREEN_WIDTH)
        expect_left = 0;
  
!     if (expect_top != f->top_pos || expect_left != f->left_pos)
        x_set_offset (f, expect_left, expect_top, 1);
  
      /* Just do this once */
!     f->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
    }
  }
  
***************
*** 8404,8422 ****
    int pixelwidth, pixelheight;
  
    check_frame_size (f, &rows, &cols);
!   f->output_data.x->vertical_scroll_bar_extra
      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
         ? 0
!        : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
!        ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
!        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
  
!   f->output_data.x->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    XSync (FRAME_X_DISPLAY (f), False);
--- 8377,8395 ----
    int pixelwidth, pixelheight;
  
    check_frame_size (f, &rows, &cols);
!   f->scroll_bar_actual_width
      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
         ? 0
!        : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
!        ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)
!        : (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)));
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
  
!   f->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    XSync (FRAME_X_DISPLAY (f), False);
***************
*** 8437,8444 ****
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   PIXEL_WIDTH (f) = pixelwidth;
!   PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
--- 8410,8417 ----
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   FRAME_PIXEL_WIDTH (f) = pixelwidth;
!   FRAME_PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
***************
*** 8512,8525 ****
  {
    int pix_x, pix_y;
  
!   pix_x = CHAR_TO_PIXEL_COL (f, x) + FONT_WIDTH  (f->output_data.x->font) / 2;
!   pix_y = CHAR_TO_PIXEL_ROW (f, y) + f->output_data.x->line_height / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > PIXEL_WIDTH (f)) pix_x = PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > PIXEL_HEIGHT (f)) pix_y = PIXEL_HEIGHT (f);
  
    BLOCK_INPUT;
  
--- 8485,8498 ----
  {
    int pix_x, pix_y;
  
!   pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
!   pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
  
    BLOCK_INPUT;
  
***************
*** 8646,8652 ****
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.x->asked_for_visible)
!       x_set_offset (f, f->output_data.x->left_pos, f->output_data.x->top_pos, 
0);
  
        f->output_data.x->asked_for_visible = 1;
  
--- 8619,8625 ----
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.x->asked_for_visible)
!       x_set_offset (f, f->left_pos, f->top_pos, 0);
  
        f->output_data.x->asked_for_visible = 1;
  
***************
*** 8684,8691 ****
         will set it when they are handled.  */
      int previously_visible = f->output_data.x->has_been_visible;
  
!     original_left = f->output_data.x->left_pos;
!     original_top = f->output_data.x->top_pos;
  
      /* This must come after we set COUNT.  */
      UNBLOCK_INPUT;
--- 8657,8664 ----
         will set it when they are handled.  */
      int previously_visible = f->output_data.x->has_been_visible;
  
!     original_left = f->left_pos;
!     original_top = f->top_pos;
  
      /* This must come after we set COUNT.  */
      UNBLOCK_INPUT;
***************
*** 8702,8708 ****
         and we don't want to override it.  */
  
      if (! FRAME_VISIBLE_P (f) && ! FRAME_ICONIFIED_P (f)
!       && f->output_data.x->win_gravity == NorthWestGravity
        && previously_visible)
        {
        Drawable rootw;
--- 8675,8681 ----
         and we don't want to override it.  */
  
      if (! FRAME_VISIBLE_P (f) && ! FRAME_ICONIFIED_P (f)
!       && f->win_gravity == NorthWestGravity
        && previously_visible)
        {
        Drawable rootw;
***************
*** 8943,8949 ****
    /* Make sure the X server knows where the window should be positioned,
       in case the user deiconifies with the window manager.  */
    if (! FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f))
!     x_set_offset (f, f->output_data.x->left_pos, f->output_data.x->top_pos, 
0);
  
    /* Since we don't know which revision of X we're running, we'll use both
       the X11R3 and X11R4 techniques.  I don't know if this is a good idea.  */
--- 8916,8922 ----
    /* Make sure the X server knows where the window should be positioned,
       in case the user deiconifies with the window manager.  */
    if (! FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f))
!     x_set_offset (f, f->left_pos, f->top_pos, 0);
  
    /* Since we don't know which revision of X we're running, we'll use both
       the X11R3 and X11R4 techniques.  I don't know if this is a good idea.  */
***************
*** 9158,9165 ****
    /* Setting PMaxSize caused various problems.  */
    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
  
!   size_hints.x = f->output_data.x->left_pos;
!   size_hints.y = f->output_data.x->top_pos;
  
  #ifdef USE_X_TOOLKIT
    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
--- 9131,9138 ----
    /* Setting PMaxSize caused various problems.  */
    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
  
!   size_hints.x = f->left_pos;
!   size_hints.y = f->top_pos;
  
  #ifdef USE_X_TOOLKIT
    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
***************
*** 9168,9183 ****
    size_hints.height = widget_height;
    size_hints.width = widget_width;
  #else /* not USE_X_TOOLKIT */
!   size_hints.height = PIXEL_HEIGHT (f);
!   size_hints.width = PIXEL_WIDTH (f);
  #endif /* not USE_X_TOOLKIT */
  
!   size_hints.width_inc = FONT_WIDTH (f->output_data.x->font);
!   size_hints.height_inc = f->output_data.x->line_height;
    size_hints.max_width
!     = FRAME_X_DISPLAY_INFO (f)->width - CHAR_TO_PIXEL_WIDTH (f, 0);
    size_hints.max_height
!     = FRAME_X_DISPLAY_INFO (f)->height - CHAR_TO_PIXEL_HEIGHT (f, 0);
  
    /* Calculate the base and minimum sizes.
  
--- 9141,9156 ----
    size_hints.height = widget_height;
    size_hints.width = widget_width;
  #else /* not USE_X_TOOLKIT */
!   size_hints.height = FRAME_PIXEL_HEIGHT (f);
!   size_hints.width = FRAME_PIXEL_WIDTH (f);
  #endif /* not USE_X_TOOLKIT */
  
!   size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
!   size_hints.height_inc = FRAME_LINE_HEIGHT (f);
    size_hints.max_width
!     = FRAME_X_DISPLAY_INFO (f)->width - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
    size_hints.max_height
!     = FRAME_X_DISPLAY_INFO (f)->height - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 
0);
  
    /* Calculate the base and minimum sizes.
  
***************
*** 9188,9195 ****
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
  
!     base_width = CHAR_TO_PIXEL_WIDTH (f, 0);
!     base_height = CHAR_TO_PIXEL_HEIGHT (f, 0);
  
      check_frame_size (f, &min_rows, &min_cols);
  
--- 9161,9168 ----
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
  
!     base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
!     base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
  
      check_frame_size (f, &min_rows, &min_cols);
  
***************
*** 9264,9270 ****
  #endif
  
  #ifdef PWinGravity
!   size_hints.win_gravity = f->output_data.x->win_gravity;
    size_hints.flags |= PWinGravity;
  
    if (user_position)
--- 9237,9243 ----
  #endif
  
  #ifdef PWinGravity
!   size_hints.win_gravity = f->win_gravity;
    size_hints.flags |= PWinGravity;
  
    if (user_position)
Index: xterm.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.h,v
retrieving revision 1.146
diff -c -r1.146 xterm.h
*** xterm.h     31 Mar 2003 20:36:37 -0000      1.146
--- xterm.h     14 May 2003 21:52:48 -0000
***************
*** 400,415 ****
  
  struct x_output
  {
-   /* Position of the X window (x and y offsets in root window).  */
-   int left_pos;
-   int top_pos;
- 
-   /* Border width of the X window as known by the X window system.  */
-   int border_width;
- 
-   /* Size of the X window in pixels.  */
-   int pixel_height, pixel_width;
- 
    /* Height of menu bar widget, in pixels.
       Zero if not using the X toolkit.
       When using the toolkit, this value is not meaningful
--- 400,405 ----
***************
*** 420,428 ****
       Zero if not using an external tool bar.  */
    int toolbar_height;
  
-   /* Height of a line, in pixels.  */
-   int line_height;
- 
    /* The tiled border used when the mouse is out of the frame.  */
    Pixmap border_tile;
  
--- 410,415 ----
***************
*** 431,441 ****
    GC reverse_gc;                      /* Reverse video */
    GC cursor_gc;                               /* cursor drawing */
  
-   /* Width of the internal border.  This is a line of background color
-      just inside the window's border.  When the frame is selected,
-      a highlighting is displayed inside the internal border.  */
-   int internal_border_width;
- 
    /* The X window used for this frame.
       May be zero while the frame object is being created
       and the X window has not yet been created.  */
--- 418,423 ----
***************
*** 551,572 ****
       to the mask as we go.  */
    XWMHints wm_hints;
  
-   /* The size of the extra width currently allotted for vertical
-      scroll bars, in pixels.  */
-   int vertical_scroll_bar_extra;
- 
-   /* The extra width currently allotted for the areas in which
-      truncation marks, continuation marks, and overlay arrows are
-      displayed.  */
-   int left_fringe_width, right_fringe_width;
-   int fringe_cols, fringes_extra;
- 
-   /* This is the gravity value for the specified window position.  */
-   int win_gravity;
- 
-   /* The geometry flags for this window.  */
-   int size_hint_flags;
- 
    /* This is the Emacs structure for the X display this frame is on.  */
    struct x_display_info *display_info;
  
--- 533,538 ----
***************
*** 616,632 ****
       zero, tell Xt not to wait.  */
    int wait_for_wm;
  
-   /* See enum below */
-   int want_fullscreen;
- 
-   /* This many pixels are the difference between the outer window (i.e. the
-      left of the window manager decoration) and FRAME_X_WINDOW. */
-   int x_pixels_diff;
- 
-   /* This many pixels are the difference between the outer window (i.e. the
-      top of the window manager titlebar) and FRAME_X_WINDOW. */
-   int y_pixels_diff;
- 
    /* As x_pixels_diff, but to FRAME_OUTER_WINDOW.  For some reason the
       two might differ by a pixel, depending on WM */
    int x_pixels_outer_diff;
--- 582,587 ----
***************
*** 688,701 ****
  
  #define FRAME_FONT(f) ((f)->output_data.x->font)
  #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
- #define FRAME_INTERNAL_BORDER_WIDTH(f) 
((f)->output_data.x->internal_border_width)
  #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
  #define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.x->toolbar_height)
- #define FRAME_LINE_HEIGHT(f) ((f)->output_data.x->line_height)
- 
- /* Width of the default font of frame F.  Must be defined by each
-    terminal specific header.  */
- #define FRAME_DEFAULT_FONT_WIDTH(F)   FONT_WIDTH (FRAME_FONT (F))
  #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset)
  
  /* This gives the x_display_info structure for the display F is on.  */
--- 643,650 ----
***************
*** 717,726 ****
  /* This is the 'font_info *' which frame F has.  */
  #define FRAME_X_FONT_TABLE(f) (FRAME_X_DISPLAY_INFO (f)->font_table)
  
- /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}.  */
- #define PIXEL_WIDTH(f) ((f)->output_data.x->pixel_width)
- #define PIXEL_HEIGHT(f) ((f)->output_data.x->pixel_height)
- 
  /* The difference in pixels between the top left corner of the
     Emacs window (including possible window manager decorations)
     and FRAME_X_WINDOW (f).  */
--- 666,671 ----
***************
*** 752,776 ****
  #define FRAME_X_IMAGE_CACHE(F) FRAME_X_DISPLAY_INFO ((F))->image_cache
  
  
- /* Total width of fringes reserved for drawing truncation bitmaps,
-    continuation bitmaps and alike.  The width is in canonical char
-    units of the frame.  This must currently be the case because window
-    sizes aren't pixel values.  If it weren't the case, we wouldn't be
-    able to split windows horizontally nicely.  */
- 
- #define FRAME_X_FRINGE_COLS(F)        ((F)->output_data.x->fringe_cols)
- 
- /* Total width of fringes in pixels.  */
- 
- #define FRAME_X_FRINGE_WIDTH(F) ((F)->output_data.x->fringes_extra)
- 
- /* Pixel-width of the left and right fringe.  */
- 
- #define FRAME_X_LEFT_FRINGE_WIDTH(F) ((F)->output_data.x->left_fringe_width)
- #define FRAME_X_RIGHT_FRINGE_WIDTH(F) ((F)->output_data.x->right_fringe_width)
- 
- 
- 
  /* X-specific scroll bar stuff.  */
  
  /* We represent scroll bars as lisp vectors.  This allows us to place
--- 697,702 ----
***************
*** 912,963 ****
  #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
  
  
- /* Manipulating pixel sizes and character sizes.
-    Knowledge of which factors affect the overall size of the window should
-    be hidden in these macros, if that's possible.
- 
-    Return the upper/left pixel position of the character cell on frame F
-    at ROW/COL.  */
- #define CHAR_TO_PIXEL_ROW(f, row) \
-   ((f)->output_data.x->internal_border_width \
-    + (row) * (f)->output_data.x->line_height)
- #define CHAR_TO_PIXEL_COL(f, col) \
-   ((f)->output_data.x->internal_border_width \
-    + (col) * FONT_WIDTH ((f)->output_data.x->font))
- 
- /* Return the pixel width/height of frame F if it has
-    WIDTH columns/HEIGHT rows.  */
- #define CHAR_TO_PIXEL_WIDTH(f, width) \
-   (CHAR_TO_PIXEL_COL (f, width) \
-    + (f)->output_data.x->vertical_scroll_bar_extra \
-    + (f)->output_data.x->fringes_extra \
-    + (f)->output_data.x->internal_border_width)
- #define CHAR_TO_PIXEL_HEIGHT(f, height) \
-   (CHAR_TO_PIXEL_ROW (f, height) \
-    + (f)->output_data.x->internal_border_width)
- 
- 
- /* Return the row/column (zero-based) of the character cell containing
-    the pixel on FRAME at ROW/COL.  */
- #define PIXEL_TO_CHAR_ROW(f, row) \
-   (((row) - (f)->output_data.x->internal_border_width) \
-    / (f)->output_data.x->line_height)
- #define PIXEL_TO_CHAR_COL(f, col) \
-   (((col) - (f)->output_data.x->internal_border_width) \
-    / FONT_WIDTH ((f)->output_data.x->font))
- 
- /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
-    frame F?  */
- #define PIXEL_TO_CHAR_WIDTH(f, width) \
-   (PIXEL_TO_CHAR_COL (f, ((width) \
-                         - (f)->output_data.x->internal_border_width \
-                         - (f)->output_data.x->fringes_extra \
-                         - (f)->output_data.x->vertical_scroll_bar_extra)))
- #define PIXEL_TO_CHAR_HEIGHT(f, height) \
-   (PIXEL_TO_CHAR_ROW (f, ((height) \
-                         - (f)->output_data.x->internal_border_width)))
- 
- 
  /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
     or SELECTION_CLEAR_EVENT, then its contents are really described
     by this structure.  */
--- 838,843 ----
***************
*** 1117,1123 ****
  
  /* Defined in xfaces.c */
  
- extern int frame_update_line_height P_ ((struct frame *));
  extern int compute_glyph_face P_ ((struct frame *, int, int));
  extern int compute_glyph_face_1 P_ ((struct frame *, Lisp_Object, int));
  extern void x_free_dpy_colors P_ ((Display *, Screen *, Colormap,
--- 997,1002 ----







reply via email to

[Prev in Thread] Current Thread [Next in Thread]