aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Rumney2003-07-06 22:01:49 +0000
committerJason Rumney2003-07-06 22:01:49 +0000
commitee79d1aa9c203ea3a3684461c9720d53d815fa08 (patch)
tree8183842e4bbc3048e490415dbc12844cc628ee5c
parentccc0fdaa3ebc3fc50e2a895318796dd1f20c4443 (diff)
downloademacs-ee79d1aa9c203ea3a3684461c9720d53d815fa08.tar.gz
emacs-ee79d1aa9c203ea3a3684461c9720d53d815fa08.zip
(last_clipboard_sequence_number): New variable.
(Fw32_set_clipboard_data, Fw32_get_clipboard_data): Use sequence number if possible.
-rw-r--r--src/ChangeLog11
-rw-r--r--src/w32select.c52
2 files changed, 46 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5ce80c64743..5efef007e00 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12003-07-06 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.h (ClipboardSequence_Proc): New type.
4
5 * w32fns.c (clipboard_sequence_fn): New variable.
6 (globals_of_w32fns): Initialize it.
7
8 * w32select.c (last_clipboard_sequence_number): New variable.
9 (Fw32_set_clipboard_data, Fw32_get_clipboard_data): Use sequence
10 number if possible.
11
12003-07-06 Stefan Monnier <monnier@cs.yale.edu> 122003-07-06 Stefan Monnier <monnier@cs.yale.edu>
2 13
3 * m/amdx86-64.h (MARKBIT): 14 * m/amdx86-64.h (MARKBIT):
diff --git a/src/w32select.c b/src/w32select.c
index 77f2aea6df7..d44ebcbb270 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -41,9 +41,14 @@ static Lisp_Object Vselection_coding_system;
41/* Coding system for the next communicating with other Windows programs. */ 41/* Coding system for the next communicating with other Windows programs. */
42static Lisp_Object Vnext_selection_coding_system; 42static Lisp_Object Vnext_selection_coding_system;
43 43
44/* The last text we put into the clipboard. This is used to prevent 44/* Sequence number, used where possible to detect when we are pasting
45 passing back our own text from the clipboard, instead of using the 45 our own text. */
46 kill ring. The former is undesirable because the clipboard data 46static DWORD last_clipboard_sequence_number;
47extern ClipboardSequence_Proc clipboard_sequence_fn;
48
49/* The last text we put into the clipboard. This is used when the OS
50 does not support sequence numbers (NT4, 95). It is undesirable to
51 use data put on the clipboard by Emacs because the clipboard data
47 could be MULEtilated by inappropriately chosen 52 could be MULEtilated by inappropriately chosen
48 (next-)selection-coding-system. For this reason, we must store the 53 (next-)selection-coding-system. For this reason, we must store the
49 text *after* it was encoded/Unix-to-DOS-converted. */ 54 text *after* it was encoded/Unix-to-DOS-converted. */
@@ -217,17 +222,23 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
217 encode_coding (&coding, src, dst, nbytes, bufsize); 222 encode_coding (&coding, src, dst, nbytes, bufsize);
218 Vlast_coding_system_used = coding.symbol; 223 Vlast_coding_system_used = coding.symbol;
219 224
220 /* Stash away the data we are about to put into the clipboard, so we 225 /* If clipboard sequence numbers are not supported, keep a copy for
221 could later check inside Fw32_get_clipboard_data whether 226 later comparison. */
222 the clipboard still holds our data. */ 227 if (!clipboard_sequence_fn)
223 if (clipboard_storage_size < coding.produced) 228 {
224 { 229 /* Stash away the data we are about to put into the
225 clipboard_storage_size = coding.produced + 100; 230 clipboard, so we could later check inside
226 last_clipboard_text = (char *) xrealloc (last_clipboard_text, 231 Fw32_get_clipboard_data whether the clipboard still
227 clipboard_storage_size); 232 holds our data. */
228 } 233 if (clipboard_storage_size < coding.produced)
229 if (last_clipboard_text) 234 {
230 memcpy (last_clipboard_text, dst, coding.produced); 235 clipboard_storage_size = coding.produced + 100;
236 last_clipboard_text = (char *) xrealloc (last_clipboard_text,
237 clipboard_storage_size);
238 }
239 if (last_clipboard_text)
240 memcpy (last_clipboard_text, dst, coding.produced);
241 }
231 242
232 GlobalUnlock (htext); 243 GlobalUnlock (htext);
233 244
@@ -243,6 +254,9 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
243 254
244 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); 255 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext);
245 256
257 if (clipboard_sequence_fn)
258 last_clipboard_sequence_number = clipboard_sequence_fn ();
259
246 CloseClipboard (); 260 CloseClipboard ();
247 261
248 if (ok) goto done; 262 if (ok) goto done;
@@ -254,6 +268,8 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
254 if (last_clipboard_text) 268 if (last_clipboard_text)
255 *last_clipboard_text = '\0'; 269 *last_clipboard_text = '\0';
256 270
271 last_clipboard_sequence_number = 0;
272
257 done: 273 done:
258 UNBLOCK_INPUT; 274 UNBLOCK_INPUT;
259 275
@@ -297,9 +313,11 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
297 data in the clipboard. This is so we don't pass our own text 313 data in the clipboard. This is so we don't pass our own text
298 from the clipboard (which might be troublesome if the killed 314 from the clipboard (which might be troublesome if the killed
299 text includes null characters). */ 315 text includes null characters). */
300 if (last_clipboard_text 316 if ((clipboard_sequence_fn
301 && clipboard_storage_size >= nbytes 317 && clipboard_sequence_fn () == last_clipboard_sequence_number)
302 && memcmp(last_clipboard_text, src, nbytes) == 0) 318 || (last_clipboard_text
319 && clipboard_storage_size >= nbytes
320 && memcmp(last_clipboard_text, src, nbytes) == 0))
303 goto closeclip; 321 goto closeclip;
304 322
305 { 323 {