From: Dmitry Antipov Date: Wed, 12 Dec 2012 15:33:30 +0000 (+0400) Subject: * dispnew.c (set_window_cursor_after_update): Use clip_to_bounds. X-Git-Tag: emacs-24.3.90~173^2~7^2~618 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2dd61a9b332356fa24d96527a71ef4fe29fb9e5c;p=emacs.git * dispnew.c (set_window_cursor_after_update): Use clip_to_bounds. * gtkutil.c (xg_set_toolkit_scroll_bar_thumb): * window.c (Frecenter): * xdisp.c (resize_mini_window, hscroll_window_tree, draw_glyphs): * xterm.c (x_set_toolkit_scroll_bar_thumb): Likewise. --- diff --git a/src/ChangeLog b/src/ChangeLog index d19b7be7395..3070fcb6e9d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-12-12 Dmitry Antipov + + * dispnew.c (set_window_cursor_after_update): Use clip_to_bounds. + * gtkutil.c (xg_set_toolkit_scroll_bar_thumb): + * window.c (Frecenter): + * xdisp.c (resize_mini_window, hscroll_window_tree, draw_glyphs): + * xterm.c (x_set_toolkit_scroll_bar_thumb): Likewise. + 2012-12-12 Daniel Colascione * unexcw.c (fixup_executable): use posix_fallocate to ensure that diff --git a/src/dispnew.c b/src/dispnew.c index 675c06c22e9..11ae112f837 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -4016,11 +4016,10 @@ set_window_cursor_after_update (struct window *w) vpos = w->cursor.vpos; } - /* Window cursor can be out of sync for horizontally split windows. */ - hpos = max (-1, hpos); /* -1 is for when cursor is on the left fringe */ - hpos = min (w->current_matrix->matrix_w - 1, hpos); - vpos = max (0, vpos); - vpos = min (w->current_matrix->nrows - 1, vpos); + /* Window cursor can be out of sync for horizontally split windows. + Horisontal position is -1 when cursor is on the left fringe. */ + hpos = clip_to_bounds (-1, hpos, w->current_matrix->matrix_w - 1); + vpos = clip_to_bounds (0, vpos, w->current_matrix->nrows - 1); rif->cursor_to (vpos, hpos, cy, cx); } diff --git a/src/gtkutil.c b/src/gtkutil.c index 52a6c37b0d5..9f2b652525f 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -3796,13 +3796,8 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, shown = (gdouble) portion / whole; } - size = shown * XG_SB_RANGE; - size = min (size, XG_SB_RANGE); - size = max (size, 1); - - value = top * XG_SB_RANGE; - value = min (value, XG_SB_MAX - size); - value = max (value, XG_SB_MIN); + size = clip_to_bounds (1, shown * XG_SB_RANGE, XG_SB_RANGE); + value = clip_to_bounds (XG_SB_MIN, top * XG_SB_RANGE, XG_SB_MAX - size); /* Assume all lines are of equal size. */ new_step = size / max (1, FRAME_LINES (f)); diff --git a/src/window.c b/src/window.c index f696e3c2a1b..28c3bf93553 100644 --- a/src/window.c +++ b/src/window.c @@ -5347,8 +5347,8 @@ and redisplay normally--don't erase and redraw the frame. */) iarg += ht; /* Don't let it get into the margin at either top or bottom. */ - iarg = max (iarg, this_scroll_margin); - iarg = min (iarg, ht - this_scroll_margin - 1); + iarg = clip_to_bounds (this_scroll_margin, iarg, + ht - this_scroll_margin - 1); pos = *vmotion (PT, - iarg, w); charpos = pos.bufpos; diff --git a/src/xdisp.c b/src/xdisp.c index ad600f3c83d..aead10a7b9b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10393,8 +10393,7 @@ resize_mini_window (struct window *w, int exact_p) max_height = total_height / 4; /* Correct that max. height if it's bogus. */ - max_height = max (1, max_height); - max_height = min (total_height, max_height); + max_height = clip_to_bounds (1, max_height, total_height); /* Find out the height of the text in the window. */ if (it.line_wrap == TRUNCATE) @@ -12496,11 +12495,7 @@ hscroll_window_tree (Lisp_Object window) if (w == XWINDOW (selected_window)) pt = PT; else - { - pt = marker_position (w->pointm); - pt = max (BEGV, pt); - pt = min (ZV, pt); - } + pt = clip_to_bounds (BEGV, marker_position (w->pointm), ZV); /* Move iterator to pt starting at cursor_row->start in a line with infinite width. */ @@ -23485,8 +23480,7 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row, /* Let's rather be paranoid than getting a SEGV. */ end = min (end, row->used[area]); - start = max (0, start); - start = min (end, start); + start = clip_to_bounds (0, start, end); /* Translate X to frame coordinates. Set last_x to the right end of the drawing area. */ diff --git a/src/xterm.c b/src/xterm.c index e9e99574663..374b6287458 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4834,9 +4834,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX is the scroll bar's maximum and MIN is the scroll bar's minimum value. */ - size = shown * XM_SB_MAX; - size = min (size, XM_SB_MAX); - size = max (size, 1); + size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX); /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */ value = top * XM_SB_MAX;