summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixKey.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixKey.c')
-rw-r--r--unix/tkUnixKey.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index 40cc779..23c4aa4 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.c
@@ -37,7 +37,7 @@
* Tk_SetCaretPos --
*
* This enables correct placement of the XIM caret. This is called by
- * widgets to indicate their cursor placement. This is currently only
+ * widgets to indicate their cursor placement. This is currently only
* used for over-the-spot XIM.
*
*----------------------------------------------------------------------
@@ -53,11 +53,10 @@ Tk_SetCaretPos(
TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
- if ( dispPtr->caret.winPtr == winPtr
- && dispPtr->caret.x == x
- && dispPtr->caret.y == y
- && dispPtr->caret.height == height)
- {
+ if ((dispPtr->caret.winPtr == winPtr)
+ && (dispPtr->caret.x == x)
+ && (dispPtr->caret.y == y)
+ && (dispPtr->caret.height == height)) {
return;
}
@@ -66,22 +65,21 @@ Tk_SetCaretPos(
dispPtr->caret.y = y;
dispPtr->caret.height = height;
-#ifdef TK_USE_INPUT_METHODS
/*
* Adjust the XIM caret position.
*/
- if ( (dispPtr->flags & TK_DISPLAY_USE_IM)
- && (dispPtr->inputStyle & XIMPreeditPosition)
- && (winPtr->inputContext != NULL) )
- {
+
+#ifdef TK_USE_INPUT_METHODS
+ if ((dispPtr->flags & TK_DISPLAY_USE_IM)
+ && (dispPtr->inputStyle & XIMPreeditPosition)
+ && (winPtr->inputContext != NULL)) {
XVaNestedList preedit_attr;
XPoint spot;
spot.x = dispPtr->caret.x;
spot.y = dispPtr->caret.y + dispPtr->caret.height;
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
- XSetICValues(winPtr->inputContext,
- XNPreeditAttributes, preedit_attr,
+ XSetICValues(winPtr->inputContext, XNPreeditAttributes, preedit_attr,
NULL);
XFree(preedit_attr);
}
@@ -106,7 +104,7 @@ Tk_SetCaretPos(
*----------------------------------------------------------------------
*/
-char *
+const char *
TkpGetString(
TkWindow *winPtr, /* Window where event occurred */
XEvent *eventPtr, /* X keyboard event. */
@@ -130,8 +128,7 @@ TkpGetString(
#ifdef TK_USE_INPUT_METHODS
if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
&& (winPtr->inputContext != NULL)
- && (eventPtr->type == KeyPress))
- {
+ && (eventPtr->type == KeyPress)) {
Status status;
#if X_HAVE_UTF8_STRING
@@ -140,7 +137,11 @@ TkpGetString(
Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr),
&kePtr->keysym, &status);
- if (status == XBufferOverflow) { /* Expand buffer and try again */
+ if (status == XBufferOverflow) {
+ /*
+ * Expand buffer and try again.
+ */
+
Tcl_DStringSetLength(dsPtr, len);
len = Xutf8LookupString(winPtr->inputContext, &eventPtr->xkey,
Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr),
@@ -157,7 +158,6 @@ TkpGetString(
Tcl_DStringInit(&buf);
Tcl_DStringSetLength(&buf, TCL_DSTRING_STATIC_SIZE-1);
-
len = XmbLookupString(winPtr->inputContext, &eventPtr->xkey,
Tcl_DStringValue(&buf), Tcl_DStringLength(&buf),
&kePtr->keysym, &status);
@@ -174,7 +174,6 @@ TkpGetString(
if ((status != XLookupChars) && (status != XLookupBoth)) {
len = 0;
}
-
Tcl_DStringSetLength(&buf, len);
Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&buf), len, dsPtr);
Tcl_DStringFree(&buf);
@@ -218,7 +217,7 @@ TkpGetString(
* from having to reenter the XIM engine. [Bug 1373712]
*/
- kePtr->charValuePtr = ckalloc((unsigned) len + 1);
+ kePtr->charValuePtr = ckalloc(len + 1);
kePtr->charValueLen = len;
memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), (unsigned) len + 1);
return Tcl_DStringValue(dsPtr);
@@ -434,7 +433,7 @@ TkpInitKeymapInfo(
dispPtr->metaModMask = 0;
dispPtr->altModMask = 0;
codePtr = modMapPtr->modifiermap;
- max = 8*modMapPtr->max_keypermod;
+ max = 8 * modMapPtr->max_keypermod;
for (i = 0; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -456,12 +455,11 @@ TkpInitKeymapInfo(
*/
if (dispPtr->modKeyCodes != NULL) {
- ckfree((char *) dispPtr->modKeyCodes);
+ ckfree(dispPtr->modKeyCodes);
}
dispPtr->numModKeyCodes = 0;
arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = (KeyCode *)
- ckalloc((unsigned) (KEYCODE_ARRAY_SIZE * sizeof(KeyCode)));
+ dispPtr->modKeyCodes = ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -473,23 +471,26 @@ TkpInitKeymapInfo(
for (j = 0; j < dispPtr->numModKeyCodes; j++) {
if (dispPtr->modKeyCodes[j] == *codePtr) {
+ /*
+ * 'continue' the outer loop.
+ */
+
goto nextModCode;
}
}
if (dispPtr->numModKeyCodes >= arraySize) {
- KeyCode *new;
+ KeyCode *newCodes;
/*
* Ran out of space in the array; grow it.
*/
arraySize *= 2;
- new = (KeyCode *)
- ckalloc((unsigned) (arraySize * sizeof(KeyCode)));
- memcpy(new, dispPtr->modKeyCodes,
- (dispPtr->numModKeyCodes * sizeof(KeyCode)));
- ckfree((char *) dispPtr->modKeyCodes);
- dispPtr->modKeyCodes = new;
+ newCodes = ckalloc(arraySize * sizeof(KeyCode));
+ memcpy(newCodes, dispPtr->modKeyCodes,
+ dispPtr->numModKeyCodes * sizeof(KeyCode));
+ ckfree(dispPtr->modKeyCodes);
+ dispPtr->modKeyCodes = newCodes;
}
dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr;
dispPtr->numModKeyCodes++;