mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 11:42:16 +00:00
Win32: Fix coding style
* brace position * add missing spaces
This commit is contained in:
parent
e4c4c7343c
commit
2130afeb02
@ -315,14 +315,16 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool
|
||||
|
||||
void _glfwInputPreedit(_GLFWwindow* window, int focusedBlock)
|
||||
{
|
||||
if (window->callbacks.preedit) {
|
||||
if (window->callbacks.preedit)
|
||||
{
|
||||
window->callbacks.preedit((GLFWwindow*) window, window->ntext, window->preeditText, window->nblocks, window->preeditAttributeBlocks, focusedBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwInputIMEStatus(_GLFWwindow* window)
|
||||
{
|
||||
if (window->callbacks.imestatus) {
|
||||
if (window->callbacks.imestatus)
|
||||
{
|
||||
window->callbacks.imestatus((GLFWwindow*) window);
|
||||
}
|
||||
}
|
||||
@ -910,7 +912,8 @@ GLFWAPI void glfwSetPreeditCursorPos(GLFWwindow* handle, int x, int y, int h)
|
||||
window->preeditCursorHeight = h;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwResetPreeditText(GLFWwindow* handle) {
|
||||
GLFWAPI void glfwResetPreeditText(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_glfwPlatformResetPreeditText(window);
|
||||
}
|
||||
|
@ -535,11 +535,12 @@ static void maximizeWindowManually(_GLFWwindow* window)
|
||||
}
|
||||
|
||||
// Set cursor position to decide candidate window
|
||||
static void _win32ChangeCursorPosition(HIMC hIMC, _GLFWwindow* window) {
|
||||
static void _win32ChangeCursorPosition(HIMC hIMC, _GLFWwindow* window)
|
||||
{
|
||||
int x = window->preeditCursorPosX;
|
||||
int y = window->preeditCursorPosY;
|
||||
int h = window->preeditCursorHeight;
|
||||
CANDIDATEFORM excludeRect = {0, CFS_EXCLUDE, {x, y}, {x, y, x, y+h}};
|
||||
CANDIDATEFORM excludeRect = { 0, CFS_EXCLUDE, { x, y }, { x, y, x, y + h } };
|
||||
ImmSetCandidateWindow(hIMC, &excludeRect);
|
||||
}
|
||||
|
||||
@ -839,35 +840,41 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
|
||||
case WM_IME_COMPOSITION:
|
||||
{
|
||||
if (lParam & GCS_RESULTSTR) {
|
||||
if (lParam & GCS_RESULTSTR)
|
||||
{
|
||||
window->nblocks = 0;
|
||||
window->ntext = 0;
|
||||
_glfwInputPreedit(window, 0);
|
||||
return TRUE;
|
||||
}
|
||||
if (lParam & GCS_COMPSTR) {
|
||||
if (lParam & GCS_COMPSTR)
|
||||
{
|
||||
HIMC hIMC = ImmGetContext(hWnd);
|
||||
// get preedit data sizes
|
||||
LONG preeditTextLength = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
|
||||
LONG attrLength = ImmGetCompositionString(hIMC, GCS_COMPATTR, NULL, 0);
|
||||
LONG clauseLength = ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, NULL, 0);
|
||||
if (preeditTextLength > 0) {
|
||||
if (preeditTextLength > 0)
|
||||
{
|
||||
// get preedit data
|
||||
int length = preeditTextLength/sizeof(WCHAR);
|
||||
LPWSTR buffer = (LPWSTR)_glfw_calloc(preeditTextLength, sizeof(WCHAR));
|
||||
LPSTR attributes = (LPSTR)_glfw_calloc(attrLength, 1);
|
||||
DWORD *clauses = (DWORD*)_glfw_calloc(clauseLength, 1);
|
||||
int length = preeditTextLength / sizeof(WCHAR);
|
||||
LPWSTR buffer = (LPWSTR) _glfw_calloc(preeditTextLength, sizeof(WCHAR));
|
||||
LPSTR attributes = (LPSTR) _glfw_calloc(attrLength, 1);
|
||||
DWORD *clauses = (DWORD*) _glfw_calloc(clauseLength, 1);
|
||||
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, buffer, preeditTextLength);
|
||||
ImmGetCompositionString(hIMC, GCS_COMPATTR, attributes, attrLength);
|
||||
ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, clauses, clauseLength);
|
||||
// store preedit text
|
||||
int ctext = window->ctext;
|
||||
while (ctext < length+1) {
|
||||
ctext = (ctext == 0) ? 1 : ctext*2;
|
||||
while (ctext < length + 1)
|
||||
{
|
||||
ctext = (ctext == 0) ? 1 : ctext * 2;
|
||||
}
|
||||
if (ctext != window->ctext) {
|
||||
unsigned int* preeditText = _glfw_realloc(window->preeditText, sizeof(unsigned int)*ctext);
|
||||
if (preeditText == NULL) {
|
||||
if (ctext != window->ctext)
|
||||
{
|
||||
unsigned int* preeditText = _glfw_realloc(window->preeditText, sizeof(unsigned int) * ctext);
|
||||
if (preeditText == NULL)
|
||||
{
|
||||
_glfw_free(buffer);
|
||||
_glfw_free(attributes);
|
||||
_glfw_free(clauses);
|
||||
@ -879,21 +886,25 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
window->ntext = length;
|
||||
window->preeditText[length] = 0;
|
||||
int i;
|
||||
for (i=0; i < length; i++) {
|
||||
for (i=0; i < length; i++)
|
||||
{
|
||||
window->preeditText[i] = buffer[i];
|
||||
}
|
||||
// store blocks
|
||||
window->nblocks = clauseLength/sizeof(DWORD)-1;
|
||||
window->nblocks = clauseLength / sizeof(DWORD) - 1;
|
||||
// last element of clauses is a block count, but
|
||||
// text length is convenient.
|
||||
clauses[window->nblocks] = length;
|
||||
int cblocks = window->cblocks;
|
||||
while (cblocks < window->nblocks) {
|
||||
cblocks = (cblocks == 0) ? 1 : cblocks*2;
|
||||
while (cblocks < window->nblocks)
|
||||
{
|
||||
cblocks = (cblocks == 0) ? 1 : cblocks * 2;
|
||||
}
|
||||
if (cblocks != window->cblocks) {
|
||||
int* blocks = _glfw_realloc(window->preeditAttributeBlocks, sizeof(int)*cblocks);
|
||||
if (blocks == NULL) {
|
||||
if (cblocks != window->cblocks)
|
||||
{
|
||||
int* blocks = _glfw_realloc(window->preeditAttributeBlocks, sizeof(int) * cblocks);
|
||||
if (blocks == NULL)
|
||||
{
|
||||
_glfw_free(buffer);
|
||||
_glfw_free(attributes);
|
||||
_glfw_free(clauses);
|
||||
@ -903,9 +914,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
window->cblocks = cblocks;
|
||||
}
|
||||
int focusedBlock = 0;
|
||||
for (i=0; i < window->nblocks; i++) {
|
||||
window->preeditAttributeBlocks[i] = clauses[i+1]-clauses[i];
|
||||
if (attributes[clauses[i]] != ATTR_CONVERTED) {
|
||||
for (i = 0; i < window->nblocks; i++)
|
||||
{
|
||||
window->preeditAttributeBlocks[i] = clauses[i + 1] - clauses[i];
|
||||
if (attributes[clauses[i]] != ATTR_CONVERTED)
|
||||
{
|
||||
focusedBlock = i;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user