diff src/scrollbar-msw.c @ 707:a307f9a2021d

[xemacs-hg @ 2001-12-20 05:49:28 by andyp] sync with 21-4-6-windows
author andyp
date Thu, 20 Dec 2001 05:49:48 +0000
parents 685b588e92d8
children 943eaba38521
line wrap: on
line diff
--- a/src/scrollbar-msw.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/scrollbar-msw.c	Thu Dec 20 05:49:48 2001 +0000
@@ -330,40 +330,45 @@
 {
   int hasVertBar, hasHorzBar;	/* Indicates presence of scroll bars */
   unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */
-  Lisp_Object win;
+  Lisp_Object win, corpore, sano;
   struct window_mirror *mirror;
+  int mene, _mene, tekel, upharsin;
+  Charbpos mens, sana;
+  Charcount in;
+  struct window *needle_in_haystack = 0;
   POINT donde_esta;
 
   donde_esta.x = where.x;
   donde_esta.y = where.y;
 
-  ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), &donde_esta);
-
   /* Find the window to scroll */
-  {
-    int mene, _mene, tekel, upharsin;
-    Charbpos mens, sana;
-    Charcount in;
-    Lisp_Object corpore, sano;
-    struct window *needle_in_haystack;
 
-    pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y,
-				&mene, &_mene, &tekel, &upharsin,
-				&needle_in_haystack,
-				&mens, &sana, &in, &corpore, &sano);
+  /* The mouse event could actually occur outside of the emacs
+     frame. */
+  if (ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 
+		      &donde_esta) != 0)
+    {
+      /* stderr_out ("donde_esta: %d %d\n", donde_esta.x, donde_esta.y); */
+      pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y,
+				  &mene, &_mene, &tekel, &upharsin,
+				  &needle_in_haystack,
+				  &mens, &sana, &in, &corpore, &sano);
+      
+      if (needle_in_haystack)
+	{
+	  XSETWINDOW (win, needle_in_haystack);
+	  /* stderr_out ("found needle\n");
+	     debug_print (win); */
+	}
+    }
+  
+  if (!needle_in_haystack)
+    {
+      win = FRAME_SELECTED_WINDOW (XFRAME (frame));
+      needle_in_haystack = XWINDOW (win);
+    }
 
-    if (needle_in_haystack)
-      {
-	XSETWINDOW (win, needle_in_haystack);
-      }
-    else
-      {
-	win = FRAME_SELECTED_WINDOW (XFRAME (frame));
-	needle_in_haystack = XWINDOW (win);
-      }
-
-    mirror = find_window_mirror (needle_in_haystack);
-  }
+  mirror = find_window_mirror (needle_in_haystack);
 
   /* Check that there is something to scroll */
   hasVertBar = can_scroll (mirror->scrollbar_vertical_instance);