+2014-09-24 Eli Zaretskii <eliz@gnu.org>
+
+ * w32term.c (w32_read_socket): Don't use frame dimensions for
+ resizing if GetClientRect returned an empty (0, 0, 0, 0)
+ rectangle. Check the return value of GetClientRect, and don't use
+ the results if it didn't succeed.
+
+ * dispnew.c (change_frame_size_1): Recompute the frame dimensions
+ in columns and lines after correcting the pixel dimensions in
+ check_frame_size.
+ (adjust_decode_mode_spec_buffer): Add assertion to avoid passing
+ negative values to xrealloc. (Bug#18528)
+
2014-09-22 Dmitry Antipov <dmantipov@yandex.ru>
On OSX, do not free font-specific data more than once (Bug#18501).
static void
adjust_decode_mode_spec_buffer (struct frame *f)
{
+ ssize_t frame_message_buf_size = FRAME_MESSAGE_BUF_SIZE (f);
+
+ eassert (frame_message_buf_size >= 0);
f->decode_mode_spec_buffer = xrealloc (f->decode_mode_spec_buffer,
- FRAME_MESSAGE_BUF_SIZE (f) + 1);
+ frame_message_buf_size + 1);
}
{
new_text_width = (new_width == 0) ? FRAME_TEXT_WIDTH (f) : new_width;
new_text_height = (new_height == 0) ? FRAME_TEXT_HEIGHT (f) : new_height;
- /* Consider rounding here: Currently, the root window can be
- larger than the frame in terms of columns/lines. */
- new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
- new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
}
else
{
/* Compute width of windows in F. */
/* Round up to the smallest acceptable size. */
check_frame_size (f, &new_text_width, &new_text_height, 1);
+ /* Recompute the dimensions in character units, since
+ check_frame_size might have changed the pixel dimensions. */
+ /* Consider rounding here: Currently, the root window can be
+ larger than the frame in terms of columns/lines. */
+ new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
+ new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
/* This is the width of the frame without vertical scroll bars and
fringe columns. Do this after rounding - see discussion of
RECT rect;
int rows, columns, width, height, text_width, text_height;
- GetClientRect (msg.msg.hwnd, &rect);
-
- height = rect.bottom - rect.top;
- width = rect.right - rect.left;
- text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, width);
- text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, height);
- 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. */
-
- /* 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 (width != FRAME_PIXEL_WIDTH (f)
- || height != FRAME_PIXEL_HEIGHT (f)
- || text_width != FRAME_TEXT_WIDTH (f)
- || text_height != FRAME_TEXT_HEIGHT (f))
+ if (GetClientRect (msg.msg.hwnd, &rect)
+ /* GetClientRect evidently returns (0, 0, 0, 0) if
+ called on a minimized frame. Such "dimensions"
+ aren't useful anyway. */
+ && !(rect.bottom == 0
+ && rect.top == 0
+ && rect.left == 0
+ && rect.right == 0))
{
- change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
- SET_FRAME_GARBAGED (f);
- cancel_mouse_face (f);
- /* Do we want to set these here ???? */
-/** FRAME_PIXEL_WIDTH (f) = width; **/
-/** FRAME_TEXT_WIDTH (f) = text_width; **/
-/** FRAME_PIXEL_HEIGHT (f) = height; **/
- f->win_gravity = NorthWestGravity;
+ height = rect.bottom - rect.top;
+ width = rect.right - rect.left;
+ text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, width);
+ text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, height);
+ 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. */
+
+ /* 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 (width != FRAME_PIXEL_WIDTH (f)
+ || height != FRAME_PIXEL_HEIGHT (f)
+ || text_width != FRAME_TEXT_WIDTH (f)
+ || text_height != FRAME_TEXT_HEIGHT (f))
+ {
+ change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
+ SET_FRAME_GARBAGED (f);
+ cancel_mouse_face (f);
+ /* Do we want to set these here ???? */
+ /** FRAME_PIXEL_WIDTH (f) = width; **/
+ /** FRAME_TEXT_WIDTH (f) = text_width; **/
+ /** FRAME_PIXEL_HEIGHT (f) = height; **/
+ f->win_gravity = NorthWestGravity;
+ }
}
}