emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Fix `window-at' and `coordinates-in-window-p'


From: Lőrentey Károly
Subject: [PATCH] Fix `window-at' and `coordinates-in-window-p'
Date: Sat, 24 Jul 2004 00:29:47 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Try this under X:

    emacs -q --no-site-file --internal-border 1
                            ^^^^^^^^^^^^^^^^^^^
        M-: (window-at 0 0) <RET>
        M-: (coordinates-in-window-p '(0 . 0) (selected-window)) <RET>

Under Emacs 21.3.1, both `window-at' and `coordinates-in-window-p'
ignore the frame's internal border, and (IMHO) correctly return
non-nil values; under the current CVS version, they both return nil.

In CVS, the following functions always return nil if the
internal-border-width frame parameter is non-zero.  I think that is wrong.

        (defun test-coord-1 (window)
          (let ((edges (window-edges window)))
            (eq window (window-at (nth 0 edges) (nth 1 edges)))))

        (defun test-coord-2 (window)
          (let ((edges (window-edges window)))
            (coordinates-in-window-p (cons (nth 0 edges)
                                           (nth 1 edges))
                                     window)))

This bug confuses the windmove.el package and renders it almost
unusable for me.  I fixed it with the following patch:

*** orig/src/frame.h
--- mod/src/frame.h
***************
*** 880,919 ****
     canonical char width is to be used.  X must be a Lisp integer or
     float.  Value is a C integer.  */
  
! #define FRAME_PIXEL_X_FROM_CANON_X(F, X)              \
!      (INTEGERP (X)                                    \
!       ? XINT (X) * FRAME_COLUMN_WIDTH (F)             \
!       : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
  
  /* Convert canonical value Y to pixels.  F is the frame whose
     canonical character height is to be used.  X must be a Lisp integer
     or float.  Value is a C integer.  */
  
  #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y)              \
!      (INTEGERP (Y)                                    \
!       ? XINT (Y) * FRAME_LINE_HEIGHT (F)              \
!       : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
  
  /* Convert pixel-value X to canonical units.  F is the frame whose
     canonical character width is to be used.  X is a C integer.  Result
     is a Lisp float if X is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define FRAME_CANON_X_FROM_PIXEL_X(F, X)                      \
!      ((X) % FRAME_COLUMN_WIDTH (F) != 0                               \
!       ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F))    \
!       : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
  
  /* Convert pixel-value Y to canonical units.  F is the frame whose
     canonical character height is to be used.  Y is a C integer.
     Result is a Lisp float if Y is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y)                      \
!      ((Y) % FRAME_LINE_HEIGHT (F)                             \
!       ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F))     \
!       : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
! 
  
  
  /* Manipulating pixel sizes and character sizes.
--- 880,924 ----
     canonical char width is to be used.  X must be a Lisp integer or
     float.  Value is a C integer.  */
  
! #define FRAME_PIXEL_X_FROM_CANON_X(F, X)                 \
!   (FRAME_INTERNAL_BORDER_WIDTH (F) +                     \
!    (INTEGERP (X)                                         \
!     ? XINT (X) * FRAME_COLUMN_WIDTH (F)                  \
!     : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F))))
  
  /* Convert canonical value Y to pixels.  F is the frame whose
     canonical character height is to be used.  X must be a Lisp integer
     or float.  Value is a C integer.  */
  
  #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y)              \
!   (FRAME_INTERNAL_BORDER_WIDTH (F) +                    \
!    (INTEGERP (Y)                                        \
!     ? XINT (Y) * FRAME_LINE_HEIGHT (F)                  \
!     : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F))))
  
  /* Convert pixel-value X to canonical units.  F is the frame whose
     canonical character width is to be used.  X is a C integer.  Result
     is a Lisp float if X is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define FRAME_CANON_X_FROM_PIXEL_X(F, X)                                \
!   ((X - FRAME_INTERNAL_BORDER_WIDTH (F)) % FRAME_COLUMN_WIDTH (F) != 0  \
!    ? make_float ((double) (X - FRAME_INTERNAL_BORDER_WIDTH (F)) /       \
!                  FRAME_COLUMN_WIDTH (F))                                \
!    : make_number ((X - FRAME_INTERNAL_BORDER_WIDTH (F)) /               \
!                   FRAME_COLUMN_WIDTH (F)))
  
  /* Convert pixel-value Y to canonical units.  F is the frame whose
     canonical character height is to be used.  Y is a C integer.
     Result is a Lisp float if Y is not a multiple of the canon width,
     otherwise it's a Lisp integer.  */
  
! #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y)                               \
!   ((Y - FRAME_INTERNAL_BORDER_WIDTH (F)) % FRAME_LINE_HEIGHT (F) != 0  \
!    ? make_float ((double) (Y - FRAME_INTERNAL_BORDER_WIDTH (F)) /      \
!                  FRAME_LINE_HEIGHT (F))                                \
!    : make_number ((Y - FRAME_INTERNAL_BORDER_WIDTH (F)) /              \
!                   FRAME_LINE_HEIGHT (F)))
  
  
  /* Manipulating pixel sizes and character sizes.
2004-07-23  Károly Lőrentey  <address@hidden>

        * frame.h (FRAME_PIXEL_X_FROM_CANON_X, FRAME_PIXEL_Y_FROM_CANON_Y)
        (FRAME_CANON_X_FROM_PIXEL_X, FRAME_CANON_Y_FROM_PIXEL_Y):  Take
        the frame's internal border width into account.

Arch changeset (from address@hidden/emacs--lorentey--patch-67):

Attachment: fix-coords.cset.tar.gz
Description: Binary data

-- 
Károly

Attachment: pgpEXcKNSX9km.pgp
Description: PGP signature


reply via email to

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