all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: lorentey@elte.hu (Lőrentey Károly)
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Fix `window-at' and `coordinates-in-window-p'
Date: Sat, 24 Jul 2004 23:00:45 +0200	[thread overview]
Message-ID: <lorentey.g.e.devel.87658dxgqq.elte@eris.elte.hu> (raw)
In-Reply-To: <200407241430.i6OEUqv27206@raven.dms.auburn.edu> (Luc Teirlinck's message of "Sat, 24 Jul 2004 09:30:52 -0500 (CDT)")


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

Luc Teirlinck <teirllm@dms.auburn.edu> 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:


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

*** 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;
  

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


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

	* window.c (coordinates_in_window): Adjust pixel coordinates to
	skip the frame's internal border.

Changeset: lorentey@elte.hu--2004/emacs--lorentey--0--patch-70


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

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


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

[-- 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

  reply	other threads:[~2004-07-24 21:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

* 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.87658dxgqq.elte@eris.elte.hu \
    --to=lorentey@elte.hu \
    --cc=emacs-devel@gnu.org \
    /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 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.