From: plau@nyquist.waterloo.edu (Patrick Lau)
Subject: Drag and Drop using xview/devguide
Keywords: drag and drop, xview, devguide, drop target, timeout
Organization: University of Waterloo
Date: Wed, 29 Jul 1992 03:03:22 GMT


Hi, I am trying to set up drag and drop between 2 applications.
More specifically, I am trying to enable dragging of
the contents of a text_field from 1 application and dropping it to 
another and have it displayed in a corresponding text_field in the
2nd application, through devguide's drop_target's.  I am using 
openwin3.  I understand that I don't need drop_targets to
achieve the equivalent.  My goal is to make the dnd work through
devguide's drop_targets.  Hope some of you have had experience doing 
the same and can lend me a hand.  Thanks in advance.

At the present I am able to drag and drop between application
1 and a text pane.  (The drop_target of application 1 is
draggable whereas that of 2 is not.)  I am also able
to drag anything I see on a screen and drop it into
the drop_target of the 2nd appl. correctly.  This includes
not just ascii text but also file and mail icons.  But
for some reason I just cannot drag from application 1 and
drop to application 2.  What happens is that the 
appl. 1 process dies and appl. 2 displays a "Dragdrop: Timed out"
error in its footer.  The error message in dbxtool is:

   signal SEGV (no mapping at the fault address) in nowalgnd at 0xf75523c0
   nowalgnd+0x10:  ld      [%o1], %o2

and "where" gives:

   nowalgnd() at 0xf75523c0
   convert_proc() at 0x41c8
   fa__DoConversion() at 0xf770aae0
   fa__HandleMultipleReply() at 0xf770ad54
   fa__OwnerHandleReply() at 0xf770ae00
   xv_sel_handle_selection_request() at 0xf770b898
   window_default_event_func() at 0xf765ddf4
   notify_next_event_func() at 0xf7657dc8
   panel_notify_event() at 0xf76a9074
   cx__ndet_p_event() at 0xf7657734
   notify_post_event_and_arg() at 0xf76579c8
   hr__win_send() at 0xf7658a40
   xv_input_pending() at 0xf765acdc
   dI__notify_fd() at 0xf7657bac
   dG__ndis_send_ascending_fd() at 0xf7657afc
   ndis_default_prioritizer() at 0xf7651d84
   notify_client() at 0xf7652890
   ndis_default_scheduler() at 0xf7652924
   gh__scheduler() at 0xf7653578
   ndis_dispatch() at 0xf7652024
   notify_start() at 0xf76f5284
   xv_main_loop() at 0xf773525c
   main(argc = 1, argv = 0xf7fff3f4), line 58 in "dnd1_stubs.c"

This error came up after the first call to the drag callback is
successfully executed but before the 2nd call is completed.
I am not sure if the 2nd call was initiated at all.

Another thing I noticed is that when I drag from appl. 1 and try to
drop to appl. 2, the cursor does not turn to the "valid drop site"
shape, but if I had dragged from, say, a text pane, it does.

My question is why would dnd fail only between the two applications?
Furthermore, what and whose is nowalgnd()?

Appended are the stubs files from application 1 and 2 respectively.
They are the only files generated by devguide's gxv program that
were modified by me.  Please excuse the poor readability.  It is a 
bare-bone senario I put together quickly so that I can post.  
I'd appreciate any help.  ** Please reply to patrick@jts.com. ** 
Thanks again.

Patrick.

v------------- Application 1: dnd1_stubs.c --------------------v
/*
 * dnd1_stubs.c - Notify and event callback function stubs.
 * This file was generated by `gxv' from `dnd1.G'.
 */

#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/textsw.h>
#include <xview/xv_xrect.h>
#include <xview/dragdrop.h>
#include <xview/cursor.h>
#include <gdd.h>
#include "dnd1_ui.h"


/*
 * Global object definitions.
 */
dnd1_window1_objects	*Dnd1_window1;

#ifdef MAIN

/*
 * Instance XV_KEY_DATA key.  An instance is a set of related
 * user interface objects.  A pointer to an object's instance
 * is stored under this key in every object.  This must be a
 * global variable.
 */
Attr_attribute	INSTANCE;

main(argc, argv)
	int	argc;
	char	**argv;
{
	/*
	 * Initialize XView.
	 */
	xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
	INSTANCE = xv_unique_key();
	
	/*
	 * Initialize user interface components.
	 * Do NOT edit the object initializations by hand.
	 */
	Dnd1_window1 = dnd1_window1_objects_initialize(NULL, NULL);
	
	/*
	 * Initialize the Drag Drop package.
	 */
	gdd_init_dragdrop(Dnd1_window1->window1);
	
	/*
	 * Turn control over to XView.
	 */
	xv_main_loop(Dnd1_window1->window1);
	exit(0);
}

#endif


/*
 * Drop callback function for `drop_target1'.
 */
void
DroppedUpon(item, event, drop_info)
	Xv_opaque	item;
	Event		*event;
	GDD_DROP_INFO	*drop_info;
{
	char *dnd_tmp;	
	Selection_item sel_item;

	dnd1_window1_objects *ip = (dnd1_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);

	dnd_tmp=(char *)malloc((101)*sizeof(char));
	strcpy(dnd_tmp,drop_info->data);
	xv_set(ip->textfield1,PANEL_VALUE,dnd_tmp,NULL);
	sel_item=(Selection_item)xv_get(ip->drop_target1,XV_KEY_DATA,
		SELECTION_ITEM);
	if (strlen(dnd_tmp)>0) {
		xv_set(sel_item,SEL_DATA,ip->textfield1,NULL);
		xv_set(ip->drop_target1,PANEL_DROP_FULL,TRUE,NULL);
	} else {
		xv_set(ip->drop_target1,PANEL_DROP_FULL,FALSE,NULL);
	}
	free(dnd_tmp);

	fputs("dnd1: DroppedUpon\n", stderr);
	fputs("Successful Drop. GDD_DROP_INFO contents:\n", stderr);
	gdd_print_drop_info(drop_info);
	
	/* gxv_start_connections DO NOT EDIT THIS SECTION */

	/* gxv_end_connections */

}

/*
 * Drag callback function for `drop_target1'.
 */
void
DraggedFrom(item, event, drop_info, drag_state)
	Xv_opaque	item;
	Event		*event;
	GDD_DROP_INFO	*drop_info;
	int		drag_state;
{
	dnd1_window1_objects *ip = (dnd1_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
	
	switch (drag_state) {
	case GDD_DRAG_STARTED:
		if (drop_info->data)
			free(drop_info->data);
		drop_info->data=(char *)malloc((101)*sizeof(char));
		strcpy(drop_info->data,(char *)xv_get(ip->textfield1,
			PANEL_VALUE));
		drop_info->length=strlen(drop_info->data);
		break;

	case GDD_DRAG_COMPLETED:
		break;

	}

	fputs("dnd1: DraggedFrom\n", stderr);
	
	/* gxv_start_connections DO NOT EDIT THIS SECTION */

	/* gxv_end_connections */

}

/*
 * Notify callback function for `textfield1'.
 */
Panel_setting
textfield1(item, event)
	Panel_item	item;
	Event		*event;
{
	Selection_item sel_item;
	dnd1_window1_objects *ip = (dnd1_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
	char *	value = (char *) xv_get(item, PANEL_VALUE);

	sel_item=(Selection_item)xv_get(Dnd1_window1->drop_target1,XV_KEY_DATA,
		SELECTION_ITEM);
	if (strlen(value)>0) {
		xv_set(sel_item,SEL_DATA,Dnd1_window1->textfield1,NULL);
		xv_set(Dnd1_window1->drop_target1,PANEL_DROP_FULL,TRUE,NULL);
	} else {
		xv_set(Dnd1_window1->drop_target1,PANEL_DROP_FULL,FALSE,NULL);
	}

	fprintf(stderr, "dnd1: textfield1: value: %s\n", value);
	
	/* gxv_start_connections DO NOT EDIT THIS SECTION */

	/* gxv_end_connections */

	return panel_text_notify(item, event);
}
^------------- Application 1: dnd1_stubs.c --------------------^

v------------- Application 2: dnd1_stubs.c --------------------v
/*
 * dnd2_stubs.c - Notify and event callback function stubs.
 * This file was generated by `gxv' from `dnd2.G'.
 */

#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/textsw.h>
#include <xview/xv_xrect.h>
#include <xview/dragdrop.h>
#include <xview/cursor.h>
#include <gdd.h>
#include "dnd2_ui.h"


/*
 * Global object definitions.
 */
dnd2_window1_objects	*Dnd2_window1;

#ifdef MAIN

/*
 * Instance XV_KEY_DATA key.  An instance is a set of related
 * user interface objects.  A pointer to an object's instance
 * is stored under this key in every object.  This must be a
 * global variable.
 */
Attr_attribute	INSTANCE;

main(argc, argv)
	int	argc;
	char	**argv;
{
	/*
	 * Initialize XView.
	 */
	xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
	INSTANCE = xv_unique_key();
	
	/*
	 * Initialize user interface components.
	 * Do NOT edit the object initializations by hand.
	 */
	Dnd2_window1 = dnd2_window1_objects_initialize(NULL, NULL);
	
	/*
	 * Initialize the Drag Drop package.
	 */
	gdd_init_dragdrop(Dnd2_window1->window1);
	
	/*
	 * Turn control over to XView.
	 */
	xv_main_loop(Dnd2_window1->window1);
	exit(0);
}

#endif


/*
 * Drop callback function for `drop_target1'.
 */
void
DroppedUpon(item, event, drop_info)
	Xv_opaque	item;
	Event		*event;
	GDD_DROP_INFO	*drop_info;
{
	char *dnd_tmp;

	dnd2_window1_objects *ip = (dnd2_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);

	dnd_tmp=(char *)malloc((101)*sizeof(char));
	strcpy(dnd_tmp,drop_info->data);
	xv_set(ip->textfield1,PANEL_VALUE,dnd_tmp,NULL);
	free(dnd_tmp);

	fputs("dnd2: DroppedUpon\n", stderr);
	fputs("Successful Drop. GDD_DROP_INFO contents:\n", stderr);
	gdd_print_drop_info(drop_info);
	
	/* gxv_start_connections DO NOT EDIT THIS SECTION */

	/* gxv_end_connections */

}

/*
 * Notify callback function for `textfield1'.
 */
Panel_setting
textfield2(item, event)
	Panel_item	item;
	Event		*event;
{
	dnd2_window1_objects *ip = (dnd2_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
	char *	value = (char *) xv_get(item, PANEL_VALUE);
	
	fprintf(stderr, "dnd2: textfield2: value: %s\n", value);
	
	/* gxv_start_connections DO NOT EDIT THIS SECTION */

	/* gxv_end_connections */

	return panel_text_notify(item, event);
}
^------------- Application 2: dnd1_stubs.c --------------------^

Newsgroups: alt.toolkits.xview