From: lorentey@elte.hu (Lőrentey Károly)
Subject: [PATCH] Fix `window-at' and `coordinates-in-window-p'
Date: Sat, 24 Jul 2004 00:29:47 +0200 [thread overview]
Message-ID: <lorentey.g.e.devel.87llhagxwk.elte@eris.elte.hu> (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
next reply other threads:[~2004-07-23 22:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-23 22:29 Lőrentey Károly [this message]
2004-07-24 1:44 ` [PATCH] Fix `window-at' and `coordinates-in-window-p' 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lorentey.g.e.devel.87llhagxwk.elte@eris.elte.hu \
--to=lorentey@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).