Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Amazingly the Windows code is almost identical to the Mac OS X code. :)
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 9, 2010
1 parent 2c7aa1b commit 5a6774a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
8 changes: 8 additions & 0 deletions VisualC/SDL/SDL_VS2005.vcproj
Expand Up @@ -568,6 +568,14 @@
RelativePath="..\..\src\video\SDL_clipboard.c"
>
</File>
<File
RelativePath="..\..\src\events\SDL_clipboardevents.c"
>
</File>
<File
RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
>
</File>
<File
RelativePath="..\..\src\SDL_compat.c"
>
Expand Down
8 changes: 8 additions & 0 deletions VisualC/SDL/SDL_VS2008.vcproj
Expand Up @@ -723,6 +723,14 @@
RelativePath="..\..\src\video\SDL_clipboard.c"
>
</File>
<File
RelativePath="..\..\src\events\SDL_clipboardevents.c"
>
</File>
<File
RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
>
</File>
<File
RelativePath="..\..\src\SDL_compat.c"
>
Expand Down
8 changes: 4 additions & 4 deletions src/video/cocoa/SDL_cocoaclipboard.m
Expand Up @@ -45,7 +45,7 @@
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
NSAutoreleasePool *pool;
NSPasteboard *pasteboard;
NSPasteboard *pasteboard;
NSString *format = GetTextFormat(_this);

pool = [[NSAutoreleasePool alloc] init];
Expand All @@ -63,7 +63,7 @@
Cocoa_GetClipboardText(_THIS)
{
NSAutoreleasePool *pool;
NSPasteboard *pasteboard;
NSPasteboard *pasteboard;
NSString *format = GetTextFormat(_this);
NSString *available;
char *text;
Expand Down Expand Up @@ -96,7 +96,7 @@
Cocoa_HasClipboardText(_THIS)
{
NSAutoreleasePool *pool;
NSPasteboard *pasteboard;
NSPasteboard *pasteboard;
NSString *format = GetTextFormat(_this);
NSString *available;
SDL_bool result;
Expand All @@ -120,7 +120,7 @@
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
{
NSAutoreleasePool *pool;
NSPasteboard *pasteboard;
NSPasteboard *pasteboard;
NSInteger count;

pool = [[NSAutoreleasePool alloc] init];
Expand Down
17 changes: 17 additions & 0 deletions src/video/win32/SDL_win32clipboard.c
Expand Up @@ -23,6 +23,7 @@

#include "SDL_win32video.h"
#include "SDL_win32window.h"
#include "../../events/SDL_clipboardevents_c.h"


#ifdef UNICODE
Expand Down Expand Up @@ -52,6 +53,7 @@ GetWindowHandle(_THIS)
int
WIN_SetClipboardText(_THIS, const char *text)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
int result = 0;

if (OpenClipboard(GetWindowHandle(_this))) {
Expand Down Expand Up @@ -93,6 +95,7 @@ WIN_SetClipboardText(_THIS, const char *text)
WIN_SetError("Couldn't set clipboard data");
result = -1;
}
data->clipboard_count = GetClipboardSequenceNumber();
}
SDL_free(tstr);

Expand Down Expand Up @@ -141,4 +144,18 @@ WIN_HasClipboardText(_THIS)
}
}

void
WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
{
DWORD count;

count = GetClipboardSequenceNumber();
if (count != data->clipboard_count) {
if (data->clipboard_count) {
SDL_SendClipboardUpdate();
}
data->clipboard_count = count;
}
}

/* vi: set ts=4 sw=4 expandtab: */
4 changes: 4 additions & 0 deletions src/video/win32/SDL_win32clipboard.h
Expand Up @@ -24,9 +24,13 @@
#ifndef _SDL_win32clipboard_h
#define _SDL_win32clipboard_h

/* Forward declaration */
struct SDL_VideoData;

extern int WIN_SetClipboardText(_THIS, const char *text);
extern char *WIN_GetClipboardText(_THIS);
extern SDL_bool WIN_HasClipboardText(_THIS);
extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data);

#endif /* _SDL_win32clipboard_h */

Expand Down
5 changes: 4 additions & 1 deletion src/video/win32/SDL_win32events.c
Expand Up @@ -162,7 +162,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(data->window);
}
/* FIXME: Update keyboard state */
/*
* FIXME: Update keyboard state
*/
WIN_CheckClipboardUpdate(data->videodata);
} else {
if (SDL_GetKeyboardFocus() == data->window) {
SDL_SetKeyboardFocus(NULL);
Expand Down
1 change: 0 additions & 1 deletion src/video/win32/SDL_win32video.c
Expand Up @@ -28,7 +28,6 @@
#include "../SDL_pixels_c.h"

#include "SDL_win32video.h"
#include "SDL_win32clipboard.h"
#include "SDL_d3drender.h"
#include "SDL_gdirender.h"

Expand Down
3 changes: 3 additions & 0 deletions src/video/win32/SDL_win32video.h
Expand Up @@ -45,6 +45,7 @@
#include "ddraw.h"
#endif

#include "SDL_win32clipboard.h"
#include "SDL_win32events.h"
#include "SDL_win32gamma.h"
#include "SDL_win32keyboard.h"
Expand Down Expand Up @@ -75,6 +76,8 @@ typedef struct SDL_VideoData
IDirectDraw *ddraw;
#endif

DWORD clipboard_count;

const SDL_scancode *key_layout;
} SDL_VideoData;

Expand Down

0 comments on commit 5a6774a

Please sign in to comment.