[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix `window-at' and `coordinates-in-window-p'
From: |
Lőrentey Károly |
Subject: |
Re: [PATCH] Fix `window-at' and `coordinates-in-window-p' |
Date: |
Sat, 24 Jul 2004 23:00:45 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Luc Teirlinck <address@hidden> writes:
> After taking a closer look at your patch, I guess one would have to be
> careful that there are no functions calling the functions you changed
> that _already_ adjust for FRAME_INTERNAL_BORDER_WIDTH, in which case
> they will double-adjust after the patch. I did not find any, but I
> have not looked that carefully.
I did a grep in the source tree, and it seems these macros are not
used anywhere else in Emacs, except for one small reference in
Fwindow_vscroll:
FRAME_PIXEL_X_FROM_CANON_X:
src/window.c:788: Fcoordinates_in_window_p
src/window.c:943: Fwindow_at
FRAME_PIXEL_Y_FROM_CANON_Y:
src/window.c:789: Fcoordinates_in_window_p
src/window.c:944: Fwindow_at
FRAME_CANON_X_FROM_PIXEL_X:
src/window.c:799: Fcoordinates_in_window_p
FRAME_CANON_Y_FROM_PIXEL_Y:
src/window.c:800: Fcoordinates_in_window_p
src/window.c:6167: Fwindow_vscroll
Unfortunately, `window-vscroll' doesn't like my patch:
(set-frame-parameter nil 'internal-border-width 20)
(set-window-vscroll nil 0.2) ==> -1.13, should be around 0.2
(window-vscroll) ==> -1.13, should be around 0.2
> I guess an alternative would be to make the adjustment inside
> `window-at' and `coordinates-in-window-p'.
I think it's easier to adjust the pixel coordinates right inside
coordinates_in_window_p, which both functions use:
*** orig/src/window.c
--- mod/src/window.c
***************
*** 607,612 ****
--- 607,616 ----
int grabbable_width = ux;
int lmargin_width, rmargin_width, text_left, text_right;
+ /* Adjust for the frame's internal border. */
+ *x += FRAME_INTERNAL_BORDER_WIDTH (f);
+ *y += FRAME_INTERNAL_BORDER_WIDTH (f);
+
if (*x < x0 || *x >= x1)
return ON_NOTHING;
2004-07-24 Károly Lőrentey <address@hidden>
* window.c (coordinates_in_window): Adjust pixel coordinates to
skip the frame's internal border.
Changeset: address@hidden/emacs--lorentey--0--patch-70
fix-coords-2.cset.tar.gz
Description: Binary data
This three-line patch fixes all problems with `window-at' and
`coordinates-in-window-p', and as far as I can see it does not affect
any other part of Emacs.
Yet another way to fix the problem would be to change the window-edges
family of functions to return ugly floats instead of nice round
integers, but on the Lisp level I think it's better to have the
frame's origin inside the frame's border. I like the above patch the
most.
> A patch that Richard sent me and that does this for `window-at'
> strangely enough seems to fail by making `window-at' return nil
> everywhere:
This is strange, as the two patches look to be equivalent.
> *** window.c 20 Jul 2004 16:52:30 -0400 1.471
> --- window.c 23 Jul 2004 20:05:29 -0400
> ***************
> *** 937,944 ****
> CHECK_NUMBER_OR_FLOAT (y);
>
> return window_from_coordinates (f,
> ! FRAME_PIXEL_X_FROM_CANON_X (f, x),
> ! FRAME_PIXEL_Y_FROM_CANON_Y (f, y),
> 0, 0, 0, 0);
> }
>
> --- 937,946 ----
> CHECK_NUMBER_OR_FLOAT (y);
>
> return window_from_coordinates (f,
> ! (FRAME_PIXEL_X_FROM_CANON_X (f, x)
> ! + FRAME_INTERNAL_BORDER_WIDTH (f)),
> ! (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
> ! + FRAME_INTERNAL_BORDER_WIDTH (f)),
> 0, 0, 0, 0);
> }
--
Károly
pgpoFpIHf8iAw.pgp
Description: PGP signature
Re: [PATCH] Fix `window-at' and `coordinates-in-window-p', Richard Stallman, 2004/07/24