Re: Clipboard improvements, II



On 25/05/2004 6:38 AM, Hans Breuer wrote:

But it still does not support copying image via Clipboard, or di I miss this? I should have been more clear with what I would like to be able to do :

- copy images to clipboard via cross-platform gtk/gdk code (could replace my winclipboard plug-in delivered with Gimp)

- copy vector data to Clipboard (one of the major drawbacks of Dia - at least on windoze - is it's diability to just copy some stuff and paste it into say word)

Under X, the contents of a selection is represented as an array of 8-bit, 16-bit or 32-bit quantities (the last two are provided to allow transfer of 16-bit and 32-bit quantities between clients with different endians).

An image or vector diagram can be represented as binary data, so transferring it as a selection is no more difficult than transferring text. It is just necessary for the two end points to agree on a target name.

To get interoperability with existing apps under Windows, you would need to know the target names that native apps use, and the format they transfer data in. If there was a GtkClipboard API for "copy this pixbuf", then the Windows version would probably want to advertise the data in the appropriate well known forms.

From a brief look at the OLE clipboard docs on MSDN, it doesn't look like there is that big a difference in how the two act. Mozilla has a cross platform API with implementations for win32 and X clipboard, so it must be possible ...

Yeah, obviously it is possible on win32 - even without OLE. The Clipboard API works with shared memory (i.e. GlobalAlloc see gimp/plug-ins/common/winclipboard.c). But on X it appears to be either so complicated or so unusual to do/want this, that nobody bothers to implement it ...

My point is that Mozilla uses the OLE clipboard, which is quite similar to the X clipboard (advertise supported flavours/targets on copy, delay the rendering of data and transfer until paste). The relevant files implementing Mozilla's Windows clipboard support are here:
   http://lxr.mozilla.org/mozilla/source/widget/src/windows/nsClipboard.cpp
   http://lxr.mozilla.org/mozilla/source/widget/src/windows/nsDataObj.cpp

When you copy something onto the clipboard, it creates an nsDataObj (which implements the IDataObject COM interface), and puts it on the clipboard. When the GetData method of data object is called, it proxies the request through to Mozilla's cross platform APIs. It also includes some special code to handle the common Windows clipboard flavours.

By the look of it, the OLE clipboard and DND both use the IDataObject interface for data transfer, so it would probably be possible to share the implementation between the two.

James.

--
Email: james daa com au
WWW:   http://www.daa.com.au/~james/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]