DnD bugfixes (hopefully :). Rasters code is still buggy, methinks - try the dnd in testgtk

This commit is contained in:
Elliot Lee 1998-03-10 21:57:05 +00:00
parent fabfc17d93
commit 120df3b8b7
7 changed files with 37 additions and 4 deletions

View File

@ -2069,7 +2069,10 @@ gdk_event_translate (GdkEvent *event,
/* XXX there has to be a better way to do this, perhaps with /* XXX there has to be a better way to do this, perhaps with
XTranslateCoordinates or XQueryTree - I don't know how, XTranslateCoordinates or XQueryTree - I don't know how,
and this sort of works */ and this sort of works */
static Window lastwin = None, curwin = None, twin; static Window lastwin = None, curwin = None;
#if 0
Window twin;
#endif
Window childwin = gdk_root_window; Window childwin = gdk_root_window;
int x, y, ox, oy; int x, y, ox, oy;
@ -2083,6 +2086,13 @@ gdk_event_translate (GdkEvent *event,
curwin = gdk_root_window; curwin = gdk_root_window;
ox = x = xevent->xmotion.x_root; ox = x = xevent->xmotion.x_root;
oy = y = xevent->xmotion.y_root; oy = y = xevent->xmotion.y_root;
#if 1
curwin = gdk_window_xid_at_coords(xevent->xmotion.x_root,
xevent->xmotion.y_root,
gdk_dnd.c->xids);
XTranslateCoordinates(gdk_display, gdk_root_window, curwin,
x, y, &x, &y, &childwin);
#else
while(childwin != None) while(childwin != None)
{ {
ox = x; oy = y; ox = x; oy = y;
@ -2095,6 +2105,7 @@ gdk_event_translate (GdkEvent *event,
x, y, &x, &y, &twin); x, y, &x, &y, &twin);
} }
} }
#endif
GDK_NOTE (DND, GDK_NOTE (DND,
g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n", g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n",
curwin, lastwin, gdk_dnd.dnd_drag_curwin)); curwin, lastwin, gdk_dnd.dnd_drag_curwin));

View File

