Commit 9173a8fb authored by Chong Yidong's avatar Chong Yidong

Cleanup of window coordinate positioning code.

Now, text area click input events measure Y from the top of the text
area, excluding the header line if any.

* src/dispnew.c (buffer_posn_from_coords): Assume that X counts from
the start of the text area.

* src/keyboard.c (make_lispy_position): For text area clicks, record Y
pixel position relative to the text area, excluding header line.
Also change X and Y to Lisp_Objects, not pointers; don't return
coordinate values via pointers.  Pass ON_TEXT_AREA coordinate to
buffer_posn_from_coords counting from the start of the text area.
(Fposn_at_x_y, make_lispy_event): Callers changed.

* src/w32term.c (w32_read_socket):
* src/msdos.c (dos_rawgetc):
* src/xterm.c (handle_one_xevent): Likewise.

* src/window.c (coordinates_in_window): Change X and Y to ints rather
than pointers; don't return coordinates via pointers.
(struct check_window_data): Change X and Y from pointers to ints.
(window_from_coordinates): Remove args WX and WY; don't return
coordinates via pointers.
(Fcoordinates_in_window_p, window_from_coordinates):
(check_window_containing, Fwindow_at): Callers changed.
(window_relative_x_coord): New function.

* src/window.h (window_from_coordinates, window_relative_x_coord):
Update prototypes.

* src/xdisp.c (remember_mouse_glyph): Change window_from_coordinates
call.  Use window_relative_x_coord.
(note_mouse_highlight): Change window_from_coordinates call.
parent 809fde05
......@@ -560,6 +560,11 @@ Notifications API. It requires D-Bus for communication.
* Incompatible Lisp Changes in Emacs 24.1
** For mouse click input events in the text area, the Y pixel
coordinate in the POSITION list now counts from the top of the text
area, excluding any header line. Previously, it counted from the top
of the header line.
** Remove obsolete name `e' (use `float-e' instead).
** A backquote not followed by a space is now always treated as new-style.
......
2010-11-16 Chong Yidong <cyd@stupidchicken.com>
* keyboard.c (make_lispy_position): For text area clicks, record Y
pixel position relative to the text area, excluding header line.
Also change X and Y to Lisp_Objects, not pointers; don't return
coordinate values via pointers. Pass ON_TEXT_AREA coordinate to
buffer_posn_from_coords counting from the start of the text area.
(Fposn_at_x_y, make_lispy_event): Callers changed.
* window.c (coordinates_in_window): Change X and Y to ints rather
than pointers; don't return coordinates via pointers.
(struct check_window_data): Change X and Y from pointers to ints.
(window_from_coordinates): Remove args WX and WY; don't return
coordinates via pointers.
(Fcoordinates_in_window_p, window_from_coordinates):
(check_window_containing, Fwindow_at): Callers changed.
(window_relative_x_coord): New function.
* window.h (window_from_coordinates, window_relative_x_coord):
Update prototypes.
* dispnew.c (buffer_posn_from_coords): Assume that X counts from
the start of the text area.
* xdisp.c (remember_mouse_glyph): Change window_from_coordinates
call. Use window_relative_x_coord.
(note_mouse_highlight): Change window_from_coordinates call.
* w32term.c (w32_read_socket):
* msdos.c (dos_rawgetc):
* xterm.c (handle_one_xevent): Likewise.
2010-11-16 Dan Nicolaescu <dann@ics.uci.edu>
* strftime.c (LOCALE_PARAM_DECL): Update for standard C.
......
......@@ -5393,7 +5393,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
start_display (&it, w, startp);
x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w);
x0 = *x;
/* First, move to the beginning of the row corresponding to *Y. We
need to be in that row to get the correct value of base paragraph
......
This diff is collapsed.
......@@ -2698,7 +2698,7 @@ dos_rawgetc (void)
mouse_window = window_from_coordinates (SELECTED_FRAME(),
mouse_last_x,
mouse_last_y,
0, 0, 0, 0);
0, 0);
/* A window will be selected only when it is not
selected now, and the last mouse movement event was
not in it. A minibuffer window will be selected iff
......
......@@ -4317,7 +4317,7 @@ w32_read_socket (struct terminal *terminal, int expected,
int x = LOWORD (msg.msg.lParam);
int y = HIWORD (msg.msg.lParam);
window = window_from_coordinates (f, x, y, 0, 0, 0, 0);
window = window_from_coordinates (f, x, y, 0, 0);
/* Window will be selected only when it is not
selected now and last mouse movement event was
......@@ -4396,7 +4396,7 @@ w32_read_socket (struct terminal *terminal, int expected,
int x = XFASTINT (inev.x);
int y = XFASTINT (inev.y);
window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
window = window_from_coordinates (f, x, y, 0, 1);
if (EQ (window, f->tool_bar_window))
{
......
This diff is collapsed.
......@@ -788,8 +788,7 @@ EXFUN (Fset_window_point, 2);
extern Lisp_Object make_window (void);
extern void delete_window (Lisp_Object);
extern Lisp_Object window_from_coordinates (struct frame *, int, int,
enum window_part *,
int *, int*, int);
enum window_part *, int);
EXFUN (Fwindow_dedicated_p, 1);
extern int window_height (Lisp_Object);
extern int window_width (Lisp_Object);
......@@ -804,6 +803,7 @@ extern void foreach_window (struct frame *,
void *);
extern void grow_mini_window (struct window *, int);
extern void shrink_mini_window (struct window *);
extern int window_relative_x_coord (struct window *, enum window_part, int);
void run_window_configuration_change_hook (struct frame *f);
......
......@@ -2218,7 +2218,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
frame pixel coordinates X/Y on frame F. */
if (!f->glyphs_initialized_p
|| (window = window_from_coordinates (f, gx, gy, &part, &x, &y, 0),
|| (window = window_from_coordinates (f, gx, gy, &part, 0),
NILP (window)))
{
width = FRAME_SMALLEST_CHAR_WIDTH (f);
......@@ -2230,6 +2230,9 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
width = WINDOW_FRAME_COLUMN_WIDTH (w);
height = WINDOW_FRAME_LINE_HEIGHT (w);
x = window_relative_x_coord (w, part, gx);
y = gy - WINDOW_TOP_EDGE_Y (w);
r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w);
......@@ -25383,7 +25386,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
}
/* Which window is that in? */
window = window_from_coordinates (f, x, y, &part, 0, 0, 1);
window = window_from_coordinates (f, x, y, &part, 1);
/* If we were displaying active text in another window, clear that.
Also clear if we move out of text area in same window. */
......
......@@ -6658,7 +6658,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
window = window_from_coordinates (f,
event.xmotion.x, event.xmotion.y,
0, 0, 0, 0);
0, 0);
/* Window will be selected only when it is not selected now and
last mouse movement event was not in it. Minibuffer window
......@@ -6797,7 +6797,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
int x = event.xbutton.x;
int y = event.xbutton.y;
window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
window = window_from_coordinates (f, x, y, 0, 1);
tool_bar_p = EQ (window, f->tool_bar_window);
if (tool_bar_p && event.xbutton.button < 4)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment