[vbox-dev] Fwd: [VirtualBox] #81: [feature-request] GuestVM addition: file drag-n-drop

Michael Thayer Michael.Thayer at Sun.COM
Fri Feb 27 20:40:34 GMT 2009


Hello Sergiy,

Sergiy Byelozyorov wrote:
> Ticket #81 [feature-request] GuestVM addition: file drag-n-drop
[snip]
> I was directed here (see forwarded email or last comment). So what do
> I do first?
Great that you responded so fast, and thanks very much for your
interest!  I will start by giving you a quick overview of how we
envisaged the feature (at least in a first version which keeps things as
simple as possible) and pointing you to the bits in the code that would
be of interest to you.  I hope that my quick overview doesn't get too
long :)  There are two things to implement here: dragging from host to
guest, and from guest to host.  They will probably need to be
implemented more or less separately.  I will start with the host to
guest, which is probably the easiest.

The first version of the feature should probably only support file DnD.
  The actual file transfer from host to guest will go via a shared
folder.  Basically, the VirtualBox application, or rather the main
widget in it, will have to act as a drop target.  When a drag action is
started and the cursor enters this widget, the widget should notify an
application running in the guest.  The widget and the guest application
will exchange any information needed about the drag and drop process,
and the guest application will initiate a drag action of its own in the
guest to match the host drag action.  Communication between host and
guest should probably use the Guest Property feature of VirtualBox, at
least in the first version of the DnD feature.

The guest to host direction is more complicated, as the guest is not
aware of anything "outside its window".  We thought that it could be
implemented as follows.  When the GUI notices that the mouse cursor has
been dragged from inside the main widget to outside, it tells the guest
that the mouse cursor has been moved over a special drop area created by
the guest application.  This enables the guest application to get
information about the drag process.  Guest and host must exchange
necessary information as they did for the other direction.

The host part would be done in our Qt4 GUI code
(http://www.virtualbox.org/browser/trunk/src/VBox/Frontends/VirtualBox
in our public subversion repository).  As Qt4 is cross platform, the
same code would work for all supported hosts (Windows, Linux, Solaris
and Mac OS).  Unfortunately, the guest work must be done separately for
each guest that we (or rather you) wish to support.  I'm not sure which
systems you are familiar with (Windows, Linux/Solaris, ... OS/2 :) )
The same code will probably work on Linux and Solaris though.  There we
have the difficulty that since we try to use a single binary for all
Linux systems, we can't really rely on any but the most standard guest
libraries, like the C library and the basic X11 ones.  In our shared
clipboard code, we used the Xt library as it is slightly (!) higher
level than basic libx11 (see
http://www.virtualbox.org/browser/trunk/src/VBox/Additions/x11/VBoxClient)
and you might want to use that as a basis if you are interested in Linux
guest stuff and if you can bear to look at that code :)  (I *will*
rewrite it when I have a bit of free time...)  For basic examples of
using the guest property code, you might want to look at VBoxManage
(host side,
http://www.virtualbox.org/browser/trunk/src/VBox/Frontends/VBoxManage)
and VBoxControl (guest side,
http://www.virtualbox.org/browser/trunk/src/VBox/Additions/common/VBoxControl).
 The VBoxControl code is cross platform, at least the basic code and the
bits that deal with guest properties.  VBoxManage is bit hard going
because of all the COM stuff in there, but that is all over our host
code I'm afraid...

OK, that ended up being rather long after all...  I hope that I haven't
scared you off with that!  I would be interested to hear what you have
to say about this.  Unfortunately our GUI programmer has already left
for the weekend, so he will probably not be able to comment until
Monday.  I really hope that you will have fun with this!

Look forward to your answer...

Regards,

Michael




More information about the vbox-dev mailing list