emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115630: Some more fixes for pixelwise resizing.


From: Martin Rudalics
Subject: [Emacs-diffs] trunk r115630: Some more fixes for pixelwise resizing.
Date: Fri, 20 Dec 2013 10:49:00 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115630
revision-id: address@hidden
parent: address@hidden
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Fri 2013-12-20 11:48:36 +0100
message:
  Some more fixes for pixelwise resizing.
  
  Remove scroll_bar_actual_width from frames.
  * frame.h (struct frame): Remove scroll_bar_actual_width slot.
  * frame.c (Fscroll_bar_width): Return scroll bar area width.
  (x_figure_window_size):
  * nsterm.m (x_set_window_size):
  * widget.c (set_frame_size):
  * w32term.c (x_set_window_size):
  * xterm.c (x_set_window_size, x_set_window_size_1): Don't set
  scroll_bar_actual_width.
  
  Convert scroll_bar members to integers on Windows.
  * w32term.h (struct scroll_bar): Convert top, left, width,
  height, start, end and dragging to integers.
  * w32fns.c (w32_createscrollbar): Remove XINT conversions for
  scroll_bar members.
  * w32term.c (w32_set_scroll_bar_thumb)
  (w32_scroll_bar_handle_click): Remove XINT conversions for
  scroll_bar members.  Treat bar->dragging as integer.
  (x_scroll_bar_create): Call ALLOCATE_PSEUDOVECTOR with "top" as
  first element.  Remove XINT conversions for scroll_bar members.
  (w32_set_vertical_scroll_bar, x_scroll_bar_report_motion):
  Remove XINT conversions for scroll_bar members.
  
  Fix assignment for new window total sizes.
  * window.c (Fwindow_resize_apply_total): Assign values for
  minibuffer window.
  * window.el (window--pixel-to-size): Remove function.
  (window--pixel-to-total-1, window--pixel-to-total): Fix
  calculation of new total sizes.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/window.el                 window.el-20091113204419-o5vbwnq5f7feedwu-94
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispnew.c                  dispnew.c-20091113204419-o5vbwnq5f7feedwu-258
  src/frame.c                    frame.c-20091113204419-o5vbwnq5f7feedwu-243
  src/frame.h                    frame.h-20091113204419-o5vbwnq5f7feedwu-229
  src/nsterm.m                   nsterm.m-20091113204419-o5vbwnq5f7feedwu-8747
  src/w32fns.c                   w32fns.c-20091113204419-o5vbwnq5f7feedwu-945
  src/w32term.c                  w32term.c-20091113204419-o5vbwnq5f7feedwu-950
  src/w32term.h                  w32term.h-20091113204419-o5vbwnq5f7feedwu-954
  src/widget.c                   widget.c-20091113204419-o5vbwnq5f7feedwu-676
  src/window.c                   window.c-20091113204419-o5vbwnq5f7feedwu-231
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-20 06:25:19 +0000
+++ b/lisp/ChangeLog    2013-12-20 10:48:36 +0000
@@ -1,3 +1,10 @@
+2013-12-20  Martin Rudalics  <address@hidden>
+
+       Fix assignment for new window total sizes.
+       * window.el (window--pixel-to-size): Remove function.
+       (window--pixel-to-total-1, window--pixel-to-total): Fix
+       calculation of new total sizes.
+
 2013-12-20  Vitalie Spinu  <address@hidden>
 
        * comint.el (comint-output-filter): Fix rear-nonsticky property

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2013-12-17 18:11:37 +0000
+++ b/lisp/window.el    2013-12-20 10:48:36 +0000
@@ -2079,30 +2079,16 @@
          size)
       (* size char-size))))
 
