]> Pileus Git - ~andy/gtk/commitdiff
Implement better mouse capturing. Do use SetCapture(). Thanks to
authorTor Lillqvist <tml@iki.fi>
Tue, 9 Jan 2001 16:45:44 +0000 (16:45 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Tue, 9 Jan 2001 16:45:44 +0000 (16:45 +0000)
2001-01-09  Tor Lillqvist  <tml@iki.fi>

* gdk/win32/gdkevents-win32.c: Implement better mouse
capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
(find_window_for_pointer_event): New function.
(gdk_event_translate): Use it when handling mouse events.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/win32/gdkevents-win32.c

index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index 4b7ae50ec887b64fd6bee0c5dc363c3c61ec914c..65bcafe4d406a613aceed1d0a1bf90412b364047 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-09  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkevents-win32.c: Implement better mouse
+       capturing. Do use SetCapture(). Thanks to jpe@archaeopteryx.com.
+       (find_window_for_pointer_event): New function.
+       (gdk_event_translate): Use it when handling mouse events.
+
 2001-01-09  Alexander Larsson  <alla@lysator.liu.se>
 
        * configure.in:
index a5f48ad536275a79d51e2518f2a325036eb9900f..51bed8a097cd0a117052afaf114e35b6a35f64bf 100644 (file)
@@ -36,6 +36,9 @@
  */
 /* define USE_TRACKMOUSEEVENT */
 
+/* Do use SetCapture, it works now. Thanks to jpe@archaeopteryx.com */
+#define USE_SETCAPTURE 1
+
 #include <stdio.h>
 
 #include "gdkprivate-win32.h"
@@ -531,11 +534,8 @@ gdk_pointer_grab (GdkWindow    *window,
          p_grab_owner_events = (owner_events != 0);
          p_grab_automatic = FALSE;
          
-#if 0 /* Menus don't work if we use mouse capture. Pity, because many other
-       * things work better with mouse capture.
-       */
+#if USE_SETCAPTURE
          SetCapture (GDK_WINDOW_HWND (window));
-#       pragma message("Warning: SetCapture call, menus won't work!")
 #endif
          return_val = GDK_GRAB_SUCCESS;
        }
@@ -574,7 +574,7 @@ gdk_pointer_ungrab (guint32 time)
 
   _gdk_input_ungrab_pointer (time);
   
-#if 1
+#if USE_SETCAPTURE
   if (GetCapture () != NULL)
     ReleaseCapture ();
 #endif
@@ -582,6 +582,63 @@ gdk_pointer_ungrab (guint32 time)
   p_grab_window = NULL;
 }
 
+/*
+ *--------------------------------------------------------------
+ * find_window_for_pointer_event
+ *
+ *   Find the window a pointer event (mouse up, down, move) should
+ *   be reported to.  If the return value != reported_window then
+ *   the ref count of reported_window will be decremented and the
+ *   ref count of the return value will be incremented.
+ *
+ * Arguments:
+ *
+ *  "reported_window" is the gdk window the xevent was reported relative to
+ *  "xevent" is the win32 message
+ *
+ * Results:
+ *
+ * Side effects:
+ *
+ *--------------------------------------------------------------
+ */
+
+static GdkWindow* 
+find_window_for_pointer_event (GdkWindow*  reported_window,
+                               MSG*        xevent)
+{
+  HWND hwnd;
+  POINTS points;
+  POINT pt;
+  GdkWindow* other_window;
+
+  if (p_grab_window == NULL || !p_grab_owner_events)
+    return reported_window;
+
+  points = MAKEPOINTS(xevent->lParam);
+  pt.x = points.x;
+  pt.y = points.y;
+  ClientToScreen (xevent->hwnd, &pt);
+
+  GDK_NOTE (EVENTS, g_print ("Finding window for grabbed pointer event at (%ld, %ld)\n",
+                             pt.x, pt.y));
+
+  hwnd = WindowFromPoint(pt);
+  if (hwnd == NULL)
+    return reported_window;
+  other_window = gdk_window_lookup(hwnd);
+  if (other_window == NULL)
+    return reported_window;
+
+  GDK_NOTE (EVENTS, g_print ("Found window %#x for point (%ld, %ld)\n",
+                            (guint) hwnd, pt.x, pt.y));
+
+  gdk_window_unref(reported_window);
+  gdk_window_ref(other_window);
+
+  return other_window;
+}
+
 /*
  *--------------------------------------------------------------
  * gdk_pointer_is_grabbed
@@ -2017,6 +2074,8 @@ gdk_event_translate (GdkEvent *event,
          break;
        }
 
+      ASSIGN_WINDOW (find_window_for_pointer_event (window, msg));
+
       if (window != current_window)
        synthesize_crossing_events (window, msg);
 
@@ -2077,6 +2136,8 @@ gdk_event_translate (GdkEvent *event,
                         (gulong) msg->hwnd,
                         LOWORD (msg->lParam), HIWORD (msg->lParam)));
 
+      ASSIGN_WINDOW (find_window_for_pointer_event (window, msg));
+
       if (GDK_WINDOW_OBJECT (window)->extension_events != 0
          && gdk_input_ignore_core)
        {
@@ -2122,6 +2183,8 @@ gdk_event_translate (GdkEvent *event,
                         (gulong) msg->hwnd, msg->wParam,
                         LOWORD (msg->lParam), HIWORD (msg->lParam)));
 
+      ASSIGN_WINDOW (find_window_for_pointer_event (window, msg));
+
       /* If we haven't moved, don't create any event.
        * Windows sends WM_MOUSEMOVE messages after button presses
        * even if the mouse doesn't move. This disturbs gtk.