summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <Joel.Bosveld@gmail.com>2009-08-14 05:20:09 +0800
committerJoel Bosveld <Joel.Bosveld@gmail.com>2009-08-14 05:20:09 +0800
commitbedcd855a277e9ad853c6e35391efbd0a76b6e6b (patch)
tree657e24319ed540ac043a97a6f0c74226b7aa0a59
parent6c2d66015840a61f4eef68b26661888b6258f8e4 (diff)
patches: add redirection to the gtk patch.
-rw-r--r--patches/gtk+.patch191
1 files 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 <Joel.Bosveld@gmail.com>
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 <X11/extensions/Xcomposite.h>
++#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 && cx<attr.width && cy<attr.height) {
++ ret = findTheRightWindow (dpy, cx, cy, c[i], cg, ignore);
++ break;
++ }
++ }
++ if (c) XFree (c);
++ }
++ }
++ else if (t)
++ {
++ Window cg;
++ XTranslateCoordinates(GDK_DISPLAY_XDISPLAY(dpy), w, t, x, y, &cx, &cy, &cg);
++ ret = findTheRightWindow (dpy, cx, cy, t, cg, ignore);
++ }
++
++ /* We've already found the deepest window with the correct property */
++ if (ret)
++ return ret;
++
++ Atom type = 0;
++ Atom wm_state_atom = gdk_x11_get_xatom_by_name_for_display (dpy, "WM_STATE");
++ int f;
++ unsigned long n, a;
++ unsigned char *data;
++
++ XGetWindowProperty(GDK_DISPLAY_XDISPLAY(dpy), w, wm_state_atom, 0, 0,
++ False, AnyPropertyType, &type, &f,&n,&a,&data);
++ if (data)
++ XFree(data);
++ if (type)
++ return w;
++
++ return 0;
++}
++
++static Window
+ get_client_window_at_coords_recurse (GdkDisplay *display,
+ Window win,
+ gboolean is_toplevel,
+@@ -573,10 +648,10 @@ get_client_window_at_coords_recurse (GdkDisplay *display,
+ }
+
+ static Window
+-get_client_window_at_coords (GdkWindowCache *cache,
+- Window ignore,
+- gint x_root,
+- gint y_root)
++get_client_window_at_coords_old (GdkWindowCache *cache,
++ Window ignore,
++ gint x_root,
++ gint y_root)
+ {
+ GList *tmp_list;
+ Window retval = None;
+@@ -614,6 +689,53 @@ get_client_window_at_coords (GdkWindowCache *cache,
+ return GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (cache->screen));
+ }
+
++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