]> Pileus Git - ~andy/gtk/blobdiff - gdk/win32/gdkevents-win32.c
Change FSF Address
[~andy/gtk] / gdk / win32 / gdkevents-win32.c
index 4f5aa62c1b923057a6a9b86749a50dec0f34911e..05a68c35dc7035531f6f81434b6c829a1e491bd9 100644 (file)
@@ -15,9 +15,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -90,6 +88,8 @@
  * Private function declarations
  */
 
+#define SYNAPSIS_ICON_WINDOW_CLASS "SynTrackCursorWindowClass"
+
 static gboolean gdk_event_translate (MSG        *msg,
                                     gint       *ret_valp);
 static void     handle_wm_paint     (MSG        *msg,
@@ -110,7 +110,7 @@ static gboolean gdk_event_dispatch (GSource     *source,
 static GList *client_filters;  /* Filters for client messages */
 extern gint       _gdk_input_ignore_core;
 
-static HCURSOR p_grab_cursor;
+HCURSOR _gdk_win32_grab_cursor;
 
 static GSourceFuncs event_funcs = {
   gdk_event_prepare,
@@ -122,6 +122,7 @@ static GSourceFuncs event_funcs = {
 GPollFD event_poll_fd;
 
 static GdkWindow *mouse_window = NULL;
+static GdkWindow *mouse_window_ignored_leave = NULL;
 static gint current_x, current_y;
 static gint current_root_x, current_root_y;
 static UINT client_message;
@@ -442,60 +443,6 @@ event_mask_string (GdkEventMask mask)
 
 #endif
 
-GdkGrabStatus
-_gdk_windowing_device_grab (GdkDevice    *device,
-                            GdkWindow    *window,
-                            GdkWindow    *native_window,
-                            gboolean      owner_events,
-                            GdkEventMask       event_mask,
-                            GdkWindow    *confine_to,
-                            GdkCursor    *cursor,
-                            guint32          time)
-{
-  HCURSOR hcursor;
-  GdkWin32Cursor *cursor_private;
-  gint return_val;
-  GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (native_window->impl);
-
-  g_return_val_if_fail (window != NULL, 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
-  g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
-  
-  cursor_private = (GdkWin32Cursor*) cursor;
-  
-  if (!cursor)
-    hcursor = NULL;
-  else if ((hcursor = CopyCursor (cursor_private->hcursor)) == NULL)
-    WIN32_API_FAILED ("CopyCursor");
-
-  return_val = GDK_DEVICE_GET_CLASS (device)->grab (device,
-                                                    native_window,
-                                                    owner_events,
-                                                    event_mask,
-                                                    confine_to,
-                                                    cursor,
-                                                    time);
-
-  /* TODO_CSW: grab brokens, confine window, input_grab */
-  if (p_grab_cursor != NULL)
-    {
-      if (GetCursor () == p_grab_cursor)
-        SetCursor (NULL);
-      DestroyCursor (p_grab_cursor);
-    }
-
-  p_grab_cursor = hcursor;
-
-  if (p_grab_cursor != NULL)
-    SetCursor (p_grab_cursor);
-  else if (impl->hcursor != NULL)
-    SetCursor (impl->hcursor);
-  else
-    SetCursor (LoadCursor (NULL, IDC_ARROW));
-
-  return return_val;
-}
-
 static GdkWindow *
 find_window_for_mouse_event (GdkWindow* reported_window,
                             MSG*       msg)
@@ -884,6 +831,14 @@ fixup_event (GdkEvent *event)
        (event->any.type == GDK_LEAVE_NOTIFY)) &&
       (event->crossing.subwindow != NULL))
     g_object_ref (event->crossing.subwindow);
+  if (((event->any.type == GDK_SELECTION_CLEAR) ||
+       (event->any.type == GDK_SELECTION_NOTIFY) ||
+       (event->any.type == GDK_SELECTION_REQUEST)) &&
+      (event->selection.requestor != NULL))
+    g_object_ref (event->selection.requestor);
+  if ((event->any.type == GDK_OWNER_CHANGE) &&
+      (event->owner_change.owner != NULL))
+    g_object_ref (event->owner_change.owner);
   event->any.send_event = InSendMessage (); 
 }
 
@@ -1898,6 +1853,7 @@ gdk_event_translate (MSG  *msg,
   BYTE key_state[256];
   HIMC himc;
   WINDOWPOS *windowpos;
+  gboolean ignore_leave;
 
   GdkEvent *event;
 
@@ -2357,6 +2313,7 @@ gdk_event_translate (MSG  *msg,
                                          msg->time,
                                          FALSE);
              assign_object (&mouse_window, new_window);
+             mouse_window_ignored_leave = NULL;
            }
        }
 
@@ -2410,9 +2367,19 @@ gdk_event_translate (MSG  *msg,
                                      msg->time,
                                      FALSE);
          assign_object (&mouse_window, new_window);
+         mouse_window_ignored_leave = NULL;
          if (new_window != NULL)
            track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (new_window));
        }
