Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
3ff2d236
Commit
3ff2d236
authored
Jul 08, 2010
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Windows clipboard support
parent
a007a286
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
235 additions
and
28 deletions
+235
-28
SDL_VS2005.vcproj
VisualC/SDL/SDL_VS2005.vcproj
+16
-0
SDL_VS2008.vcproj
VisualC/SDL/SDL_VS2008.vcproj
+16
-3
SDLmain_VS2008.vcproj
VisualC/SDLmain/SDLmain_VS2008.vcproj
+0
-3
SDL_clipboard.c
src/video/SDL_clipboard.c
+3
-0
SDL_win32clipboard.c
src/video/win32/SDL_win32clipboard.c
+144
-0
SDL_win32clipboard.h
src/video/win32/SDL_win32clipboard.h
+33
-0
SDL_win32events.c
src/video/win32/SDL_win32events.c
+0
-13
SDL_win32events.h
src/video/win32/SDL_win32events.h
+0
-1
SDL_win32video.c
src/video/win32/SDL_win32video.c
+18
-0
SDL_win32video.h
src/video/win32/SDL_win32video.h
+1
-0
SDL_win32window.c
src/video/win32/SDL_win32window.c
+4
-8
No files found.
VisualC/SDL/SDL_VS2005.vcproj
View file @
3ff2d236
...
...
@@ -235,6 +235,10 @@
RelativePath=
"..\..\include\SDL_audio.h"
>
</File>
<File
RelativePath=
"..\..\include\SDL_clipboard.h"
>
</File>
<File
RelativePath=
"..\..\include\SDL_compat.h"
>
...
...
@@ -560,6 +564,10 @@
RelativePath=
"..\..\src\video\SDL_bmp.c"
>
</File>
<File
RelativePath=
"..\..\src\video\SDL_clipboard.c"
>
</File>
<File
RelativePath=
"..\..\src\SDL_compat.c"
>
...
...
@@ -940,6 +948,14 @@
RelativePath=
"..\..\src\audio\SDL_wave.h"
>
</File>
<File
RelativePath=
"..\..\src\video\win32\SDL_win32clipboard.c"
>
</File>
<File
RelativePath=
"..\..\src\video\win32\SDL_win32clipboard.h"
>
</File>
<File
RelativePath=
"..\..\src\video\win32\SDL_win32events.c"
>
...
...
VisualC/SDL/SDL_VS2008.vcproj
View file @
3ff2d236
...
...
@@ -5,9 +5,6 @@
Name=
"SDL"
ProjectGUID=
"{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}"
RootNamespace=
"SDL"
SccProjectName=
"Perforce Project"
SccLocalPath=
"..\.."
SccProvider=
"MSSCCI:Perforce SCM"
TargetFrameworkVersion=
"131072"
>
<Platforms>
...
...
@@ -385,6 +382,10 @@
RelativePath=
"..\..\include\SDL_audio.h"
>
</File>
<File
RelativePath=
"..\..\include\SDL_clipboard.h"
>
</File>
<File
RelativePath=
"..\..\include\SDL_compat.h"
>
...
...
@@ -718,6 +719,10 @@
RelativePath=
"..\..\src\video\SDL_bmp.c"
>
</File>
<File
RelativePath=
"..\..\src\video\SDL_clipboard.c"
>
</File>
<File
RelativePath=
"..\..\src\SDL_compat.c"
>
...
...
@@ -1098,6 +1103,14 @@
RelativePath=
"..\..\src\audio\SDL_wave.h"
>
</File>
<File
RelativePath=
"..\..\src\video\win32\SDL_win32clipboard.c"
>
</File>
<File
RelativePath=
"..\..\src\video\win32\SDL_win32clipboard.h"
>
</File>
<File
RelativePath=
"..\..\src\video\win32\SDL_win32events.c"
>
...
...
VisualC/SDLmain/SDLmain_VS2008.vcproj
View file @
3ff2d236
...
...
@@ -4,9 +4,6 @@
Version=
"9.00"
Name=
"SDLmain"
ProjectGUID=
"{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"
SccProjectName=
"Perforce Project"
SccLocalPath=
"..\.."
SccProvider=
"MSSCCI:Perforce SCM"
TargetFrameworkVersion=
"131072"
>
<Platforms>
...
...
src/video/SDL_clipboard.c
View file @
3ff2d236
...
...
@@ -30,6 +30,9 @@ SDL_SetClipboardText(const char *text)
{
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
if
(
!
text
)
{
text
=
""
;
}
if
(
_this
->
SetClipboardText
)
{
return
_this
->
SetClipboardText
(
_this
,
text
);
}
else
{
...
...
src/video/win32/SDL_win32clipboard.c
0 → 100644
View file @
3ff2d236
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_win32video.h"
#include "SDL_win32window.h"
#ifdef UNICODE
#define TEXT_FORMAT CF_UNICODETEXT
#else
#define TEXT_FORMAT CF_TEXT
#endif
/* Get any application owned window handle for clipboard association */
static
HWND
GetWindowHandle
(
_THIS
)
{
SDL_VideoDisplay
*
display
;
SDL_Window
*
window
;
display
=
_this
->
displays
;
if
(
display
)
{
window
=
display
->
windows
;
if
(
window
)
{
return
((
SDL_WindowData
*
)
window
->
driverdata
)
->
hwnd
;
}
}
return
NULL
;
}
int
WIN_SetClipboardText
(
_THIS
,
const
char
*
text
)
{
int
result
=
0
;
if
(
OpenClipboard
(
GetWindowHandle
(
_this
)))
{
HANDLE
hMem
;
LPTSTR
tstr
;
SIZE_T
i
,
size
;
/* Convert the text from UTF-8 to Windows Unicode */
tstr
=
WIN_UTF8ToString
(
text
);
if
(
!
tstr
)
{
return
-
1
;
}
/* Find out the size of the data */
for
(
size
=
0
,
i
=
0
;
tstr
[
i
];
++
i
,
++
size
)
{
if
(
tstr
[
i
]
==
'\n'
&&
(
i
==
0
||
tstr
[
i
-
1
]
!=
'\r'
))
{
/* We're going to insert a carriage return */
++
size
;
}
}
size
=
(
size
+
1
)
*
sizeof
(
*
tstr
);
/* Save the data to the clipboard */
hMem
=
GlobalAlloc
(
GMEM_MOVEABLE
,
size
);
if
(
hMem
)
{
LPTSTR
dst
=
(
LPTSTR
)
GlobalLock
(
hMem
);
/* Copy the text over, adding carriage returns as necessary */
for
(
i
=
0
;
tstr
[
i
];
++
i
)
{
if
(
tstr
[
i
]
==
'\n'
&&
(
i
==
0
||
tstr
[
i
-
1
]
!=
'\r'
))
{
*
dst
++
=
'\r'
;
}
*
dst
++
=
tstr
[
i
];
}
*
dst
=
0
;
GlobalUnlock
(
hMem
);
EmptyClipboard
();
if
(
!
SetClipboardData
(
TEXT_FORMAT
,
hMem
))
{
WIN_SetError
(
"Couldn't set clipboard data"
);
result
=
-
1
;
}
}
SDL_free
(
tstr
);
CloseClipboard
();
}
else
{
WIN_SetError
(
"Couldn't open clipboard"
);
result
=
-
1
;
}
return
result
;
}
char
*
WIN_GetClipboardText
(
_THIS
)
{
char
*
text
;
text
=
NULL
;
if
(
IsClipboardFormatAvailable
(
TEXT_FORMAT
)
&&
OpenClipboard
(
GetWindowHandle
(
_this
)))
{
HANDLE
hMem
;
LPTSTR
tstr
;
hMem
=
GetClipboardData
(
TEXT_FORMAT
);
if
(
hMem
)
{
tstr
=
(
LPTSTR
)
GlobalLock
(
hMem
);
text
=
WIN_StringToUTF8
(
tstr
);
GlobalUnlock
(
hMem
);
}
else
{
WIN_SetError
(
"Couldn't get clipboard data"
);
}
CloseClipboard
();
}
if
(
!
text
)
{
text
=
SDL_strdup
(
""
);
}
return
text
;
}
SDL_bool
WIN_HasClipboardText
(
_THIS
)
{
if
(
IsClipboardFormatAvailable
(
TEXT_FORMAT
))
{
return
SDL_TRUE
;
}
else
{
return
SDL_FALSE
;
}
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/win32/SDL_win32clipboard.h
0 → 100644
View file @
3ff2d236
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_win32clipboard_h
#define _SDL_win32clipboard_h
extern
int
WIN_SetClipboardText
(
_THIS
,
const
char
*
text
);
extern
char
*
WIN_GetClipboardText
(
_THIS
);
extern
SDL_bool
WIN_HasClipboardText
(
_THIS
);
#endif
/* _SDL_win32clipboard_h */
/* vi: set ts=4 sw=4 expandtab: */
src/video/win32/SDL_win32events.c
View file @
3ff2d236
...
...
@@ -585,17 +585,4 @@ SDL_UnregisterApp()
}
}
/* Sets an error message based on GetLastError() */
void
WIN_SetError
(
const
char
*
prefix
)
{
TCHAR
buffer
[
1024
];
char
*
message
;
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
GetLastError
(),
0
,
buffer
,
SDL_arraysize
(
buffer
),
NULL
);
message
=
WIN_StringToUTF8
(
buffer
);
SDL_SetError
(
"%s%s%s"
,
prefix
?
prefix
:
""
,
prefix
?
": "
:
""
,
message
);
SDL_free
(
message
);
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/win32/SDL_win32events.h
View file @
3ff2d236
...
...
@@ -31,7 +31,6 @@ extern HINSTANCE SDL_Instance;
extern
LRESULT
CALLBACK
WIN_WindowProc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
);
extern
void
WIN_PumpEvents
(
_THIS
);
extern
void
WIN_SetError
(
const
char
*
prefix
);
#endif
/* _SDL_win32events_h */
...
...
src/video/win32/SDL_win32video.c
View file @
3ff2d236
...
...
@@ -28,6 +28,7 @@
#include "../SDL_pixels_c.h"
#include "SDL_win32video.h"
#include "SDL_win32clipboard.h"
#include "SDL_d3drender.h"
#include "SDL_gdirender.h"
...
...
@@ -35,6 +36,19 @@
static
int
WIN_VideoInit
(
_THIS
);
static
void
WIN_VideoQuit
(
_THIS
);
/* Sets an error message based on GetLastError() */
void
WIN_SetError
(
const
char
*
prefix
)
{
TCHAR
buffer
[
1024
];
char
*
message
;
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
GetLastError
(),
0
,
buffer
,
SDL_arraysize
(
buffer
),
NULL
);
message
=
WIN_StringToUTF8
(
buffer
);
SDL_SetError
(
"%s%s%s"
,
prefix
?
prefix
:
""
,
prefix
?
": "
:
""
,
message
);
SDL_free
(
message
);
}
/* WIN32 driver bootstrap functions */
static
int
...
...
@@ -163,6 +177,10 @@ WIN_CreateDevice(int devindex)
device
->
GL_DeleteContext
=
WIN_GL_DeleteContext
;
#endif
device
->
SetClipboardText
=
WIN_SetClipboardText
;
device
->
GetClipboardText
=
WIN_GetClipboardText
;
device
->
HasClipboardText
=
WIN_HasClipboardText
;
device
->
free
=
WIN_DeleteDevice
;
return
device
;
...
...
src/video/win32/SDL_win32video.h
View file @
3ff2d236
...
...
@@ -60,6 +60,7 @@
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
#endif
extern
void
WIN_SetError
(
const
char
*
prefix
);
/* Private display data */
...
...
src/video/win32/SDL_win32window.c
View file @
3ff2d236
...
...
@@ -633,8 +633,7 @@ SDL_HelperWindowCreate(void)
/* Register the class. */
SDL_HelperWindowClass
=
RegisterClass
(
&
wce
);
if
(
SDL_HelperWindowClass
==
0
)
{
SDL_SetError
(
"Unable to create Helper Window Class: error %d."
,
GetLastError
());
WIN_SetError
(
"Unable to create Helper Window Class"
);
return
-
1
;
}
...
...
@@ -652,8 +651,7 @@ SDL_HelperWindowCreate(void)
hInstance
,
NULL
);
if
(
SDL_HelperWindow
==
NULL
)
{
UnregisterClass
(
SDL_HelperWindowClassName
,
hInstance
);
SDL_SetError
(
"Unable to create Helper Window: error %d."
,
GetLastError
());
WIN_SetError
(
"Unable to create Helper Window"
);
return
-
1
;
}
...
...
@@ -672,8 +670,7 @@ SDL_HelperWindowDestroy(void)
/* Destroy the window. */
if
(
SDL_HelperWindow
!=
NULL
)
{
if
(
DestroyWindow
(
SDL_HelperWindow
)
==
0
)
{
SDL_SetError
(
"Unable to destroy Helper Window: error %d."
,
GetLastError
());
WIN_SetError
(
"Unable to destroy Helper Window"
);
return
;
}
SDL_HelperWindow
=
NULL
;
...
...
@@ -682,8 +679,7 @@ SDL_HelperWindowDestroy(void)
/* Unregister the class. */
if
(
SDL_HelperWindowClass
!=
0
)
{
if
((
UnregisterClass
(
SDL_HelperWindowClassName
,
hInstance
))
==
0
)
{
SDL_SetError
(
"Unable to destroy Helper Window Class: error %d."
,
GetLastError
());
WIN_SetError
(
"Unable to destroy Helper Window Class"
);
return
;
}
SDL_HelperWindowClass
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment