From bedcd855a277e9ad853c6e35391efbd0a76b6e6b Mon Sep 17 00:00:00 2001 From: Joel Bosveld Date: Fri, 14 Aug 2009 05:20:09 +0800 Subject: patches: add redirection to the gtk patch. --- patches/gtk+.patch | 191 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 161 insertions(+), 30 deletions(-) diff --git a/patches/gtk+.patch b/patches/gtk+.patch index a0691ff..a54dbc8 100644 --- a/patches/gtk+.patch +++ b/patches/gtk+.patch @@ -1,45 +1,176 @@ -From dc001c9a257ba6f96687d52336adf0c3e3505e7a Mon Sep 17 00:00:00 2001 +From dc1d1934931d4659d9371b8442efd53a9aa60106 Mon Sep 17 00:00:00 2001 From: Joel Bosveld Date: Mon, 13 Jul 2009 18:14:01 +0800 Subject: [PATCH] Make drag and drop work correctly with transformed top level windows --- - gdk/x11/gdkdnd-x11.c | 17 +++++++++++++---- - gdk/x11/gdkx.h | 2 ++ - gtk/gtkdnd.c | 25 ++++++++++++++++++++----- - 3 files changed, 35 insertions(+), 9 deletions(-) + gdk/x11/gdkdnd-x11.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++-- + gdk/x11/gdkx.h | 2 + + gtk/gtkdnd.c | 25 ++++++++-- + 3 files changed, 148 insertions(+), 9 deletions(-) diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c -index 118d793..cb4e6f8 100644 +index 118d793..299e12d 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c -@@ -591,13 +591,22 @@ get_client_window_at_coords (GdkWindowCache *cache, +@@ -40,6 +40,10 @@ + #include "gdkdisplay-x11.h" + #include "gdkalias.h" - if ((child->xid != ignore) && (child->mapped)) - { -- if ((x_root >= child->x) && (x_root < child->x + child->width) && -- (y_root >= child->y) && (y_root < child->y + child->height)) -+ gint x,y; -+#ifdef TRANSFORMATION -+ Window c; -+ Display *d = gdk_x11_display_get_xdisplay (gdk_screen_get_display (cache->screen)); -+ Window root = GDK_WINDOW_XID (gdk_screen_get_root_window (cache->screen)); -+ XTranslateCoordinates (d, root, child->xid, x_root, y_root, &x, &y, &c); -+#else -+ x = root_x - child->x; -+ y = root_y - child->y; ++#ifdef HAVE_XCOMPOSITE ++#include ++#endif ++ + typedef struct _GdkDragContextPrivateX11 GdkDragContextPrivateX11; + + typedef enum { +@@ -519,6 +523,77 @@ gdk_window_cache_destroy (GdkWindowCache *cache) + } + + static Window ++findTheRightWindow (GdkDisplay *dpy, int x, int y, Window w, Window t /*Probably the child */, Window ignore) ++{ ++ int cx, cy; ++ /* d is the destination window, if the window is redirecting */ ++ Window ret = 0, d = 0; ++ ++#ifdef HAVE_XCOMPOSITE ++ if (gdk_display_supports_composite (dpy)) ++ d = XCompositeGetDestinationWindow (GDK_DISPLAY_XDISPLAY(dpy), w); +#endif + -+ if ((x >= 0) && (x < child->width) && (y >= 0) && (y < child->height)) - { - retval = get_client_window_at_coords_recurse (gdk_screen_get_display (cache->screen), - child->xid, TRUE, -- x_root - child->x, -- y_root - child->y); -+ x, y); - if (!retval) - retval = child->xid; - } ++ if (d) { ++ w = d; ++ t = 0; ++ } ++ ++ /* Child needs to be skipped, so find the real child */ ++ if (d || (t && t == ignore)) { ++ Window root, p; ++ Window *c; ++ uint nc; ++ t = 0; ++ if (XQueryTree(GDK_DISPLAY_XDISPLAY(dpy), w, &root, &p, &c, &nc)) { ++ unsigned i; ++ for (i=nc; i--;) { ++ Window cg; ++ XWindowAttributes attr; ++ ++ if (c[i] == ignore) continue; ++ ++ XGetWindowAttributes(GDK_DISPLAY_XDISPLAY(dpy), c[i], &attr); ++ XTranslateCoordinates(GDK_DISPLAY_XDISPLAY(dpy), w, c[i], x, y, &cx, &cy, &cg); ++ ++ if (attr.map_state == IsUnmapped) continue; ++ ++ if (cx>=0 && cy>=0 && cxscreen)); + } + ++static Window ++get_client_window_at_coords (GdkWindowCache *cache, ++ Window ignore, ++ gint x_root, ++ gint y_root) ++{ ++ GdkDisplay *dpy = gdk_screen_get_display (cache->screen); ++ Window ret, r, t; ++ int x, y; ++ ++ if (g_getenv ("GTK_USE_OLD_DND_PATH")) ++ return get_client_window_at_coords_old (cache, ignore, x_root, y_root); ++ ++ r = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (cache->screen)); ++ ++ XTranslateCoordinates(GDK_DISPLAY_XDISPLAY(dpy), r, r, x_root, y_root, &x, &y, &t); ++ ret = findTheRightWindow (dpy, x_root, y_root, r, t, ignore); ++ if (!ret) ++ { ++ if (t && t != ignore) ++ ret = t; ++ else if (t) // t == ignore ++ { ++ GList *tmp_list = cache->children; ++ while (tmp_list) ++ { ++ GdkCacheChild *child = tmp_list->data; ++ ++ if ((child->xid != ignore) && (child->mapped)) ++ { ++ if ((x_root >= child->x) && (x_root < child->x + child->width) && ++ (y_root >= child->y) && (y_root < child->y + child->height)) ++ { ++ ret = child->xid; ++ break; ++ } ++ ++ } ++ tmp_list = tmp_list->next; ++ } ++ } ++ if (!ret) ++ ret = r; ++ } ++ return ret; ++} ++ + /************************************************************* + ***************************** MOTIF ************************* + *************************************************************/ diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index baa395d..6519a2d 100644 --- a/gdk/x11/gdkx.h -- cgit v1.2.3