all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix `window-at' and `coordinates-in-window-p'
@ 2004-07-23 22:29 Lőrentey Károly
  2004-07-24  1:44 ` Luc Teirlinck
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Lőrentey Károly @ 2004-07-23 22:29 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 982 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: Type: text/x-patch, Size: 4016 bytes --]

*** 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)))
! 
  
  \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)))
  
  \f
  /* Manipulating pixel sizes and character sizes.

[-- Attachment #1.1.3: Type: text/plain, Size: 313 bytes --]


2004-07-23  Károly Lőrentey  <lorentey@elte.hu>

	* 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 lorentey@elte.hu--2004/emacs--lorentey--patch-67):

[-- Attachment #1.1.4: fix-coords.cset.tar.gz --]
[-- Type: application/octet-stream, Size: 1802 bytes --]

[-- Attachment #1.1.5: Type: text/plain, Size: 15 bytes --]


-- 
Károly

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-07-25 20:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-23 22:29 [PATCH] Fix `window-at' and `coordinates-in-window-p' Lőrentey Károly
2004-07-24  1:44 ` Luc Teirlinck
2004-07-24  8:51 ` Eli Zaretskii
2004-07-24 21:06   ` Lőrentey Károly
2004-07-24 14:30 ` Luc Teirlinck
2004-07-24 21:00   ` Lőrentey Károly
2004-07-25  0:12     ` Luc Teirlinck
2004-07-25 20:38       ` Lőrentey Károly
2004-07-25 17:46     ` Richard Stallman
2004-07-25 20:52       ` Lőrentey Károly
2004-07-24 19:44 ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.