This commit moves dnd variables around a bit, and has a try at using hints for the shape dragging (this is for quartic)

This commit is contained in:
Elliot Lee 1998-03-06 05:14:09 +00:00
parent 2a4c36a73d
commit 3033d6b47a
5 changed files with 119 additions and 104 deletions

105
gdk/gdk.c
View File

@ -1668,11 +1668,6 @@ gdk_event_translate (GdkEvent *event,
gint return_val; gint return_val;
/* Are static variables used for this purpose thread-safe? */ /* Are static variables used for this purpose thread-safe? */
static GdkPoint dnd_drag_start = {0,0},
dnd_drag_oldpos = {0,0};
static GdkRectangle dnd_drag_dropzone = {0,0,0,0};
static GdkWindowPrivate *real_sw = NULL;
static Window dnd_drag_curwin = None;
return_val = FALSE; return_val = FALSE;
@ -1913,9 +1908,9 @@ gdk_event_translate (GdkEvent *event,
&& !gdk_dnd.drag_really) && !gdk_dnd.drag_really)
{ {
gdk_dnd.drag_perhaps = 1; gdk_dnd.drag_perhaps = 1;
dnd_drag_start.x = xevent->xbutton.x_root; gdk_dnd.dnd_drag_start.x = xevent->xbutton.x_root;
dnd_drag_start.y = xevent->xbutton.y_root; gdk_dnd.dnd_drag_start.y = xevent->xbutton.y_root;
real_sw = window_private; gdk_dnd.real_sw = window_private;
if(gdk_dnd.drag_startwindows) if(gdk_dnd.drag_startwindows)
{ {
@ -1938,7 +1933,8 @@ gdk_event_translate (GdkEvent *event,
window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask; window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask;
dnd_setwinattr.event_mask = dnd_setwinattr.event_mask =
window_private->dnd_drag_eventmask = ButtonMotionMask | EnterWindowMask | LeaveWindowMask; window_private->dnd_drag_eventmask = ButtonMotionMask |
EnterWindowMask | LeaveWindowMask;
XChangeWindowAttributes(gdk_display, window_private->xwindow, XChangeWindowAttributes(gdk_display, window_private->xwindow,
CWEventMask, &dnd_setwinattr); CWEventMask, &dnd_setwinattr);
} }
@ -1982,8 +1978,8 @@ gdk_event_translate (GdkEvent *event,
XSetWindowAttributes attrs; XSetWindowAttributes attrs;
/* Reset event mask to pre-drag value, assuming event_mask /* Reset event mask to pre-drag value, assuming event_mask
doesn't change during drag */ doesn't change during drag */
attrs.event_mask = real_sw->dnd_drag_savedeventmask; attrs.event_mask = gdk_dnd.real_sw->dnd_drag_savedeventmask;
XChangeWindowAttributes(gdk_display, real_sw->xwindow, XChangeWindowAttributes(gdk_display, gdk_dnd.real_sw->xwindow,
CWEventMask, &attrs); CWEventMask, &attrs);
} }
@ -2013,14 +2009,14 @@ gdk_event_translate (GdkEvent *event,
gdk_dnd.drag_startwindows = NULL; gdk_dnd.drag_startwindows = NULL;
} }
real_sw = NULL; gdk_dnd.real_sw = NULL;
} }
gdk_dnd.drag_perhaps = 0; gdk_dnd.drag_perhaps = 0;
dnd_drag_start.x = dnd_drag_start.y = 0; gdk_dnd.dnd_drag_start.x = gdk_dnd.dnd_drag_start.y = 0;
dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0;
dnd_drag_dropzone.width = dnd_drag_dropzone.height = 0; gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0;
dnd_drag_curwin = None; gdk_dnd.dnd_drag_curwin = None;
return_val = window_private?TRUE:FALSE; return_val = window_private?TRUE:FALSE;
} else } else
return_val = window_private && !window_private->destroyed; return_val = window_private && !window_private->destroyed;
@ -2056,12 +2052,13 @@ gdk_event_translate (GdkEvent *event,
event->motion.source = GDK_SOURCE_MOUSE; event->motion.source = GDK_SOURCE_MOUSE;
event->motion.deviceid = GDK_CORE_POINTER; event->motion.deviceid = GDK_CORE_POINTER;
#define IS_IN_ZONE(cx, cy) (cx >= dnd_drag_dropzone.x \ #define IS_IN_ZONE(cx, cy) (cx >= gdk_dnd.dnd_drag_dropzone.x \
&& cy >= dnd_drag_dropzone.y \ && cy >= gdk_dnd.dnd_drag_dropzone.y \
&& cx < (dnd_drag_dropzone.x + dnd_drag_dropzone.width) \ && cx < (gdk_dnd.dnd_drag_dropzone.x + gdk_dnd.dnd_drag_dropzone.width) \
&& cy < (dnd_drag_dropzone.y + dnd_drag_dropzone.height)) && cy < (gdk_dnd.dnd_drag_dropzone.y + gdk_dnd.dnd_drag_dropzone.height))
if(gdk_dnd.drag_perhaps && gdk_dnd.drag_really) if(gdk_dnd.drag_perhaps && gdk_dnd.drag_really
/* && event->motion.is_hint */ /* HINTME */)
{ {
/* First, we have to find what window the motion was in... */ /* First, we have to find what window the motion was in... */
/* 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
@ -2095,37 +2092,37 @@ gdk_event_translate (GdkEvent *event,
} }
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, dnd_drag_curwin)); curwin, lastwin, gdk_dnd.dnd_drag_curwin));
if(curwin != dnd_drag_curwin && curwin != lastwin) if(curwin != gdk_dnd.dnd_drag_curwin && curwin != lastwin)
{ {
/* We have left one window and entered another /* We have left one window and entered another
(do leave & enter bits) */ (do leave & enter bits) */
if(dnd_drag_curwin != None) if(gdk_dnd.dnd_drag_curwin != None)
gdk_dnd_drag_leave(dnd_drag_curwin); gdk_dnd_drag_leave(gdk_dnd.dnd_drag_curwin);
dnd_drag_curwin = curwin; gdk_dnd.dnd_drag_curwin = curwin;
gdk_dnd_drag_enter(dnd_drag_curwin); gdk_dnd_drag_enter(gdk_dnd.dnd_drag_curwin);
dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0;
dnd_drag_dropzone.width = dnd_drag_dropzone.height = 0; gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0;
gdk_dnd.dnd_drag_target = None; gdk_dnd.dnd_drag_target = None;
GDK_NOTE (DND, GDK_NOTE (DND,
g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n", g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n",
curwin, lastwin, dnd_drag_curwin)); curwin, lastwin, gdk_dnd.dnd_drag_curwin));
gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, gdk_dnd_display_drag_cursor(xevent->xmotion.x_root,
xevent->xmotion.y_root, xevent->xmotion.y_root,
FALSE, TRUE); FALSE, TRUE);
} }
else if(dnd_drag_dropzone.width > 0 else if(gdk_dnd.dnd_drag_dropzone.width > 0
&& dnd_drag_dropzone.height > 0 && gdk_dnd.dnd_drag_dropzone.height > 0
&& curwin == dnd_drag_curwin) && curwin == gdk_dnd.dnd_drag_curwin)
{ {
/* Handle all that dropzone stuff - thanks John ;-) */ /* Handle all that dropzone stuff - thanks John ;-) */
if (gdk_dnd.dnd_drag_target != None) if (gdk_dnd.dnd_drag_target != None)
{ {
gboolean in_zone = IS_IN_ZONE(xevent->xmotion.x_root, gboolean in_zone = IS_IN_ZONE(xevent->xmotion.x_root,
xevent->xmotion.y_root); xevent->xmotion.y_root);
gboolean old_in_zone = IS_IN_ZONE(dnd_drag_oldpos.x, gboolean old_in_zone = IS_IN_ZONE(gdk_dnd.dnd_drag_oldpos.x,
dnd_drag_oldpos.y); gdk_dnd.dnd_drag_oldpos.y);
if (!in_zone && old_in_zone) if (!in_zone && old_in_zone)
{ {
@ -2141,8 +2138,8 @@ gdk_event_translate (GdkEvent *event,
/* We were outside drop zone but in the window /* We were outside drop zone but in the window
- have to send enter events */ - have to send enter events */
gdk_dnd_drag_enter(curwin); gdk_dnd_drag_enter(curwin);
dnd_drag_curwin = curwin; gdk_dnd.dnd_drag_curwin = curwin;
dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0;
gdk_dnd.dnd_drag_target = None; gdk_dnd.dnd_drag_target = None;
} }
} }
@ -2209,12 +2206,12 @@ gdk_event_translate (GdkEvent *event,
{ {
g_print("We may[%d] have a drag into %#lx = %#lx\n", g_print("We may[%d] have a drag into %#lx = %#lx\n",
gdk_dnd.drag_really, gdk_dnd.drag_really,
xevent->xcrossing.window, real_sw->xwindow); xevent->xcrossing.window, gdk_dnd.real_sw->xwindow);
} }
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */
if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really && if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow)) (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow))
{ {
gdk_dnd.drag_really = 0; gdk_dnd.drag_really = 0;
@ -2280,19 +2277,25 @@ gdk_event_translate (GdkEvent *event,
{ {
g_print("We may[%d] have a drag out of %#lx = %#lx\n", g_print("We may[%d] have a drag out of %#lx = %#lx\n",
gdk_dnd.drag_really, gdk_dnd.drag_really,
xevent->xcrossing.window, real_sw->xwindow); xevent->xcrossing.window, gdk_dnd.real_sw->xwindow);
} }
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */
if (gdk_dnd.drag_perhaps && !gdk_dnd.drag_really && if (gdk_dnd.drag_perhaps && !gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow)) (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow))
{ {
gdk_dnd_drag_addwindow((GdkWindow *) real_sw); gboolean xgpret;
gdk_dnd_drag_begin((GdkWindow *) real_sw); gdk_dnd_drag_addwindow((GdkWindow *) gdk_dnd.real_sw);
XGrabPointer(gdk_display, real_sw->xwindow, False, gdk_dnd_drag_begin((GdkWindow *) gdk_dnd.real_sw);
ButtonMotionMask | xgpret =
XGrabPointer(gdk_display, gdk_dnd.real_sw->xwindow, False,
ButtonMotionMask | PointerMotionMask |
/* PointerMotionHintMask | */ /* HINTME */
ButtonPressMask | ButtonReleaseMask, ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, gdk_root_window, GrabModeAsync, GrabModeAsync, gdk_root_window,
None, CurrentTime); None, CurrentTime);
#ifdef G_ENABLE_DEBUG
GDK_NOTE(DND, g_print("xgpret = %d\n", xgpret));
#endif
gdk_dnd.dnd_grabbed = TRUE; gdk_dnd.dnd_grabbed = TRUE;
gdk_dnd.drag_really = 1; gdk_dnd.drag_really = 1;
gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, gdk_dnd_display_drag_cursor(xevent->xmotion.x_root,
@ -2751,7 +2754,7 @@ gdk_event_translate (GdkEvent *event,
return_val = FALSE; return_val = FALSE;
if (window && gdk_dnd.drag_really && if (window && gdk_dnd.drag_really &&
xevent->xclient.data.l[0] == dnd_drag_curwin && xevent->xclient.data.l[0] == gdk_dnd.dnd_drag_curwin &&
event->dragrequest.u.flags.sendreply == 0) event->dragrequest.u.flags.sendreply == 0)
{ {
/* Got request - do we need to ask user? */ /* Got request - do we need to ask user? */
@ -2775,14 +2778,14 @@ gdk_event_translate (GdkEvent *event,
window_private->dnd_drag_data_type = window_private->dnd_drag_data_type =
xevent->xclient.data.l[4]; xevent->xclient.data.l[4];
gdk_dnd.dnd_drag_target = dnd_drag_curwin; gdk_dnd.dnd_drag_target = gdk_dnd.dnd_drag_curwin;
gdk_dnd_display_drag_cursor(-1, -1, TRUE, TRUE); gdk_dnd_display_drag_cursor(-1, -1, TRUE, TRUE);
} }
dnd_drag_dropzone.x = xevent->xclient.data.l[2] & 65535; gdk_dnd.dnd_drag_dropzone.x = xevent->xclient.data.l[2] & 65535;
dnd_drag_dropzone.y = gdk_dnd.dnd_drag_dropzone.y =
(xevent->xclient.data.l[2] >> 16) & 65535; (xevent->xclient.data.l[2] >> 16) & 65535;
dnd_drag_dropzone.width = xevent->xclient.data.l[3] & 65535; gdk_dnd.dnd_drag_dropzone.width = xevent->xclient.data.l[3] & 65535;
dnd_drag_dropzone.height = gdk_dnd.dnd_drag_dropzone.height =
(xevent->xclient.data.l[3] >> 16) & 65535; (xevent->xclient.data.l[3] >> 16) & 65535;
} }
} }

View File

@ -43,7 +43,9 @@ GdkDndGlobals gdk_dnd = {None,None,None,
0, 0,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
None, None,
{0,0}}; {0,0},
{0,0}, {0,0},
{0,0,0,0}, NULL, None};
gchar *gdk_progname = NULL; gchar *gdk_progname = NULL;
gchar *gdk_progclass = NULL; gchar *gdk_progclass = NULL;
gint gdk_error_code; gint gdk_error_code;

View File

@ -160,6 +160,11 @@ struct _GdkDndGlobals {
gboolean drag_really, drag_perhaps, dnd_grabbed; gboolean drag_really, drag_perhaps, dnd_grabbed;
Window dnd_drag_target; Window dnd_drag_target;
GdkPoint drag_dropcoords; GdkPoint drag_dropcoords;
GdkPoint dnd_drag_start, dnd_drag_oldpos;
GdkRectangle dnd_drag_dropzone;
GdkWindowPrivate *real_sw;
Window dnd_drag_curwin;
}; };
typedef struct _GdkDndGlobals GdkDndGlobals; typedef struct _GdkDndGlobals GdkDndGlobals;

View File

@ -43,7 +43,9 @@ GdkDndGlobals gdk_dnd = {None,None,None,
0, 0,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
None, None,
{0,0}}; {0,0},
{0,0}, {0,0},
{0,0,0,0}, NULL, None};
gchar *gdk_progname = NULL; gchar *gdk_progname = NULL;
gchar *gdk_progclass = NULL; gchar *gdk_progclass = NULL;
gint gdk_error_code; gint gdk_error_code;

View File

@ -1668,11 +1668,6 @@ gdk_event_translate (GdkEvent *event,
gint return_val; gint return_val;
/* Are static variables used for this purpose thread-safe? */ /* Are static variables used for this purpose thread-safe? */
static GdkPoint dnd_drag_start = {0,0},
dnd_drag_oldpos = {0,0};
static GdkRectangle dnd_drag_dropzone = {0,0,0,0};
static GdkWindowPrivate *real_sw = NULL;
static Window dnd_drag_curwin = None;
return_val = FALSE; return_val = FALSE;
@ -1913,9 +1908,9 @@ gdk_event_translate (GdkEvent *event,
&& !gdk_dnd.drag_really) && !gdk_dnd.drag_really)
{ {
gdk_dnd.drag_perhaps = 1; gdk_dnd.drag_perhaps = 1;
dnd_drag_start.x = xevent->xbutton.x_root; gdk_dnd.dnd_drag_start.x = xevent->xbutton.x_root;
dnd_drag_start.y = xevent->xbutton.y_root; gdk_dnd.dnd_drag_start.y = xevent->xbutton.y_root;
real_sw = window_private; gdk_dnd.real_sw = window_private;
if(gdk_dnd.drag_startwindows) if(gdk_dnd.drag_startwindows)
{ {
@ -1938,7 +1933,8 @@ gdk_event_translate (GdkEvent *event,
window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask; window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask;
dnd_setwinattr.event_mask = dnd_setwinattr.event_mask =
window_private->dnd_drag_eventmask = ButtonMotionMask | EnterWindowMask | LeaveWindowMask; window_private->dnd_drag_eventmask = ButtonMotionMask |
EnterWindowMask | LeaveWindowMask;
XChangeWindowAttributes(gdk_display, window_private->xwindow, XChangeWindowAttributes(gdk_display, window_private->xwindow,
CWEventMask, &dnd_setwinattr); CWEventMask, &dnd_setwinattr);
} }
@ -1982,8 +1978,8 @@ gdk_event_translate (GdkEvent *event,
XSetWindowAttributes attrs; XSetWindowAttributes attrs;
/* Reset event mask to pre-drag value, assuming event_mask /* Reset event mask to pre-drag value, assuming event_mask
doesn't change during drag */ doesn't change during drag */
attrs.event_mask = real_sw->dnd_drag_savedeventmask; attrs.event_mask = gdk_dnd.real_sw->dnd_drag_savedeventmask;
XChangeWindowAttributes(gdk_display, real_sw->xwindow, XChangeWindowAttributes(gdk_display, gdk_dnd.real_sw->xwindow,
CWEventMask, &attrs); CWEventMask, &attrs);
} }
@ -2013,14 +2009,14 @@ gdk_event_translate (GdkEvent *event,
gdk_dnd.drag_startwindows = NULL; gdk_dnd.drag_startwindows = NULL;
} }
real_sw = NULL; gdk_dnd.real_sw = NULL;
} }
gdk_dnd.drag_perhaps = 0; gdk_dnd.drag_perhaps = 0;
dnd_drag_start.x = dnd_drag_start.y = 0; gdk_dnd.dnd_drag_start.x = gdk_dnd.dnd_drag_start.y = 0;
dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0;
dnd_drag_dropzone.width = dnd_drag_dropzone.height = 0; gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0;
dnd_drag_curwin = None; gdk_dnd.dnd_drag_curwin = None;
return_val = window_private?TRUE:FALSE; return_val = window_private?TRUE:FALSE;
} else } else
return_val = window_private && !window_private->destroyed; return_val = window_private && !window_private->destroyed;
@ -2056,12 +2052,13 @@ gdk_event_translate (GdkEvent *event,
event->motion.source = GDK_SOURCE_MOUSE; event->motion.source = GDK_SOURCE_MOUSE;
event->motion.deviceid = GDK_CORE_POINTER; event->motion.deviceid = GDK_CORE_POINTER;
#define IS_IN_ZONE(cx, cy) (cx >= dnd_drag_dropzone.x \ #define IS_IN_ZONE(cx, cy) (cx >= gdk_dnd.dnd_drag_dropzone.x \
&& cy >= dnd_drag_dropzone.y \ && cy >= gdk_dnd.dnd_drag_dropzone.y \
&& cx < (dnd_drag_dropzone.x + dnd_drag_dropzone.width) \ && cx < (gdk_dnd.dnd_drag_dropzone.x + gdk_dnd.dnd_drag_dropzone.width) \
&& cy < (dnd_drag_dropzone.y + dnd_drag_dropzone.height)) && cy < (gdk_dnd.dnd_drag_dropzone.y + gdk_dnd.dnd_drag_dropzone.height))
if(gdk_dnd.drag_perhaps && gdk_dnd.drag_really) if(gdk_dnd.drag_perhaps && gdk_dnd.drag_really
/* && event->motion.is_hint */ /* HINTME */)
{ {
/* First, we have to find what window the motion was in... */ /* First, we have to find what window the motion was in... */
/* 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
@ -2095,37 +2092,37 @@ gdk_event_translate (GdkEvent *event,
} }
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, dnd_drag_curwin)); curwin, lastwin, gdk_dnd.dnd_drag_curwin));
if(curwin != dnd_drag_curwin && curwin != lastwin) if(curwin != gdk_dnd.dnd_drag_curwin && curwin != lastwin)
{ {
/* We have left one window and entered another /* We have left one window and entered another
(do leave & enter bits) */ (do leave & enter bits) */
if(dnd_drag_curwin != None) if(gdk_dnd.dnd_drag_curwin != None)
gdk_dnd_drag_leave(dnd_drag_curwin); gdk_dnd_drag_leave(gdk_dnd.dnd_drag_curwin);
dnd_drag_curwin = curwin; gdk_dnd.dnd_drag_curwin = curwin;
gdk_dnd_drag_enter(dnd_drag_curwin); gdk_dnd_drag_enter(gdk_dnd.dnd_drag_curwin);
dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0;
dnd_drag_dropzone.width = dnd_drag_dropzone.height = 0; gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0;
gdk_dnd.dnd_drag_target = None; gdk_dnd.dnd_drag_target = None;
GDK_NOTE (DND, GDK_NOTE (DND,
g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n", g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n",
curwin, lastwin, dnd_drag_curwin)); curwin, lastwin, gdk_dnd.dnd_drag_curwin));
gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, gdk_dnd_display_drag_cursor(xevent->xmotion.x_root,
xevent->xmotion.y_root, xevent->xmotion.y_root,
FALSE, TRUE); FALSE, TRUE);
} }
else if(dnd_drag_dropzone.width > 0 else if(gdk_dnd.dnd_drag_dropzone.width > 0
&& dnd_drag_dropzone.height > 0 && gdk_dnd.dnd_drag_dropzone.height > 0
&& curwin == dnd_drag_curwin) && curwin == gdk_dnd.dnd_drag_curwin)
{ {
/* Handle all that dropzone stuff - thanks John ;-) */ /* Handle all that dropzone stuff - thanks John ;-) */
if (gdk_dnd.dnd_drag_target != None) if (gdk_dnd.dnd_drag_target != None)
{ {
gboolean in_zone = IS_IN_ZONE(xevent->xmotion.x_root, gboolean in_zone = IS_IN_ZONE(xevent->xmotion.x_root,
xevent->xmotion.y_root); xevent->xmotion.y_root);
gboolean old_in_zone = IS_IN_ZONE(dnd_drag_oldpos.x, gboolean old_in_zone = IS_IN_ZONE(gdk_dnd.dnd_drag_oldpos.x,
dnd_drag_oldpos.y); gdk_dnd.dnd_drag_oldpos.y);
if (!in_zone && old_in_zone) if (!in_zone && old_in_zone)
{ {
@ -2141,8 +2138,8 @@ gdk_event_translate (GdkEvent *event,
/* We were outside drop zone but in the window /* We were outside drop zone but in the window
- have to send enter events */ - have to send enter events */
gdk_dnd_drag_enter(curwin); gdk_dnd_drag_enter(curwin);
dnd_drag_curwin = curwin; gdk_dnd.dnd_drag_curwin = curwin;
dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0;
gdk_dnd.dnd_drag_target = None; gdk_dnd.dnd_drag_target = None;
} }
} }
@ -2209,12 +2206,12 @@ gdk_event_translate (GdkEvent *event,
{ {
g_print("We may[%d] have a drag into %#lx = %#lx\n", g_print("We may[%d] have a drag into %#lx = %#lx\n",
gdk_dnd.drag_really, gdk_dnd.drag_really,
xevent->xcrossing.window, real_sw->xwindow); xevent->xcrossing.window, gdk_dnd.real_sw->xwindow);
} }
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */
if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really && if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow)) (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow))
{ {
gdk_dnd.drag_really = 0; gdk_dnd.drag_really = 0;
@ -2280,19 +2277,25 @@ gdk_event_translate (GdkEvent *event,
{ {
g_print("We may[%d] have a drag out of %#lx = %#lx\n", g_print("We may[%d] have a drag out of %#lx = %#lx\n",
gdk_dnd.drag_really, gdk_dnd.drag_really,
xevent->xcrossing.window, real_sw->xwindow); xevent->xcrossing.window, gdk_dnd.real_sw->xwindow);
} }
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */
if (gdk_dnd.drag_perhaps && !gdk_dnd.drag_really && if (gdk_dnd.drag_perhaps && !gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow)) (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow))
{ {
gdk_dnd_drag_addwindow((GdkWindow *) real_sw); gboolean xgpret;
gdk_dnd_drag_begin((GdkWindow *) real_sw); gdk_dnd_drag_addwindow((GdkWindow *) gdk_dnd.real_sw);
XGrabPointer(gdk_display, real_sw->xwindow, False, gdk_dnd_drag_begin((GdkWindow *) gdk_dnd.real_sw);
ButtonMotionMask | xgpret =
XGrabPointer(gdk_display, gdk_dnd.real_sw->xwindow, False,
ButtonMotionMask | PointerMotionMask |
/* PointerMotionHintMask | */ /* HINTME */
ButtonPressMask | ButtonReleaseMask, ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, gdk_root_window, GrabModeAsync, GrabModeAsync, gdk_root_window,
None, CurrentTime); None, CurrentTime);
#ifdef G_ENABLE_DEBUG
GDK_NOTE(DND, g_print("xgpret = %d\n", xgpret));
#endif
gdk_dnd.dnd_grabbed = TRUE; gdk_dnd.dnd_grabbed = TRUE;
gdk_dnd.drag_really = 1; gdk_dnd.drag_really = 1;
gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, gdk_dnd_display_drag_cursor(xevent->xmotion.x_root,
@ -2751,7 +2754,7 @@ gdk_event_translate (GdkEvent *event,
return_val = FALSE; return_val = FALSE;
if (window && gdk_dnd.drag_really && if (window && gdk_dnd.drag_really &&
xevent->xclient.data.l[0] == dnd_drag_curwin && xevent->xclient.data.l[0] == gdk_dnd.dnd_drag_curwin &&
event->dragrequest.u.flags.sendreply == 0) event->dragrequest.u.flags.sendreply == 0)
{ {
/* Got request - do we need to ask user? */ /* Got request - do we need to ask user? */
@ -2775,14 +2778,14 @@ gdk_event_translate (GdkEvent *event,
window_private->dnd_drag_data_type = window_private->dnd_drag_data_type =
xevent->xclient.data.l[4]; xevent->xclient.data.l[4];
gdk_dnd.dnd_drag_target = dnd_drag_curwin; gdk_dnd.dnd_drag_target = gdk_dnd.dnd_drag_curwin;
gdk_dnd_display_drag_cursor(-1, -1, TRUE, TRUE); gdk_dnd_display_drag_cursor(-1, -1, TRUE, TRUE);
} }
dnd_drag_dropzone.x = xevent->xclient.data.l[2] & 65535; gdk_dnd.dnd_drag_dropzone.x = xevent->xclient.data.l[2] & 65535;
dnd_drag_dropzone.y = gdk_dnd.dnd_drag_dropzone.y =
(xevent->xclient.data.l[2] >> 16) & 65535; (xevent->xclient.data.l[2] >> 16) & 65535;
dnd_drag_dropzone.width = xevent->xclient.data.l[3] & 65535; gdk_dnd.dnd_drag_dropzone.width = xevent->xclient.data.l[3] & 65535;
dnd_drag_dropzone.height = gdk_dnd.dnd_drag_dropzone.height =
(xevent->xclient.data.l[3] >> 16) & 65535; (xevent->xclient.data.l[3] >> 16) & 65535;
} }
} }