chuck@trantor.harris-atd.com (Chuck Musciano) (11/14/90)
I am trying to initiate a drag and drop operation from an XView tool.
I successfully create a cursor and get a fullscreen, and drag the cursor
to another window. When I release the mouse button, my code sends a message
to the XV_POINTER_WINDOW under the mouse.
Here's the problem. If the receiver is filemgr, the message is received,
and the file is copied. Any other tool, like textedit, ignores the message.
Even my tool, which can receive ACTION_DRAG_LOAD events, doesn't get the
message. Why is it that messages from filemgr are received, but messages
from me are not?
To further mystify matters, if I open a textedit window by double-clicking
a file in filemgr, and then drop something in that textedit window from my tool,
the message is received by filemgr!
Could it be that receiving a DRAG event is an XView-level thing, while
sending a DRAG event is an X-level thing, and that tools need to be set to
receive both XView-level DRAG and X-level DRAG? My tool receives XView-level
stuff as described in the XView Programmer's Guide. How do I set it to
receive the equivalent X-level DRAG events?
Here is my code, taken from a sample included with GUIDE. Any
suggestions are appreciated. Is this covered in any reference guide?
There is plenty on receiving a DRAG event, but nothing on starting one.
typedef struct {XID xid;
int x;
int y;
Window window;
Atom property;
} Drag_message;
Xv_window dest_win;
Fullscreen fullscreen;
int xdrop, ydrop;
Window source_xid, dest_xid;
Atom drag_atom;
Drag_message msg;
/* setting up fullscreen stuff removed for clarity */
source_xid = (Window) xv_get(source_window, XV_XID);
drag_atom = XInternAtom(display, "DRAG_DROP", FALSE);
XChangeProperty(display, source_xid, drag_atom, XA_STRING, 8,
PropModeReplace, path, strlen(path) + 1);
msg.xid = XV_POINTER_WINDOW;
msg.x = xdrop;
msg.y = ydrop;
msg.window = source_xid;
msg.property = drag_atom;
xv_send_message(source_window, XV_POINTER_WINDOW, "XV_DO_DRAG_LOAD",
32, &msg, sizeof(msg));
--
Chuck Musciano ARPA : chuck@trantor.harris-atd.com
Harris Corporation Usenet: ...!uunet!x102a!trantor!chuck
PO Box 37, MS 3A/1912 AT&T : (407) 727-6131
Melbourne, FL 32902 FAX : (407) 729-2537
A good newspaper is never good enough,
but a lousy newspaper is a joy forever. -- Garrison Keillor
chuck@trantor.harris-atd.com (Chuck Musciano) (11/15/90)
In article <4861@trantor.harris-atd.com>, I write: > I am trying to initiate a drag and drop operation from an XView tool. > I successfully create a cursor and get a fullscreen, and drag the cursor > to another window. When I release the mouse button, my code sends a message > to the XV_POINTER_WINDOW under the mouse. > > Here's the problem. If the receiver is filemgr, the message is received, > and the file is copied. Any other tool, like textedit, ignores the message. > Even my tool, which can receive ACTION_DRAG_LOAD events, doesn't get the > message. Why is it that messages from filemgr are received, but messages > from me are not? Well, I have explored this problem a little further, with some help from Brent Browning from Sun. First, using XV_POINTER_WINDOW is unreliable. You need to derive the window under the mouse explicitly, using the undocumented routine: Window win_pointer_under(source_window, x, y) Window source_window; int x; int y; which returns the XID of the target window. Then, I discovered that there are two ways to send the dragged information to the recipient. The "X-ish" way is to place the data in a WindowProperty named "DRAG_DROP", and to place the handle of this property in the last (fifth) component of the message packet. X tools retrieve the data from the property. The "XView-ish" way is to set the fifth element to zero, and place the data in the primary selection. XView tools then get the data from the selection service. This requires that sending tools set up the X and XView techniques, since they have no idea who the receiver is going to be, and that receiving tools set up both receiving methods, since they have no idea who the sender is. An example of a dual receiver is in the XView 2 MIT distribution, in lib/libxvin/misc/drop.c. Thankfully, according to Brent, Sun is reworking this entire interface into something mere mortals can understand for OpenWindows 3.0. -- Chuck Musciano ARPA : chuck@trantor.harris-atd.com Harris Corporation Usenet: ...!uunet!x102a!trantor!chuck PO Box 37, MS 3A/1912 AT&T : (407) 727-6131 Melbourne, FL 32902 FAX : (407) 729-2537 A good newspaper is never good enough, but a lousy newspaper is a joy forever. -- Garrison Keillor