From 99f10a5dae1270696e9d65f0089985e8c89c28ab Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Fri, 7 Feb 2014 10:32:15 +0100 Subject: [PATCH] Constrain window box sizes (Bug#16649). * xdisp.c (window_box_width): Don't return less than zero. (window_box_left_offset, window_box_right_offset): Don't return more than the window's pixel width. --- src/ChangeLog | 7 +++++++ src/xdisp.c | 23 ++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9efaff3d20c..07a6aaaf871 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-02-07 Martin Rudalics + + Constrain window box sizes (Bug#16649). + * xdisp.c (window_box_width): Don't return less than zero. + (window_box_left_offset, window_box_right_offset): Don't return + more than the window's pixel width. + 2014-02-07 Glenn Morris * nsterm.m (syms_of_nsterm): Doc fix. diff --git a/src/xdisp.c b/src/xdisp.c index 980e905b097..430551b2b68 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1019,23 +1019,25 @@ window_text_bottom_y (struct window *w) int window_box_width (struct window *w, enum glyph_row_area area) { - int pixels = w->pixel_width; + int width = w->pixel_width; if (!w->pseudo_window_p) { - pixels -= WINDOW_SCROLL_BAR_AREA_WIDTH (w); - pixels -= WINDOW_RIGHT_DIVIDER_WIDTH (w); + width -= WINDOW_SCROLL_BAR_AREA_WIDTH (w); + width -= WINDOW_RIGHT_DIVIDER_WIDTH (w); if (area == TEXT_AREA) - pixels -= (WINDOW_MARGINS_WIDTH (w) + width -= (WINDOW_MARGINS_WIDTH (w) + WINDOW_FRINGES_WIDTH (w)); else if (area == LEFT_MARGIN_AREA) - pixels = WINDOW_LEFT_MARGIN_WIDTH (w); + width = WINDOW_LEFT_MARGIN_WIDTH (w); else if (area == RIGHT_MARGIN_AREA) - pixels = WINDOW_RIGHT_MARGIN_WIDTH (w); + width = WINDOW_RIGHT_MARGIN_WIDTH (w); } - return pixels; + /* With wide margins, fringes, etc. we might end up with a negative + width, correct that here. */ + return max (0, width); } @@ -1115,7 +1117,8 @@ window_box_left_offset (struct window *w, enum glyph_row_area area) && WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) x += WINDOW_LEFT_FRINGE_WIDTH (w); - return x; + /* Don't return more than the window's pixel width. */ + return min (x, w->pixel_width); } @@ -1126,7 +1129,9 @@ window_box_left_offset (struct window *w, enum glyph_row_area area) int window_box_right_offset (struct window *w, enum glyph_row_area area) { - return window_box_left_offset (w, area) + window_box_width (w, area); + /* Don't return more than the window's pixel width. */ + return min (window_box_left_offset (w, area) + window_box_width (w, area), + w->pixel_width); } /* Return the frame-relative coordinate of the left edge of display -- 2.11.4.GIT