+      else if (new_window != NULL && 
+              new_window == mouse_window_ignored_leave)
+       {
+         /* If we ignored a leave event for this window and we're now getting
+            input again we need to re-arm the mouse tracking, as that was
+            cancelled by the mouseleave. */
+         mouse_window_ignored_leave = NULL;
+         track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (new_window));
+       }
 
       assign_object (&window, find_window_for_mouse_event (window, msg));
 
@@ -2456,24 +2423,38 @@ gdk_event_translate (MSG  *msg,
 
       new_window = NULL;
       hwnd = WindowFromPoint (msg->pt);
+      ignore_leave = FALSE;
       if (hwnd != NULL)
        {
+         char classname[64];
+
          POINT client_pt = msg->pt;
 
+         /* The synapitics trackpad drivers have this irritating
+            feature where it pops up a window right under the pointer
+            when you scroll. We ignore the leave and enter events for 
+            this window */
+         if (GetClassNameA (hwnd, classname, sizeof(classname)) &&
+             strcmp (classname, SYNAPSIS_ICON_WINDOW_CLASS) == 0)
+           ignore_leave = TRUE;
+
          ScreenToClient (hwnd, &client_pt);
          GetClientRect (hwnd, &rect);
          if (PtInRect (&rect, client_pt))
            new_window = gdk_win32_handle_table_lookup (hwnd);
        }
 
-      synthesize_crossing_events (_gdk_display,
-                                 mouse_window, new_window,
-                                 GDK_CROSSING_NORMAL,
-                                 &msg->pt,
-                                 0, /* TODO: Set right mask */
-                                 msg->time,
-                                 FALSE);
+      if (!ignore_leave)
+       synthesize_crossing_events (_gdk_display,
+                                   mouse_window, new_window,
+                                   GDK_CROSSING_NORMAL,
+                                   &msg->pt,
+                                   0, /* TODO: Set right mask */
+                                   msg->time,
+                                   FALSE);
       assign_object (&mouse_window, new_window);
+      mouse_window_ignored_leave = ignore_leave ? new_window : NULL;
+
 
       return_val = TRUE;
       break;
@@ -2491,6 +2472,30 @@ gdk_event_translate (MSG  *msg,
 
       if ((hwnd = WindowFromPoint (point)) == NULL)
        break;
+      
+      {
+       char classname[64];
+
+       /* The synapitics trackpad drivers have this irritating
+          feature where it pops up a window right under the pointer
+          when you scroll. We backtrack and to the toplevel and
+          find the innermost child instead. */
+       if (GetClassNameA (hwnd, classname, sizeof(classname)) &&
+           strcmp (classname, SYNAPSIS_ICON_WINDOW_CLASS) == 0)
+         {
+           HWND hwndc;
+
+           /* Find our toplevel window */
+           hwnd = GetAncestor (msg->hwnd, GA_ROOT);
+
+           /* Walk back up to the outermost child at the desired point */
+           do {
+             ScreenToClient (hwnd, &point);
+             hwndc = ChildWindowFromPoint (hwnd, point);
+             ClientToScreen (hwnd, &point);
+           } while (hwndc != hwnd && (hwnd = hwndc, 1));
+         }
+      }
 
       msg->hwnd = hwnd;
       if ((new_window = gdk_win32_handle_table_lookup (msg->hwnd)) == NULL)
@@ -2560,8 +2565,6 @@ gdk_event_translate (MSG  *msg,
 
      case WM_MOUSEACTIVATE:
        {
-        GdkWindow *tmp;
-
         if (gdk_window_get_window_type (window) == GDK_WINDOW_TEMP 
             || !window->accept_focus)
           {
@@ -2631,8 +2634,8 @@ gdk_event_translate (MSG  *msg,
       if (grab_window == NULL && LOWORD (msg->lParam) != HTCLIENT)
        break;
 
-      if (grab_window != NULL && p_grab_cursor != NULL)
-       hcursor = p_grab_cursor;
+      if (grab_window != NULL && _gdk_win32_grab_cursor != NULL)
+       hcursor = _gdk_win32_grab_cursor;
       else if (!GDK_WINDOW_DESTROYED (window))
        hcursor = GDK_WINDOW_IMPL_WIN32 (window->impl)->hcursor;
       else
@@ -2725,7 +2728,8 @@ gdk_event_translate (MSG  *msg,
                gdk_pointer_ungrab (msg->time);
            }
 
-         if (keyboard_grab->window == window)
+         if (keyboard_grab != NULL &&
+             keyboard_grab->window == window)
            gdk_keyboard_ungrab (msg->time);
        }