comparison src/video/win32/SDL_win32clipboard.c @ 4504:9faebccfefb3

Amazingly the Windows code is almost identical to the Mac OS X code. :)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 08 Jul 2010 23:07:34 -0700
parents eff4e88cc1e8
children e1664f94f026
comparison
equal deleted inserted replaced
4503:524dfefd554c 4504:9faebccfefb3
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_win32video.h" 24 #include "SDL_win32video.h"
25 #include "SDL_win32window.h" 25 #include "SDL_win32window.h"
26 #include "../../events/SDL_clipboardevents_c.h"
26 27
27 28
28 #ifdef UNICODE 29 #ifdef UNICODE
29 #define TEXT_FORMAT CF_UNICODETEXT 30 #define TEXT_FORMAT CF_UNICODETEXT
30 #else 31 #else
50 } 51 }
51 52
52 int 53 int
53 WIN_SetClipboardText(_THIS, const char *text) 54 WIN_SetClipboardText(_THIS, const char *text)
54 { 55 {
56 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
55 int result = 0; 57 int result = 0;
56 58
57 if (OpenClipboard(GetWindowHandle(_this))) { 59 if (OpenClipboard(GetWindowHandle(_this))) {
58 HANDLE hMem; 60 HANDLE hMem;
59 LPTSTR tstr; 61 LPTSTR tstr;
91 EmptyClipboard(); 93 EmptyClipboard();
92 if (!SetClipboardData(TEXT_FORMAT, hMem)) { 94 if (!SetClipboardData(TEXT_FORMAT, hMem)) {
93 WIN_SetError("Couldn't set clipboard data"); 95 WIN_SetError("Couldn't set clipboard data");
94 result = -1; 96 result = -1;
95 } 97 }
98 data->clipboard_count = GetClipboardSequenceNumber();
96 } 99 }
97 SDL_free(tstr); 100 SDL_free(tstr);
98 101
99 CloseClipboard(); 102 CloseClipboard();
100 } else { 103 } else {
139 } else { 142 } else {
140 return SDL_FALSE; 143 return SDL_FALSE;
141 } 144 }
142 } 145 }
143 146
147 void
148 WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
149 {
150 DWORD count;
151
152 count = GetClipboardSequenceNumber();
153 if (count != data->clipboard_count) {
154 if (data->clipboard_count) {
155 SDL_SendClipboardUpdate();
156 }
157 data->clipboard_count = count;
158 }
159 }
160
144 /* vi: set ts=4 sw=4 expandtab: */ 161 /* vi: set ts=4 sw=4 expandtab: */