@ -26,6 +26,8 @@ gdk_dnd_set_drag_cursors(GdkCursor *default_cursor, GdkCursor *goahead_cursor)
gdk_window_unref(gdk_dnd.c->drag_pm_ok); gdk_window_unref(gdk_dnd.c->drag_pm_ok);
} }
gdk_dnd.c->drag_pm_default = gdk_dnd.c->drag_pm_ok = NULL; gdk_dnd.c->drag_pm_default = gdk_dnd.c->drag_pm_ok = NULL;
g_list_free(gdk_dnd.c->xids);
gdk_dnd.c->xids = NULL;
} }
gdk_dnd_display_drag_cursor(-1, -1, gdk_dnd_display_drag_cursor(-1, -1,
gdk_dnd.dnd_drag_target?TRUE:FALSE, gdk_dnd.dnd_drag_target?TRUE:FALSE,
@ -41,6 +43,7 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin,
{ {
g_return_if_fail(default_pixmapwin != NULL); g_return_if_fail(default_pixmapwin != NULL);
g_list_free(gdk_dnd.c->xids); gdk_dnd.c->xids = NULL;
if(gdk_dnd.c->drag_pm_default) if(gdk_dnd.c->drag_pm_default)
gdk_window_unref(gdk_dnd.c->drag_pm_default); gdk_window_unref(gdk_dnd.c->drag_pm_default);
if(gdk_dnd.c->drag_pm_ok) if(gdk_dnd.c->drag_pm_ok)
@ -51,9 +54,11 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin,
gdk_window_ref(default_pixmapwin); gdk_window_ref(default_pixmapwin);
gdk_dnd.c->drag_pm_default = default_pixmapwin; gdk_dnd.c->drag_pm_default = default_pixmapwin;
gdk_dnd.c->default_hotspot = *default_hotspot; gdk_dnd.c->default_hotspot = *default_hotspot;
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, ((GdkWindowPrivate *)default_pixmapwin)->xwindow);
if(goahead_pixmapwin) if(goahead_pixmapwin)
{ {
gdk_window_ref(goahead_pixmapwin); gdk_window_ref(goahead_pixmapwin);
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, ((GdkWindowPrivate *)goahead_pixmapwin)->xwindow);
gdk_dnd.c->drag_pm_ok = goahead_pixmapwin; gdk_dnd.c->drag_pm_ok = goahead_pixmapwin;
gdk_dnd.c->ok_hotspot = *goahead_hotspot; gdk_dnd.c->ok_hotspot = *goahead_hotspot;
} }

View File

@ -34,7 +34,7 @@ Atom gdk_wm_protocols;
Atom gdk_wm_window_protocols[2]; Atom gdk_wm_window_protocols[2];
Atom gdk_selection_property; Atom gdk_selection_property;
GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL, GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL,
{0,0}, {0,0}}; {0,0}, {0,0}, NULL};
GdkDndGlobals gdk_dnd = {None,None,None, GdkDndGlobals gdk_dnd = {None,None,None,
None,None,None, None,None,None,
None, None,

View File

@ -146,6 +146,7 @@ struct _GdkDndCursorInfo {
Cursor gdk_cursor_dragdefault, gdk_cursor_dragok; Cursor gdk_cursor_dragdefault, gdk_cursor_dragok;
GdkWindow *drag_pm_default, *drag_pm_ok; GdkWindow *drag_pm_default, *drag_pm_ok;
GdkPoint default_hotspot, ok_hotspot; GdkPoint default_hotspot, ok_hotspot;
GList *xids;
}; };
typedef struct _GdkDndCursorInfo GdkDndCursorInfo; typedef struct _GdkDndCursorInfo GdkDndCursorInfo;

View File

@ -26,6 +26,8 @@ gdk_dnd_set_drag_cursors(GdkCursor *default_cursor, GdkCursor *goahead_cursor)
gdk_window_unref(gdk_dnd.c->drag_pm_ok); gdk_window_unref(gdk_dnd.c->drag_pm_ok);
} }
gdk_dnd.c->drag_pm_default = gdk_dnd.c->drag_pm_ok = NULL; gdk_dnd.c->drag_pm_default = gdk_dnd.c->drag_pm_ok = NULL;
g_list_free(gdk_dnd.c->xids);
gdk_dnd.c->xids = NULL;
} }
gdk_dnd_display_drag_cursor(-1, -1, gdk_dnd_display_drag_cursor(-1, -1,
gdk_dnd.dnd_drag_target?TRUE:FALSE, gdk_dnd.dnd_drag_target?TRUE:FALSE,
@ -41,6 +43,7 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin,
{ {
g_return_if_fail(default_pixmapwin != NULL); g_return_if_fail(default_pixmapwin != NULL);
g_list_free(gdk_dnd.c->xids); gdk_dnd.c->xids = NULL;
if(gdk_dnd.c->drag_pm_default) if(gdk_dnd.c->drag_pm_default)
gdk_window_unref(gdk_dnd.c->drag_pm_default); gdk_window_unref(gdk_dnd.c->drag_pm_default);
if(gdk_dnd.c->drag_pm_ok) if(gdk_dnd.c->drag_pm_ok)
@ -51,9 +54,11 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin,
gdk_window_ref(default_pixmapwin); gdk_window_ref(default_pixmapwin);
gdk_dnd.c->drag_pm_default = default_pixmapwin; gdk_dnd.c->drag_pm_default = default_pixmapwin;
gdk_dnd.c->default_hotspot = *default_hotspot; gdk_dnd.c->default_hotspot = *default_hotspot;
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, ((GdkWindowPrivate *)default_pixmapwin)->xwindow);
if(goahead_pixmapwin) if(goahead_pixmapwin)
{ {
gdk_window_ref(goahead_pixmapwin); gdk_window_ref(goahead_pixmapwin);
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, ((GdkWindowPrivate *)goahead_pixmapwin)->xwindow);
gdk_dnd.c->drag_pm_ok = goahead_pixmapwin; gdk_dnd.c->drag_pm_ok = goahead_pixmapwin;
gdk_dnd.c->ok_hotspot = *goahead_hotspot; gdk_dnd.c->ok_hotspot = *goahead_hotspot;
} }

View File

@ -34,7 +34,7 @@ Atom gdk_wm_protocols;
Atom gdk_wm_window_protocols[2]; Atom gdk_wm_window_protocols[2];
Atom gdk_selection_property; Atom gdk_selection_property;
GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL, GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL,
{0,0}, {0,0}}; {0,0}, {0,0}, NULL};
GdkDndGlobals gdk_dnd = {None,None,None, GdkDndGlobals gdk_dnd = {None,None,None,
None,None,None, None,None,None,
None, None,

View File

@ -2069,7 +2069,10 @@ gdk_event_translate (GdkEvent *event,
/* XXX there has to be a better way to do this, perhaps with /* XXX there has to be a better way to do this, perhaps with
XTranslateCoordinates or XQueryTree - I don't know how, XTranslateCoordinates or XQueryTree - I don't know how,
and this sort of works */ and this sort of works */
static Window lastwin = None, curwin = None, twin; static Window lastwin = None, curwin = None;
#if 0
Window twin;
#endif
Window childwin = gdk_root_window; Window childwin = gdk_root_window;
int x, y, ox, oy; int x, y, ox, oy;
@ -2083,6 +2086,13 @@ gdk_event_translate (GdkEvent *event,
curwin = gdk_root_window; curwin = gdk_root_window;
ox = x = xevent->xmotion.x_root; ox = x = xevent->xmotion.x_root;
oy = y = xevent->xmotion.y_root; oy = y = xevent->xmotion.y_root;
#if 1
curwin = gdk_window_xid_at_coords(xevent->xmotion.x_root,
xevent->xmotion.y_root,
gdk_dnd.c->xids);
XTranslateCoordinates(gdk_display, gdk_root_window, curwin,
x, y, &x, &y, &childwin);
#else
while(childwin != None) while(childwin != None)
{ {
ox = x; oy = y; ox = x; oy = y;
@ -2095,6 +2105,7 @@ gdk_event_translate (GdkEvent *event,
x, y, &x, &y, &twin); x, y, &x, &y, &twin);
} }
} }
#endif
GDK_NOTE (DND, GDK_NOTE (DND,
g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n", g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n",
curwin, lastwin, gdk_dnd.dnd_drag_curwin)); curwin, lastwin, gdk_dnd.dnd_drag_curwin));