]> git.eshelyaron.com Git - emacs.git/commitdiff
Some more fixes following pixelwise resize changes including one for Bug#16306.
authorMartin Rudalics <rudalics@gmx.at>
Tue, 31 Dec 2013 09:48:54 +0000 (10:48 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Tue, 31 Dec 2013 09:48:54 +0000 (10:48 +0100)
* gtkutil.c (x_wm_set_size_hint): Have size hints respect value
of frame_resize_pixelwise.
* widget.c (pixel_to_text_size): New function.
(update_wm_hints): Have size hints respect value of
frame_resize_pixelwise.
(EmacsFrameResize): Alway process resize requests pixelwise.
* window.c (grow_mini_window): Make sure mini window is at least
one line tall.
* xdisp.c (display_menu_bar): Make sure menubar extends till
right end of frame.
* xfns.c (x_set_menu_bar_lines): Resize frame windows pixelwise.
(x_set_tool_bar_lines): Calculate pixelwise.
* xterm.c (x_wm_set_size_hint): Have size hints respect value of
frame_resize_pixelwise.

src/ChangeLog
src/gtkutil.c
src/widget.c
src/window.c
src/xdisp.c
src/xfns.c
src/xterm.c

index bfc4ac548c9424b500e0ffbd18862ad266d95e0a..d7c772df2ddda5232369c9a85319d774ae861eb7 100644 (file)
@@ -1,3 +1,22 @@
+2013-12-31  Martin Rudalics  <rudalics@gmx.at>
+
+       Some more fixes following pixelwise resize changes including one
+       for Bug#16306.
+       * gtkutil.c (x_wm_set_size_hint): Have size hints respect value
+       of frame_resize_pixelwise.
+       * widget.c (pixel_to_text_size): New function.
+       (update_wm_hints): Have size hints respect value of
+       frame_resize_pixelwise.
+       (EmacsFrameResize): Alway process resize requests pixelwise.
+       * window.c (grow_mini_window): Make sure mini window is at least
+       one line tall.
+       * xdisp.c (display_menu_bar): Make sure menubar extends till
+       right end of frame.
+       * xfns.c (x_set_menu_bar_lines): Resize frame windows pixelwise.
+       (x_set_tool_bar_lines): Calculate pixelwise.
+       * xterm.c (x_wm_set_size_hint): Have size hints respect value of
+       frame_resize_pixelwise.
+
 2013-12-30  Juanma Barranquero  <lekktu@gmail.com>
 
        * fileio.c (Fcopy_file) [!WINDOWSNT]: Don't declare on Windows
@@ -10,7 +29,7 @@
 2013-12-30  Martin Rudalics  <rudalics@gmx.at>
 
        * dispnew.c (change_frame_size_1): Take old width of root window
-       from that window's pixel width.  Bug#16284.
+       from that window's pixel width.  (Bug#16284)
 
 2013-12-29  Paul Eggert  <eggert@cs.ucla.edu>
 
index e5d6414cf75d3e06bfb17d325dbc378ff4c5365e..3f4e44eb196b289ab4b0f01d8d84ddb28c05a10e 100644 (file)
@@ -1354,8 +1354,8 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
   hint_flags = f->output_data.x->hint_flags;
 
   hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;
-  size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
-  size_hints.height_inc = FRAME_LINE_HEIGHT (f);
+  size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
+  size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
 
   hint_flags |= GDK_HINT_BASE_SIZE;
   /* Use one row/col here so base_height/width does not become zero.
@@ -1370,8 +1370,8 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
 
   size_hints.base_width = base_width;
   size_hints.base_height = base_height;
-  size_hints.min_width  = base_width + min_cols * size_hints.width_inc;
-  size_hints.min_height = base_height + min_rows * size_hints.height_inc;
+  size_hints.min_width  = base_width + min_cols * FRAME_COLUMN_WIDTH (f);;
+  size_hints.min_height = base_height + min_rows * FRAME_LINE_HEIGHT (f);
 
   /* These currently have a one to one mapping with the X values, but I
      don't think we should rely on that.  */
index 73c5149e2cdd1b385c6db9a02173fa0fe7ac0165..7f6722f9ec7c0cd2d590fb3d334ba00abbe1b580 100644 (file)
@@ -189,6 +189,14 @@ pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height
   *char_height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (int) pixel_height);
 }
 
+static void
+pixel_to_text_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height, int *text_width, int *text_height)
+{
+  struct frame* f = ew->emacs_frame.frame;
+  *text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, (int) pixel_width);
+  *text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, (int) pixel_height);
+}
+
 static void
 char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, Dimension *pixel_width, Dimension *pixel_height)
 {
@@ -487,8 +495,8 @@ update_wm_hints (EmacsFrame ew)
   XtVaSetValues (wmshell,
                 XtNbaseWidth, (XtArgVal) base_width,
                 XtNbaseHeight, (XtArgVal) base_height,
-                XtNwidthInc, (XtArgVal) cw,
-                XtNheightInc, (XtArgVal) ch,
+                XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw),
+                XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch),
                 XtNminWidth, (XtArgVal) (base_width + min_cols * cw),
                 XtNminHeight, (XtArgVal) (base_height + min_rows * ch),
                 NULL);
