On 18/09/2011 11:00, Dieter Verfaillie wrote: > This does most likely does break the wip generic OLE DnD method > though, but I'm not sure if we should care much about that in > the 2.24 branch? Cleaned up patch fixing the above. Tested various DnD operations with testtreeview and gtk-demo. Together with Peter's patch-set, GTK+ 2.24 is starting to behave as it should again :) mvg, Dieter
>From 0fb53f625235ebb71ca250c480c0888d9a376879 Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie <dieterv@xxxxxxxxxxxxxxxxx> Date: Sun, 18 Sep 2011 11:44:37 +0200 Subject: [PATCH] win32: Fix TreeView DnD By reverting gdk_drag_find_window_for_screen logic to what it was before eb21a7df290936223f6a80cef36b52a8c68a1d22. The old logic knew how to ignore drag_window when searching for dest_window, but that code was removed (I guess by accident) in eb21a7df290936223f6a80cef36b52a8c68a1d22 --- gdk/win32/gdkdnd-win32.c | 65 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 53 insertions(+), 12 deletions(-) diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index daf5291..16abed7 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -1970,6 +1970,43 @@ gdk_drag_get_protocol_for_display (GdkDisplay *display, return 0; } +typedef struct { + gint x; + gint y; + HWND ignore; + HWND result; +} find_window_enum_arg; + +static BOOL CALLBACK +find_window_enum_proc (HWND hwnd, + LPARAM lparam) +{ + RECT rect; + POINT tl, br; + find_window_enum_arg *a = (find_window_enum_arg *) lparam; + + if (hwnd == a->ignore) + return TRUE; + + if (!IsWindowVisible (hwnd)) + return TRUE; + + tl.x = tl.y = 0; + ClientToScreen (hwnd, &tl); + GetClientRect (hwnd, &rect); + br.x = rect.right; + br.y = rect.bottom; + ClientToScreen (hwnd, &br); + + if (a->x >= tl.x && a->y >= tl.y && a->x < br.x && a->y < br.y) + { + a->result = hwnd; + return FALSE; + } + else + return TRUE; +} + void gdk_drag_find_window_for_screen (GdkDragContext *context, GdkWindow *drag_window, @@ -1979,37 +2016,41 @@ gdk_drag_find_window_for_screen (GdkDragContext *context, GdkWindow **dest_window, GdkDragProtocol *protocol) { - POINT pt; - HWND hwnd; + find_window_enum_arg a; - pt.x = x_root - _gdk_offset_x; - pt.y = y_root - _gdk_offset_y; + a.x = x_root - _gdk_offset_x; + a.y = y_root - _gdk_offset_y; + a.ignore = drag_window ? GDK_WINDOW_HWND (drag_window) : NULL; + a.result = NULL; - hwnd = WindowFromPoint (pt); + EnumWindows (find_window_enum_proc, (LPARAM) &a); - if (hwnd == NULL) + if (a.result == NULL) *dest_window = NULL; else { - *dest_window = gdk_win32_handle_table_lookup (hwnd); + *dest_window = gdk_win32_handle_table_lookup (a.result); if (*dest_window) - g_object_ref (*dest_window); + { + *dest_window = gdk_window_get_toplevel (*dest_window); + g_object_ref (*dest_window); + } else - *dest_window = gdk_window_foreign_new_for_display (_gdk_display, hwnd); + *dest_window = gdk_win32_window_foreign_new_for_display (_gdk_display, a.result); if (use_ole2_dnd) - *protocol = GDK_DRAG_PROTO_OLE2; + *protocol = GDK_DRAG_PROTO_OLE2; else if (context->source_window) *protocol = GDK_DRAG_PROTO_LOCAL; else - *protocol = GDK_DRAG_PROTO_WIN32_DROPFILES; + *protocol = GDK_DRAG_PROTO_WIN32_DROPFILES; } GDK_NOTE (DND, g_print ("gdk_drag_find_window: %p %+d%+d: %p: %p %s\n", (drag_window ? GDK_WINDOW_HWND (drag_window) : NULL), x_root, y_root, - hwnd, + a.result, (*dest_window ? GDK_WINDOW_HWND (*dest_window) : NULL), _gdk_win32_drag_protocol_to_string (*protocol))); } -- 1.7.6.msysgit.0
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list