
Example 19-2. A drop-site item example (continued)
window_fit(frame);
xv_main_loop(frame);
exit(0);
}
void
EventProc(window, event)
Xv_Window window;
Event *event;
{
switch (event_action(event)) {
/* When drop previewing is available, if
* the drop site has selected for previewing
* events (DROP_SITE_EVENT_MASK) then it will
* receive ACTION_DRAG_PREVIEW events from
* the source as requested.
*/
case ACTION_DRAG_PREVIEW:
switch(event_id(event)) {
case LOC_WINENTER:
inverted = True;
break;
case LOC_WINEXIT:
inverted = False;
break;
case LOC_DRAG:
break;
}
PaintCanvas(NULL, window, XV_DISPLAY_FROM_WINDOW(window),
xv_get(window, XV_XID), NULL);
break;
case ACTION_DRAG_COPY:
case ACTION_DRAG_MOVE: {
Xv_drop_site ds;
Xv_Server server = XV_SERVER_FROM_WINDOW(event_window(event));
/* If the user dropped over an acceptable
* drop site, the owner of the drop site will
* be sent an ACTION_DROP_{COPY, MOVE} event.
*/
/* To acknowledge the drop and to associate the
* rank of the source’s selection to our
* requestor selection object, we call
* dnd_decode_drop().
*/
if ((ds = dnd_decode_drop(sel, event)) != XV_ERROR) {
if (xv_get(ds, DROP_SITE_ID) == BULLSEYE_SITE)
UpdatePanel(server, sel);
/* If this is a move operation, we must ask
* the source to delete the selection object.
* We should only do this if the transfer of
* data was successful.
*/
Drag and Drop
Drag and Drop 453