changeset 6644:8e2379ce4fcb

(fast_find_position): Always return coords within the window. (note_mouse_highlight): Handle disable_mouse_highlight.
author Richard M. Stallman <rms@gnu.org>
date Sun, 03 Apr 1994 02:04:04 +0000
parents 07be9ae289ce
children ba0c1af167e6
files src/xterm.c
diffstat 1 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Sun Apr 03 02:03:30 1994 +0000
+++ b/src/xterm.c	Sun Apr 03 02:04:04 1994 +0000
@@ -1912,6 +1912,9 @@
     }
 }
 
+/* This is used for debugging, to turn off note_mouse_highlight.  */
+static int disable_mouse_highlight;
+
 /* Take proper action when the mouse has moved to position X, Y on frame F
    as regards highlighting characters that have mouse-face properties.
    Also dehighlighting chars where the mouse was before.  */
@@ -1925,6 +1928,9 @@
   Lisp_Object window;
   struct window *w;
 
+  if (disable_mouse_highlight)
+    return;
+
   mouse_face_mouse_x = x;
   mouse_face_mouse_y = y;
   mouse_face_mouse_frame = f;
@@ -2059,7 +2065,10 @@
 
 /* Find the row and column of position POS in window WINDOW.
    Store them in *COLUMNP and *ROWP.
-   This assumes display in WINDOW is up to date.  */
+   This assumes display in WINDOW is up to date.
+   If POS is above start of WINDOW, return coords
+   of start of first screen line.
+   If POS is after end of WINDOW, return coords of end of last screen line.  */
 
 static int
 fast_find_position (window, pos, columnp, rowp)
@@ -2076,6 +2085,7 @@
   int height = XFASTINT (w->height) - ! MINI_WINDOW_P (w);
   int width = window_internal_width (w);
   int *charstarts;
+  int lastcol;
 
   for (i = 0;
        i < height;
@@ -2089,14 +2099,21 @@
     }
 
   charstarts = FRAME_CURRENT_GLYPHS (f)->charstarts[top + row];
+  lastcol = left;
   for (i = 0; i < width; i++)
-    if (charstarts[left + i] == pos)
-      {
-	*rowp = row + top;
-	*columnp = i + left;
-	return 1;
-      }
-
+    {
+      if (charstarts[left + i] == pos)
+	{
+	  *rowp = row + top;
+	  *columnp = i + left;
+	  return 1;
+	}
+      else if (charstarts[left + i] > pos)
+	lastcol = left + i;
+    }
+
+  *rowp = row + top;
+  *columnp = lastcol;
   return 0;
 }