Updated SDL 1.3 to rev hg-4510
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_atomic.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_clipboard.h"
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
76
alienblaster/project/jni/sdl/include/SDL_clipboard.h
Normal file
76
alienblaster/project/jni/sdl/include/SDL_clipboard.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_clipboard.h
|
||||
*
|
||||
* Include file for SDL clipboard handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_clipboard_h
|
||||
#define _SDL_clipboard_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Put UTF-8 text into the clipboard
|
||||
*
|
||||
* \sa SDL_GetClipboardText()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
|
||||
|
||||
/**
|
||||
* \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
|
||||
*
|
||||
* \sa SDL_SetClipboardText()
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
|
||||
|
||||
/**
|
||||
* \brief Returns whether the clipboard has text
|
||||
*
|
||||
* \sa SDL_GetClipboardText()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_clipboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -145,12 +145,9 @@ typedef unsigned long uintptr_t;
|
||||
#define SDL_POWER_UIKIT 1
|
||||
|
||||
/* enable iPhone keyboard support */
|
||||
#define SDL_IPHONE_KEYBOARD 0
|
||||
#define SDL_IPHONE_KEYBOARD 1
|
||||
|
||||
/* Enable emulation of multiple mice through multi-touch */
|
||||
#define SDL_IPHONE_MULTIPLE_MICE 1
|
||||
|
||||
/* Set max recognized G-force from acceleromter
|
||||
/* Set max recognized G-force from accelerometer
|
||||
See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed
|
||||
*/
|
||||
#define SDL_IPHONE_MAX_GFORCE 5.0
|
||||
|
||||
@@ -90,6 +90,9 @@ typedef enum
|
||||
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
|
||||
SDL_JOYBUTTONUP, /**< Joystick button released */
|
||||
|
||||
/* Clipboard events */
|
||||
SDL_CLIPBOARDUPDATE = 0x700, /**< The clipboard changed */
|
||||
|
||||
/* Obsolete events */
|
||||
SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
|
||||
SDL_EVENT_COMPAT2,
|
||||
|
||||
@@ -112,8 +112,7 @@ enum
|
||||
SDL_PACKEDLAYOUT_1010102
|
||||
};
|
||||
|
||||
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) \
|
||||
((A) | ((B) << 8) | ((C) << 16) | ((D) << 24))
|
||||
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
|
||||
|
||||
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
|
||||
((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define SDL_REVISION "hg-4485:82d661ea0d5a"
|
||||
#define SDL_REVISION "hg-4510:6f8175ad0335"
|
||||
|
||||
@@ -101,6 +101,13 @@
|
||||
#endif
|
||||
/*@}*//*Cast operators*/
|
||||
|
||||
/* Define a four character code as a Uint32 */
|
||||
#define SDL_FOURCC(A, B, C, D) \
|
||||
((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
|
||||
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
|
||||
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
|
||||
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
|
||||
|
||||
/**
|
||||
* \name Basic data types
|
||||
*/
|
||||
|
||||
@@ -106,24 +106,6 @@ struct SDL_SysWMinfo
|
||||
{
|
||||
Display *display; /**< The X11 display */
|
||||
Window window; /**< The X11 display window */
|
||||
/**
|
||||
* These locking functions should be called around
|
||||
* any X11 functions using the display variable.
|
||||
* They lock the event thread, so should not be
|
||||
* called around event functions or from event filters.
|
||||
*/
|
||||
/*@{*/
|
||||
void (*lock_func) (void);
|
||||
void (*unlock_func) (void);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Introduced in SDL 1.0.2.
|
||||
*/
|
||||
/*@{*/
|
||||
Window fswindow; /**< The X11 fullscreen window */
|
||||
Window wmwindow; /**< The X11 managed input window */
|
||||
/*@}*/
|
||||
} x11;
|
||||
} info;
|
||||
};
|
||||
|
||||
@@ -291,6 +291,7 @@ SDL_StreamLength(SDL_AudioStreamer * stream)
|
||||
}
|
||||
|
||||
/* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */
|
||||
#if 0
|
||||
static int
|
||||
SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
|
||||
{
|
||||
@@ -309,6 +310,7 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Deinitialize the stream simply by freeing the buffer */
|
||||
static void
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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"
|
||||
|
||||
/* Clipboard event handling code for SDL */
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_clipboardevents_c.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_SendClipboardUpdate(void)
|
||||
{
|
||||
int posted;
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_CLIPBOARDUPDATE;
|
||||
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return (posted);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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_clipboardevents_c_h
|
||||
#define _SDL_clipboardevents_c_h
|
||||
|
||||
extern int SDL_SendClipboardUpdate(void);
|
||||
|
||||
#endif /* _SDL_clipboardevents_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -551,6 +551,10 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
|
||||
int
|
||||
SDL_KeyboardInit(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
/* Set the default keymap */
|
||||
SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
76
alienblaster/project/jni/sdl/src/video/SDL_clipboard.c
Normal file
76
alienblaster/project/jni/sdl/src/video/SDL_clipboard.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
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_clipboard.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_SetClipboardText(const char *text)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (!text) {
|
||||
text = "";
|
||||
}
|
||||
if (_this->SetClipboardText) {
|
||||
return _this->SetClipboardText(_this, text);
|
||||
} else {
|
||||
_this->clipboard_text = SDL_strdup(text);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetClipboardText(void)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (_this->GetClipboardText) {
|
||||
return _this->GetClipboardText(_this);
|
||||
} else {
|
||||
const char *text = _this->clipboard_text;
|
||||
if (!text) {
|
||||
text = "";
|
||||
}
|
||||
return SDL_strdup(text);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_HasClipboardText(void)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (_this->HasClipboardText) {
|
||||
return _this->HasClipboardText(_this);
|
||||
} else {
|
||||
if (_this->clipboard_text) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -851,7 +851,7 @@ SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format,
|
||||
/* Enable alpha blending by default if the new surface has an
|
||||
* alpha channel or alpha modulation */
|
||||
if ((surface->format->Amask && format->Amask) ||
|
||||
(copy_flags & SDL_COPY_MODULATE_ALPHA)) {
|
||||
(copy_flags & (SDL_COPY_COLORKEY|SDL_COPY_MODULATE_ALPHA))) {
|
||||
SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
|
||||
|
||||
@@ -305,6 +305,11 @@ struct SDL_VideoDevice
|
||||
void (*StopTextInput) (_THIS);
|
||||
void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
|
||||
|
||||
/* Clipboard */
|
||||
int (*SetClipboardText) (_THIS, const char *text);
|
||||
char * (*GetClipboardText) (_THIS);
|
||||
SDL_bool (*HasClipboardText) (_THIS);
|
||||
|
||||
/* * * */
|
||||
/* Data common to all drivers */
|
||||
SDL_bool suspend_screensaver;
|
||||
@@ -314,6 +319,7 @@ struct SDL_VideoDevice
|
||||
Uint8 window_magic;
|
||||
Uint8 texture_magic;
|
||||
Uint32 next_object_id;
|
||||
char * clipboard_text;
|
||||
|
||||
/* * * */
|
||||
/* Data used by the GL drivers */
|
||||
|
||||
@@ -3024,6 +3024,10 @@ SDL_VideoQuit(void)
|
||||
SDL_free(_this->displays);
|
||||
_this->displays = NULL;
|
||||
}
|
||||
if (_this->clipboard_text) {
|
||||
SDL_free(_this->clipboard_text);
|
||||
_this->clipboard_text = NULL;
|
||||
}
|
||||
_this->free(_this);
|
||||
_this = NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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_cocoaclipboard_h
|
||||
#define _SDL_cocoaclipboard_h
|
||||
|
||||
/* Forward declaration */
|
||||
struct SDL_VideoData;
|
||||
|
||||
extern int Cocoa_SetClipboardText(_THIS, const char *text);
|
||||
extern char *Cocoa_GetClipboardText(_THIS);
|
||||
extern SDL_bool Cocoa_HasClipboardText(_THIS);
|
||||
extern void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data);
|
||||
|
||||
#endif /* _SDL_cocoaclipboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
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_cocoavideo.h"
|
||||
#include "../../events/SDL_clipboardevents_c.h"
|
||||
|
||||
static NSString *
|
||||
GetTextFormat(_THIS)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
return NSStringPboardType;
|
||||
#else
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (data->osversion >= 0x1060) {
|
||||
return NSPasteboardTypeString;
|
||||
} else {
|
||||
return NSStringPboardType;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_SetClipboardText(_THIS, const char *text)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
|
||||
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
Cocoa_GetClipboardText(_THIS)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
NSString *available;
|
||||
char *text;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
|
||||
if ([available isEqualToString:format]) {
|
||||
NSString* string;
|
||||
const char *utf8;
|
||||
|
||||
string = [pasteboard stringForType:format];
|
||||
if (string == nil) {
|
||||
utf8 = "";
|
||||
} else {
|
||||
utf8 = [string UTF8String];
|
||||
}
|
||||
text = SDL_strdup(utf8);
|
||||
} else {
|
||||
text = SDL_strdup("");
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
Cocoa_HasClipboardText(_THIS)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
NSString *available;
|
||||
SDL_bool result;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
|
||||
if ([available isEqualToString:format]) {
|
||||
result = SDL_TRUE;
|
||||
} else {
|
||||
result = SDL_FALSE;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSInteger count;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
count = [pasteboard changeCount];
|
||||
if (count != data->clipboard_count) {
|
||||
if (data->clipboard_count) {
|
||||
SDL_SendClipboardUpdate();
|
||||
}
|
||||
data->clipboard_count = count;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "SDL_keysym.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#include "SDL_cocoaclipboard.h"
|
||||
#include "SDL_cocoaevents.h"
|
||||
#include "SDL_cocoakeyboard.h"
|
||||
#include "SDL_cocoamodes.h"
|
||||
@@ -59,6 +60,7 @@ typedef struct SDL_VideoData
|
||||
unsigned int modifierFlags;
|
||||
void *key_layout;
|
||||
SDLTranslatorResponder *fieldEdit;
|
||||
NSInteger clipboard_count;
|
||||
Uint32 screensaver_activity;
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
@@ -108,6 +108,10 @@ Cocoa_CreateDevice(int devindex)
|
||||
device->StopTextInput = Cocoa_StopTextInput;
|
||||
device->SetTextInputRect = Cocoa_SetTextInputRect;
|
||||
|
||||
device->SetClipboardText = Cocoa_SetClipboardText;
|
||||
device->GetClipboardText = Cocoa_GetClipboardText;
|
||||
device->HasClipboardText = Cocoa_HasClipboardText;
|
||||
|
||||
device->free = Cocoa_DeleteDevice;
|
||||
|
||||
return device;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
@@ -128,6 +128,9 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||
{
|
||||
/* We're going to get keyboard events, since we're key. */
|
||||
SDL_SetKeyboardFocus(_data->window);
|
||||
|
||||
/* Check to see if someone updated the clipboard */
|
||||
Cocoa_CheckClipboardUpdate(_data->videodata);
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey:(NSNotification *)aNotification
|
||||
|
||||
@@ -42,11 +42,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* store arguments */
|
||||
forward_argc = argc;
|
||||
forward_argv = (char **)malloc(argc * sizeof(char *));
|
||||
forward_argv = (char **)malloc((argc+1) * sizeof(char *));
|
||||
for (i=0; i<argc; i++) {
|
||||
forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
|
||||
strcpy(forward_argv[i], argv[i]);
|
||||
}
|
||||
forward_argv[i] = NULL;
|
||||
|
||||
/* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
|
||||
UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate");
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "SDL_uikitwindow.h"
|
||||
#include "jumphack.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
@@ -125,7 +127,11 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
UIKit_GL_DeleteContext(_this, view);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Make this window the current mouse focus for touch input */
|
||||
SDL_SetMouseFocus(window);
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_mouse_c.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
#if SDL_IPHONE_MULTIPLE_MICE
|
||||
@@ -38,7 +36,7 @@
|
||||
#else
|
||||
@interface SDL_uikitview : UIView {
|
||||
#endif
|
||||
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
|
||||
#endif
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
|
||||
#import "SDL_uikitview.h"
|
||||
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#if SDL_IPHONE_KEYBOARD
|
||||
#import "SDL_keyboard_c.h"
|
||||
#import "keyinfotable.h"
|
||||
#import "SDL_uikitappdelegate.h"
|
||||
#import "SDL_uikitwindow.h"
|
||||
@@ -33,7 +35,6 @@
|
||||
|
||||
- (void)dealloc {
|
||||
#if SDL_IPHONE_KEYBOARD
|
||||
SDL_DelKeyboard(0);
|
||||
[textField release];
|
||||
#endif
|
||||
[super dealloc];
|
||||
@@ -64,7 +65,7 @@
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
NSEnumerator *enumerator = [touches objectEnumerator];
|
||||
UITouch *touch =(UITouch*)[enumerator nextObject];
|
||||
UITouch *touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
/* associate touches with mice, so long as we have slots */
|
||||
@@ -101,12 +102,21 @@
|
||||
/* re-calibrate relative mouse motion */
|
||||
SDL_GetRelativeMouseState(i, NULL, NULL);
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
/* switch back to our old mouse */
|
||||
SDL_SelectMouse(oldMouse);
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#else
|
||||
if (touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
|
||||
|
||||
/* send mouse down event */
|
||||
SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -114,10 +124,10 @@
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
NSEnumerator *enumerator = [touches objectEnumerator];
|
||||
UITouch *touch=nil;
|
||||
UITouch *touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
while(touch = (UITouch *)[enumerator nextObject]) {
|
||||
while(touch) {
|
||||
/* search for the mouse slot associated with this touch */
|
||||
int i, found = NO;
|
||||
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
|
||||
@@ -131,6 +141,14 @@
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#else
|
||||
if (touch) {
|
||||
/* send mouse up */
|
||||
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -147,10 +165,10 @@
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
NSEnumerator *enumerator = [touches objectEnumerator];
|
||||
UITouch *touch=nil;
|
||||
UITouch *touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
while(touch = (UITouch *)[enumerator nextObject]) {
|
||||
while(touch) {
|
||||
/* try to find the mouse associated with this touch */
|
||||
int i, found = NO;
|
||||
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
|
||||
@@ -163,6 +181,16 @@
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#else
|
||||
if (touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -198,15 +226,6 @@
|
||||
keyboardVisible = NO;
|
||||
/* add the UITextField (hidden) to our view */
|
||||
[self addSubview: textField];
|
||||
|
||||
/* create our SDL_Keyboard */
|
||||
SDL_Keyboard keyboard;
|
||||
SDL_zero(keyboard);
|
||||
SDL_AddKeyboard(&keyboard, 0);
|
||||
SDLKey keymap[SDL_NUM_SCANCODES];
|
||||
SDL_GetDefaultKeymap(keymap);
|
||||
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
|
||||
|
||||
}
|
||||
|
||||
/* reveal onscreen virtual keyboard */
|
||||
@@ -226,8 +245,8 @@
|
||||
|
||||
if ([string length] == 0) {
|
||||
/* it wants to replace text with nothing, ie a delete */
|
||||
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE);
|
||||
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
|
||||
}
|
||||
else {
|
||||
/* go through all the characters in the string we've been sent
|
||||
@@ -253,14 +272,14 @@
|
||||
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift down */
|
||||
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
/* send a keydown and keyup even for the character */
|
||||
SDL_SendKeyboardKey( 0, SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey( 0, SDL_RELEASED, code);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift back up */
|
||||
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
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"
|
||||
#include "../../events/SDL_clipboardevents_c.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)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
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;
|
||||
}
|
||||
data->clipboard_count = GetClipboardSequenceNumber();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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: */
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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
|
||||
|
||||
/* 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 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -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);
|
||||
@@ -585,17 +588,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: */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -35,6 +35,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 +176,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;
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "ddraw.h"
|
||||
#endif
|
||||
|
||||
#include "SDL_win32clipboard.h"
|
||||
#include "SDL_win32events.h"
|
||||
#include "SDL_win32gamma.h"
|
||||
#include "SDL_win32keyboard.h"
|
||||
@@ -60,6 +61,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 */
|
||||
|
||||
@@ -74,6 +76,8 @@ typedef struct SDL_VideoData
|
||||
IDirectDraw *ddraw;
|
||||
#endif
|
||||
|
||||
DWORD clipboard_count;
|
||||
|
||||
const SDL_scancode *key_layout;
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
@@ -184,7 +184,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
HWND hwnd;
|
||||
HWND top;
|
||||
RECT rect;
|
||||
SDL_Rect bounds;
|
||||
DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
||||
@@ -202,11 +201,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
/* Figure out what the window area will be */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
top = HWND_TOPMOST;
|
||||
} else {
|
||||
top = HWND_NOTOPMOST;
|
||||
}
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = window->w;
|
||||
@@ -216,9 +210,17 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
h = (rect.bottom - rect.top);
|
||||
|
||||
WIN_GetDisplayBounds(_this, display, &bounds);
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
/* The bounds when this window is visible is the fullscreen mode */
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
||||
bounds.w = fullscreen_mode.w;
|
||||
bounds.h = fullscreen_mode.h;
|
||||
}
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
x = bounds.x + (bounds.w - window->w) / 2;
|
||||
x = bounds.x + (bounds.w - w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
if (bounds.x == 0) {
|
||||
x = CW_USEDEFAULT;
|
||||
@@ -230,7 +232,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
y = bounds.y + (bounds.h - window->h) / 2;
|
||||
y = bounds.y + (bounds.h - h) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
if (bounds.x == 0) {
|
||||
y = CW_USEDEFAULT;
|
||||
@@ -387,6 +389,7 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
HWND top;
|
||||
BOOL menu;
|
||||
int x, y;
|
||||
int w, h;
|
||||
|
||||
/* Figure out what the window area will be */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
@@ -405,17 +408,27 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
|
||||
#endif
|
||||
AdjustWindowRectEx(&rect, style, menu, 0);
|
||||
w = (rect.right - rect.left);
|
||||
h = (rect.bottom - rect.top);
|
||||
|
||||
WIN_GetDisplayBounds(_this, display, &bounds);
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
/* The bounds when this window is visible is the fullscreen mode */
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
||||
bounds.w = fullscreen_mode.w;
|
||||
bounds.h = fullscreen_mode.h;
|
||||
}
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
x = bounds.x + (bounds.w - window->w) / 2;
|
||||
x = bounds.x + (bounds.w - w) / 2;
|
||||
} else {
|
||||
x = bounds.x + window->x + rect.left;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
y = bounds.y + (bounds.h - window->h) / 2;
|
||||
y = bounds.y + (bounds.h - h) / 2;
|
||||
} else {
|
||||
y = bounds.y + window->y + rect.top;
|
||||
}
|
||||
@@ -620,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;
|
||||
}
|
||||
|
||||
@@ -639,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;
|
||||
}
|
||||
|
||||
@@ -659,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;
|
||||
@@ -669,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;
|
||||
|
||||
156
alienblaster/project/jni/sdl/src/video/x11/SDL_x11clipboard.c
Normal file
156
alienblaster/project/jni/sdl/src/video/x11/SDL_x11clipboard.c
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
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 <limits.h> /* For INT_MAX */
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_x11video.h"
|
||||
|
||||
|
||||
/* If you don't support UTF-8, you might use XA_STRING here */
|
||||
#if 1
|
||||
#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False)
|
||||
#else
|
||||
#define TEXT_FORMAT XA_STRING
|
||||
#endif
|
||||
|
||||
/* Get any application owned window handle for clipboard association */
|
||||
static Window
|
||||
GetWindow(_THIS)
|
||||
{
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Window *window;
|
||||
|
||||
display = _this->displays;
|
||||
if (display) {
|
||||
window = display->windows;
|
||||
if (window) {
|
||||
return ((SDL_WindowData *) window->driverdata)->xwindow;
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
int
|
||||
X11_SetClipboardText(_THIS, const char *text)
|
||||
{
|
||||
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
|
||||
Atom format;
|
||||
Window window;
|
||||
|
||||
/* Get the SDL window that will own the selection */
|
||||
window = GetWindow(_this);
|
||||
if (window == None) {
|
||||
SDL_SetError("Couldn't find a window to own the selection");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save the selection on the root window */
|
||||
format = TEXT_FORMAT;
|
||||
XChangeProperty(display, DefaultRootWindow(display),
|
||||
XA_CUT_BUFFER0, format, 8, PropModeReplace,
|
||||
(const unsigned char *)text, SDL_strlen(text));
|
||||
|
||||
if (XGetSelectionOwner(display, XA_PRIMARY) != window) {
|
||||
XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
X11_GetClipboardText(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
Display *display = videodata->display;
|
||||
Atom format;
|
||||
Window window;
|
||||
Window owner;
|
||||
Atom selection;
|
||||
Atom seln_type;
|
||||
int seln_format;
|
||||
unsigned long nbytes;
|
||||
unsigned long overflow;
|
||||
unsigned char *src;
|
||||
char *text;
|
||||
|
||||
text = NULL;
|
||||
|
||||
/* Get the window that holds the selection */
|
||||
window = GetWindow(_this);
|
||||
format = TEXT_FORMAT;
|
||||
owner = XGetSelectionOwner(display, XA_PRIMARY);
|
||||
if ((owner == None) || (owner == window)) {
|
||||
owner = DefaultRootWindow(display);
|
||||
selection = XA_CUT_BUFFER0;
|
||||
} else {
|
||||
/* Request that the selection owner copy the data to our window */
|
||||
owner = window;
|
||||
selection = XInternAtom(display, "SDL_SELECTION", False);
|
||||
XConvertSelection(display, XA_PRIMARY, format, selection, owner,
|
||||
CurrentTime);
|
||||
|
||||
/* FIXME: Should we have a timeout here? */
|
||||
videodata->selection_waiting = SDL_TRUE;
|
||||
while (videodata->selection_waiting) {
|
||||
SDL_PumpEvents();
|
||||
}
|
||||
}
|
||||
|
||||
if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False,
|
||||
format, &seln_type, &seln_format, &nbytes, &overflow, &src)
|
||||
== Success) {
|
||||
if (seln_type == format) {
|
||||
text = (char *)SDL_malloc(nbytes+1);
|
||||
if (text) {
|
||||
SDL_memcpy(text, src, nbytes);
|
||||
text[nbytes] = '\0';
|
||||
}
|
||||
}
|
||||
XFree(src);
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
text = SDL_strdup("");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
X11_HasClipboardText(_THIS)
|
||||
{
|
||||
/* Not an easy way to tell with X11, as far as I know... */
|
||||
char *text;
|
||||
SDL_bool retval;
|
||||
|
||||
text = X11_GetClipboardText(_this);
|
||||
if (*text) {
|
||||
retval = SDL_TRUE;
|
||||
} else {
|
||||
retval = SDL_FALSE;
|
||||
}
|
||||
SDL_free(text);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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_x11clipboard_h
|
||||
#define _SDL_x11clipboard_h
|
||||
|
||||
extern int X11_SetClipboardText(_THIS, const char *text);
|
||||
extern char *X11_GetClipboardText(_THIS);
|
||||
extern SDL_bool X11_HasClipboardText(_THIS);
|
||||
|
||||
#endif /* _SDL_x11clipboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h> /* For INT_MAX */
|
||||
|
||||
#include "SDL_x11video.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
@@ -33,6 +34,8 @@
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
/*#define DEBUG_XEVENTS*/
|
||||
|
||||
static void
|
||||
X11_DispatchEvent(_THIS)
|
||||
{
|
||||
@@ -286,6 +289,55 @@ X11_DispatchEvent(_THIS)
|
||||
}
|
||||
break;
|
||||
|
||||
/* Copy the selection from XA_CUT_BUFFER0 to the requested property */
|
||||
case SelectionRequest: {
|
||||
Display *display = videodata->display;
|
||||
XSelectionRequestEvent *req;
|
||||
XEvent sevent;
|
||||
int seln_format;
|
||||
unsigned long nbytes;
|
||||
unsigned long overflow;
|
||||
unsigned char *seln_data;
|
||||
|
||||
req = &xevent.xselectionrequest;
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("SelectionRequest (requestor = %ld, target = %ld)\n",
|
||||
req->requestor, req->target);
|
||||
#endif
|
||||
|
||||
sevent.xselection.type = SelectionNotify;
|
||||
sevent.xselection.display = req->display;
|
||||
sevent.xselection.selection = req->selection;
|
||||
sevent.xselection.target = None;
|
||||
sevent.xselection.property = None;
|
||||
sevent.xselection.requestor = req->requestor;
|
||||
sevent.xselection.time = req->time;
|
||||
if (XGetWindowProperty(display, DefaultRootWindow(display),
|
||||
XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
|
||||
&sevent.xselection.target, &seln_format, &nbytes,
|
||||
&overflow, &seln_data) == Success) {
|
||||
if (sevent.xselection.target == req->target) {
|
||||
XChangeProperty(display, req->requestor, req->property,
|
||||
sevent.xselection.target, seln_format, PropModeReplace,
|
||||
seln_data, nbytes);
|
||||
sevent.xselection.property = req->property;
|
||||
}
|
||||
XFree(seln_data);
|
||||
}
|
||||
XSendEvent(display, req->requestor, False, 0, &sevent);
|
||||
XSync(display, False);
|
||||
}
|
||||
break;
|
||||
|
||||
case SelectionNotify: {
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("SelectionNotify (requestor = %ld, target = %ld)\n",
|
||||
xevent.xselection.requestor, xevent.xselection.target);
|
||||
#endif
|
||||
videodata->selection_waiting = SDL_FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:{
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("Unhandled event %d\n", xevent.type);
|
||||
|
||||
@@ -37,6 +37,7 @@ SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSe
|
||||
SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XCopyArea,(Display* a,Drawable b,Drawable c,GC d,int e,int f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
|
||||
@@ -71,10 +72,11 @@ SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e,
|
||||
SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return)
|
||||
SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
|
||||
SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return)
|
||||
SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return)
|
||||
@@ -114,14 +116,15 @@ SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return)
|
||||
SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
|
||||
SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
|
||||
SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
|
||||
SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
|
||||
SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
|
||||
SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include <unistd.h> /* For getpid() and readlink() */
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
@@ -225,6 +227,10 @@ X11_CreateDevice(int devindex)
|
||||
device->GL_DeleteContext = X11_GLES_DeleteContext;
|
||||
#endif
|
||||
|
||||
device->SetClipboardText = X11_SetClipboardText;
|
||||
device->GetClipboardText = X11_GetClipboardText;
|
||||
device->HasClipboardText = X11_HasClipboardText;
|
||||
|
||||
device->free = X11_DeleteDevice;
|
||||
|
||||
return device;
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "SDL_x11dyn.h"
|
||||
|
||||
#include "SDL_x11clipboard.h"
|
||||
#include "SDL_x11events.h"
|
||||
#include "SDL_x11gamma.h"
|
||||
#include "SDL_x11keyboard.h"
|
||||
@@ -69,6 +70,7 @@ typedef struct SDL_VideoData
|
||||
int windowlistlength;
|
||||
Atom WM_DELETE_WINDOW;
|
||||
SDL_scancode key_layout[256];
|
||||
SDL_bool selection_waiting;
|
||||
} SDL_VideoData;
|
||||
|
||||
extern SDL_bool X11_UseDirectColorVisuals(void);
|
||||
|
||||
@@ -289,9 +289,9 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
Sint32 r, g, b;
|
||||
|
||||
/* Is the colormap we need already registered in SDL? */
|
||||
if (colormap =
|
||||
if ((colormap =
|
||||
X11_LookupColormap(data->display,
|
||||
displaydata->screen, visual->visualid)) {
|
||||
displaydata->screen, visual->visualid))) {
|
||||
xattr.colormap = colormap;
|
||||
/* printf("found existing colormap\n"); */
|
||||
} else {
|
||||
@@ -1014,8 +1014,14 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
|
||||
SDL_bool
|
||||
X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
/* FIXME! */
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_X11;
|
||||
info->info.x11.display = display;
|
||||
info->info.x11.window = data->xwindow;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
|
||||
Reference in New Issue
Block a user