matthiasm wrote:

On 30.10.2008, at 09:44, Albrecht Schlosser wrote:

MacArthur, Ian (SELEX GALILEO, UK) wrote:

Not clear what the USE_TRACK_MOUSE stuff is actually meant to do, since
the mingw build (that does not use it) seems to function just fine...
Maybe someone else knows?

If activated, it requests from Windows to send a WM_MOUSELEAVE message
to the window, when the mouse leaves the window. When FLTK gets the
WM_MOUSELEAVE message, it sends an FL_LEAVE event to the window.

It sends a message when it leaves the window declared by hWnd in that call. Maybe hWnd is wrong, so we immediatly get the leave event since we were not in the given window to begin with. This of course is only a wild uess because I am currently Mac-only and can't test the MS Windows version.

It's a combination of more than one fact - I tested it for a while, and the attached patch (for FLTK 1.3) fixes _almost_ all symptoms. However, this is only for testing, I could not do any regression tests - maybe there are side effects...

(E.g. the modification in Fl_Group.cxx filters FL_LEAVE events, but I don't know if this would be needed for other reasons).

The fact that dragging the mouse sent events to the wrong window (and therefore generated FL_LEAVE events) had to do with the SetCapture() call that always used the main window for mouse events after clicking (and holding) a button. I changed it to use the "mouse_window", but maybe this also has side effects.

The last remaining issue is when you enter the GL window with the mouse. Windows _first_ sends a WM_MOUSEMOVE message with the hWnd of the (entered) GL window, and then a WM_MOUSELEAVE event with the (just left) main window's hWnd. This leads to an FL_ENTER event, immediately followed by an FL_LEAVE event and another FL_ENTER event for the GL window. But there are the same number of FL_ENTER and FL_LEAVE events with this patch.

More to come ...

Albrecht
Index: src/Fl_win32.cxx
===================================================================
--- src/Fl_win32.cxx    (revision 6479)
+++ src/Fl_win32.cxx    (working copy)
@@ -152,7 +152,9 @@
 // enter/leave notification under Windows.
 //
 
-//#define USE_TRACK_MOUSE
+// 
+#define USE_TRACK_MOUSE
+// #define DEBUG_TRACK_MOUSE
 
 #if !defined(__GNUC__)
 #  define USE_TRACK_MOUSE
@@ -612,6 +614,7 @@
   ClientToScreen(fl_xid(window), &pt);
   Fl::e_x_root = pt.x;
   Fl::e_y_root = pt.y;
+  Fl_Window *mouse_window = window;
   while (window->parent()) {
     Fl::e_x += window->x();
     Fl::e_y += window->y();
@@ -635,7 +638,7 @@
   case 0: // single-click
     Fl::e_clicks = 0;
   J1:
-    if (!fl_capture) SetCapture(fl_xid(window));
+    if (!fl_capture) SetCapture(fl_xid(mouse_window));
     Fl::e_keysym = FL_Button + button;
     Fl::e_is_click = 1;
     px = pmx = Fl::e_x_root; py = pmy = Fl::e_y_root;
@@ -854,8 +857,15 @@
   case WM_RBUTTONUP:    mouse_event(window, 2, 3, wParam, lParam); return 0;
 
   case WM_MOUSEMOVE:
+#ifdef DEBUG_TRACK_MOUSE
+      printf("### WM_MOUSEMOVE : window=%p, hWnd=%p, parent=%p\n",
+        window,hWnd,window->parent());
+#endif // DEBUG_TRACK_MOUSE
 #ifdef USE_TRACK_MOUSE
     if (Fl::belowmouse() != window) {
+#ifdef DEBUG_TRACK_MOUSE
+      printf("--- calling _TrackMouseEvent ...\n");
+#endif // DEBUG_TRACK_MOUSE
       TRACKMOUSEEVENT tme;
       tme.cbSize    = sizeof(TRACKMOUSEEVENT);
       tme.dwFlags   = TME_LEAVE;
@@ -867,6 +877,10 @@
     return 0;
 
   case WM_MOUSELEAVE:
+#ifdef DEBUG_TRACK_MOUSE
+    printf("### WM_MOUSELEAVE: window=%p, hWnd=%p, parent=%p ***L***\n",
+      window,hWnd,window->parent());
+#endif // DEBUG_TRACK_MOUSE
     Fl::belowmouse(0);
     if (!window->parent()) Fl::handle(FL_LEAVE, window);
     break;
Index: src/Fl_Group.cxx
===================================================================
--- src/Fl_Group.cxx    (revision 6479)
+++ src/Fl_Group.cxx    (working copy)
@@ -278,6 +278,9 @@
     }
     return 1;
 
+  case FL_LEAVE:
+    return 0;
+
   default:
     // For all other events, try to give to each child, starting at focus:
     for (i = 0; i < children(); i ++)
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to