static int displayed_window_lines (struct window *);
static int count_windows (struct window *);
static int get_leaf_windows (struct window *, struct window **, int);
-static void window_scroll (Lisp_Object, EMACS_INT, int, int);
-static void window_scroll_pixel_based (Lisp_Object, int, int, int);
-static void window_scroll_line_based (Lisp_Object, int, int, int);
-static int freeze_window_start (struct window *, void *);
+static void window_scroll (Lisp_Object, EMACS_INT, bool, int);
+static void window_scroll_pixel_based (Lisp_Object, int, bool, int);
+static void window_scroll_line_based (Lisp_Object, int, bool, int);
static Lisp_Object window_list (void);
static int add_window_to_list (struct window *, void *);
-static int candidate_window_p (Lisp_Object, Lisp_Object, Lisp_Object,
- Lisp_Object);
static Lisp_Object next_window (Lisp_Object, Lisp_Object,
Lisp_Object, int);
static void decode_next_window_args (Lisp_Object *, Lisp_Object *,
w->display_table = val;
}
static void
-wset_left_fringe_width (struct window *w, Lisp_Object val)
-{
- w->left_fringe_width = val;
-}
-static void
-wset_left_margin_cols (struct window *w, Lisp_Object val)
-{
- w->left_margin_cols = val;
-}
-static void
wset_new_normal (struct window *w, Lisp_Object val)
{
w->new_normal = val;
w->pointm = val;
}
static void
-wset_right_fringe_width (struct window *w, Lisp_Object val)
-{
- w->right_fringe_width = val;
-}
-static void
-wset_right_margin_cols (struct window *w, Lisp_Object val)
-{
- w->right_margin_cols = val;
-}
-static void
wset_scroll_bar_width (struct window *w, Lisp_Object val)
{
w->scroll_bar_width = val;
w->horizontal = horflag;
}
+/* Nonzero if leaf window W doesn't reflect the actual state
+ of displayed buffer due to its text or overlays change. */
+
+bool
+window_outdated (struct window *w)
+{
+ struct buffer *b = XBUFFER (w->contents);
+ return (w->last_modified < BUF_MODIFF (b)
+ || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b));
+}
+
struct window *
decode_live_window (register Lisp_Object window)
{
CHECK_LIVE_WINDOW (window);
w = XWINDOW (window);
- w->frozen_window_start_p = 0;
/* Make the selected window's buffer current. */
Fset_buffer (w->contents);
static int
check_window_containing (struct window *w, void *user_data)
{
- struct check_window_data *cw = (struct check_window_data *) user_data;
+ struct check_window_data *cw = user_data;
enum window_part found;
int continue_p = 1;
|| !w->window_end_valid
|| b->clip_changed
|| b->prevent_redisplay_optimizations_p
- || w->last_modified < BUF_MODIFF (b)
- || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b))
+ || window_outdated (w))
&& !noninteractive)
{
struct text_pos startp;
if (NILP (noforce))
w->force_start = 1;
w->update_mode_line = 1;
- w->last_modified = 0;
- w->last_overlay_modified = 0;
- if (!EQ (window, selected_window))
+ if (w != XWINDOW (selected_window))
+ /* Enforce full redisplay. FIXME: make it more selective. */
windows_or_buffers_changed++;
return pos;
|| windows_or_buffers_changed
|| b->clip_changed
|| b->prevent_redisplay_optimizations_p
- || w->last_modified < BUF_MODIFF (b)
- || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b))
+ || window_outdated (w))
return Qnil;
if (NILP (line))
wset_window_end_vpos (n, make_number (0));
wset_window_end_pos (n, make_number (0));
n->window_end_valid = 0;
- n->frozen_window_start_p = 0;
}
tem = o->next;
static int
add_window_to_list (struct window *w, void *user_data)
{
- Lisp_Object *list = (Lisp_Object *) user_data;
+ Lisp_Object *list = user_data;
Lisp_Object window;
XSETWINDOW (window, w);
*list = Fcons (window, *list);
a window means search the frame that window belongs to,
a frame means consider windows on that frame, only. */
-static int
-candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf, Lisp_Object all_frames)
+static bool
+candidate_window_p (Lisp_Object window, Lisp_Object owindow,
+ Lisp_Object minibuf, Lisp_Object all_frames)
{
struct window *w = XWINDOW (window);
struct frame *f = XFRAME (w->frame);
- int candidate_p = 1;
+ bool candidate_p = 1;
if (!BUFFERP (w->contents))
candidate_p = 0;
minimum allowable size. */
void
-check_frame_size (FRAME_PTR frame, int *rows, int *cols)
+check_frame_size (struct frame *frame, int *rows, int *cols)
{
/* For height, we have to see:
how many windows the frame has at minimum (one or two),
if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
{
if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
- {
- wset_left_margin_cols (w, make_number (margin_cols / 2));
- wset_right_margin_cols (w, make_number (margin_cols / 2));
- }
+ w->left_margin_cols = w->right_margin_cols = margin_cols / 2;
else
- wset_right_margin_cols (w, make_number (margin_cols));
+ w->right_margin_cols = margin_cols;
}
else
- wset_left_margin_cols (w, make_number (margin_cols));
+ w->left_margin_cols = margin_cols;
return 1;
}
\f
call0 (XCAR (funs));
}
-static Lisp_Object
+static void
select_window_norecord (Lisp_Object window)
{
- return WINDOW_LIVE_P (window)
- ? Fselect_window (window, Qt) : selected_window;
+ if (WINDOW_LIVE_P (window))
+ Fselect_window (window, Qt);
}
-static Lisp_Object
+static void
select_frame_norecord (Lisp_Object frame)
{
- return FRAME_LIVE_P (XFRAME (frame))
- ? Fselect_frame (frame, Qt) : selected_frame;
+ if (FRAME_LIVE_P (XFRAME (frame)))
+ Fselect_frame (frame, Qt);
}
void
if (SELECTED_FRAME () != f)
{
- record_unwind_protect (select_frame_norecord, Fselected_frame ());
+ record_unwind_protect (select_frame_norecord, selected_frame);
select_frame_norecord (frame);
}
buffer)))
{
ptrdiff_t inner_count = SPECPDL_INDEX ();
- record_unwind_protect (select_window_norecord, Fselected_window ());
+ record_unwind_protect (select_window_norecord, selected_window);
select_window_norecord (window);
run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook,
buffer));
buffer);
w->start_at_line_beg = 0;
w->force_start = 0;
- w->last_modified = 0;
- w->last_overlay_modified = 0;
}
/* Maybe we could move this into the `if' but it's not obviously safe and
I doubt it's worth the trouble. */
/* This may call adjust_window_margins three times, so
temporarily disable window margins. */
- Lisp_Object save_left = w->left_margin_cols;
- Lisp_Object save_right = w->right_margin_cols;
+ int save_left = w->left_margin_cols;
+ int save_right = w->right_margin_cols;
- wset_left_margin_cols (w, Qnil);
- wset_right_margin_cols (w, Qnil);
+ w->left_margin_cols = 0;
+ w->right_margin_cols = 0;
Fset_window_fringes (window,
BVAR (b, left_fringe_width), BVAR (b, right_fringe_width),
BVAR (b, scroll_bar_width),
BVAR (b, vertical_scroll_bar_type), Qnil);
- wset_left_margin_cols (w, save_left);
- wset_right_margin_cols (w, save_right);
+ w->left_margin_cols = save_left;
+ w->right_margin_cols = save_right;
Fset_window_margins (window,
BVAR (b, left_margin_cols), BVAR (b, right_margin_cols));
Note: Both Fselect_window and select_window_norecord may
set-buffer to the buffer displayed in the window,
so we need to save the current buffer. --stef */
- record_unwind_protect (Fset_buffer, prev_buffer);
+ record_unwind_protect (restore_buffer, prev_buffer);
record_unwind_protect (select_window_norecord, prev_window);
Fselect_window (window, Qt);
Fset_buffer (w->contents);
/* Initialize non-Lisp data. Note that allocate_window zeroes out all
non-Lisp data, so do it only for slots which should not be zero. */
w->nrows_scale_factor = w->ncols_scale_factor = 1;
+ w->left_fringe_width = w->right_fringe_width = -1;
w->phys_cursor_type = -1;
w->phys_cursor_width = -1;
w->column_number_displayed = -1;
c = NILP (c->next) ? 0 : XWINDOW (c->next);
}
}
-
- /* Clear out some redisplay caches. */
- w->last_modified = 0;
- w->last_overlay_modified = 0;
}
memset (&n->last_cursor, 0, sizeof n->last_cursor);
/* Get special geometry settings from reference window. */
- wset_left_margin_cols (n, r->left_margin_cols);
- wset_right_margin_cols (n, r->right_margin_cols);
- wset_left_fringe_width (n, r->left_fringe_width);
- wset_right_fringe_width (n, r->right_fringe_width);
+ n->left_margin_cols = r->left_margin_cols;
+ n->right_margin_cols = r->right_margin_cols;
+ n->left_fringe_width = r->left_fringe_width;
+ n->right_fringe_width = r->right_fringe_width;
n->fringes_outside_margins = r->fringes_outside_margins;
wset_scroll_bar_width (n, r->scroll_bar_width);
wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type);
/* Grow the mini-window. */
w->top_line = r->top_line + r->total_lines;
w->total_lines -= XINT (value);
- w->last_modified = 0;
- w->last_overlay_modified = 0;
-
+ /* Enforce full redisplay. FIXME: make it more selective. */
windows_or_buffers_changed++;
adjust_glyphs (f);
unblock_input ();
/* Shrink the mini-window. */
w->top_line = r->top_line + r->total_lines;
w->total_lines = 1;
-
- w->last_modified = 0;
- w->last_overlay_modified = 0;
-
+ /* Enforce full redisplay. FIXME: make it more selective. */
windows_or_buffers_changed++;
adjust_glyphs (f);
unblock_input ();
respectively. */
static void
-window_scroll (Lisp_Object window, EMACS_INT n, int whole, int noerror)
+window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror)
{
immediate_quit = 1;
n = clip_to_bounds (INT_MIN, n, INT_MAX);
descriptions. */
static void
-window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
+window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
{
struct it it;
struct window *w = XWINDOW (window);
int vscrolled = 0;
int x, y, rtop, rbot, rowh, vpos;
void *itdata = NULL;
+ int window_total_lines;
+ int frame_line_height = default_line_pixel_height (w);
SET_TEXT_POS_FROM_MARKER (start, w->start);
/* Scrolling a minibuffer window via scroll bar when the echo area
if (rtop || rbot) /* partially visible */
{
int px;
- int dy = WINDOW_FRAME_LINE_HEIGHT (w);
+ int dy = frame_line_height;
if (whole)
dy = max ((window_box_height (w)
- next_screen_context_lines * dy),
w->contents);
w->start_at_line_beg = 1;
w->update_mode_line = 1;
- w->last_modified = 0;
- w->last_overlay_modified = 0;
/* Set force_start so that redisplay_window will run the
window-scroll-functions. */
w->force_start = 1;
if (whole)
{
ptrdiff_t start_pos = IT_CHARPOS (it);
- int dy = WINDOW_FRAME_LINE_HEIGHT (w);
+ int dy = frame_line_height;
dy = max ((window_box_height (w)
- next_screen_context_lines * dy),
dy) * n;
bytepos = marker_byte_position (w->start);
w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
w->update_mode_line = 1;
- w->last_modified = 0;
- w->last_overlay_modified = 0;
/* Set force_start so that redisplay_window will run the
window-scroll-functions. */
w->force_start = 1;
/* Move PT out of scroll margins.
This code wants current_y to be zero at the window start position
even if there is a header line. */
+ window_total_lines
+ = w->total_lines * WINDOW_FRAME_LINE_HEIGHT (w) / frame_line_height;
this_scroll_margin = max (0, scroll_margin);
this_scroll_margin
- = min (this_scroll_margin, w->total_lines / 4);
- this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
+ = min (this_scroll_margin, window_total_lines / 4);
+ this_scroll_margin *= frame_line_height;
if (n > 0)
{
See the comment of window_scroll for parameter descriptions. */
static void
-window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
+window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror)
{
register struct window *w = XWINDOW (window);
/* Fvertical_motion enters redisplay, which can trigger
register ptrdiff_t pos, pos_byte;
register int ht = window_internal_height (w);
register Lisp_Object tem;
- int lose;
+ bool lose;
Lisp_Object bolp;
ptrdiff_t startpos = marker_position (w->start);
ptrdiff_t startbyte = marker_byte_position (w->start);
set_marker_restricted_both (w->start, w->contents, pos, pos_byte);
w->start_at_line_beg = !NILP (bolp);
w->update_mode_line = 1;
- w->last_modified = 0;
- w->last_overlay_modified = 0;
/* Set force_start so that redisplay_window will run
the window-scroll-functions. */
w->force_start = 1;
struct window *w = XWINDOW (selected_window);
struct buffer *buf = XBUFFER (w->contents);
struct buffer *obuf = current_buffer;
- int center_p = 0;
+ bool center_p = 0;
ptrdiff_t charpos, bytepos;
EMACS_INT iarg IF_LINT (= 0);
int this_scroll_margin;
struct Lisp_Vector *saved_windows;
Lisp_Object new_current_buffer;
Lisp_Object frame;
- FRAME_PTR f;
+ struct frame *f;
ptrdiff_t old_point = -1;
CHECK_WINDOW_CONFIGURATION (configuration);
w->hscroll = XFASTINT (p->hscroll);
w->min_hscroll = XFASTINT (p->min_hscroll);
wset_display_table (w, p->display_table);
- wset_left_margin_cols (w, p->left_margin_cols);
- wset_right_margin_cols (w, p->right_margin_cols);
- wset_left_fringe_width (w, p->left_fringe_width);
- wset_right_fringe_width (w, p->right_fringe_width);
+ w->left_margin_cols = XINT (p->left_margin_cols);
+ w->right_margin_cols = XINT (p->right_margin_cols);
+ w->left_fringe_width = XINT (p->left_fringe_width);
+ w->right_fringe_width = XINT (p->right_fringe_width);
w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
wset_scroll_bar_width (w, p->scroll_bar_width);
wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type);
}
}
- w->last_modified = 0;
- w->last_overlay_modified = 0;
-
if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
/* If saved buffer is alive, install it. */
{
return (FRAME_LIVE_P (f) ? Qt : Qnil);
}
+void
+restore_window_configuration (Lisp_Object configuration)
+{
+ Fset_window_configuration (configuration);
+}
+
/* If WINDOW is an internal window, recursively delete all child windows
reachable via the next and contents slots of WINDOW. Otherwise setup
XSETFASTINT (p->hscroll, w->hscroll);
XSETFASTINT (p->min_hscroll, w->min_hscroll);
p->display_table = w->display_table;
- 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->left_margin_cols = make_number (w->left_margin_cols);
+ p->right_margin_cols = make_number (w->right_margin_cols);
+ p->left_fringe_width = make_number (w->left_fringe_width);
+ p->right_fringe_width = make_number (w->right_fringe_width);
p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
p->scroll_bar_width = w->scroll_bar_width;
p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
Second arg LEFT-WIDTH specifies the number of character cells to
reserve for the left marginal area. Optional third arg RIGHT-WIDTH
does the same for the right marginal area. A nil width parameter
-means no margin. */)
+means no margin.
+
+Return t if any margin was actually changed and nil otherwise. */)
(Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
{
struct window *w = decode_live_window (window);
+ int left, right;
- /* Translate negative or zero widths to nil.
- Margins that are too wide have to be checked elsewhere. */
+ /* FIXME: what about margins that are too wide? */
- if (!NILP (left_width))
- {
- CHECK_NUMBER (left_width);
- if (XINT (left_width) <= 0)
- left_width = Qnil;
- }
+ left = (NILP (left_width) ? 0
+ : (CHECK_NATNUM (left_width), XINT (left_width)));
+ right = (NILP (right_width) ? 0
+ : (CHECK_NATNUM (right_width), XINT (right_width)));
- if (!NILP (right_width))
+ if (w->left_margin_cols != left || w->right_margin_cols != right)
{
- CHECK_NUMBER (right_width);
- if (XINT (right_width) <= 0)
- right_width = Qnil;
- }
-
- if (!EQ (w->left_margin_cols, left_width)
- || !EQ (w->right_margin_cols, right_width))
- {
- wset_left_margin_cols (w, left_width);
- wset_right_margin_cols (w, right_width);
+ 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 Qt;
}
return Qnil;
(Lisp_Object window)
{
struct window *w = decode_live_window (window);
- return Fcons (w->left_margin_cols, w->right_margin_cols);
+ return Fcons (w->left_margin_cols ? make_number (w->left_margin_cols) : Qnil,
+ w->right_margin_cols ? make_number (w->right_margin_cols) : Qnil);
}
the command `set-fringe-style'.
If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
outside of the display margins. By default, fringes are drawn between
-display marginal areas and the text area. */)
- (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins)
+display marginal areas and the text area.
+
+Return t if any fringe was actually changed and nil otherwise. */)
+ (Lisp_Object window, Lisp_Object left_width,
+ Lisp_Object right_width, Lisp_Object outside_margins)
{
struct window *w = decode_live_window (window);
- int outside = !NILP (outside_margins);
+ int left, right, outside = !NILP (outside_margins);
- if (!NILP (left_width))
- CHECK_NATNUM (left_width);
- if (!NILP (right_width))
- CHECK_NATNUM (right_width);
+ left = (NILP (left_width) ? -1
+ : (CHECK_NATNUM (left_width), XINT (left_width)));
+ right = (NILP (right_width) ? -1
+ : (CHECK_NATNUM (right_width), XINT (right_width)));
- /* Do nothing on a tty. */
+ /* Do nothing on a tty or if nothing to actually change. */
if (FRAME_WINDOW_P (WINDOW_XFRAME (w))
- && (!EQ (w->left_fringe_width, left_width)
- || !EQ (w->right_fringe_width, right_width)
+ && (w->left_fringe_width != left
+ || w->right_fringe_width != right
|| w->fringes_outside_margins != outside))
{
- wset_left_fringe_width (w, left_width);
- wset_right_fringe_width (w, right_width);
+ w->left_fringe_width = left;
+ w->right_fringe_width = right;
w->fringes_outside_margins = outside;
adjust_window_margins (w);
++windows_or_buffers_changed;
adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
+ return Qt;
}
return Qnil;
return cont;
}
-
-/* Freeze or unfreeze the window start of W unless it is a
- mini-window or the selected window. FREEZE_P non-null means freeze
- the window start. */
-
-static int
-freeze_window_start (struct window *w, void *freeze_p)
-{
- if (MINI_WINDOW_P (w)
- || (WINDOWP (selected_window) /* Can be nil in corner cases. */
- && (w == XWINDOW (selected_window)
- || (MINI_WINDOW_P (XWINDOW (selected_window))
- && ! NILP (Vminibuf_scroll_window)
- && w == XWINDOW (Vminibuf_scroll_window)))))
- freeze_p = NULL;
-
- w->frozen_window_start_p = freeze_p != NULL;
- return 1;
-}
-
-
-/* Freeze or unfreeze the window starts of all leaf windows on frame
- F, except the selected window and a mini-window. FREEZE_P non-zero
- means freeze the window start. */
-
-void
-freeze_window_starts (struct frame *f, bool freeze_p)
-{
- foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0));
-}
-
-\f
/***********************************************************************
Initialization
***********************************************************************/