@@ -670,21 +678,41 @@ EmacsFrameResize (Widget widget)
   EmacsFrame ew = (EmacsFrame)widget;
   struct frame *f = ew->emacs_frame.frame;
   struct x_output *x = f->output_data.x;
-  int columns;
-  int rows;
-
-  pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows);
-  if (columns != FRAME_COLS (f)
-      || rows != FRAME_LINES (f)
-      || ew->core.width != FRAME_PIXEL_WIDTH (f)
-      || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f))
+
+#if 0  /* Always process resize requests pixelwise.  Frame maximizing
+         should work even when frame_resize_pixelwise is nil.  */
+  if (frame_resize_pixelwise)
     {
-      change_frame_size (f, columns, rows, 0, 1, 0, 0);
+#endif /* 0 */
+      int width, height;
+
+      pixel_to_text_size (ew, ew->core.width, ew->core.height, &width, &height);
+      change_frame_size (f, width, height, 0, 1, 0, 1);
+
       update_wm_hints (ew);
       update_various_frame_slots (ew);
 
       cancel_mouse_face (f);
+#if 0  /* See comment above.  */
     }
+  else
+    {
+      int columns, rows;
+
+      pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows);
+      if (columns != FRAME_COLS (f)
+         || rows != FRAME_LINES (f)
+         || ew->core.width != FRAME_PIXEL_WIDTH (f)
+         || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f))
+       {
+         change_frame_size (f, columns, rows, 0, 1, 0, 0);
+         update_wm_hints (ew);
+         update_various_frame_slots (ew);
+
+         cancel_mouse_face (f);
+       }
+    }
+#endif /* 0 */
 }
 
 static Boolean
@@ -724,6 +752,7 @@ EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, Ar
 
   if (has_to_recompute_size)
     {
+      /* Don't do this pixelwise, hopefully.  */
       pixel_width = new->core.width;
       pixel_height = new->core.height;
       pixel_to_char_size (new, pixel_width, pixel_height, &char_width,
index 9bc95224f7ccbbb4c1cba6c5cf4606df751ca405..1e3d70fd88d81e26372baf5245350da840e94ef0 100644 (file)
@@ -4582,14 +4582,16 @@ grow_mini_window (struct window *w, int delta, bool pixelwise)
 
          if (pixelwise)
            {
-             pixel_height = min (-XINT (height), INT_MAX - w->pixel_height);
+             pixel_height = max (min (-XINT (height), INT_MAX - w->pixel_height),
+                                 FRAME_LINE_HEIGHT (f));
              line_height = pixel_height / FRAME_LINE_HEIGHT (f);
            }
          else
            {
-             line_height = min (-XINT (height),
-                                ((INT_MAX - w->pixel_height)
-                                 / FRAME_LINE_HEIGHT (f)));
+             line_height = max (min (-XINT (height),
+                                     ((INT_MAX - w->pixel_height)
+                                      / FRAME_LINE_HEIGHT (f))),
+                                1);
              pixel_height = line_height * FRAME_LINE_HEIGHT (f);
            }
 
index 1c157c7be0a4465148a506b38ef4aa834f557c77..8a0a714cdfcd6d2c975d28e886c81ee997310c47 100644 (file)
@@ -20882,8 +20882,7 @@ display_menu_bar (struct window *w)
   eassert (!FRAME_WINDOW_P (f));
   init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID);
   it.first_visible_x = 0;
-  /* PXW: Use FRAME_PIXEL_WIDTH (f) here?  */
-  it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
+  it.last_visible_x = FRAME_PIXEL_WIDTH (f);
 #elif defined (HAVE_X_WINDOWS) /* X without toolkit.  */
   if (FRAME_WINDOW_P (f))
     {
@@ -20894,8 +20893,7 @@ display_menu_bar (struct window *w)
       init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
                     MENU_FACE_ID);
       it.first_visible_x = 0;
-      /* PXW: Use FRAME_PIXEL_WIDTH (f) here?  */
-      it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
+      it.last_visible_x = FRAME_PIXEL_WIDTH (f);
     }
   else
 #endif /* not USE_X_TOOLKIT and not USE_GTK */
index 7200c5fb2e7c9fb5186414a390c54574c0ee7132..3b49ab5af75fdce66d4e6b6fe42d98f3d23c752c 100644 (file)
@@ -997,7 +997,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 #else /* not USE_X_TOOLKIT && not USE_GTK */
   FRAME_MENU_BAR_LINES (f) = nlines;
   FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f);
