emacs-pretest-bug
[Top][All Lists]
Advanced

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

[PATCH] Window resizing


From: Nick Roberts
Subject: [PATCH] Window resizing
Date: Tue, 22 Nov 2005 10:16:19 +1300

This is a patch for the window resizing bug in FOR-RELEASE.  Its not rigorous
but it seems to work.  If its not considered suitable its a starting point
anyway.

The bug seems to arise because dragging the mode line is done through
enlarge-window which can sometimes move the top of the window rather than the
bottom.  mouse.el seems to have an inappropriate constraint on enlarge-window
(third arg t window gets larger).  My approach is to enlarge/shrink the
window below if that is wider than the selected window.

There is a an analogue which is this bug rotated by 90 degrees: 

  C-x 3, C-x 2, C-x 3. Now try to move the right side of the 
  second window to the left.

which could presumably be treated similarly.

If mouse drags are extended for too long then there are small spurious
movements as reported by Michael Cadhilac which seems to be due to
mouse-drag-mode-line-1 picking up extra events:

        (while (not done)
          (setq event (read-event)
                mouse (mouse-position))

In practice, however, they are not much of a problem.

Nick


*** mouse.el    04 Nov 2005 14:54:28 +1300      1.286
--- mouse.el    22 Nov 2005 09:39:46 +1300      
***************
*** 366,371 ****
--- 366,385 ----
        (setq window (previous-window window)))
      above-window))
  
+ (defun mouse-drag-window-below (window)
+   "Return the (or a) window directly above WINDOW.
+ That means one whose bottom edge is at the same height as WINDOW's top edge."
+   (let ((bottom (nth 3 (window-edges window)))
+       (start-window window)
+       below-window)
+     (setq window (previous-window window 0))
+     (while (and (not below-window) (not (eq window start-window)))
+       (if (= (- (nth 3 (window-edges window)) (window-height window))
+            bottom)
+         (setq below-window window))
+       (setq window (previous-window window)))
+     below-window))
+ 
  (defun mouse-drag-move-window-bottom (window growth)
    "Move the bottom of WINDOW up or down by GROWTH lines.
  Move it down if GROWTH is positive, or up if GROWTH is negative.
***************
*** 378,386 ****
        (let ((window-above (mouse-drag-window-above window)))
          (if window-above
              (mouse-drag-move-window-bottom window-above (- excess))))))
!   (save-selected-window
!     (select-window window)
!     (enlarge-window growth nil (> growth 0))))
  
  (defsubst mouse-drag-move-window-top (window growth)
    "Move the top of WINDOW up or down by GROWTH lines.
--- 392,399 ----
        (let ((window-above (mouse-drag-window-above window)))
          (if window-above
              (mouse-drag-move-window-bottom window-above (- excess))))))
!   (with-selected-window window
!     (enlarge-window growth)))
  
  (defsubst mouse-drag-move-window-top (window growth)
    "Move the top of WINDOW up or down by GROWTH lines.
***************
*** 499,507 ****
                   ;; no.  grow/shrink the selected window
                   ;(message "growth = %d" growth)
                   (if mode-line-p
!                      (mouse-drag-move-window-bottom start-event-window growth)
!                    (mouse-drag-move-window-top start-event-window growth)))
! 
                 ;; if this window's growth caused another
                 ;; window to be deleted because it was too
                 ;; short, rescind the change.
--- 512,533 ----
                   ;; no.  grow/shrink the selected window
                   ;(message "growth = %d" growth)
                   (if mode-line-p
!                        (let ((below (mouse-drag-window-below
!                                      start-event-window)))
!                          (if (and below
!                                   (< (window-width start-event-window)
!                                      (window-width below)))
!                              (mouse-drag-move-window-bottom below (- growth))
!                            (mouse-drag-move-window-bottom
!                             start-event-window growth)))
!                    (let ((above (mouse-drag-window-above
!                                  start-event-window)))
!                      (if (> (window-width start-event-window)
!                             (window-width above))
!                          (mouse-drag-move-window-bottom
!                           start-event-window growth)
!                        (mouse-drag-move-window-top
!                         start-event-window growth)))))
                 ;; if this window's growth caused another
                 ;; window to be deleted because it was too
                 ;; short, rescind the change.
***************
*** 514,520 ****
                 ;; around it.
                 (when (or (/= start-nwindows (count-windows t))
                           (and (not should-enlarge-minibuffer)
!                               (> growth 0)
                                mode-line-p
                                (/= top (nth 1 (window-edges)))))
                   (set-window-configuration wconfig)))))))))
--- 540,546 ----
                 ;; around it.
                 (when (or (/= start-nwindows (count-windows t))
                           (and (not should-enlarge-minibuffer)
!                               (= growth 0)
                                mode-line-p
                                (/= top (nth 1 (window-edges)))))
                   (set-window-configuration wconfig)))))))))




reply via email to

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