]> code.delx.au - gnu-emacs/commitdiff
Fix issues related to pixelwise resizing. (Bug#16013) (Bug#16033)
authorMartin Rudalics <rudalics@gmx.at>
Tue, 3 Dec 2013 07:45:54 +0000 (08:45 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Tue, 3 Dec 2013 07:45:54 +0000 (08:45 +0100)
* 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).

src/ChangeLog
src/gtkutil.c
src/gtkutil.h
src/window.c
src/xfns.c
src/xterm.c

index d26a3798b09bf33f8c6a67bea333c800a472b343..bdd111f5083843e0891f6f6a6c3b1e3f3f492732 100644 (file)
@@ -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.
index d30a68a41933899611529d5288ff64f636827cfe..4ecdd18aeb2ce1b9bc31745c6baff2fbb5b0dd06 100644 (file)
@@ -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));
             }
         }
     }
index 1c26d2aa44b3909a5d522cbe40aa4f3bca5a82b9..a2c5bb3ee7696267f4873cb5526062519fdc0b1a 100644 (file)
@@ -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);
index e2770410bce5c4efd1c709c0a30b18e169ff32f0..1ef2b4a0e382e423c6241c1bc54cf09d7b0542a6 100644 (file)
@@ -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
index 2830a79972c15a5d60a9b3abb5c4c720ddaf79d3..2222eee6097c67ebe16db987276ab325d8f4c5a4 100644 (file)
@@ -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
index 35f7facc80ef393e27eda59d6e2b95f2a41e3f71..60db9e107fecc598738a09210d0cff0c97bb894c 100644 (file)
@@ -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 */