+2014-02-07 Martin Rudalics <rudalics@gmx.at>
+
+ 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 <rgm@gnu.org>
* nsterm.m (syms_of_nsterm): Doc fix.
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);
}
&& 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);
}
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