Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit b2c7665

Browse files
[[ RawClipboard ]] Remove the old clipboard code (generic and OSX for now)
1 parent 838bafb commit b2c7665

19 files changed

+135
-2900
lines changed

engine/engine-sources.gypi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
'src/securemode.h',
145145
'src/sha1.h',
146146
'src/text.h',
147-
'src/transfer.h',
148147
'src/uidc.h',
149148
'src/unicode.h',
150149
'src/util.h',
@@ -168,7 +167,6 @@
168167
'src/securemode.cpp',
169168
'src/sha1.cpp',
170169
'src/text.cpp',
171-
'src/transfer.cpp',
172170
'src/uidc.cpp',
173171
'src/unicode.cpp',
174172
'src/util.cpp',
@@ -542,7 +540,6 @@
542540
'src/desktop-dc.cpp',
543541
'src/desktop-stack.cpp',
544542
'src/desktop-menu.cpp',
545-
'src/desktop-pasteboard.cpp',
546543
'src/desktop-image.cpp',
547544
'src/desktop-ans.cpp',
548545
'src/legacy_spec.cpp',
@@ -935,7 +932,6 @@
935932
'src/desktop-dc.cpp',
936933
'src/desktop-image.cpp',
937934
'src/desktop-menu.cpp',
938-
'src/desktop-pasteboard.cpp',
939935
'src/desktop-stack.cpp',
940936
'src/platform.cpp',
941937
'src/platform-recorder.cpp',

engine/src/clipboard.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ void MCClipboard::Clear()
9595
// Pass on the request
9696
Lock();
9797
m_clipboard->Clear();
98+
m_dirty = true;
9899
Unlock();
99100
}
100101

@@ -121,6 +122,12 @@ bool MCClipboard::PushUpdates(bool p_force) const
121122
return true;
122123
}
123124

125+
void MCClipboard::FlushData()
126+
{
127+
// Pass on the request
128+
m_clipboard->FlushData();
129+
}
130+
124131
bool MCClipboard::Rebind(MCRawClipboard* p_clipboard)
125132
{
126133
// Change the underlying clipboard

engine/src/clipboard.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class MCClipboard :
6666
// If forced, the clipboard will be pushed even in the absence of changes.
6767
bool PushUpdates(bool p_force = false) const;
6868

69+
// Ensures all data in this clipboard has been pushed out to the OS'
70+
// clipboard. This means that the data will still be available after
71+
// LiveCode exits.
72+
void FlushData();
73+
6974
// On some platforms, the drag board used for an incoming drag-and-drop
7075
// operation may be different from the main system drag board. This
7176
// method can be called to get this clipboard to re-bind to the supplied
@@ -161,8 +166,7 @@ class MCClipboard :
161166
MCDataRef m_private_data;
162167

163168
// Set whenever a modification is made to the clipboard. No updates are
164-
// pushed if no modifications have been made. Clearing the clipboard does
165-
// *not* count as a modification.
169+
// pushed if no modifications have been made.
166170
bool m_dirty;
167171

168172

engine/src/desktop-dc.cpp

Lines changed: 0 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -967,218 +967,6 @@ MCPrinter *MCScreenDC::createprinter(void)
967967

968968
////////////////////////////////////////////////////////////////////////////////
969969

970-
static uindex_t s_clipboard_generation = 0;
971-
static MCPasteboard *s_local_clipboard = nil;
972-
973-
bool MCConvertStyledTextToUTF8(MCDataRef p_in, MCDataRef& r_out)
974-
{
975-
MCObject *t_object;
976-
t_object = MCObject::unpickle(p_in, MCtemplatefield -> getstack());
977-
if (t_object != NULL)
978-
{
979-
MCParagraph *t_paragraphs;
980-
MCAutoStringRef t_exported;
981-
t_paragraphs = ((MCStyledText *)t_object) -> getparagraphs();
982-
bool t_success;
983-
t_success = true;
984-
985-
// MW-2012-02-21: [[ FieldExport ]] Use the new plain text export method.
986-
if (t_paragraphs != NULL)
987-
{
988-
t_success = MCtemplatefield -> exportasplaintext(t_paragraphs, 0, INT32_MAX, &t_exported)
989-
&& MCStringEncode(*t_exported, kMCStringEncodingUTF8, false, r_out);
990-
}
991-
else
992-
r_out = MCValueRetain(kMCEmptyData);
993-
994-
delete t_object;
995-
return t_success;
996-
}
997-
998-
return false;
999-
}
1000-
1001-
bool MCConvertUnicodeTextToUTF8(MCDataRef p_in, MCDataRef &r_out)
1002-
{
1003-
MCAutoStringRef t_pivot;
1004-
return MCStringDecode(p_in, kMCStringEncodingUTF16, false, &t_pivot)
1005-
&& MCStringEncode(*t_pivot, kMCStringEncodingUTF8, false, r_out);
1006-
}
1007-
1008-
bool MCConvertTextToUTF8(MCDataRef p_in, MCDataRef &r_out)
1009-
{
1010-
MCAutoStringRef t_pivot;
1011-
return MCStringDecode(p_in, kMCStringEncodingNative, false, &t_pivot)
1012-
&& MCStringEncode(*t_pivot, kMCStringEncodingUTF8, false, r_out);
1013-
}
1014-
1015-
bool MCConvertIdentity(MCDataRef p_in, MCDataRef &r_out)
1016-
{
1017-
r_out = MCValueRetain(p_in);
1018-
return true;
1019-
}
1020-
1021-
static struct { MCTransferType type; MCPlatformPasteboardFlavor flavor; bool (*convert)(MCDataRef p_in, MCDataRef &r_out); } s_pasteboard_fetchers[] =
1022-
{
1023-
{ TRANSFER_TYPE_STYLED_TEXT, kMCPlatformPasteboardFlavorRTF, MCConvertStyledTextToRTF },
1024-
{ TRANSFER_TYPE_STYLED_TEXT, kMCPlatformPasteboardFlavorUTF8, MCConvertStyledTextToUTF8 },
1025-
{ TRANSFER_TYPE_UNICODE_TEXT, kMCPlatformPasteboardFlavorUTF8, MCConvertUnicodeTextToUTF8 },
1026-
{ TRANSFER_TYPE_TEXT, kMCPlatformPasteboardFlavorUTF8, MCConvertTextToUTF8 },
1027-
{ TRANSFER_TYPE_IMAGE, kMCPlatformPasteboardFlavorPNG, MCConvertIdentity },
1028-
{ TRANSFER_TYPE_IMAGE, kMCPlatformPasteboardFlavorGIF, MCConvertIdentity },
1029-
{ TRANSFER_TYPE_IMAGE, kMCPlatformPasteboardFlavorJPEG, MCConvertIdentity },
1030-
{ TRANSFER_TYPE_FILES, kMCPlatformPasteboardFlavorFiles, MCConvertIdentity },
1031-
{ TRANSFER_TYPE_OBJECTS, kMCPlatformPasteboardFlavorObjects, MCConvertIdentity },
1032-
};
1033-
1034-
static bool fetch_pasteboard(MCPasteboard *p_pasteboard, MCPlatformPasteboardFlavor p_flavor, void*& r_data, size_t& r_data_size)
1035-
{
1036-
MCTransferType *t_types;
1037-
size_t t_type_count;
1038-
if (!p_pasteboard -> Query(t_types, t_type_count))
1039-
return false;
1040-
1041-
for(uindex_t i = 0; i < sizeof(s_pasteboard_fetchers) / sizeof(s_pasteboard_fetchers[0]); i++)
1042-
for(uindex_t j = 0; j < t_type_count; j++)
1043-
if (s_pasteboard_fetchers[i] . type == t_types[j] && s_pasteboard_fetchers[i] . flavor == p_flavor)
1044-
{
1045-
MCAutoDataRef t_data;
1046-
if (!p_pasteboard -> Fetch(t_types[j], &t_data))
1047-
return false;
1048-
1049-
bool t_success;
1050-
t_success = false;
1051-
1052-
MCAutoDataRef t_new_data;
1053-
if (s_pasteboard_fetchers[i] . convert(*t_data, &t_new_data))
1054-
{
1055-
if (MCMemoryAllocateCopy(MCDataGetBytePtr(*t_new_data), MCDataGetLength(*t_new_data), r_data))
1056-
{
1057-
r_data_size = MCDataGetLength(*t_new_data);
1058-
t_success = true;
1059-
}
1060-
}
1061-
1062-
return t_success;
1063-
}
1064-
1065-
return true;
1066-
}
1067-
1068-
static bool fetch_clipboard(MCPlatformPasteboardFlavor p_flavor, void*& r_data, size_t& r_data_size)
1069-
{
1070-
if (s_local_clipboard == nil)
1071-
return false;
1072-
1073-
return fetch_pasteboard(s_local_clipboard, p_flavor, r_data, r_data_size);
1074-
}
1075-
1076-
void MCScreenDC::flushclipboard(void)
1077-
{
1078-
}
1079-
1080-
bool MCScreenDC::ownsclipboard(void)
1081-
{
1082-
MCPlatformPasteboardRef t_pasteboard;
1083-
MCPlatformGetClipboard(t_pasteboard);
1084-
if (MCPlatformPasteboardGetGeneration(t_pasteboard) == s_clipboard_generation)
1085-
return true;
1086-
1087-
if (s_local_clipboard != nil)
1088-
{
1089-
s_local_clipboard -> Release();
1090-
s_local_clipboard = nil;
1091-
}
1092-
1093-
return false;
1094-
}
1095-
1096-
bool MCScreenDC::setclipboard(MCPasteboard *p_pasteboard)
1097-
{
1098-
MCPlatformPasteboardRef t_clipboard;
1099-
MCPlatformGetClipboard(t_clipboard);
1100-
1101-
MCPlatformPasteboardClear(t_clipboard);
1102-
if (s_local_clipboard != nil)
1103-
{
1104-
s_local_clipboard -> Release();
1105-
s_local_clipboard = nil;
1106-
}
1107-
1108-
MCTransferType *t_types;
1109-
size_t t_type_count;
1110-
if (!p_pasteboard -> Query(t_types, t_type_count))
1111-
return false;
1112-
1113-
// We must set the pasteboard here as we might get our data callback invoked
1114-
// whilst setting data.
1115-
s_local_clipboard = p_pasteboard;
1116-
s_local_clipboard -> Retain();
1117-
1118-
for(uindex_t i = 0; i < t_type_count; i++)
1119-
{
1120-
MCPlatformPasteboardFlavor t_flavors[2];
1121-
uindex_t t_flavor_count;
1122-
t_flavor_count = 0;
1123-
1124-
switch(t_types[i])
1125-
{
1126-
case TRANSFER_TYPE_TEXT:
1127-
case TRANSFER_TYPE_UNICODE_TEXT:
1128-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorUTF8;
1129-
break;
1130-
case TRANSFER_TYPE_STYLED_TEXT:
1131-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorRTF;
1132-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorUTF8;
1133-
break;
1134-
case TRANSFER_TYPE_IMAGE:
1135-
{
1136-
MCAutoDataRef t_data;
1137-
if (p_pasteboard -> Fetch(TRANSFER_TYPE_IMAGE, &t_data))
1138-
{
1139-
if (MCImageDataIsPNG(*t_data))
1140-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorPNG;
1141-
if (MCImageDataIsGIF(*t_data))
1142-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorGIF;
1143-
if (MCImageDataIsJPEG(*t_data))
1144-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorJPEG;
1145-
}
1146-
}
1147-
break;
1148-
case TRANSFER_TYPE_FILES:
1149-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorFiles;
1150-
break;
1151-
case TRANSFER_TYPE_OBJECTS:
1152-
t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorObjects;
1153-
break;
1154-
case TRANSFER_TYPE_PRIVATE:
1155-
break;
1156-
}
1157-
1158-
if (t_flavor_count != 0)
1159-
MCPlatformPasteboardStore(t_clipboard, t_flavors, t_flavor_count, (void *)fetch_clipboard);
1160-
}
1161-
1162-
s_clipboard_generation = MCPlatformPasteboardGetGeneration(t_clipboard);
1163-
1164-
return true;
1165-
}
1166-
1167-
MCPasteboard *MCScreenDC::getclipboard(void)
1168-
{
1169-
MCPlatformPasteboardRef t_pasteboard;
1170-
MCPlatformGetClipboard(t_pasteboard);
1171-
1172-
MCPasteboard *t_clipboard;
1173-
t_clipboard = new MCSystemPasteboard(t_pasteboard);
1174-
1175-
MCPlatformPasteboardRelease(t_pasteboard);
1176-
1177-
return t_clipboard;
1178-
}
1179-
1180-
////////////////////////////////////////////////////////////////////////////////
1181-
1182970
// TD-2013-07-01: [[ DynamicFonts ]]
1183971
bool MCScreenDC::loadfont(MCStringRef p_path, bool p_globally, void*& r_loaded_font_handle)
1184972
{
@@ -1252,16 +1040,6 @@ MCScriptEnvironment *MCScreenDC::createscriptenvironment(MCStringRef p_language)
12521040

12531041
////////////////////////////////////////////////////////////////////////////////
12541042

1255-
static MCPasteboard *s_local_dragboard = nil;
1256-
1257-
static bool fetch_dragboard(MCPlatformPasteboardFlavor p_flavor, void*& r_data, size_t& r_data_size)
1258-
{
1259-
if (s_local_dragboard == nil)
1260-
return false;
1261-
1262-
return fetch_pasteboard(s_local_dragboard, p_flavor, r_data, r_data_size);
1263-
}
1264-
12651043
MCDragAction MCScreenDC::dodragdrop(Window w, MCDragActionSet p_allowed_actions, MCImage *p_image, const MCPoint* p_image_offset)
12661044
{
12671045
MCPlatformAllowedDragOperations t_operations;

engine/src/desktop-dc.h

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,30 @@
1+
/* Copyright (C) 2003-2015 LiveCode Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
117
#ifndef __MC_DESKTOP_DC__
218
#define __MC_DESKTOP_DC__
319

4-
#ifndef __MC_UIDC__
520
#include "uidc.h"
6-
#endif
7-
8-
#ifndef __MC_PLATFORM__
921
#include "platform.h"
10-
#endif
11-
12-
class MCSystemPasteboard: public MCPasteboard
13-
{
14-
public:
15-
MCSystemPasteboard(MCPlatformPasteboardRef pasteboard);
16-
~MCSystemPasteboard(void);
17-
18-
virtual void Retain(void);
19-
virtual void Release(void);
20-
21-
virtual bool Query(MCTransferType*& r_types, size_t& r_type_count);
22-
virtual bool Fetch(MCTransferType p_type, MCDataRef& r_data);
23-
24-
private:
25-
bool IsValid(void);
26-
void Resolve(void);
27-
void AddEntry(MCTransferType type, MCPlatformPasteboardFlavor flavor);
28-
29-
struct Entry
30-
{
31-
MCTransferType type;
32-
MCPlatformPasteboardFlavor flavor;
33-
MCDataRef data;
34-
};
35-
36-
uint32_t m_references;
37-
38-
MCPlatformPasteboardRef m_pasteboard;
39-
uindex_t m_generation;
40-
41-
MCTransferType *m_types;
42-
Entry *m_entries;
43-
uindex_t m_entry_count;
44-
45-
bool m_valid;
46-
};
4722

4823
class MCScreenDC: public MCUIDC
4924
{
5025
private:
5126
uint2 beeppitch;
27+
5228
uint2 beepduration;
5329
Boolean menubarhidden;
5430

@@ -143,11 +119,6 @@ class MCScreenDC: public MCUIDC
143119
virtual bool listprinters(MCStringRef& r_printers);
144120
virtual MCPrinter *createprinter(void);
145121

146-
virtual void flushclipboard(void);
147-
virtual bool ownsclipboard(void);
148-
virtual bool setclipboard(MCPasteboard *p_pasteboard);
149-
virtual MCPasteboard *getclipboard(void);
150-
151122
virtual bool loadfont(MCStringRef p_path, bool p_globally, void*& r_loaded_font_handle);
152123
virtual bool unloadfont(MCStringRef p_path, bool p_globally, void *r_loaded_font_handle);
153124

0 commit comments

Comments
 (0)