-(defun window--pixel-to-size (window size &optional horizontal round-up)
-  "For WINDOW convert SIZE pixels to lines.
-WINDOW must be a valid window and defaults to the selected one.
-Optional argument HORIZONTAL non-nil means convert SIZE pixels to
-columns.  Optional argument ROUND-UP means to round up the return
-value."
-  (let ((char-size (frame-char-size
-                   (window-normalize-window window) horizontal)))
-    (if round-up
-       (/ (+ size char-size -1) char-size)
-      (/ size char-size))))
-
 (defun window--pixel-to-total-1 (window horizontal char-size)
   "Subroutine of `window--pixel-to-total'."
   (let ((child (window-child window)))
     (if (window-combination-p window horizontal)
        ;; In an iso-combination distribute sizes proportionally.
        (let ((remainder (window-new-total window))
-             size best-child best-size)
+             size best-child rem best-rem)
          ;; Initialize total sizes to each child's floor.
          (while child
-           (setq size (window--pixel-to-size
-                       child (window-size child horizontal t)
-                       horizontal))
+           (setq size (max (/ (window-size child horizontal t) char-size) 1))
            (set-window-new-total child size)
            (setq remainder (- remainder size))
            (setq child (window-next-sibling child)))
@@ -2110,15 +2096,15 @@
          (while (> remainder 0)
            (setq child (window-last-child window))
            (setq best-child nil)
-           (setq best-size 0)
-           ;; We want those auxiliary fields in the window structure to
-           ;; avoid this.
+           (setq best-rem 0)
            (while child
-             (setq size (- (/ (window-size child horizontal t) char-size)
-                           (window-new-total child)))
-             (when (> size best-size)
-               (setq best-child child)
-               (setq best-size size))
+             (when (and (<= (window-new-total child)
+                            (/ (window-size child horizontal t) char-size))
+                        (> (setq rem (% (window-size child horizontal t)
+                                        char-size))
+                           best-rem))
+                  (setq best-child child)
+                  (setq best-rem rem))
              (setq child (window-prev-sibling child)))
            ;; We MUST have a best-child here.
            (set-window-new-total best-child 1 t)
@@ -2142,14 +2128,39 @@
 Optional argument HORIZONTAL non-nil means assign new total
 window widths from pixel widths."
   (setq frame (window-normalize-frame frame))
-  (let ((root (frame-root-window))
-       (char-size (frame-char-size frame horizontal)))
-    (set-window-new-total
-     root (window--pixel-to-size
-          root (window-size root horizontal t) horizontal))
+  (let* ((char-size (frame-char-size frame horizontal))
+        (root (frame-root-window))
+        (root-size (window-size root horizontal t))
+        ;; We have to care about the minibuffer window only if it
+        ;; appears together with the root window on this frame.
+        (mini (let ((mini (minibuffer-window frame)))
+                (and (eq (window-frame mini) frame)
+                     (not (eq mini root)) mini)))
+        (mini-size (and mini (window-size mini horizontal t))))
+    ;; We round the line/column sizes of windows here to the nearest
+    ;; integer.  In some cases this can make windows appear _larger_
+    ;; than the containing frame (line/column-wise) because the latter's
+    ;; sizes are not (yet) rounded.  We might eventually fix that.
+    (if (and mini (not horizontal))
+       (let (lines)
+         (set-window-new-total root (max (/ root-size char-size) 1))
+         (set-window-new-total mini (max (/ mini-size char-size) 1))
+         (setq lines (- (round (+ root-size mini-size) char-size)
+                        (+ (window-new-total root) (window-new-total mini))))
+         (while (> lines 0)
+           (if (>= (% root-size (window-new-total root))
+                   (% mini-size (window-new-total mini)))
+               (set-window-new-total root 1 t)
+             (set-window-new-total mini 1 t))
+           (setq lines (1- lines))))
+      (set-window-new-total root (round root-size char-size))
+      (when mini
+       ;; This is taken in the horizontal case only.
+       (set-window-new-total mini (round mini-size char-size))))
     (unless (window-buffer root)
-      (window--pixel-to-total-1 root horizontal char-size)))
-  (window-resize-apply-total frame horizontal))
+      (window--pixel-to-total-1 root horizontal char-size))
+    ;; Apply the new sizes.
+    (window-resize-apply-total frame horizontal)))
 
 (defun window--resize-reset (&optional frame horizontal)
   "Reset resize values for all windows on FRAME.

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-12-20 07:12:04 +0000
+++ b/src/ChangeLog     2013-12-20 10:48:36 +0000
@@ -1,3 +1,32 @@
+2013-12-20  Martin Rudalics  <address@hidden>
+
+       Remove scroll_bar_actual_width from frames.
+       * frame.h (struct frame): Remove scroll_bar_actual_width slot.
+       * frame.c (Fscroll_bar_width): Return scroll bar area width.
+       (x_figure_window_size):
+       * nsterm.m (x_set_window_size):
+       * widget.c (set_frame_size):
+       * w32term.c (x_set_window_size):
+       * xterm.c (x_set_window_size, x_set_window_size_1): Don't set
+       scroll_bar_actual_width.
+
+       Convert scroll_bar members to integers on Windows.
+       * w32term.h (struct scroll_bar): Convert top, left, width,
+       height, start, end and dragging to integers.
+       * w32fns.c (w32_createscrollbar): Remove XINT conversions for
+       scroll_bar members.
+       * w32term.c (w32_set_scroll_bar_thumb)
+       (w32_scroll_bar_handle_click): Remove XINT conversions for
+       scroll_bar members.  Treat bar->dragging as integer.
+       (x_scroll_bar_create): Call ALLOCATE_PSEUDOVECTOR with "top" as
+       first element.  Remove XINT conversions for scroll_bar members.
+       (w32_set_vertical_scroll_bar, x_scroll_bar_report_motion):
+       Remove XINT conversions for scroll_bar members.
+
+       Fix assignment for new window total sizes.
+       * window.c (Fwindow_resize_apply_total): Assign values for
+       minibuffer window.
+
 2013-12-20  Chong Yidong  <address@hidden>
 
        * textprop.c (Fadd_face_text_property): Doc fix.  Rename `appendp'

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2013-12-14 21:36:44 +0000
+++ b/src/dispnew.c     2013-12-20 10:48:36 +0000
@@ -5488,6 +5488,8 @@
     {
       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);
     }
@@ -5507,7 +5509,6 @@
      fringe columns.  Do this after rounding - see discussion of
      bug#9723.  */
   new_root_width = (new_text_width
-                   /* PXM: Use the configured scrollbar width !??  */
                    + FRAME_SCROLL_BAR_AREA_WIDTH (f)
                    + FRAME_TOTAL_FRINGE_WIDTH (f));
   /* If we're not changing the frame size, quit now.  */

=== modified file 'src/frame.c'
--- a/src/frame.c       2013-12-17 17:46:31 +0000
+++ b/src/frame.c       2013-12-20 10:48:36 +0000
@@ -2515,7 +2515,7 @@
        doc: /* Return scroll bar width of FRAME in pixels.  */)
   (Lisp_Object frame)
 {
-  return make_number (decode_any_frame (frame)->scroll_bar_actual_width);
+  return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame)));
 }
 
 DEFUN ("frame-fringe-width", Ffringe_width, Sfringe_width, 0, 1, 0,
@@ -4237,8 +4237,6 @@
        window_prompting |= PSize;
     }
 
-  f->scroll_bar_actual_width
-    = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
 
   /* This used to be done _before_ calling x_figure_window_size, but
      since the height is reset here, this was really a no-op.  I

=== modified file 'src/frame.h'
--- a/src/frame.h       2013-12-15 16:27:25 +0000
+++ b/src/frame.h       2013-12-20 10:48:36 +0000
@@ -436,10 +436,6 @@
   int config_scroll_bar_width;
   int config_scroll_bar_cols;
 
-  /* The size of the extra width currently allotted for vertical
-     scroll bars in this frame, in pixels.  */
-  int scroll_bar_actual_width;
-
   /* The baud rate that was used to calculate costs for this frame.  */
   int cost_calculation_baud_rate;
 

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2013-12-19 10:25:48 +0000
+++ b/src/nsterm.m      2013-12-20 10:48:36 +0000
@@ -1289,7 +1289,6 @@
 
   check_frame_size (f, &width, &height, pixelwise);
 
-  f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f);
   compute_fringe_widths (f, 0);
 
   if (pixelwise)

=== modified file 'src/w32fns.c'
--- a/src/w32fns.c      2013-12-18 16:21:17 +0000
+++ b/src/w32fns.c      2013-12-20 10:48:36 +0000
@@ -1912,8 +1912,7 @@
 {
   return CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,
                       /* Position and size of scroll bar.  */
-                      XINT (bar->left), XINT (bar->top),
-                      XINT (bar->width), XINT (bar->height),
+                      bar->left, bar->top, bar->width, bar->height,
                       FRAME_W32_WINDOW (f), NULL, hinst, NULL);
 }
 

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2013-12-17 17:46:31 +0000
+++ b/src/w32term.c     2013-12-20 10:48:36 +0000
@@ -3451,9 +3451,7 @@
               = x_window_to_scroll_bar (WindowFromPoint (pt));
 
            if (bar)
-             {
-               f1 = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
-             }
+             f1 = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
          }
 
        if (f1 == 0 && insist > 0)
@@ -3560,10 +3558,10 @@
   /* We use the whole scroll-bar height in the calculations below, to
      avoid strange effects like scrolling backwards when just clicking
      on the handle (without moving it).  */
-  double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height))
+  double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height)
                  + VERTICAL_SCROLL_BAR_MIN_HANDLE;
   int sb_page, sb_pos;
-  BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
+  BOOL draggingp = bar->dragging ? TRUE : FALSE;
   SCROLLINFO si;
 
   /* We used to change the nPage setting while dragging the handle,
@@ -3708,19 +3706,19 @@
   HWND hwnd;
   SCROLLINFO si;
   struct scroll_bar *bar
-    = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, fringe_extended_p, PVEC_OTHER);
+    = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, top, PVEC_OTHER);
   Lisp_Object barobj;
 
   block_input ();
 
   XSETWINDOW (bar->window, w);
-  XSETINT (bar->top, top);
-  XSETINT (bar->left, left);
-  XSETINT (bar->width, width);
-  XSETINT (bar->height, height);
-  XSETINT (bar->start, 0);
-  XSETINT (bar->end, 0);
-  bar->dragging = Qnil;
+  bar->top = top;
+  bar->left = left;
+  bar->width = width;
+  bar->height = height;
+  bar->start = 0;
+  bar->end = 0;
+  bar->dragging = 0;
   bar->fringe_extended_p = 0;
 
   /* Requires geometry to be set before call to create the real window */
@@ -3838,10 +3836,10 @@
       hwnd = SCROLL_BAR_W32_WINDOW (bar);
 
       /* If already correctly positioned, do nothing.  */
-      if (XINT (bar->left) == sb_left
-         && XINT (bar->top) == top
-         && XINT (bar->width) == sb_width
-         && XINT (bar->height) == height
+      if (bar->left == sb_left
+         && bar->top == top
+         && bar->width == sb_width
+         && bar->height == height
          && bar->fringe_extended_p == fringe_extended_p)
         {
           /* Redraw after clear_frame. */
@@ -3883,10 +3881,10 @@
           /* InvalidateRect (w, NULL, FALSE);  */
 
           /* Remember new settings.  */
-          XSETINT (bar->left, sb_left);
-          XSETINT (bar->top, top);
-          XSETINT (bar->width, sb_width);
-          XSETINT (bar->height, height);
+          bar->left = sb_left;
+          bar->top = top;
+          bar->width = sb_width;
+          bar->height = height;
 
           unblock_input ();
         }
@@ -4026,9 +4024,9 @@
   emacs_event->timestamp = msg->msg.time;
 
   {
-    int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+    int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
     int y;
-    int dragging = !NILP (bar->dragging);
+    int dragging = bar->dragging;
     SCROLLINFO si;
 
     si.cbSize = sizeof (si);
@@ -4037,7 +4035,7 @@
     GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
     y = si.nPos;
 
-    bar->dragging = Qnil;
+    bar->dragging = 0;
     FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
 
     switch (LOWORD (msg->msg.wParam))
@@ -4064,9 +4062,9 @@
        break;
       case SB_THUMBTRACK:
       case SB_THUMBPOSITION:
-       if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)) <= 0xffff)
+       if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height) <= 0xffff)
           y = HIWORD (msg->msg.wParam);
-       bar->dragging = Qt;
+       bar->dragging = 1; /* ??????? */
        emacs_event->part = scroll_bar_handle;
 
        /* "Silently" update current position.  */
@@ -4090,8 +4088,8 @@
        if (dragging)
          {
            SCROLLINFO si;
-           int start = XINT (bar->start);
-           int end = XINT (bar->end);
+           int start = bar->start;
+           int end = bar->end;
 
            si.cbSize = sizeof (si);
            si.fMask = SIF_PAGE | SIF_POS;
@@ -4126,7 +4124,7 @@
   Window w = SCROLL_BAR_W32_WINDOW (bar);
   struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
   int pos;
-  int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+  int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
   SCROLLINFO si;
 
   block_input ();
@@ -4146,7 +4144,7 @@
   case SB_THUMBPOSITION:
   case SB_THUMBTRACK:
       *part = scroll_bar_handle;
-      if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)) <= 0xffff)
+      if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height) <= 0xffff)
        pos = HIWORD (dpyinfo->last_mouse_scroll_bar_pos);
       break;
   case SB_LINEDOWN:
@@ -5710,8 +5708,6 @@
   block_input ();
 
   check_frame_size (f, &width, &height, pixelwise);
-  f->scroll_bar_actual_width
-    = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
 
   compute_fringe_widths (f, 0);
 

=== modified file 'src/w32term.h'
--- a/src/w32term.h     2013-12-02 13:35:53 +0000
+++ b/src/w32term.h     2013-12-20 10:48:36 +0000
@@ -429,7 +429,7 @@
 
   /* The position and size of the scroll bar in pixels, relative to the
      frame.  */
-  Lisp_Object top, left, width, height;
+  int top, left, width, height;
 
   /* The starting and ending positions of the handle, relative to the
      handle area (i.e. zero is the top position, not
@@ -442,13 +442,13 @@
      drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
      where they would be normally; the bottom and top are in a
      different co-ordinate system.  */
-  Lisp_Object start, end;
+  int start, end;
 
   /* If the scroll bar handle is currently being dragged by the user,
      this is the number of pixels from the top of the handle to the
      place where the user grabbed it.  If the handle isn't currently
      being dragged, this is Qnil.  */
-  Lisp_Object dragging;
+  int dragging;
 
   /* 1 if the background of the fringe that is adjacent to a scroll
      bar is extended to the gap between the fringe and the bar.  */

=== modified file 'src/widget.c'
--- a/src/widget.c      2013-11-30 09:25:31 +0000
+++ b/src/widget.c      2013-12-20 10:48:36 +0000
@@ -404,8 +404,6 @@
        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);
 

=== modified file 'src/window.c'
--- a/src/window.c      2013-12-11 10:03:46 +0000
+++ b/src/window.c      2013-12-20 10:48:36 +0000
@@ -4001,6 +4001,20 @@
   r->left_col = 0;
   r->top_line = FRAME_TOP_MARGIN (f);
   window_resize_apply_total (r, !NILP (horizontal));
+  /* Handle the mini window.  */
+  if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
+    {
+      struct window *m = XWINDOW (f->minibuffer_window);
+
+      if (NILP (horizontal))
+       {
+         m->top_line = r->top_line + r->total_lines;
+         m->total_lines = XFASTINT (m->new_total);
+       }
+      else
+       m->total_cols = XFASTINT (m->new_total);
+    }
+
   unblock_input ();
 
   return Qt;

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2013-12-14 21:36:44 +0000
+++ b/src/xterm.c       2013-12-20 10:48:36 +0000
@@ -8537,10 +8537,6 @@
   int pixelwidth, pixelheight;
 
   check_frame_size (f, &width, &height, pixelwise);
-  f->scroll_bar_actual_width
-    = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
-       ? 0
-       : FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f));
 
   compute_fringe_widths (f, 0);
 
@@ -8623,10 +8619,7 @@
 #endif
       text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, FRAME_PIXEL_WIDTH (f));
       text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelh);
-      /* Update f->scroll_bar_actual_width because it is used in
-         FRAME_PIXEL_WIDTH_TO_TEXT_COLS.  */
-      f->scroll_bar_actual_width
-        = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
+
       change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
     }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]