[gtk+] Some cursor work for csw(win32), more left to do



commit c5c87a918f891f791131d13ea4bc0fcbae8b69c3
Author: Hans Breuer <hans breuer org>
Date:   Sun Jul 26 19:08:49 2009 +0200

    Some cursor work for csw(win32), more left to do

 gdk/win32/gdkevents-win32.c |   49 ++++++++++++++++++++++++++++++++++++++++--
 gdk/win32/gdkwindow-win32.c |    3 +-
 2 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 2cc4910..9a3c919 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -474,9 +474,52 @@ _gdk_windowing_pointer_grab (GdkWindow    *window,
 			     GdkCursor    *cursor,
 			     guint32	time)
 {
-  SetCapture (GDK_WINDOW_HWND (native_window));
-  /* TODO_CSW: grab brokens, confine window, cursor, input_grab */
-  return GDK_GRAB_SUCCESS;
+  HCURSOR hcursor;
+  GdkCursorPrivate *cursor_private;
+  gint return_val;
+
+  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 = (GdkCursorPrivate*) cursor;
+  
+  if (!cursor)
+    hcursor = NULL;
+  else if ((hcursor = CopyCursor (cursor_private->hcursor)) == NULL)
+    WIN32_API_FAILED ("CopyCursor");
+
+  return_val = _gdk_input_grab_pointer (native_window,
+					owner_events,
+					event_mask,
+					confine_to,
+					time);
+
+  if (return_val == GDK_GRAB_SUCCESS)
+    {
+      GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) native_window)->impl);
+
+      SetCapture (GDK_WINDOW_HWND (native_window));
+      /* 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;
 }
 
 void
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index de709ac..d341449 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -1928,7 +1928,8 @@ gdk_win32_window_set_cursor (GdkWindow *window,
     {
       /* If the pointer is over our window, set new cursor */
       GdkWindow *curr_window = gdk_window_get_pointer (window, NULL, NULL, NULL);
-      if (curr_window == window)
+      if (curr_window == window ||
+	  (curr_window && window == gdk_window_get_toplevel (curr_window)))
         SetCursor (impl->hcursor);
       else
 	{



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]