summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2013-12-03 08:45:54 +0100
committerMartin Rudalics <rudalics@gmx.at>2013-12-03 08:45:54 +0100
commit7303a0aefc1fbabfea1b6b7711a6da2289aecdb2 (patch)
tree3d00b2cab57dac461a9810a9a77f7bdeefd4fbf1
parent39fa32d6359c8292dd91ce1c58da1aa3f8668bd8 (diff)
downloademacs-7303a0aefc1fbabfea1b6b7711a6da2289aecdb2.tar.gz
Fix issues related to pixelwise resizing. (Bug#16013) (Bug#16033)
* window.c (Fset_window_new_pixel): Don't choke at negative argument value (Bug#16033). * xfns.c (Fx_create_frame): Add another call to change_frame_size to avoid crash in window_box_height. * gtkutil.h: Fix external declaration of xg_frame_set_char_size. * gtkutil.c (xg_frame_set_char_size, style_changed_cb): Fix size calculation. * xterm.c (x_set_window_size): Fix size calculation (Bug#16013).
-rw-r--r--src/ChangeLog13
-rw-r--r--src/gtkutil.c24
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/window.c4
-rw-r--r--src/xfns.c14
-rw-r--r--src/xterm.c12
6 files changed, 44 insertions, 25 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d26a3798b09..bdd111f5083 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2013-12-03 Martin Rudalics <rudalics@gmx.at>
+
+ * window.c (Fset_window_new_pixel): Don't choke at negative
+ argument value (Bug#16033).
+
+ * xfns.c (Fx_create_frame): Add another call to change_frame_size
+ to avoid crash in window_box_height.
+
+ * gtkutil.h: Fix external declaration of xg_frame_set_char_size.
+ * gtkutil.c (xg_frame_set_char_size, style_changed_cb): Fix size
+ calculation.
+ * xterm.c (x_set_window_size): Fix size calculation (Bug#16013).
+
2013-12-03 Paul Eggert <eggert@cs.ucla.edu>
Minor integer overflow fixes.
diff --git a/src/gtkutil.c b/src/gtkutil.c
index d30a68a4193..4ecdd18aeb2 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -940,26 +940,12 @@ xg_frame_resized (struct frame *f, int pixelwidth, int pixelheight)
void
xg_frame_set_char_size (struct frame *f, int width, int height)
{
- int pixelwidth;
+ int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
if (FRAME_PIXEL_HEIGHT (f) == 0)
return;
- /* Take into account the size of the scroll bar. Always use the
- number of columns occupied by the scroll bar here otherwise we
- might end up with a frame width that is not a multiple of the
- frame's character width which is bad for vertically split
- windows. */
- f->scroll_bar_actual_width
- = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
-
- compute_fringe_widths (f, 0);
-
- /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it
- after calculating that value. */
- pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
-
/* Do this before resize, as we don't know yet if we will be resized. */
xg_clear_under_internal_border (f);
@@ -987,11 +973,7 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
x_wait_for_event (f, ConfigureNotify);
}
else
- {
- change_frame_size (f, width, height, 0, 1, 0, 1);
- FRAME_PIXEL_WIDTH (f) = pixelwidth;
- FRAME_PIXEL_HEIGHT (f) = pixelheight;
- }
+ change_frame_size (f, width, height, 0, 1, 0, 1);
}
/* Handle height/width changes (i.e. add/remove/move menu/toolbar).
@@ -1095,7 +1077,7 @@ style_changed_cb (GObject *go,
&& FRAME_X_DISPLAY (f) == dpy)
{
x_set_scroll_bar_default_width (f);
- xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f));
+ xg_frame_set_char_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f));
}
}
}
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 1c26d2aa44b..a2c5bb3ee76 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -139,7 +139,7 @@ extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
extern void xg_frame_resized (struct frame *f,
int pixelwidth,
int pixelheight);
-extern void xg_frame_set_char_size (struct frame *f, int cols, int rows);
+extern void xg_frame_set_char_size (struct frame *f, int width, int height);
extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
extern void xg_display_open (char *display_name, Display **dpy);
diff --git a/src/window.c b/src/window.c
index e2770410bce..1ef2b4a0e38 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3646,10 +3646,12 @@ Note: This function does not operate on any child windows of WINDOW. */)
(Lisp_Object window, Lisp_Object size, Lisp_Object add)
{
struct window *w = decode_valid_window (window);
+ EMACS_INT size_min = (max (INT_MIN, MOST_NEGATIVE_FIXNUM)
+ + (NILP (add) ? 0 : XINT (w->new_pixel)));
EMACS_INT size_max = (min (INT_MAX, MOST_POSITIVE_FIXNUM)
- (NILP (add) ? 0 : XINT (w->new_pixel)));
- CHECK_RANGED_INTEGER (size, 0, size_max);
+ CHECK_RANGED_INTEGER (size, size_min, size_max);
if (NILP (add))
wset_new_pixel (w, size);
else
diff --git a/src/xfns.c b/src/xfns.c
index 2830a79972c..2222eee6097 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3069,6 +3069,20 @@ This function is an internal primitive--use `make-frame' instead. */)
happen. */
init_frame_faces (f);
+ /* PXW: This is a duplicate from below. We have to do it here since
+ otherwise x_set_tool_bar_lines will work with the character sizes
+ installed by init_frame_faces while the frame's pixel size is still
+ calculated from a character size of 1 and we subsequently hit the
+ eassert (height >= 0) assertion in window_box_height. The
+ non-pixelwise code apparently worked around this because it had one
+ frame line vs one toolbar line which left us with a zero root
+ window height which was obviously wrong as well ... */
+ width = FRAME_TEXT_WIDTH (f);
+ height = FRAME_TEXT_HEIGHT (f);
+ FRAME_TEXT_HEIGHT (f) = 0;
+ SET_FRAME_WIDTH (f, 0);
+ change_frame_size (f, width, height, 1, 0, 0, 1);
+
/* Set the menu-bar-lines and tool-bar-lines parameters. We don't
look up the X resources controlling the menu-bar and tool-bar
here; they are processed specially at startup, and reflected in
diff --git a/src/xterm.c b/src/xterm.c
index 35f7facc80e..60db9e107fe 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8610,6 +8610,8 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b
{
block_input ();
+ check_frame_size (f, &width, &height, pixelwise);
+
if (NILP (tip_frame) || XFRAME (tip_frame) != f)
{
int text_width, text_height;
@@ -8636,14 +8638,20 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b
change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
}
+ if (! pixelwise)
+ {
+ width = width * FRAME_COLUMN_WIDTH (f);
+ height = height * FRAME_LINE_HEIGHT (f);
+ }
+
#ifdef USE_GTK
if (FRAME_GTK_WIDGET (f))
xg_frame_set_char_size (f, width, height);
else
- x_set_window_size_1 (f, change_gravity, width, height, pixelwise);
+ x_set_window_size_1 (f, change_gravity, width, height, 1);
#else /* not USE_GTK */
- x_set_window_size_1 (f, change_gravity, width, height, pixelwise);
+ x_set_window_size_1 (f, change_gravity, width, height, 1);
#endif /* not USE_GTK */