-  resize_frame_windows (f, FRAME_LINES (f), 0, 0);
+  resize_frame_windows (f, FRAME_TEXT_HEIGHT (f), 0, 1);
 
   /* If the menu bar height gets changed, the internal border below
      the top margin has to be cleared.  Also, if the menu bar gets
@@ -1052,7 +1052,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
   int nlines;
 #if ! defined (USE_GTK)
   int delta, root_height;
-  Lisp_Object root_window;
+  int unit = FRAME_LINE_HEIGHT (f);
 #endif
 
   /* Treat tool bars like menu bars.  */
@@ -1089,20 +1089,29 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
   /* Make sure we redisplay all windows in this frame.  */
   windows_or_buffers_changed = 60;
 
-  delta = nlines - FRAME_TOOL_BAR_LINES (f);
+  /* DELTA is in pixels now.  */
+  delta = (nlines - FRAME_TOOL_BAR_LINES (f)) * unit;
 
-  /* Don't resize the tool-bar to more than we have room for.  */
-  root_window = FRAME_ROOT_WINDOW (f);
-  root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
-  if (root_height - delta < 1)
+  /* Don't resize the tool-bar to more than we have room for.  Note: The
+     calculations below and the subsequent call to resize_frame_windows
+     are inherently flawed because they can make the toolbar higher than
+     the containing frame.  */
+  if (delta > 0)
     {
-      delta = root_height - 1;
-      nlines = FRAME_TOOL_BAR_LINES (f) + delta;
+      root_height = WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_ROOT_WINDOW (f)));
+      if (root_height - delta < unit)
+       {
+         delta = root_height - unit;
+         /* When creating a new frame and toolbar mode is enabled, we
+            need at least one toolbar line.  */
+         nlines = max (FRAME_TOOL_BAR_LINES (f) + delta / unit, 1);
+       }
     }
 
   FRAME_TOOL_BAR_LINES (f) = nlines;
   FRAME_TOOL_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f);
-  resize_frame_windows (f, FRAME_LINES (f), 0, 0);
+  ++windows_or_buffers_changed;
+  resize_frame_windows (f, FRAME_TEXT_HEIGHT (f), 0, 1);
   adjust_frame_glyphs (f);
 
   /* We also have to make sure that the internal border at the top of
@@ -1124,7 +1133,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
     {
       int height = FRAME_INTERNAL_BORDER_WIDTH (f);
       int width = FRAME_PIXEL_WIDTH (f);
-      int y = (FRAME_MENU_BAR_LINES (f) + nlines) * FRAME_LINE_HEIGHT (f);
+      int y = nlines * unit;
 
       /* height can be zero here. */
       if (height > 0 && width > 0)
@@ -1139,7 +1148,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
        clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
     }
 
-    run_window_configuration_change_hook (f);
+  run_window_configuration_change_hook (f);
 #endif /* USE_GTK */
 }
 
index f634feb21f9d619b048bec8d9ec43eb78f961325..399262e0fb1f96ce61786745b2f79b566be714ec 100644 (file)
@@ -9293,8 +9293,9 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
   size_hints.height = FRAME_PIXEL_HEIGHT (f);
   size_hints.width = FRAME_PIXEL_WIDTH (f);
 
-  size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
-  size_hints.height_inc = FRAME_LINE_HEIGHT (f);
+  size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
+  size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
+
   size_hints.max_width = x_display_pixel_width (FRAME_DISPLAY_INFO (f))
     - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
   size_hints.max_height = x_display_pixel_height (FRAME_DISPLAY_INFO (f))
@@ -9310,6 +9311,14 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
 
     check_frame_size (f, &min_cols, &min_rows, 0);
 
+    if (frame_resize_pixelwise)
+      /* Needed to prevent a bad protocol error crash when making the
+        frame size very small.  */
+      {
+       min_cols = 2 * min_cols;
+       min_rows = 2 * min_rows;
+      }
+
     /* The window manager uses the base width hints to calculate the
        current number of rows and columns in the frame while
        resizing; min_width and min_height aren't useful for this
@@ -9323,8 +9332,8 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
     size_hints.flags |= PBaseSize;
     size_hints.base_width = base_width;
     size_hints.base_height = base_height + FRAME_MENUBAR_HEIGHT (f);
-    size_hints.min_width  = base_width + min_cols * size_hints.width_inc;
-    size_hints.min_height = base_height + min_rows * size_hints.height_inc;
+    size_hints.min_width  = base_width + min_cols * FRAME_COLUMN_WIDTH (f);
+    size_hints.min_height = base_height + min_rows * FRAME_LINE_HEIGHT (f);
   }
 
   /* If we don't need the old flags, we don't need the old hint at all.  */