diff src/scrollbar-msw.c @ 464:5aa1854ad537 r21-2-47

Import from CVS: tag r21-2-47
author cvs
date Mon, 13 Aug 2007 11:45:51 +0200
parents abe6d1db359e
children 54fa1a5c2d12
line wrap: on
line diff
--- a/src/scrollbar-msw.c	Mon Aug 13 11:44:39 2007 +0200
+++ b/src/scrollbar-msw.c	Mon Aug 13 11:45:51 2007 +0200
@@ -266,7 +266,7 @@
 }
 
 static int
-can_scroll(struct scrollbar_instance* scrollbar)
+can_scroll (struct scrollbar_instance* scrollbar)
 {
   return scrollbar != NULL
 	&& IsWindowVisible (SCROLLBAR_MSW_HANDLE (scrollbar))
@@ -274,15 +274,48 @@
 }
 
 int
-mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta)
+mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta,
+				   POINTS where)
 {
   int hasVertBar, hasHorzBar;	/* Indicates presence of scroll bars */
   unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */
+  Lisp_Object win;
+  struct window_mirror *mirror;
+  POINT donde_esta;
 
-  /* Find the currently selected window */
-  Lisp_Object win = FRAME_SELECTED_WINDOW (XFRAME (frame));
-  struct window* w = XWINDOW (win);
-  struct window_mirror* mirror = find_window_mirror (w);
+  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;
+    Bufpos mens, sana;
+    Charcount in;
+    Lisp_Object corpore, sano;
+    struct window *needle_in_haystack;
+
+    // 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);
+      }
+    else
+      {
+	win = FRAME_SELECTED_WINDOW (XFRAME (frame));
+	needle_in_haystack = XWINDOW (win);
+      }
+
+    mirror = find_window_mirror (needle_in_haystack);
+  }
 
   /* Check that there is something to scroll */
   hasVertBar = can_scroll (mirror->scrollbar_vertical_instance);