|
wxMaxima
|
Clipboard formats that are only rendered once a program asks for them (GH #2030). More...
#include "precomp.h"#include <wx/bitmap.h>#include <wx/dataobj.h>#include <wx/string.h>#include <functional>#include <memory>#include <optional>#include <string>#include <utility>Go to the source code of this file.
Data Structures | |
| class | LazyValue< T > |
| A value that is computed the first time it is asked for. More... | |
| class | ClipboardSnapshot |
| A private copy of the cells a copy was made from. More... | |
| struct | ClipboardContents |
| Everything one copy operation puts on the clipboard. More... | |
| class | LazyDataObject |
| A clipboard format whose bytes are rendered when a program asks for them. More... | |
| class | LazyBitmapDataObject |
| A bitmap that is only drawn when a program asks for it. More... | |
| class | LazyPngDataObject |
| The same bitmap, as PNG bytes, for ports that can only hand over bytes. More... | |
Clipboard formats that are only rendered once a program asks for them (GH #2030).
A copy used to render every format it offered – RTF, MathML, a bitmap, an SVG, ... – before it put anything on the clipboard, so a big selection cost seconds and hundreds of megabytes for formats nobody might ever paste. The config dialogue therefore made the user pick which formats to offer at all.
The clipboard does not need the data up front: it only needs to know which formats are available, and asks the owner for the actual bytes when a program pastes in one of them (GTK answers a SelectionRequest, Windows' OLE clipboard calls IDataObject::GetData()). wxWidgets forwards both to wxDataObject::GetDataSize()/GetDataHere(), so a data object that renders in there is all delayed rendering needs. (macOS' wxClipboard writes every format to the pasteboard as soon as it is set, so there everything still renders at copy time.)
The pieces:
The catch is that a program that has exited can no longer answer requests: see Worksheet::RenderClipboardContents(), which replaces the lazy data by the formats worth keeping when the worksheet that owns them goes away.