summaryrefslogtreecommitdiff
path: root/src/Misc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Misc.cpp')
-rw-r--r--src/Misc.cpp141
1 files changed, 0 insertions, 141 deletions
diff --git a/src/Misc.cpp b/src/Misc.cpp
index 830f0ca..8c18871 100644
--- a/src/Misc.cpp
+++ b/src/Misc.cpp
@@ -49,15 +49,6 @@ std::string URLEscape(std::string source)
return finalString;
}
-#if defined(USE_SDL) && defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
-#include <SDL/SDL.h>
-#include <SDL/SDL_syswm.h>
-SDL_SysWMinfo sdl_wminfo;
-Atom XA_CLIPBOARD, XA_TARGETS;
-#endif
-
-char *clipboardText = NULL;
-
char *exe_name(void)
{
#if defined(WIN)
@@ -368,138 +359,6 @@ vector2d v2d_new(float x, float y)
return result;
}
-void clipboard_init()
-{
-#if defined (USE_SDL) && defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
- SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
- SDL_VERSION(&sdl_wminfo.version);
- SDL_GetWMInfo(&sdl_wminfo);
- sdl_wminfo.info.x11.lock_func();
- XA_CLIPBOARD = XInternAtom(sdl_wminfo.info.x11.display, "CLIPBOARD", 1);
- XA_TARGETS = XInternAtom(sdl_wminfo.info.x11.display, "TARGETS", 1);
- sdl_wminfo.info.x11.unlock_func();
-#endif
-}
-
-#if defined (USE_SDL) && defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
-void clipboard_event(SDL_Event event)
-{
- if (event.syswm.msg->subsystem != SDL_SYSWM_X11)
- return;
- sdl_wminfo.info.x11.lock_func();
- XEvent xe = event.syswm.msg->event.xevent;
- if (xe.type==SelectionClear)
- {
- if (clipboardText != NULL) {
- free(clipboardText);
- clipboardText = NULL;
- }
- }
- else if (xe.type==SelectionRequest)
- {
- XEvent xr;
- xr.xselection.type = SelectionNotify;
- xr.xselection.requestor = xe.xselectionrequest.requestor;
- xr.xselection.selection = xe.xselectionrequest.selection;
- xr.xselection.target = xe.xselectionrequest.target;
- xr.xselection.property = xe.xselectionrequest.property;
- xr.xselection.time = xe.xselectionrequest.time;
- if (xe.xselectionrequest.target==XA_TARGETS)
- {
- // send list of supported formats
- Atom targets[] = {XA_TARGETS, XA_STRING};
- xr.xselection.property = xe.xselectionrequest.property;
- XChangeProperty(sdl_wminfo.info.x11.display, xe.xselectionrequest.requestor, xe.xselectionrequest.property, XA_ATOM, 32, PropModeReplace, (unsigned char*)targets, (int)(sizeof(targets)/sizeof(Atom)));
- }
- // TODO: Supporting more targets would be nice
- else if (xe.xselectionrequest.target==XA_STRING && clipboardText)
- {
- XChangeProperty(sdl_wminfo.info.x11.display, xe.xselectionrequest.requestor, xe.xselectionrequest.property, xe.xselectionrequest.target, 8, PropModeReplace, (unsigned char*)clipboardText, strlen(clipboardText)+1);
- }
- else
- {
- // refuse clipboard request
- xr.xselection.property = None;
- }
- XSendEvent(sdl_wminfo.info.x11.display, xe.xselectionrequest.requestor, 0, 0, &xr);
- }
- sdl_wminfo.info.x11.unlock_func();
-}
-#endif
-
-void clipboard_push_text(char * text)
-{
- if (clipboardText != NULL) {
- free(clipboardText);
- clipboardText = NULL;
- }
- clipboardText = mystrdup(text);
-#ifdef MACOSX
- PasteboardRef newclipboard;
-
- if (PasteboardCreate(kPasteboardClipboard, &newclipboard)!=noErr) return;
- if (PasteboardClear(newclipboard)!=noErr) return;
- PasteboardSynchronize(newclipboard);
-
- CFDataRef data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text));
- PasteboardPutItemFlavor(newclipboard, (PasteboardItemID)1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0);
-#elif defined(WIN)
- if (OpenClipboard(NULL))
- {
- HGLOBAL cbuffer;
- char * glbuffer;
-
- EmptyClipboard();
-
- cbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1);
- glbuffer = (char*)GlobalLock(cbuffer);
-
- strcpy(glbuffer, text);
-
- GlobalUnlock(cbuffer);
- SetClipboardData(CF_TEXT, cbuffer);
- CloseClipboard();
- }
-#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
- sdl_wminfo.info.x11.lock_func();
- XSetSelectionOwner(sdl_wminfo.info.x11.display, XA_CLIPBOARD, sdl_wminfo.info.x11.window, CurrentTime);
- XFlush(sdl_wminfo.info.x11.display);
- sdl_wminfo.info.x11.unlock_func();
-#else
- printf("Not implemented: put text on clipboard \"%s\"\n", text);
-#endif
-}
-
-char * clipboard_pull_text()
-{
-#ifdef MACOSX
- printf("Not implemented: get text from clipboard\n");
-#elif defined(WIN)
- if (OpenClipboard(NULL))
- {
- HANDLE cbuffer;
- char * glbuffer;
-
- cbuffer = GetClipboardData(CF_TEXT);
- glbuffer = (char*)GlobalLock(cbuffer);
- GlobalUnlock(cbuffer);
- CloseClipboard();
- if(glbuffer!=NULL){
- return mystrdup(glbuffer);
- }// else {
- // return mystrdup("");
- //}
- }
-#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
- printf("Not implemented: get text from clipboard\n");
-#else
- printf("Not implemented: get text from clipboard\n");
-#endif
- if (clipboardText)
- return mystrdup(clipboardText);
- return mystrdup("");
-}
-
int register_extension()
{
#if defined(WIN)