LIBS: updated sdl2
parent
9a659426d7
commit
3f36288fd5
|
@ -48,6 +48,7 @@ macro(CheckDLOPEN)
|
|||
int main(int argc, char **argv) {
|
||||
void *handle = dlopen(\"\", RTLD_NOW);
|
||||
const char *loaderror = (char *) dlerror();
|
||||
return 0;
|
||||
}" HAVE_DLOPEN)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
endif()
|
||||
|
@ -57,8 +58,7 @@ macro(CheckO_CLOEXEC)
|
|||
check_c_source_compiles("
|
||||
#include <fcntl.h>
|
||||
int flag = O_CLOEXEC;
|
||||
int main(void) {
|
||||
}" HAVE_O_CLOEXEC)
|
||||
int main(int argc, char **argv) { return 0; }" HAVE_O_CLOEXEC)
|
||||
endmacro()
|
||||
|
||||
# Requires:
|
||||
|
@ -68,12 +68,12 @@ macro(CheckOSS)
|
|||
set(OSS_HEADER_FILE "sys/soundcard.h")
|
||||
check_c_source_compiles("
|
||||
#include <sys/soundcard.h>
|
||||
int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
|
||||
int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" OSS_FOUND)
|
||||
if(NOT OSS_FOUND)
|
||||
set(OSS_HEADER_FILE "soundcard.h")
|
||||
check_c_source_compiles("
|
||||
#include <soundcard.h>
|
||||
int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
|
||||
int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" OSS_FOUND)
|
||||
endif()
|
||||
|
||||
if(OSS_FOUND)
|
||||
|
@ -481,7 +481,8 @@ macro(CheckX11)
|
|||
XGenericEventCookie *cookie = &event.xcookie;
|
||||
XNextEvent(display, &event);
|
||||
XGetEventData(display, cookie);
|
||||
XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
|
||||
XFreeEventData(display, cookie);
|
||||
return 0; }" HAVE_XGENERICEVENT)
|
||||
if(HAVE_XGENERICEVENT)
|
||||
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
|
||||
endif()
|
||||
|
@ -533,7 +534,7 @@ macro(CheckX11)
|
|||
{
|
||||
return (Status)0;
|
||||
}
|
||||
int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
|
||||
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT2_MULTITOUCH)
|
||||
if(HAVE_XINPUT2_MULTITOUCH)
|
||||
set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
|
||||
endif()
|
||||
|
@ -547,7 +548,7 @@ macro(CheckX11)
|
|||
#include <X11/extensions/XInput2.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
BarrierEventID b;
|
||||
int main(void) { }" HAVE_XFIXES_H)
|
||||
int main(int argc, char **argv) { return 0; }" HAVE_XFIXES_H)
|
||||
endif()
|
||||
if(SDL_X11_XFIXES AND HAVE_XFIXES_H AND HAVE_XINPUT2_H)
|
||||
if(HAVE_X11_SHARED AND XFIXES_LIB)
|
||||
|
@ -777,12 +778,12 @@ macro(CheckVivante)
|
|||
if(SDL_VIVANTE)
|
||||
check_c_source_compiles("
|
||||
#include <gc_vdk.h>
|
||||
int main(int argc, char** argv) {}" HAVE_VIVANTE_VDK)
|
||||
int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_VDK)
|
||||
check_c_source_compiles("
|
||||
#define LINUX
|
||||
#define EGL_API_FB
|
||||
#include <EGL/eglvivante.h>
|
||||
int main(int argc, char** argv) {}" HAVE_VIVANTE_EGL_FB)
|
||||
int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_EGL_FB)
|
||||
if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB)
|
||||
set(HAVE_VIVANTE TRUE)
|
||||
set(HAVE_SDL_VIDEO TRUE)
|
||||
|
@ -807,7 +808,7 @@ macro(CheckGLX)
|
|||
if(SDL_OPENGL)
|
||||
check_c_source_compiles("
|
||||
#include <GL/glx.h>
|
||||
int main(int argc, char** argv) {}" HAVE_OPENGL_GLX)
|
||||
int main(int argc, char** argv) { return 0; }" HAVE_OPENGL_GLX)
|
||||
if(HAVE_OPENGL_GLX)
|
||||
set(SDL_VIDEO_OPENGL_GLX 1)
|
||||
endif()
|
||||
|
@ -826,7 +827,7 @@ macro(CheckEGL)
|
|||
#define EGL_NO_X11
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
int main (int argc, char** argv) {}" HAVE_OPENGL_EGL)
|
||||
int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL)
|
||||
if(HAVE_OPENGL_EGL)
|
||||
set(SDL_VIDEO_OPENGL_EGL 1)
|
||||
endif()
|
||||
|
@ -840,7 +841,7 @@ macro(CheckOpenGL)
|
|||
check_c_source_compiles("
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
int main(int argc, char** argv) {}" HAVE_OPENGL)
|
||||
int main(int argc, char** argv) { return 0; }" HAVE_OPENGL)
|
||||
if(HAVE_OPENGL)
|
||||
set(SDL_VIDEO_OPENGL 1)
|
||||
set(SDL_VIDEO_RENDER_OGL 1)
|
||||
|
@ -855,7 +856,7 @@ macro(CheckOpenGLES)
|
|||
check_c_source_compiles("
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
int main (int argc, char** argv) {}" HAVE_OPENGLES_V1)
|
||||
int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V1)
|
||||
if(HAVE_OPENGLES_V1)
|
||||
set(HAVE_OPENGLES TRUE)
|
||||
set(SDL_VIDEO_OPENGL_ES 1)
|
||||
|
@ -864,7 +865,7 @@ macro(CheckOpenGLES)
|
|||
check_c_source_compiles("
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
int main (int argc, char** argv) {}" HAVE_OPENGLES_V2)
|
||||
int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V2)
|
||||
if(HAVE_OPENGLES_V2)
|
||||
set(HAVE_OPENGLES TRUE)
|
||||
set(SDL_VIDEO_OPENGL_ES2 1)
|
||||
|
|
|
@ -102,6 +102,7 @@ typedef enum
|
|||
SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
|
||||
input language or keyboard layout change.
|
||||
*/
|
||||
SDL_TEXTEDITING_EXT, /**< Extended keyboard text editing (composition) */
|
||||
|
||||
/* Mouse events */
|
||||
SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
|
||||
|
@ -243,6 +244,19 @@ typedef struct SDL_TextEditingEvent
|
|||
Sint32 length; /**< The length of selected editing text */
|
||||
} SDL_TextEditingEvent;
|
||||
|
||||
/**
|
||||
* \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
|
||||
* truncated if stored in the text buffer SDL_TextEditingEvent
|
||||
*/
|
||||
typedef struct SDL_TextEditingExtEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
|
||||
Sint32 start; /**< The start cursor of selected editing text */
|
||||
Sint32 length; /**< The length of selected editing text */
|
||||
} SDL_TextEditingExtEvent;
|
||||
|
||||
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
|
||||
/**
|
||||
|
@ -601,6 +615,7 @@ typedef union SDL_Event
|
|||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||
SDL_TextEditingExtEvent editExt; /**< Extended text editing event data */
|
||||
SDL_TextInputEvent text; /**< Text input event data */
|
||||
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
|
||||
SDL_MouseButtonEvent button; /**< Mouse button event data */
|
||||
|
|
|
@ -579,6 +579,17 @@ extern "C" {
|
|||
*/
|
||||
#define SDL_HINT_IME_SHOW_UI "SDL_IME_SHOW_UI"
|
||||
|
||||
/**
|
||||
* \brief A variable to control if extended IME text support is enabled.
|
||||
* If enabled then SDL_TextEditingExtEvent will be issued if the text would be truncated otherwise.
|
||||
* Additionally SDL_TextInputEvent will be dispatched multiple times so that it is not truncated.
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - Legacy behavior. Text can be truncated, no heap allocations. (default)
|
||||
* "1" - Modern behavior.
|
||||
*/
|
||||
#define SDL_HINT_IME_SUPPORT_EXTENDED_TEXT "SDL_IME_SUPPORT_EXTENDED_TEXT"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the home indicator bar on iPhone X
|
||||
* should be hidden.
|
||||
|
|
|
@ -268,6 +268,23 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
|
|||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
|
||||
|
||||
/**
|
||||
* Dismiss the composition window/IME without disabling the subsystem.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.22.
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
* \sa SDL_StopTextInput
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ClearComposition(void);
|
||||
|
||||
/**
|
||||
* Returns if an IME Composite or Candidate window is currently shown.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.22.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
|
||||
|
||||
/**
|
||||
* Set the rectangle used to type Unicode text inputs.
|
||||
*
|
||||
|
|
|
@ -857,3 +857,5 @@
|
|||
#define SDL_PremultiplyAlpha SDL_PremultiplyAlpha_REAL
|
||||
#define SDL_AndroidSendMessage SDL_AndroidSendMessage_REAL
|
||||
#define SDL_GetTouchName SDL_GetTouchName_REAL
|
||||
#define SDL_ClearComposition SDL_ClearComposition_REAL
|
||||
#define SDL_IsTextInputShown SDL_IsTextInputShown_REAL
|
||||
|
|
|
@ -928,3 +928,5 @@ SDL_DYNAPI_PROC(int,SDL_PremultiplyAlpha,(int a, int b, Uint32 c, const void *d,
|
|||
SDL_DYNAPI_PROC(int,SDL_AndroidSendMessage,(Uint32 a, int b),(a,b),return)
|
||||
#endif
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetTouchName,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_ClearComposition,(void),(),)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_IsTextInputShown,(void),(),return)
|
||||
|
|
|
@ -894,6 +894,22 @@ SDL_SendEditingText(const char *text, int start, int length)
|
|||
event.edit.start = start;
|
||||
event.edit.length = length;
|
||||
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE) &&
|
||||
SDL_strlen(text) > SDL_arraysize(event.text.text)) {
|
||||
event.editExt.type = SDL_TEXTEDITING_EXT;
|
||||
event.editExt.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.editExt.text = text ? SDL_strdup(text) : NULL;
|
||||
event.editExt.start = start;
|
||||
event.editExt.length = length;
|
||||
} else {
|
||||
event.edit.type = SDL_TEXTEDITING;
|
||||
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.edit.start = start;
|
||||
event.edit.length = length;
|
||||
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
|
||||
}
|
||||
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return (posted);
|
||||
|
|
|
@ -128,7 +128,7 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt)
|
|||
* leave alpha with a zero mask, but we should still swizzle the bits.
|
||||
*/
|
||||
/* ARGB */
|
||||
const static const struct SDL_PixelFormat default_pixel_format = {
|
||||
static const struct SDL_PixelFormat default_pixel_format = {
|
||||
0, NULL, 0, 0,
|
||||
{0, 0},
|
||||
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
|
||||
|
|
|
@ -307,6 +307,8 @@ struct SDL_VideoDevice
|
|||
void (*StartTextInput) (_THIS);
|
||||
void (*StopTextInput) (_THIS);
|
||||
void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
|
||||
void (*ClearComposition) (_THIS);
|
||||
SDL_bool (*IsTextInputShown) (_THIS);
|
||||
|
||||
/* Screen keyboard */
|
||||
SDL_bool (*HasScreenKeyboardSupport) (_THIS);
|
||||
|
|
|
@ -4135,6 +4135,24 @@ SDL_StartTextInput(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ClearComposition(void)
|
||||
{
|
||||
if (_this && _this->ClearComposition) {
|
||||
_this->ClearComposition(_this);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IsTextInputShown(void)
|
||||
{
|
||||
if (_this && _this->IsTextInputShown) {
|
||||
return _this->IsTextInputShown(_this);
|
||||
}
|
||||
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IsTextInputActive(void)
|
||||
{
|
||||
|
|
|
@ -493,7 +493,7 @@ static EM_BOOL
|
|||
Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
|
||||
{
|
||||
Uint32 scancode;
|
||||
SDL_bool prevent_default;
|
||||
SDL_bool prevent_default = SDL_FALSE;
|
||||
SDL_bool is_nav_key;
|
||||
|
||||
/* .keyCode is deprecated, but still the most reliable way to get keys */
|
||||
|
@ -577,12 +577,10 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi
|
|||
break;
|
||||
}
|
||||
}
|
||||
SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
|
||||
prevent_default = SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
|
||||
prevent_default = SDL_GetEventState(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_KEYDOWN : SDL_KEYUP) == SDL_ENABLE;
|
||||
|
||||
/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
|
||||
* we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
|
||||
*/
|
||||
|
|
|
@ -67,10 +67,12 @@ OS2VIDEOOUTPUT voDive = {
|
|||
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo)
|
||||
{
|
||||
DIVE_CAPS sDiveCaps = { 0 };
|
||||
FOURCC fccFormats[100] = { 0 };
|
||||
DIVE_CAPS sDiveCaps;
|
||||
FOURCC fccFormats[100];
|
||||
|
||||
/* Query information about display hardware from DIVE. */
|
||||
SDL_zeroa(fccFormats);
|
||||
SDL_zero(sDiveCaps);
|
||||
sDiveCaps.pFormatData = fccFormats;
|
||||
sDiveCaps.ulFormatLength = 100;
|
||||
sDiveCaps.ulStructLen = sizeof(DIVE_CAPS);
|
||||
|
@ -172,7 +174,7 @@ static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
|||
/* Setup DIVE blitter. */
|
||||
SETUP_BLITTER sSetupBlitter;
|
||||
SWP swp;
|
||||
POINTL pointl = { 0 };
|
||||
POINTL pointl = { 0,0 };
|
||||
|
||||
WinQueryWindowPos(hwnd, &swp);
|
||||
WinMapWindowPoints(hwnd, HWND_DESKTOP, &pointl, 1);
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
||||
{
|
||||
HBITMAP hbm;
|
||||
BITMAPINFOHEADER2 bmih = { 0 };
|
||||
BITMAPINFO bmi = { 0 };
|
||||
BITMAPINFOHEADER2 bmih;
|
||||
BITMAPINFO bmi;
|
||||
HPS hps;
|
||||
PULONG pulBitmap;
|
||||
PULONG pulDst, pulSrc, pulDstMask;
|
||||
|
@ -40,7 +40,7 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
|||
return NULLHANDLE;
|
||||
}
|
||||
|
||||
pulBitmap = SDL_malloc(surface->h * surface->w * 4 * 2);
|
||||
pulBitmap = (PULONG) SDL_malloc(surface->h * surface->w * 2 * sizeof(ULONG));
|
||||
if (pulBitmap == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULLHANDLE;
|
||||
|
@ -72,6 +72,9 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
|||
}
|
||||
|
||||
/* Create system bitmap object. */
|
||||
SDL_zero(bmih);
|
||||
SDL_zero(bmi);
|
||||
|
||||
bmih.cbFix = sizeof(BITMAPINFOHEADER2);
|
||||
bmih.cx = surface->w;
|
||||
bmih.cy = 2 * surface->h;
|
||||
|
|
|
@ -335,7 +335,7 @@ static VOID _wmChar(WINDATA *pWinData, MPARAM mp1, MPARAM mp2)
|
|||
static VOID _wmMove(WINDATA *pWinData)
|
||||
{
|
||||
SDL_DisplayMode *pSDLDisplayMode = _getDisplayModeForSDLWindow(pWinData->window);
|
||||
POINTL pointl = { 0 };
|
||||
POINTL pointl = { 0,0 };
|
||||
RECTL rectl;
|
||||
|
||||
WinQueryWindowRect(pWinData->hwnd, &rectl);
|
||||
|
@ -1219,7 +1219,7 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape,
|
|||
{
|
||||
SDL_ShapeTree *pShapeTree;
|
||||
WINDATA *pWinData;
|
||||
SHAPERECTS stShapeRects = { 0 };
|
||||
SHAPERECTS stShapeRects;
|
||||
HPS hps;
|
||||
|
||||
debug_os2("Enter");
|
||||
|
@ -1235,6 +1235,7 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape,
|
|||
pShapeTree = SDL_CalculateShapeTree(*shape_mode, shape);
|
||||
shaper->driverdata = pShapeTree;
|
||||
|
||||
SDL_zero(stShapeRects);
|
||||
stShapeRects.ulWinHeight = shaper->window->h;
|
||||
SDL_TraverseShapeTree(pShapeTree, &_combineRectRegions, &stShapeRects);
|
||||
|
||||
|
|
|
@ -91,10 +91,10 @@ static VOID APIENTRY ExitVMan(VOID)
|
|||
static BOOL _vmanInit(void)
|
||||
{
|
||||
ULONG ulRC;
|
||||
CHAR acBuf[255];
|
||||
CHAR acBuf[256];
|
||||
INITPROCOUT stInitProcOut;
|
||||
|
||||
if (hmodVMan != NULLHANDLE) /* Already was initialized */
|
||||
if (hmodVMan != NULLHANDLE) /* already initialized */
|
||||
return TRUE;
|
||||
|
||||
/* Load vman.dll */
|
||||
|
@ -108,8 +108,7 @@ static BOOL _vmanInit(void)
|
|||
/* Get VMIEntry */
|
||||
ulRC = DosQueryProcAddr(hmodVMan, 0L, "VMIEntry", (PFN *)&pfnVMIEntry);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("Could not query address of pfnVMIEntry func. of VMAN.DLL, "
|
||||
"rc = %u", ulRC);
|
||||
debug_os2("Could not query address of VMIEntry from VMAN.DLL (Err: %lu)", ulRC);
|
||||
DosFreeModule(hmodVMan);
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
|
@ -327,9 +326,8 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
|||
PPOINTL pptlSrcOrg;
|
||||
PBLTRECT pbrDst;
|
||||
HWREQIN sHWReqIn;
|
||||
BITBLTINFO sBitbltInfo = { 0 };
|
||||
BITBLTINFO sBitbltInfo;
|
||||
ULONG ulIdx;
|
||||
/* RECTL rectlScreenUpdate;*/
|
||||
|
||||
if (pVOData->pBuffer == NULL)
|
||||
return FALSE;
|
||||
|
@ -454,6 +452,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
|||
rclSrcBounds.xRight = bmiSrc.ulWidth;
|
||||
rclSrcBounds.yTop = bmiSrc.ulHeight;
|
||||
|
||||
SDL_zero(sBitbltInfo);
|
||||
sBitbltInfo.ulLength = sizeof(BITBLTINFO);
|
||||
sBitbltInfo.ulBltFlags = BF_DEFAULT_STATE | BF_ROP_INCL_SRC | BF_PAT_HOLLOW;
|
||||
sBitbltInfo.cBlits = cSDLRects;
|
||||
|
|
|
@ -36,6 +36,8 @@ static void IME_Init(SDL_VideoData *videodata, HWND hwnd);
|
|||
static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Quit(SDL_VideoData *videodata);
|
||||
static void IME_ClearComposition(SDL_VideoData *videodata);
|
||||
static SDL_bool IME_IsTextInputShown(SDL_VideoData* videodata);
|
||||
#endif /* !SDL_DISABLE_WINDOWS_IME */
|
||||
|
||||
#ifndef MAPVK_VK_TO_VSC
|
||||
|
@ -62,6 +64,8 @@ WIN_InitKeyboard(_THIS)
|
|||
data->ime_hwnd_main = 0;
|
||||
data->ime_hwnd_current = 0;
|
||||
data->ime_himc = 0;
|
||||
data->ime_composition_length = 32 * sizeof(WCHAR);
|
||||
data->ime_composition = (WCHAR*)SDL_malloc(data->ime_composition_length);
|
||||
data->ime_composition[0] = 0;
|
||||
data->ime_readingstring[0] = 0;
|
||||
data->ime_cursor = 0;
|
||||
|
@ -272,6 +276,18 @@ WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
|
|||
}
|
||||
}
|
||||
|
||||
void WIN_ClearComposition(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
IME_ClearComposition(videodata);
|
||||
}
|
||||
|
||||
SDL_bool WIN_IsTextInputShown(_THIS)
|
||||
{
|
||||
SDL_VideoData* videodata = (SDL_VideoData*)_this->driverdata;
|
||||
return IME_IsTextInputShown(videodata);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WIN_ShouldShowNativeUI()
|
||||
{
|
||||
|
@ -742,18 +758,48 @@ IME_ClearComposition(SDL_VideoData *videodata)
|
|||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
IME_IsTextInputShown(SDL_VideoData* videodata)
|
||||
{
|
||||
if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
|
||||
return SDL_FALSE;
|
||||
|
||||
return videodata->ime_uicontext != 0 ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
|
||||
{
|
||||
LONG length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, sizeof(videodata->ime_composition) - sizeof(videodata->ime_composition[0]));
|
||||
LONG length;
|
||||
DWORD dwLang = ((DWORD_PTR)videodata->ime_hkl & 0xffff);
|
||||
|
||||
length = ImmGetCompositionStringW(himc, string, NULL, 0);
|
||||
if (length > 0 && videodata->ime_composition_length < length) {
|
||||
if (videodata->ime_composition != NULL)
|
||||
SDL_free(videodata->ime_composition);
|
||||
|
||||
videodata->ime_composition = (WCHAR*)SDL_malloc(length + sizeof(WCHAR));
|
||||
videodata->ime_composition_length = length;
|
||||
}
|
||||
|
||||
length = ImmGetCompositionStringW(
|
||||
himc,
|
||||
string,
|
||||
videodata->ime_composition,
|
||||
videodata->ime_composition_length
|
||||
);
|
||||
|
||||
if (length < 0)
|
||||
length = 0;
|
||||
|
||||
length /= sizeof(videodata->ime_composition[0]);
|
||||
length /= sizeof(WCHAR);
|
||||
videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0));
|
||||
if (videodata->ime_cursor > 0 &&
|
||||
videodata->ime_cursor < SDL_arraysize(videodata->ime_composition) &&
|
||||
videodata->ime_composition[videodata->ime_cursor] == 0x3000) {
|
||||
if ((dwLang == LANG_CHT || dwLang == LANG_CHS) &&
|
||||
videodata->ime_cursor > 0 &&
|
||||
videodata->ime_cursor < videodata->ime_composition_length / sizeof(WCHAR) &&
|
||||
(videodata->ime_composition[0] == 0x3000 || videodata->ime_composition[0] == 0x0020)) {
|
||||
// Traditional Chinese IMEs add a placeholder U+3000
|
||||
// Simplified Chinese IMEs seem to add a placholder U+0020 sometimes
|
||||
int i;
|
||||
for (i = videodata->ime_cursor + 1; i < length; ++i)
|
||||
videodata->ime_composition[i - 1] = videodata->ime_composition[i];
|
||||
|
@ -762,6 +808,39 @@ IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
|
|||
}
|
||||
|
||||
videodata->ime_composition[length] = 0;
|
||||
|
||||
// Get the correct caret position if we've selected a candidate from the candidate window
|
||||
if (videodata->ime_cursor == 0 && length > 0) {
|
||||
Sint32 start = 0;
|
||||
Sint32 end = 0;
|
||||
|
||||
length = ImmGetCompositionStringW(himc, GCS_COMPATTR, NULL, 0);
|
||||
if (length > 0) {
|
||||
Uint8* attributes = (Uint8*)SDL_malloc(length);
|
||||
ImmGetCompositionString(himc, GCS_COMPATTR, attributes, length);
|
||||
|
||||
for (start = 0; start < length; ++start) {
|
||||
if (attributes[start] == ATTR_TARGET_CONVERTED ||
|
||||
attributes[start] == ATTR_TARGET_NOTCONVERTED)
|
||||
break;
|
||||
}
|
||||
|
||||
for (end = start; end < length; ++end) {
|
||||
if (attributes[end] != ATTR_TARGET_CONVERTED &&
|
||||
attributes[end] != ATTR_TARGET_NOTCONVERTED)
|
||||
break;
|
||||
}
|
||||
|
||||
if (start == length) {
|
||||
start = 0;
|
||||
end = length;
|
||||
}
|
||||
|
||||
SDL_free(attributes);
|
||||
}
|
||||
|
||||
videodata->ime_cursor = end;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -780,22 +859,30 @@ IME_SendInputEvent(SDL_VideoData *videodata)
|
|||
static void
|
||||
IME_SendEditingEvent(SDL_VideoData *videodata)
|
||||
{
|
||||
char *s = 0;
|
||||
WCHAR buffer[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
const size_t size = SDL_arraysize(buffer);
|
||||
buffer[0] = 0;
|
||||
char *s = NULL;
|
||||
WCHAR *buffer = NULL;
|
||||
size_t size = videodata->ime_composition_length;
|
||||
if (videodata->ime_readingstring[0]) {
|
||||
size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor);
|
||||
|
||||
size += sizeof(videodata->ime_readingstring);
|
||||
buffer = (WCHAR*)SDL_malloc(size);
|
||||
buffer[0] = 0;
|
||||
|
||||
SDL_wcslcpy(buffer, videodata->ime_composition, len + 1);
|
||||
SDL_wcslcat(buffer, videodata->ime_readingstring, size);
|
||||
SDL_wcslcat(buffer, &videodata->ime_composition[len], size);
|
||||
}
|
||||
else {
|
||||
buffer = (WCHAR*)SDL_malloc(size);
|
||||
buffer[0] = 0;
|
||||
SDL_wcslcpy(buffer, videodata->ime_composition, size);
|
||||
}
|
||||
|
||||
s = WIN_StringToUTF8W(buffer);
|
||||
SDL_SendEditingText(s, videodata->ime_cursor + (int)SDL_wcslen(videodata->ime_readingstring), 0);
|
||||
SDL_free(s);
|
||||
SDL_free(buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -914,6 +1001,15 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
|||
return SDL_FALSE;
|
||||
|
||||
switch (msg) {
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_PROCESSKEY)
|
||||
{
|
||||
videodata->ime_uicontext = 1;
|
||||
trap = SDL_TRUE;
|
||||
}
|
||||
else
|
||||
videodata->ime_uicontext = 0;
|
||||
break;
|
||||
case WM_INPUTLANGCHANGE:
|
||||
IME_InputLangChanged(videodata);
|
||||
break;
|
||||
|
@ -922,14 +1018,17 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
|||
*lParam = 0;
|
||||
}
|
||||
break;
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
videodata->ime_suppress_endcomposition_event = SDL_FALSE;
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
case WM_IME_COMPOSITION:
|
||||
trap = SDL_TRUE;
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (*lParam & GCS_RESULTSTR) {
|
||||
videodata->ime_suppress_endcomposition_event = SDL_TRUE;
|
||||
IME_GetCompositionString(videodata, himc, GCS_RESULTSTR);
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
IME_SendInputEvent(videodata);
|
||||
}
|
||||
if (*lParam & GCS_COMPSTR) {
|
||||
|
@ -942,10 +1041,13 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
|||
ImmReleaseContext(hwnd, himc);
|
||||
break;
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
videodata->ime_uicontext = 0;
|
||||
videodata->ime_composition[0] = 0;
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
videodata->ime_cursor = 0;
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
if (videodata->ime_suppress_endcomposition_event == SDL_FALSE)
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
videodata->ime_suppress_endcomposition_event = SDL_FALSE;
|
||||
break;
|
||||
case WM_IME_NOTIFY:
|
||||
switch (wParam) {
|
||||
|
@ -959,10 +1061,12 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
|||
break;
|
||||
|
||||
trap = SDL_TRUE;
|
||||
videodata->ime_uicontext = 1;
|
||||
IME_GetCandidateList(hwnd, videodata);
|
||||
break;
|
||||
case IMN_CLOSECANDIDATE:
|
||||
trap = SDL_TRUE;
|
||||
videodata->ime_uicontext = 0;
|
||||
IME_HideCandidateList(videodata);
|
||||
break;
|
||||
case IMN_PRIVATE:
|
||||
|
@ -1023,6 +1127,7 @@ UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pca
|
|||
DWORD pgstart = 0;
|
||||
DWORD pgsize = 0;
|
||||
UINT i, j;
|
||||
|
||||
if (IME_ShowCandidateList(videodata) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ extern void WIN_ResetDeadKeys(void);
|
|||
extern void WIN_StartTextInput(_THIS);
|
||||
extern void WIN_StopTextInput(_THIS);
|
||||
extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect);
|
||||
extern void WIN_ClearComposition(_THIS);
|
||||
extern SDL_bool WIN_IsTextInputShown(_THIS);
|
||||
|
||||
extern SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata);
|
||||
|
||||
|
|
|
@ -216,6 +216,8 @@ WIN_CreateDevice(int devindex)
|
|||
device->StartTextInput = WIN_StartTextInput;
|
||||
device->StopTextInput = WIN_StopTextInput;
|
||||
device->SetTextInputRect = WIN_SetTextInputRect;
|
||||
device->ClearComposition = WIN_ClearComposition;
|
||||
device->IsTextInputShown = WIN_IsTextInputShown;
|
||||
|
||||
device->SetClipboardText = WIN_SetClipboardText;
|
||||
device->GetClipboardText = WIN_GetClipboardText;
|
||||
|
|
|
@ -151,9 +151,11 @@ typedef struct SDL_VideoData
|
|||
SDL_bool ime_available;
|
||||
HWND ime_hwnd_main;
|
||||
HWND ime_hwnd_current;
|
||||
SDL_bool ime_suppress_endcomposition_event;
|
||||
HIMC ime_himc;
|
||||
|
||||
WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
WCHAR* ime_composition;
|
||||
int ime_composition_length;
|
||||
WCHAR ime_readingstring[16];
|
||||
int ime_cursor;
|
||||
|
||||
|
@ -189,6 +191,7 @@ typedef struct SDL_VideoData
|
|||
DWORD ime_convmodesinkcookie;
|
||||
TSFSink *ime_uielemsink;
|
||||
TSFSink *ime_ippasink;
|
||||
LONG ime_uicontext;
|
||||
|
||||
BYTE pre_hook_key_state[256];
|
||||
UINT _SDL_WAKEUP;
|
||||
|
|
Loading…
Reference in New Issue