src/java.desktop/aix/native/libawt_xawt/awt/awt_InputMethod.c
author itakiguchi
Tue, 30 Apr 2019 14:30:17 -0700
changeset 54867 65297f60ba19
parent 52263 680ab6b53f6f
permissions -rw-r--r--
8213232: Unix/X11 setCompositionEnableNative issue Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2802
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2802
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2802
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2802
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2802
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
    #error This file should not be included in headless library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "awt.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "awt_p.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    33
#include <sun_awt_X11InputMethodBase.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <sun_awt_X11InputMethod.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <sun_awt_X11_XInputMethod.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    37
#include <langinfo.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    38
#include <stdio.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    39
#include <stdlib.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    40
#include <sys/time.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    41
#include <wchar.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    42
#include <wctype.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    43
#include <X11/Intrinsic.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    44
#include <X11/keysym.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    45
#include <X11/Xlib.h>
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    46
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define THROW_OUT_OF_MEMORY_ERROR() \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
struct X11InputMethodIDs {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  jfieldID pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
} x11InputMethodIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    54
static int PreeditStartCallback(XIC, XPointer, XPointer);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
static void PreeditDoneCallback(XIC, XPointer, XPointer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
static void PreeditDrawCallback(XIC, XPointer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                                XIMPreeditDrawCallbackStruct *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
static void PreeditCaretCallback(XIC, XPointer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                 XIMPreeditCaretCallbackStruct *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
static void StatusStartCallback(XIC, XPointer, XPointer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
static void StatusDoneCallback(XIC, XPointer, XPointer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
static void StatusDrawCallback(XIC, XPointer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                               XIMStatusDrawCallbackStruct *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define ROOT_WINDOW_STYLES      (XIMPreeditNothing | XIMStatusNothing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define NO_STYLES               (XIMPreeditNone | XIMStatusNone)
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    67
/* added style to allow for in-place composition, such as "dead" keys for accents */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    68
#define IN_PLACE_STYLES         (XIMPreeditNothing | XIMStatusNone)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#define PreeditStartIndex       0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define PreeditDoneIndex        1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define PreeditDrawIndex        2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define PreeditCaretIndex       3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define StatusStartIndex        4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#define StatusDoneIndex         5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#define StatusDrawIndex         6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define NCALLBACKS              7
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    78
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    79
#define STATUS_BORDER 2         /* Status Border width */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    80
#define CARET_OFFSET 1          /* Offset of caret position (pixel) */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    81
#define BORDER_MARGIN 3         /* BORDER MARGIN width */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    82
#define STATUS_MARGIN 7         /* Margin between the status window and its parent window */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    83
#define PREEDIT_ATTR_MASK (XIMReverse|XIMUnderline)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
    84
          /* Preedit attribute which host adapter can handle */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * Callback function pointers: the order has to match the *Index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * values above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
static XIMProc callback_funcs[NCALLBACKS] = {
54867
65297f60ba19 8213232: Unix/X11 setCompositionEnableNative issue
itakiguchi
parents: 52263
diff changeset
    91
    (XIMProc)(void *)&PreeditStartCallback,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    (XIMProc)PreeditDoneCallback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    (XIMProc)PreeditDrawCallback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    (XIMProc)PreeditCaretCallback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    (XIMProc)StatusStartCallback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    (XIMProc)StatusDoneCallback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    (XIMProc)StatusDrawCallback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define MAX_STATUS_LEN  100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    Window   w;                /*status window id        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    Window   root;             /*the root window id      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    Window   parent;           /*parent shell window     */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   105
    Window   grandParent;      /*window has WM frame     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    int      x, y;             /*parent's upperleft position */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    int      width, height;    /*parent's width, height  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    GC       lightGC;          /*gc for light border     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    GC       dimGC;            /*gc for dim border       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    GC       bgGC;             /*normal painting         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    GC       fgGC;             /*normal painting         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    int      statusW, statusH; /*status window's w, h    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    int      rootW, rootH;     /*root window's w, h    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    int      bWidth;           /*border width            */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   115
    wchar_t  status[MAX_STATUS_LEN + 1]; /*status text       */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    XFontSet fontset;           /*fontset for drawing    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    int      off_x, off_y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    Bool     on;                /*if the status window on*/
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   119
    int      fOff;              /* font base line(in pixel) from top */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   120
    int      fBot;              /* font bottom line(in pixel) from top */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   121
    int      peTextW;           /* Composition text width in pixel */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   122
    wchar_t* peText;            /* Composed string (wide char.) */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   123
    XIMFeedback* peAttr;        /* Composed text attribute */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   124
    int      peCaret;           /* Caret position in number of character */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   125
    Bool     status_ready;      /* Not draw Status at XCreateIC */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
} StatusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * X11InputMethodData keeps per X11InputMethod instance information. A pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * to this data structure is kept in an X11InputMethod object (pData).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
typedef struct _X11InputMethodData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    XIC         current_ic;     /* current X Input Context */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    XIC         ic_active;      /* X Input Context for active clients */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    XIC         ic_passive;     /* X Input Context for passive clients */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    XIMCallback *callbacks;     /* callback parameters */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    jobject     x11inputmethod; /* global ref to X11InputMethod instance */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                /* associated with the XIC */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    StatusWindow *statusWindow; /* our own status window  */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   140
    Bool        passiveStatusWindow;/* Passive Client uses StatusWindow */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   141
    Bool        isActiveClient;     /* True:clinet is active */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   142
    Bool        forceReset;     /* True: call resetXIC before UnsetICFocus */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
} X11InputMethodData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
/* reference to the current X11InputMethod instance, it is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
   point to the global reference to the X11InputMethodObject since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
   it could be referenced by different threads. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
jobject currentX11InputMethodInstance = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
Window  currentFocusWindow = 0;  /* current window that has focus for input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                       method. (the best place to put this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                       information should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                       currentX11InputMethodInstance's pData) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
static XIM X11im = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
Display * dpy = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#define GetJNIEnv() (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
static X11InputMethodData * getX11InputMethodData(JNIEnv *, jobject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
static void setX11InputMethodData(JNIEnv *, jobject, X11InputMethodData *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
static void destroyX11InputMethodData(JNIEnv *, X11InputMethodData *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
static void freeX11InputMethodData(JNIEnv *, X11InputMethodData *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   164
/* Prototype for this function is missing in AIX Xlib.h */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
extern char *XSetIMValues(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
#if NeedVarargsPrototypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    XIM /* im */, ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   170
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   171
static int st_wcslen(wchar_t *string);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   172
static Bool isPreeditStateActive(XIC ic);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   173
static void * buf_insert(void * src, void * insert, int size,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   174
                         int src_len, int ins_len, int offset);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   175
static void * handle_buffer(void * source, void * insert,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   176
                            int size, int src_len, int ins_len,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   177
                            int del_len, int offset);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   178
static void preedit_draw_passive(X11InputMethodData *pX11IMData,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   179
                                 XIMPreeditDrawCallbackStruct *pre_draw);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   180
static void resetPassivePreeditText(StatusWindow *statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   181
static void draw_caret(StatusWindow *statusWindow, GC gc, int pos);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   182
static int  get_next_attr(int len, unsigned long *attr);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   183
static void draw_preedit(StatusWindow *statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   184
static void align_status(StatusWindow *statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   185
static void shrink_status(StatusWindow *statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   186
static GC create_gc(Window win, Bool isReverse);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   187
static XFontSet create_fontset(void);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   188
static Bool is_text_available(XIMText * text);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   189
static Bool isNativeIm();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   190
static Window getGrandParent(Window parent);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   191
static void moveStatusWindow(StatusWindow *statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   192
static void arrange_window_stack(StatusWindow* statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   193
static Window get_current_focus(XIC ic);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
 * This function is stolen from /src/solaris/hpi/src/system_md.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 * It is used in setting the time in Java-level InputEvents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
awt_util_nowMillisUTC()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    struct timeval t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    gettimeofday(&t, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    return ((jlong)t.tv_sec) * 1000 + (jlong)(t.tv_usec/1000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * Converts the wchar_t string to a multi-byte string calling wcstombs(). A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 * buffer is allocated by malloc() to store the multi-byte string. NULL is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 * returned if the given wchar_t string pointer is NULL or buffer allocation is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 * failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
static char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
wcstombsdmp(wchar_t *wcs, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    size_t n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    char *mbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    if (wcs == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    n = len*MB_CUR_MAX + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    mbs = (char *) malloc(n * sizeof(char));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    if (mbs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    /* TODO: check return values... Handle invalid characters properly...  */
35677
c243e74116f8 8146317: Memory leak in wcstombsdmp
serb
parents: 30935
diff changeset
   231
    if (wcstombs(mbs, wcs, n) == (size_t)-1) {
c243e74116f8 8146317: Memory leak in wcstombsdmp
serb
parents: 30935
diff changeset
   232
        free(mbs);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return NULL;
35677
c243e74116f8 8146317: Memory leak in wcstombsdmp
serb
parents: 30935
diff changeset
   234
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    return mbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
static X11InputMethodData * getX11InputMethodData(JNIEnv * env, jobject imInstance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    X11InputMethodData *pX11IMData =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        (X11InputMethodData *)JNU_GetLongFieldAsPtr(env, imInstance, x11InputMethodIDs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * In case the XIM server was killed somehow, reset X11InputMethodData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    if (X11im == NULL && pX11IMData != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                             "flushText",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                             "()V");
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
   250
        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        /* IMPORTANT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
           The order of the following calls is critical since "imInstance" may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
           point to the global reference itself, if "freeX11InputMethodData" is called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
           first, the global reference will be destroyed and "setX11InputMethodData"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
           will in fact fail silently. So pX11IMData will not be set to NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
           This could make the original java object refers to a deleted pX11IMData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
           object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        setX11InputMethodData(env, imInstance, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        freeX11InputMethodData(env, pX11IMData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    return pX11IMData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
static void setX11InputMethodData(JNIEnv * env, jobject imInstance, X11InputMethodData *pX11IMData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    JNU_SetLongFieldFromPtr(env, imInstance, x11InputMethodIDs.pData, pX11IMData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
/* this function should be called within AWT_LOCK() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
destroyX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Destroy XICs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    if (pX11IMData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    if (pX11IMData->ic_active != (XIC)0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        XUnsetICFocus(pX11IMData->ic_active);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        XDestroyIC(pX11IMData->ic_active);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        if (pX11IMData->ic_active != pX11IMData->ic_passive) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            if (pX11IMData->ic_passive != (XIC)0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                XUnsetICFocus(pX11IMData->ic_passive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                XDestroyIC(pX11IMData->ic_passive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            pX11IMData->ic_passive = (XIC)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            pX11IMData->current_ic = (XIC)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    freeX11InputMethodData(env, pX11IMData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    if (pX11IMData->statusWindow != NULL){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        StatusWindow *sw = pX11IMData->statusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        XFreeGC(awt_display, sw->lightGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        XFreeGC(awt_display, sw->dimGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        XFreeGC(awt_display, sw->bgGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        XFreeGC(awt_display, sw->fgGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        if (sw->fontset != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            XFreeFontSet(awt_display, sw->fontset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        XDestroyWindow(awt_display, sw->w);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   311
        if (pX11IMData->statusWindow->peText){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   312
            free((void *)pX11IMData->statusWindow->peText);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   313
            pX11IMData->statusWindow->peText = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   314
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   315
        if (pX11IMData->statusWindow->peAttr){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   316
            free((void *)pX11IMData->statusWindow->peAttr);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   317
            pX11IMData->statusWindow->peAttr = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   318
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        free((void*)sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    if (pX11IMData->callbacks)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        free((void *)pX11IMData->callbacks);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    if (env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        (*env)->DeleteGlobalRef(env, pX11IMData->x11inputmethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    free((void *)pX11IMData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
 * Sets or unsets the focus to the given XIC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
setXICFocus(XIC ic, unsigned short req)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    if (ic == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        (void)fprintf(stderr, "Couldn't find X Input Context\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    if (req == 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        XSetICFocus(ic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        XUnsetICFocus(ic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
 * Sets the focus window to the given XIC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
setXICWindowFocus(XIC ic, Window w)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    if (ic == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        (void)fprintf(stderr, "Couldn't find X Input Context\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    (void) XSetICValues(ic, XNFocusWindow, w, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
 * Invokes XmbLookupString() to get something from the XIM. It invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
 * X11InputMethod.dispatchCommittedText() if XmbLookupString() returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
 * committed text.  This function is called from handleKeyEvent in canvas.c and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
 * it's under the Motif event loop thread context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
 * Buffer usage: There is a bug in XFree86-4.3.0 XmbLookupString implementation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
 * where it never returns XBufferOverflow.  We need to allocate the initial lookup buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
 * big enough, so that the possibility that user encounters this problem is relatively
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * small.  When this bug gets fixed, we can make the initial buffer size smaller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * Note that XmbLookupString() sometimes produces a non-null-terminated string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 * Returns True when there is a keysym value to be handled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
#define INITIAL_LOOKUP_BUF_SIZE 512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
18135
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17923
diff changeset
   377
Boolean
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    JNIEnv *env = GetJNIEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    X11InputMethodData *pX11IMData = NULL;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   382
    int buf_len = INITIAL_LOOKUP_BUF_SIZE;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   383
    char mbbuf[INITIAL_LOOKUP_BUF_SIZE];
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   384
    char *buf;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    KeySym keysym = NoSymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    Status status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    int mblen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    jstring javastr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    XIC ic;
18135
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17923
diff changeset
   390
    Boolean result = True;
d9be76f1a19c 8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
pchelko
parents: 17923
diff changeset
   391
    static Boolean composing = False;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
      printf("lookupString: entering...\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    if (pX11IMData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    if ((ic = pX11IMData->current_ic) == (XIC)0){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   407
    buf = mbbuf;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   408
    mblen = XmbLookupString(ic, event, buf,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   409
                            buf_len - 1, &keysym, &status);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * In case of overflow, a buffer is allocated and it retries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * XmbLookupString().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    if (status == XBufferOverflow) {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   416
        buf_len = mblen + 1;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   417
        buf = (char *)malloc(buf_len);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   418
        if (buf == NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   422
        mblen = XmbLookupString(ic, event, buf, buf_len, &keysym, &status);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   424
    buf[mblen] = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    /* Get keysym without taking modifiers into account first to map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * to AWT keyCode table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    switch (status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    case XLookupBoth:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        if (!composing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            if (event->keycode != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                *keysymp = keysym;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                result = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        composing = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        /*FALLTHRU*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    case XLookupChars:
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   441
        /*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   442
        printf("lookupString: status=XLookupChars, type=%d, state=%x, keycode=%x, keysym=%x\n",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   443
               event->type, event->state, event->keycode, keysym);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   444
        */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   445
        javastr = JNU_NewStringPlatform(env, (const char *)buf);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        if (javastr != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            JNU_CallMethodByName(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                 currentX11InputMethodInstance,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                 "dispatchCommittedText",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                                 "(Ljava/lang/String;J)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                                 javastr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                                 event->time);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   453
            if ((*env)->ExceptionOccurred(env)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   454
                (*env)->ExceptionDescribe(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   455
                (*env)->ExceptionClear(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   456
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    case XLookupKeySym:
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   461
        /*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   462
        printf("lookupString: status=XLookupKeySym, type=%d, state=%x, keycode=%x, keysym=%x\n",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   463
               event->type, event->state, event->keycode, keysym);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   464
        */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        if (keysym == XK_Multi_key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            composing = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        if (! composing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            *keysymp = keysym;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            result = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    case XLookupNone:
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   474
        /*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   475
        printf("lookupString: status=XLookupNone, type=%d, state=%x, keycode=%x, keysym=%x\n",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   476
               event->type, event->state, event->keycode, keysym);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   477
        */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   481
    if (buf != mbbuf) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   482
        free(buf);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   483
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   487
static StatusWindow *createStatusWindow(Window parent) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    StatusWindow *statusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    XSetWindowAttributes attrib;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    unsigned long attribmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    Window containerWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    Window status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    Window child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    XWindowAttributes xwa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    XWindowAttributes xxwa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    /* Variable for XCreateFontSet()*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    char **mclr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    int  mccr = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    char *dsr;
37699
c3d9835483f9 8154269: Remove unused or unnecessary Xm/Xt files and header includes
prr
parents: 35677
diff changeset
   500
    unsigned long bg, fg, light, dim;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   501
    int x, y, off_x, off_y, xx, yy;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   502
    unsigned int w, h, bw, depth;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    XGCValues values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    unsigned long valuemask = 0;  /*ignore XGCvalue and use defaults*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    int screen = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    AwtGraphicsConfigDataPtr adata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    extern int awt_numScreens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /*hardcode the size right now, should get the size base on font*/
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   510
    int width=80, height=22;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    Window rootWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    Window *ignoreWindowPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    unsigned int ignoreUnit;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   514
    Window grandParent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   515
    Window target;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   516
    XFontSet fontset;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   517
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   518
    fontset = create_fontset();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   519
    if (NULL == fontset) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   520
        return NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   521
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    XGetGeometry(dpy, parent, &rootWindow, &x, &y, &w, &h, &bw, &depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    attrib.override_redirect = True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    attribmask = CWOverrideRedirect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    for (i = 0; i < awt_numScreens; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        if (RootWindow(dpy, i) == rootWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            screen = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    adata = getDefaultConfig(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    bg    = adata->AwtColorMatch(255, 255, 255, adata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    fg    = adata->AwtColorMatch(0, 0, 0, adata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    light = adata->AwtColorMatch(195, 195, 195, adata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    dim   = adata->AwtColorMatch(128, 128, 128, adata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   539
    grandParent = getGrandParent(parent);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   540
    target = (grandParent == 0) ? parent : grandParent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   541
    XGetWindowAttributes(dpy, target, &xwa);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    bw = 2; /*xwa.border_width does not have the correct value*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    /*compare the size difference between parent container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
      and shell widget, the diff should be the border frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
      and title bar height (?)*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    XQueryTree( dpy,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   549
                target,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                &rootWindow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                &containerWindow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                &ignoreWindowPtr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                &ignoreUnit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    XGetWindowAttributes(dpy, containerWindow, &xxwa);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   556
    XTranslateCoordinates(dpy,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   557
                          target, xwa.root,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   558
                          0, 0,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   559
                          &x, &y, &child);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   560
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   561
    if (containerWindow == rootWindow) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   562
        off_x = 0; off_y = STATUS_MARGIN;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   563
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   564
        XGetWindowAttributes(dpy, containerWindow, &xxwa);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   565
        off_x = (xxwa.width - xwa.width) / 2;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   566
        /* off_y = xxwa.height - xwa.height - off_x;*/ /*it's magic:-) */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   567
        {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   568
            int cx, cy;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   569
            XTranslateCoordinates(dpy,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   570
                                  containerWindow, xxwa.root,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   571
                                  0, 0,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   572
                                  &cx, &cy,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   573
                                  &child);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   574
            off_y = (xxwa.height + cy) - (xwa.height + y);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   575
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   576
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    /*get the size of root window*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    XGetWindowAttributes(dpy, rootWindow, &xxwa);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    XTranslateCoordinates(dpy,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   582
                          target, xwa.root,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                          xwa.x, xwa.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                          &x, &y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                          &child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    xx = x - off_x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    yy = y + xwa.height - off_y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    if (xx < 0 ){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        xx = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   591
    if (xx + width > xxwa.width) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        xx = xxwa.width - width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   594
    if (yy + height > xxwa.height) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        yy = xxwa.height - height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   598
    if ((DefaultVisual(dpy,screen))->class != adata->awt_visInfo.visual->class &&
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   599
        adata->awt_visInfo.visual->class == TrueColor) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   600
        attrib.colormap = XCreateColormap(dpy, xwa.root,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   601
            adata->awt_visInfo.visual, AllocNone );
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   602
        attrib.border_pixel = BlackPixel(dpy, screen) ;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   603
        attribmask |= CWColormap | CWBorderPixel;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   604
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   605
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    status =  XCreateWindow(dpy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                            xwa.root,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                            xx, yy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                            width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                            0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                            xwa.depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                            InputOutput,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                            adata->awt_visInfo.visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                            attribmask, &attrib);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    XSelectInput(dpy, status,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                 ExposureMask | StructureNotifyMask | EnterWindowMask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                 LeaveWindowMask | VisibilityChangeMask);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   618
    if (grandParent != 0){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   619
        long mask;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   620
        XGetWindowAttributes(dpy, grandParent, &xwa);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   621
        mask = xwa.your_event_mask | StructureNotifyMask |
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   622
               VisibilityChangeMask | PropertyChangeMask;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   623
        XSelectInput(dpy, grandParent,mask);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   624
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   625
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    statusWindow = (StatusWindow*) calloc(1, sizeof(StatusWindow));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    if (statusWindow == NULL){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    statusWindow->w = status;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   632
    statusWindow->fontset = fontset;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    statusWindow->parent = parent;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   634
    statusWindow->grandParent = grandParent;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    statusWindow->on  = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    statusWindow->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    statusWindow->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    statusWindow->width = xwa.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    statusWindow->height = xwa.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    statusWindow->off_x = off_x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    statusWindow->off_y = off_y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    statusWindow->bWidth  = bw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    statusWindow->statusH = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    statusWindow->statusW = width;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   645
    statusWindow->peTextW = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    statusWindow->rootH = xxwa.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    statusWindow->rootW = xxwa.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    statusWindow->lightGC = XCreateGC(dpy, status, valuemask, &values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    XSetForeground(dpy, statusWindow->lightGC, light);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    statusWindow->dimGC = XCreateGC(dpy, status, valuemask, &values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    XSetForeground(dpy, statusWindow->dimGC, dim);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   652
    statusWindow->fgGC = create_gc(status, FALSE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    XSetForeground(dpy, statusWindow->fgGC, fg);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   654
    statusWindow->bgGC = create_gc(status, TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    XSetForeground(dpy, statusWindow->bgGC, bg);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   656
    statusWindow->status_ready = False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   657
    wcscpy(statusWindow->status, L"");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    return statusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
/* This method is to turn off or turn on the status window. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
static void onoffStatusWindow(X11InputMethodData* pX11IMData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                                Window parent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                                Bool ON){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    XWindowAttributes xwa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    Window child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    int x, y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    StatusWindow *statusWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   670
    if (NULL == pX11IMData ||
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        NULL == (statusWindow =  pX11IMData->statusWindow)){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   675
    if (ON == False) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        XUnmapWindow(dpy, statusWindow->w);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   677
        return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   678
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   679
    if (NULL == currentX11InputMethodInstance){
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   682
    {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   683
        JNIEnv *env = GetJNIEnv();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   684
        parent = JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   685
                                      "getCurrentParentWindow",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   686
                                      "()J").j;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   687
        if ((*env)->ExceptionOccurred(env)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   688
            (*env)->ExceptionDescribe(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   689
            (*env)->ExceptionClear(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   690
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   691
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   692
    if (statusWindow->parent != parent) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        statusWindow->parent = parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   695
    if (st_wcslen(statusWindow->status) > 0 ||
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   696
        (statusWindow->peText != NULL && st_wcslen(statusWindow->peText) > 0 )) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   697
        moveStatusWindow(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   698
        XMapRaised(dpy, statusWindow->w);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
void paintStatusWindow(StatusWindow *statusWindow){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    Window  win  = statusWindow->w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    GC  lightgc = statusWindow->lightGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    GC  dimgc = statusWindow->dimGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    GC  bggc = statusWindow->bgGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    GC  fggc = statusWindow->fgGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    int width = statusWindow->statusW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    int height = statusWindow->statusH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    int bwidth = statusWindow->bWidth;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   712
    int len;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   713
    XRectangle logical, ink;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   715
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   716
    if ((len = st_wcslen(statusWindow->status)) == 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   717
        return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   718
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   719
    XwcTextExtents(statusWindow->fontset, statusWindow->status,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   720
                   len, &ink, &logical);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   721
    width = logical.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   722
    height = logical.height;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   724
    XFillRectangle(dpy, win, bggc, 0, 0, width+2, height+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   725
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   726
    XDrawLine(dpy, win, fggc, 0, 0, width+2, 0);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   727
    XDrawLine(dpy, win, fggc, 0, height+2, width+2, height+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   728
    XDrawLine(dpy, win, fggc, 0, 0, 0, height+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   729
    XDrawLine(dpy, win, fggc, width+2, 0, width+2, height+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   730
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   731
    if (statusWindow->fontset) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   732
        XwcDrawString(dpy, win, statusWindow->fontset, fggc,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   733
                      -logical.x + 1, -logical.y + 1,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                      statusWindow->status,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   735
                      st_wcslen(statusWindow->status));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   736
    } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        /*too bad we failed to create a fontset for this locale*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        XDrawString(dpy, win, fggc, bwidth + 2, height - bwidth - 4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                    "[InputMethod ON]", strlen("[InputMethod ON]"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   743
Bool statusWindowEventHandler(XEvent event) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    JNIEnv *env = GetJNIEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    X11InputMethodData *pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    StatusWindow *statusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   748
    if (NULL == currentX11InputMethodInstance ||
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   749
        NULL == (pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance)) ||
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   750
        NULL == (statusWindow = pX11IMData->statusWindow))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   751
    {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   752
        return False;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   755
    if (statusWindow->w == event.xany.window) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   756
        switch (event.type) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   757
        case Expose:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   758
            paintStatusWindow(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   759
            if (statusWindow->peText)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   760
                draw_preedit(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   761
            arrange_window_stack(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   762
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   763
        case ConfigureNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   764
        case VisibilityNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   765
            arrange_window_stack(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   766
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   767
        /*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   768
        case UnmapNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   769
        case VisibilityNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   770
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   771
        */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   772
        default:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   773
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   775
        return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   776
    } else if ((statusWindow->parent == event.xany.window) ||
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   777
               (statusWindow->grandParent && statusWindow->grandParent == event.xany.window)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   778
        switch (event.type) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   779
        case MapNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   780
            if (statusWindow->on) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   781
                onoffStatusWindow(pX11IMData, statusWindow->parent, True);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   782
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   783
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   784
        case UnmapNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   785
            onoffStatusWindow(pX11IMData, 0, False);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   786
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   787
        case VisibilityNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   788
            if (statusWindow->on) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   789
                arrange_window_stack(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   790
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   791
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   792
        case ConfigureNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   793
            if (statusWindow->grandParent && statusWindow->on) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   794
                moveStatusWindow(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   795
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   796
        case PropertyNotify:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   797
            if (statusWindow->on) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   798
                arrange_window_stack(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   799
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   800
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   801
        default:
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   802
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   803
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   804
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   805
    return False;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   808
static void adjustStatusWindow(Window shell) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    JNIEnv *env = GetJNIEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    X11InputMethodData *pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    StatusWindow *statusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    if (NULL == currentX11InputMethodInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        || NULL == (pX11IMData = getX11InputMethodData(env,currentX11InputMethodInstance))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        || NULL == (statusWindow = pX11IMData->statusWindow)
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   816
        || !statusWindow->on)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   817
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   821
    moveStatusWindow(statusWindow);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
}
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   823
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
 * Creates two XICs, one for active clients and the other for passive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
 * clients. All information on those XICs are stored in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
 * X11InputMethodData given by the pX11IMData parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
 * For active clients: Try to use preedit callback to support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
 * on-the-spot. If tc is not null, the XIC to be created will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
 * share the Status Area with Motif widgets (TextComponents). If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
 * preferable styles can't be used, fallback to root-window styles. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
 * root-window styles failed, fallback to None styles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
 * For passive clients: Try to use root-window styles. If failed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
 * fallback to None styles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
static Bool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    XVaNestedList preedit = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    XVaNestedList status = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    XIMStyle on_the_spot_styles = XIMPreeditCallbacks,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   844
             in_place_styles = 0,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
             active_styles = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
             passive_styles = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
             no_styles = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    XIMCallback *callbacks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    unsigned short i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    XIMStyles *im_styles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    char *ret = NULL;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   852
    Bool passiveStatusWindow = False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   853
    pX11IMData->statusWindow = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    if (X11im == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    }
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   858
    if (!w) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   862
    if (getenv("IBMJAVA_PASSIVE") == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   863
        passiveStatusWindow = False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   864
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   865
        passiveStatusWindow = True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   866
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   867
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   868
    if (isNativeIm()) { passiveStatusWindow = True; }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   869
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    ret = XGetIMValues(X11im, XNQueryInputStyle, &im_styles, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    if (ret != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        jio_fprintf(stderr,"XGetIMValues: %s\n",ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        return FALSE ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    on_the_spot_styles |= XIMStatusNothing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    /*kinput does not support XIMPreeditCallbacks and XIMStatusArea
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
      at the same time, so use StatusCallback to draw the status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
      ourself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    for (i = 0; i < im_styles->count_styles; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        if (im_styles->supported_styles[i] == (XIMPreeditCallbacks | XIMStatusCallbacks)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            on_the_spot_styles = (XIMPreeditCallbacks | XIMStatusCallbacks);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    for (i = 0; i < im_styles->count_styles; i++) {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   891
        if (im_styles->supported_styles[i] == on_the_spot_styles)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   892
            active_styles = im_styles->supported_styles[i];
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   893
        if (im_styles->supported_styles[i] == ROOT_WINDOW_STYLES)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   894
            passive_styles = im_styles->supported_styles[i];
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   895
        if (im_styles->supported_styles[i] == IN_PLACE_STYLES) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   896
            in_place_styles = im_styles->supported_styles[i];
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   897
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   898
        if (im_styles->supported_styles[i] == NO_STYLES) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   899
            no_styles = im_styles->supported_styles[i];
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   900
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    XFree(im_styles);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    if (active_styles != on_the_spot_styles) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        if (passive_styles == ROOT_WINDOW_STYLES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            active_styles = passive_styles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        else {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   909
          if (in_place_styles == IN_PLACE_STYLES){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   910
              active_styles = passive_styles = IN_PLACE_STYLES;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   911
          } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            if (no_styles == NO_STYLES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                active_styles = passive_styles = NO_STYLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                active_styles = passive_styles = 0;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   916
          }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    } else {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   919
      if (!passiveStatusWindow) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        if (passive_styles != ROOT_WINDOW_STYLES) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            if (no_styles == NO_STYLES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                active_styles = passive_styles = NO_STYLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                active_styles = passive_styles = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   926
      } else
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   927
          passive_styles = active_styles;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    if (active_styles == on_the_spot_styles) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        callbacks = (XIMCallback *)malloc(sizeof(XIMCallback) * NCALLBACKS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        if (callbacks == (XIMCallback *)NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        pX11IMData->callbacks = callbacks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        for (i = 0; i < NCALLBACKS; i++, callbacks++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            callbacks->client_data = (XPointer) pX11IMData->x11inputmethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            callbacks->callback = callback_funcs[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        callbacks = pX11IMData->callbacks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        preedit = (XVaNestedList)XVaCreateNestedList(0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                        XNPreeditStartCallback, &callbacks[PreeditStartIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                        XNPreeditDoneCallback,  &callbacks[PreeditDoneIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                        XNPreeditDrawCallback,  &callbacks[PreeditDrawIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                        XNPreeditCaretCallback, &callbacks[PreeditCaretIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                        NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        if (preedit == (XVaNestedList)NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            goto err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        /*always try XIMStatusCallbacks for active client...*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   952
        if (on_the_spot_styles & XIMStatusCallbacks) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            status = (XVaNestedList)XVaCreateNestedList(0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                        XNStatusStartCallback, &callbacks[StatusStartIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                        XNStatusDoneCallback,  &callbacks[StatusDoneIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                        XNStatusDrawCallback, &callbacks[StatusDrawIndex],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                        NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            if (status == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                goto err;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   961
          }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            pX11IMData->statusWindow = createStatusWindow(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            pX11IMData->ic_active = XCreateIC(X11im,
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   964
                                              XNClientWindow, w,
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   965
                                              XNFocusWindow, w,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                                              XNInputStyle, active_styles,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                                              XNPreeditAttributes, preedit,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                                              XNStatusAttributes, status,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                                              NULL);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   970
            if (NULL != pX11IMData->statusWindow) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   971
                pX11IMData->statusWindow->status_ready = True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   972
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            XFree((void *)status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            XFree((void *)preedit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   976
        if (passiveStatusWindow) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   977
            pX11IMData->ic_passive = pX11IMData->ic_active;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   978
        } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   979
            pX11IMData->ic_passive = XCreateIC(X11im,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   980
                                               XNClientWindow, w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   981
                                               XNFocusWindow, w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   982
                                               XNInputStyle, passive_styles,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   983
                                               NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   984
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        pX11IMData->ic_active = XCreateIC(X11im,
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   987
                                          XNClientWindow, w,
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   988
                                          XNFocusWindow, w,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                                          XNInputStyle, active_styles,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                                          NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        pX11IMData->ic_passive = pX11IMData->ic_active;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   994
    // The code set the IC mode that the preedit state is not initialied
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   995
    // at XmbResetIC.  This attribute can be set at XCreateIC.  I separately
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   996
    // set the attribute to avoid the failure of XCreateIC at some platform
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   997
    // which does not support the attribute.
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   998
    if (pX11IMData->ic_active != 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
   999
        XSetICValues(pX11IMData->ic_active,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1000
                        XNResetState, XIMPreserveState, NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1001
    if (pX11IMData->ic_passive != 0 &&
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1002
        pX11IMData->ic_active != pX11IMData->ic_passive)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1003
            XSetICValues(pX11IMData->ic_passive,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1004
             XNResetState, XIMInitialState, NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1005
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1006
    pX11IMData->passiveStatusWindow = passiveStatusWindow;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1007
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    if (pX11IMData->ic_active == (XIC)0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        || pX11IMData->ic_passive == (XIC)0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1013
    /* Unset focus to avoid unexpected IM on */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1014
    setXICFocus(pX11IMData->ic_active, False);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1015
    if (pX11IMData->ic_active != pX11IMData->ic_passive)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1016
        setXICFocus(pX11IMData->ic_passive, False);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    return True;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
 err:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    if (preedit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        XFree((void *)preedit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
    return False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1027
static int
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
PreeditStartCallback(XIC ic, XPointer client_data, XPointer call_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
{
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1030
    JNIEnv *env = GetJNIEnv();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1031
    X11InputMethodData *pX11IMData;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1032
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1033
    pX11IMData = getX11InputMethodData(env, (jobject)client_data);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1034
    if (pX11IMData == NULL || pX11IMData->statusWindow == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1035
        return 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1036
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1037
    resetPassivePreeditText(pX11IMData->statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1038
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1039
    return -1;  /* unlimited length for preedit text  */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
PreeditDoneCallback(XIC ic, XPointer client_data, XPointer call_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
{
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1045
    JNIEnv *env = GetJNIEnv();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1046
    X11InputMethodData *pX11IMData;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1047
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1048
    pX11IMData = getX11InputMethodData(env, (jobject)client_data);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1049
    if (pX11IMData == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1050
        return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1051
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1052
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1053
    if (!pX11IMData->isActiveClient) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1054
        resetPassivePreeditText(pX11IMData->statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1055
        shrink_status(pX11IMData->statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1056
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1057
    else{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1058
            JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1059
                                 "clearComposedText",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1060
                                 "(J)V",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1061
                                 awt_util_nowMillisUTC());
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1062
            if ((*env)->ExceptionOccurred(env)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1063
                (*env)->ExceptionDescribe(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1064
                (*env)->ExceptionClear(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1065
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1066
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
 * Translate the preedit draw callback items to Java values and invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
 * X11InputMethod.dispatchComposedText().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
 * client_data: X11InputMethod object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
PreeditDrawCallback(XIC ic, XPointer client_data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                    XIMPreeditDrawCallbackStruct *pre_draw)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    JNIEnv *env = GetJNIEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    X11InputMethodData *pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    jmethodID x11imMethodID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    XIMText *text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    jstring javastr = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    jintArray style = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    /* printf("Native: PreeditDrawCallback() \n"); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    if (pre_draw == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    AWT_LOCK();
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1092
    if ((pX11IMData = getX11InputMethodData(env, (jobject)client_data)) == NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        goto finally;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1095
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1096
    if (!pX11IMData->isActiveClient){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1097
        if (ic == pX11IMData->ic_passive) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1098
            preedit_draw_passive(pX11IMData, pre_draw);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1099
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        goto finally;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    if ((text = pre_draw->text) != NULL) {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1104
        if (is_text_available(text)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1105
            if (text->string.multi_byte != NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1106
                if (pre_draw->text->encoding_is_wchar == False) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1107
                    javastr = JNU_NewStringPlatform(env, (const char *)text->string.multi_byte);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1108
                    if (javastr == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1109
                        goto finally;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1110
                    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1111
                } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1112
                    char *mbstr = wcstombsdmp(text->string.wide_char, text->length);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1113
                    if (mbstr == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1114
                        goto finally;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1115
                    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1116
                    javastr = JNU_NewStringPlatform(env, (const char *)mbstr);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1117
                    free(mbstr);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1118
                    if (javastr == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1119
                        goto finally;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1120
                    }
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1121
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        if (text->feedback != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            int cnt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            jint *tmpstyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
            style = (*env)->NewIntArray(env, text->length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
            if (JNU_IsNull(env, style)) {
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1130
                (*env)->ExceptionClear(env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                goto finally;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            if (sizeof(XIMFeedback) == sizeof(jint)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                 * Optimization to avoid copying the array
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                (*env)->SetIntArrayRegion(env, style, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                                          text->length, (jint *)text->feedback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                tmpstyle  = (jint *)malloc(sizeof(jint)*(text->length));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                if (tmpstyle == (jint *) NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                    THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                    goto finally;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                for (cnt = 0; cnt < (int)text->length; cnt++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                        tmpstyle[cnt] = text->feedback[cnt];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                (*env)->SetIntArrayRegion(env, style, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                                          text->length, (jint *)tmpstyle);
52263
680ab6b53f6f 8211393: Memory leak issue on awt_InputMethod.c
itakiguchi
parents: 50350
diff changeset
  1151
                free(tmpstyle);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
    JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                         "dispatchComposedText",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                         "(Ljava/lang/String;[IIIIJ)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                         javastr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                         style,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                         (jint)pre_draw->chg_first,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                         (jint)pre_draw->chg_length,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
                         (jint)pre_draw->caret,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                         awt_util_nowMillisUTC());
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1164
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1165
    if ((*env)->ExceptionOccurred(env)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1166
        (*env)->ExceptionDescribe(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1167
        (*env)->ExceptionClear(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1168
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1169
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
finally:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
PreeditCaretCallback(XIC ic, XPointer client_data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                     XIMPreeditCaretCallbackStruct *pre_caret)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
{
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1179
    XIMPreeditDrawCallbackStruct pre_draw;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1181
    if (pre_caret != NULL && pre_caret->direction == XIMAbsolutePosition) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1182
        pre_draw.caret = pre_caret->position;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1183
        pre_draw.chg_first = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1184
        pre_draw.chg_length = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1185
        pre_draw.text = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1186
        PreeditDrawCallback(ic, client_data, &pre_draw);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1187
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
    /*ARGSUSED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    /*printf("StatusStartCallback:\n");  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
StatusDoneCallback(XIC ic, XPointer client_data, XPointer call_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    /*ARGSUSED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    /*printf("StatusDoneCallback:\n"); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1204
static void StatusDrawCallback
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1205
  (XIC ic, XPointer client_data, XIMStatusDrawCallbackStruct *status_draw)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    /*ARGSUSED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    /*printf("StatusDrawCallback:\n"); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    JNIEnv *env = GetJNIEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
    X11InputMethodData *pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    StatusWindow *statusWindow;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1212
    int value_make = CWX|CWWidth|CWHeight;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1213
    XRectangle logical, ink;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1214
    XWindowChanges xwc;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1215
    int len;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    if (NULL == (pX11IMData = getX11InputMethodData(env, (jobject)client_data))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
        || NULL == (statusWindow = pX11IMData->statusWindow)){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
        goto finally;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1224
    if (status_draw->type == XIMTextType) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
        XIMText *text = (status_draw->data).text;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1226
        if (text != NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1227
            if (text->string.multi_byte != NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1228
                if(!strcmp(text->string.multi_byte," ")){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1229
                    wcscpy(statusWindow->status, L"");
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1230
                    onoffStatusWindow(pX11IMData, 0, False);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1231
                    goto finally;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1232
                }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1233
                mbstowcs(statusWindow->status,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1234
                         (const char *)text->string.multi_byte,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1235
                         (size_t)MAX_STATUS_LEN);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1236
            } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1237
                if (0 == st_wcslen(text->string.wide_char)){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1238
                    wcscpy(statusWindow->status, L"");
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1239
                    onoffStatusWindow(pX11IMData, 0, False);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1240
                    goto finally;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1241
                }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1242
                wcsncpy(statusWindow->status,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1243
                        text->string.wide_char,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1244
                        MAX_STATUS_LEN);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1245
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1246
            XwcTextExtents(statusWindow->fontset, statusWindow->status,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1247
                           st_wcslen(statusWindow->status), &ink, &logical);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1248
            statusWindow->statusW = logical.width + BORDER_MARGIN;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1249
            statusWindow->statusH = logical.height + BORDER_MARGIN;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1250
            xwc.x = statusWindow->x - statusWindow->off_x;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1251
            if (xwc.x < 0 ) xwc.x = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1252
            xwc.width = statusWindow->statusW;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1253
            xwc.height = statusWindow->statusH;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1254
            if (xwc.x + xwc.width > statusWindow->rootW){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1255
                xwc.x = statusWindow->rootW - xwc.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1256
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1257
            XConfigureWindow(dpy, statusWindow->w, value_make, &xwc);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1258
          if (statusWindow->status_ready && statusWindow->on == True){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1259
            onoffStatusWindow(pX11IMData, statusWindow->parent, True);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
          }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1261
            paintStatusWindow(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1262
            if (statusWindow->peText)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1263
                draw_preedit(statusWindow);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        else {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1266
            wcscpy(statusWindow->status, L"");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
            /*just turnoff the status window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
            paintStatusWindow(statusWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
            onoffStatusWindow(pX11IMData, 0, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
 finally:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1278
/* return the string length without trailing spaces    */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1279
/* work around code for Japanese AIXIM is implemented. */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1280
static int st_wcslen(wchar_t *string)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1281
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1282
    int len = (int32_t)wcslen(string);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1283
    if (len == 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1284
        return 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1285
   for (len--;len >= 0; len--) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1286
        if (!iswspace((wint_t) string[len])) break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1287
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1288
    return len+1;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1289
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1291
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1292
 * Checks whether given XIMText contains a string data.
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1293
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1294
static Bool is_text_available(XIMText * text)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1295
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1296
    if (text == NULL || text->length==0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1297
        return False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1298
    if (text->encoding_is_wchar) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1299
        if(text->string.wide_char[0] == L'\0')
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1300
            return False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1301
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1302
        if (text->string.multi_byte[0] == '\0')
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1303
            return False;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1305
    return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1306
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1308
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1309
 * check if preedit status is active
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1310
*/
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1311
static Bool isPreeditStateActive(XIC ic)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1312
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1313
    XIMPreeditState state = XIMPreeditUnKnown;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1314
    XVaNestedList pr_atrb;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1315
    char* nosupportAttr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1316
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1317
    if (ic == NULL) return False;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1319
    pr_atrb = XVaCreateNestedList(0,XNPreeditState,&state,NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1320
    nosupportAttr=XGetICValues(ic,XNPreeditAttributes,pr_atrb,NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1321
    XFree(pr_atrb);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1322
    if (nosupportAttr==NULL && state & XIMPreeditDisable)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1323
        return False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1324
    else
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1325
        return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1326
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1327
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1328
static void * buf_insert(void * src, void * insert, int size,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1329
                         int src_len, int ins_len, int offset)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1330
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1331
    char *temp;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1332
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1333
    temp = realloc(src, size*(src_len+ins_len+1));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1334
    if (temp == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1335
        THROW_OUT_OF_MEMORY_ERROR();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1336
        return src;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
    }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1338
    if (offset != src_len) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1339
        memmove(&temp[size*(offset+ins_len)],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1340
                &((char *)temp)[size*offset],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1341
                size*(src_len-offset));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1342
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1343
    memcpy(&temp[size*offset], insert, size*ins_len);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1344
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1345
    return (void *)temp;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1348
static void * handle_buffer(void * source, void * insert,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1349
                            int size,int src_len, int ins_len,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1350
                            int del_len, int offset)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1351
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1352
    void * temp = source;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1354
    if (del_len > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1355
        if (del_len == ins_len) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1356
            memcpy(&((char *)source)[size*offset], insert, size*ins_len);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1357
            return source;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1358
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1359
        else if (src_len > offset+del_len) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1360
            memmove(&((char *)source)[size*offset],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1361
                    &((char *)source)[size*(offset+del_len)],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1362
                    size*(src_len-offset-del_len));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1363
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1364
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1365
    if (ins_len > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1366
        temp = buf_insert(source, insert, size, src_len,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1367
                          ins_len, offset);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1368
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1369
    return temp;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1370
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1371
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1372
 * Display the given preedit text to the root window which is ownd by
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1373
 * myself. All of the character is converted to wide char.
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1374
 * this function is used for the passive client.
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1375
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1376
static void preedit_draw_passive(X11InputMethodData *pX11IMData,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1377
                    XIMPreeditDrawCallbackStruct *pre_draw)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1378
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1379
    XIMText *text;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1380
    wchar_t *tempbuf = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1381
    StatusWindow *statusWindow;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1382
    wchar_t *cur_text;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1383
    unsigned long *cur_attr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1384
    int     cur_len = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1385
    int     chg_len = pre_draw->chg_length;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1386
    int     chg_1st = pre_draw->chg_first;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1387
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1388
    if (NULL == (statusWindow = pX11IMData->statusWindow))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
        return;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1390
    cur_text = statusWindow->peText;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1391
    cur_attr = statusWindow->peAttr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1392
    if (cur_text == NULL && pre_draw->text == NULL)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1393
        return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1395
    if (cur_text != NULL)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1396
        cur_len = (int32_t)wcslen(cur_text);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1397
    text = pre_draw->text;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1398
    if (text == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1399
        /* delete only */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1400
        if (cur_len >  chg_1st+chg_len) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1401
            memmove(&cur_text[chg_1st],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1402
                    &cur_text[chg_1st+chg_len],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1403
                    sizeof(wchar_t)*(cur_len-chg_1st-chg_len));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1404
            memmove(&cur_attr[chg_1st],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1405
                    &cur_attr[chg_1st+chg_len],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1406
                    sizeof(long)*(cur_len-chg_1st-chg_len));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1407
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1408
        if ((pre_draw->chg_length <= cur_len ) && (pre_draw->chg_length >0))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1409
            cur_text[cur_len-pre_draw->chg_length] =L'\0';
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1410
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1411
        /* insert or replace */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1412
        int     ins_len = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1413
        void *  ins_text = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1415
        /* if invalid offset is specified, do nothing. */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1416
        /* this fix is for aixim for eucTW             */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1417
        if (cur_len < chg_1st)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1418
            return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1419
        if(is_text_available(text)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1420
            /* insert or replace the text */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1421
            if (text->encoding_is_wchar == False) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1422
                /* convert the text to wide chars.
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1423
                   allocate enough size buffer
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1424
                */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1425
                tempbuf = (wchar_t *)malloc(sizeof(wchar_t)*(text->length+1));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1426
                if (tempbuf == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1427
                    THROW_OUT_OF_MEMORY_ERROR();
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1428
                    return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1429
                }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1430
                ins_len = (int32_t)mbstowcs(tempbuf, text->string.multi_byte,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1431
                                   text->length);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1432
                if (ins_len == -1) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1433
                        free(tempbuf);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1434
                        return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1435
                }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1436
                ins_text = (void *)tempbuf;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1437
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1438
            else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1439
                ins_len = text->length;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1440
                ins_text = text->string.wide_char;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1441
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1442
            /* finish prepare the data to be inserted */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1443
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1444
            statusWindow->peText =
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1445
                    handle_buffer(cur_text, ins_text, sizeof(wchar_t),
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1446
                                  cur_len, ins_len, chg_len, chg_1st);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1447
            statusWindow->peAttr =
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1448
                    handle_buffer(cur_attr, text->feedback, sizeof(long),
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1449
                                  cur_len, ins_len, chg_len, chg_1st);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1450
            statusWindow->peText[cur_len-chg_len+ins_len] =L'\0';
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1451
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1452
            if (tempbuf != NULL)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1453
                free(tempbuf);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1454
        } /* endof insert or replace text */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1455
        else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1456
            /* change attribute only */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1457
            memcpy(&cur_attr[chg_1st], text->feedback,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1458
                    sizeof(long)*text->length);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1459
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1460
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1461
    statusWindow->peCaret= pre_draw->caret;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1462
    draw_preedit(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1463
    if (statusWindow->on && wcslen(statusWindow->peText) > 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1464
        onoffStatusWindow(pX11IMData, statusWindow->parent, True);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1465
    else if (wcslen(statusWindow->status) == 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1466
        onoffStatusWindow(pX11IMData, 0, False);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
/*
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1470
 * reset predit test of passive mode
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
 */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1472
static void
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1473
resetPassivePreeditText(StatusWindow *statusWindow)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1474
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1475
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1476
    if(statusWindow->peText != NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1477
        free(statusWindow->peText);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1478
        statusWindow->peText = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1479
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1480
    if(statusWindow->peAttr != NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1481
        free(statusWindow->peAttr);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1482
        statusWindow->peAttr = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1483
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1484
    statusWindow->peCaret= 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1485
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1486
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1487
static void draw_caret(StatusWindow *statusWindow, GC gc, int pos)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1488
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1489
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1490
    XSetFunction(dpy, gc, GXinvert);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1491
    XDrawLine(dpy, statusWindow->w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1492
              gc, pos, STATUS_BORDER/2,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1493
              pos, STATUS_BORDER/2+statusWindow->fOff);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1494
    XSetFunction(dpy, gc, GXcopy);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1495
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1496
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1497
static int  get_next_attr(int len, unsigned long *attr)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1498
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1499
    int count;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1500
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1501
    for (count = 1; count < len; count++)  {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1502
        if ((attr[count-1] & PREEDIT_ATTR_MASK)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1503
            != (attr[count] & PREEDIT_ATTR_MASK))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1504
            break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1505
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1506
    return count;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1507
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1508
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1509
static void draw_preedit(StatusWindow *statusWindow)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1510
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1511
    unsigned long *attr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1512
    int x_pos,x_caret;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1513
    unsigned int  len;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1514
    int len_disp, pos;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1515
    wchar_t *str;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1516
    GC  gc;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1517
    XRectangle ink, rect, rect_c;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1518
    Bool caret_done = False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1519
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1520
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1521
    align_status(statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1522
    XFillRectangle(dpy, statusWindow->w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1523
                   statusWindow->bgGC,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1524
                   statusWindow->statusW,0,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1525
                   statusWindow->statusW + statusWindow->peTextW + BORDER_MARGIN,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1526
                   statusWindow->fBot+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1527
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1528
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1529
    XDrawLine(dpy, statusWindow->w, statusWindow->fgGC,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1530
              statusWindow->statusW, 0,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1531
              statusWindow->statusW + statusWindow->peTextW + BORDER_MARGIN, 0);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1532
    XDrawLine(dpy, statusWindow->w, statusWindow->fgGC,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1533
              statusWindow->statusW, statusWindow->fBot+2,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1534
              statusWindow->statusW + statusWindow->peTextW + BORDER_MARGIN,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1535
              statusWindow->fBot+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1536
    XDrawLine(dpy, statusWindow->w, statusWindow->fgGC,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1537
              statusWindow->statusW + statusWindow->peTextW + BORDER_MARGIN, 0,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1538
              statusWindow->statusW + statusWindow->peTextW + BORDER_MARGIN,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1539
              statusWindow->fBot+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1540
    if (0 == statusWindow->statusW)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1541
        XDrawLine(dpy, statusWindow->w, statusWindow->fgGC,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1542
                  0, 0, 0, statusWindow->fBot+2);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1543
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1544
    str =  statusWindow->peText;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1546
    if (str != NULL &&  (len = (int32_t)wcslen(str)) != 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1547
        pos = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1548
        attr = statusWindow->peAttr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1549
        x_pos = x_caret = statusWindow->statusW + STATUS_BORDER;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1550
        while((int)len-1 >= pos) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1551
            len_disp = get_next_attr(len - pos, &attr[pos]);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1552
            if (attr[pos] & XIMReverse) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1553
                gc = statusWindow->bgGC;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1554
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1555
            else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1556
                gc = statusWindow->fgGC;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1557
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1558
            XwcTextExtents(statusWindow->fontset,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1559
                           &str[pos],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1560
                           len_disp, &ink, &rect);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1561
            XwcDrawImageString(dpy, statusWindow->w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1562
                               statusWindow->fontset, gc,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1563
                               x_pos, statusWindow->fOff+1, &str[pos], len_disp);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1564
            if (attr[pos] & XIMUnderline) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1565
                XDrawLine(dpy, statusWindow->w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1566
                          gc, x_pos, statusWindow->fBot,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1567
                          x_pos+rect.width, statusWindow->fBot);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1568
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1569
            if (!caret_done) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1570
                if( statusWindow->peCaret >= pos &&
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1571
                    statusWindow->peCaret <= pos+len_disp) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1572
                    if (statusWindow->peCaret == 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1573
                        x_caret = x_pos;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1574
                    else if (statusWindow->peCaret == pos+len_disp)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1575
                        x_caret = x_pos+rect.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1576
                    else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1577
                        XwcTextExtents(statusWindow->fontset,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1578
                                        &str[pos],
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1579
                                        statusWindow->peCaret-pos,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1580
                                        &ink, &rect_c);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1581
                        x_caret = x_pos+ rect_c.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1582
                    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1583
                    x_caret-=CARET_OFFSET;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1584
                    caret_done = True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1585
                }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1586
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1587
            pos += len_disp;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1588
            x_pos += rect.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1589
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1590
        if (caret_done)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1591
            draw_caret(statusWindow, statusWindow->fgGC, x_caret);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1592
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1593
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1594
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1595
/* calc required status window size and resize the window */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1596
static void align_status(StatusWindow *statusWindow)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
{
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1598
    int len_st, len_pe = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1599
    XRectangle rect_st, rect_pe, ink;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1600
    Dimension cur_w;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1601
    int value_make = CWX|CWWidth|CWHeight;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1602
    XWindowChanges xwc;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1603
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1604
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1605
    if ((len_st = st_wcslen(statusWindow->status)) == 0
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1606
        && (statusWindow->peText == NULL || st_wcslen(statusWindow->peText) == 0 ))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1607
        return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1608
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1609
    rect_pe.x = rect_pe.y = rect_pe.width = rect_pe.height = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1610
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1611
    XwcTextExtents(statusWindow->fontset,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1612
                   statusWindow->status,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1613
                   len_st, &ink, &rect_st);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1614
    if (statusWindow->peText != NULL
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1615
        && (len_pe = (int32_t)wcslen(statusWindow->peText)) > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1616
        XwcTextExtents(statusWindow->fontset,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1617
                       statusWindow->peText,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1618
                       len_pe, &ink, &rect_pe);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1619
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1620
    statusWindow->fOff = max(-rect_st.y, -rect_pe.y);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1621
    statusWindow->fBot = max(rect_st.height, rect_pe.height);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1622
    statusWindow->statusW =rect_st.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1623
    if (rect_st.width > 0) statusWindow->statusW += BORDER_MARGIN;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1624
    statusWindow->peTextW = rect_pe.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1625
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1626
    xwc.x = statusWindow->x - statusWindow->off_x;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1627
    if (xwc.x < 0 ) xwc.x = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1628
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1629
    if (len_pe > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1630
        xwc.width = statusWindow->statusW
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1631
                    + statusWindow->peTextW + BORDER_MARGIN + 1;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1632
        xwc.height = statusWindow->fBot + BORDER_MARGIN;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1633
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1634
        xwc.width = statusWindow->statusW;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1635
        xwc.height = statusWindow->fBot + BORDER_MARGIN;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1636
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1637
    if (xwc.x + xwc.width > statusWindow->rootW){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1638
      xwc.x = statusWindow->rootW - xwc.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1639
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1640
    XConfigureWindow(dpy, statusWindow->w, value_make, &xwc);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1641
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1642
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1643
static void shrink_status(StatusWindow *statusWindow)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1644
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1645
    int value_make = CWX|CWWidth|CWHeight;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1646
    XWindowChanges xwc;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1647
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1648
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1649
    xwc.width  = statusWindow->statusW;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1650
    xwc.height = statusWindow->statusH;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1651
    statusWindow->peTextW = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1652
    xwc.x = statusWindow->x - statusWindow->off_x;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1653
    if (xwc.x < 0 ) xwc.x = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1654
    if (xwc.x + xwc.width > statusWindow->rootW){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1655
      xwc.x = statusWindow->rootW - xwc.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1656
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1657
    XConfigureWindow(dpy, statusWindow->w, value_make, &xwc);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1658
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1659
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1660
static GC create_gc(Window win, Bool isReverse)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1661
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1662
    XGCValues xgcv;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1663
    unsigned long mask;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1664
    AwtScreenDataPtr defaultScreen;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1665
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1666
    defaultScreen = getScreenData(DefaultScreen(dpy));
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1667
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1668
    mask = (GCForeground | GCBackground );
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1669
    if (isReverse) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1670
        xgcv.foreground = defaultScreen->whitepixel;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1671
        xgcv.background = defaultScreen->blackpixel;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1672
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1673
        xgcv.foreground = defaultScreen->blackpixel;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1674
        xgcv.background = defaultScreen->whitepixel;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1675
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1676
    return XCreateGC(dpy, win, mask, &xgcv);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1679
static Bool isNativeIm()
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1680
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1681
#define XIMMODIFIER          "@im="
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1682
#define XIM_SERVER_CATEGORY  "@server="
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1683
    char *immodifiers;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1684
    char *imserver, *imserverPtr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1685
    Atom imserverAtom;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1686
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1687
    if (!(immodifiers = getenv("XMODIFIERS"))) return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1688
    if (!(imserver = calloc(1,strlen(immodifiers)+strlen(XIM_SERVER_CATEGORY)+1))) return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1689
    if (!(immodifiers = strstr(immodifiers,XIMMODIFIER))) return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1690
    immodifiers += strlen(XIMMODIFIER);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1691
    strcpy(imserver,XIM_SERVER_CATEGORY);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1692
    imserverPtr = imserver + strlen(imserver);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1693
    while(*immodifiers != '@' && *immodifiers != '\0') {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1694
        *imserverPtr = *immodifiers;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1695
        imserverPtr++;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1696
        immodifiers++;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1697
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1698
    imserverAtom = XInternAtom(awt_display, imserver, True);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1699
    free(imserver);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1700
    if (imserverAtom > 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1701
        return False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1702
    else
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1703
        return True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1704
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1705
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1706
static Window getGrandParent(Window parent)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1707
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1708
    Window containerWindow,rootWindow,tmp;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1709
    Window *ignoreWindowPtr;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1710
    unsigned int ignoreUnit;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1711
    Window grandParent=0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1712
    XWindowAttributes xwa;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1713
    Atom WM_STATE;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1714
    Atom type = None;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1715
    int32_t format;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1716
    unsigned long nitems, after;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1717
    unsigned char * data;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1718
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1719
    if (parent == 0) return grandParent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1720
    WM_STATE = XInternAtom(dpy, "WM_STATE", True);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1721
    if (WM_STATE == None) return grandParent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1722
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1723
    tmp=parent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1724
    while(XQueryTree(dpy, tmp,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1725
                     &rootWindow, &containerWindow,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1726
                     &ignoreWindowPtr, &ignoreUnit)){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1727
        XFree(ignoreWindowPtr);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1728
        if (containerWindow == rootWindow) break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1729
        if (XGetWindowProperty(dpy, containerWindow, WM_STATE,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1730
                    0, 0, False, AnyPropertyType,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1731
                    &type, &format, &nitems, &after, &data) == Success) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1732
            XFree(data);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1733
            if (type) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1734
                XGetWindowAttributes(dpy, containerWindow, &xwa);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1735
                if (FALSE == xwa.override_redirect){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1736
                    grandParent=containerWindow;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1737
                }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1738
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1739
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1740
        tmp=containerWindow;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1741
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1742
    return grandParent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1743
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1744
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1745
static void moveStatusWindow(StatusWindow *statusWindow)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1746
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1747
    XWindowAttributes xwa;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1748
    Window child;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1749
    int x, y, width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1750
    Window target;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1751
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1752
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1753
    if (statusWindow->grandParent) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1754
        target = statusWindow->grandParent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1755
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1756
        target = statusWindow->parent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1757
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1758
    XGetWindowAttributes(dpy, target, &xwa);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1759
    XTranslateCoordinates(dpy,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1760
                          target, xwa.root,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1761
                          0, 0,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1762
                          &x, &y,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1763
                          &child);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1764
    if (statusWindow->x != x
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1765
        || statusWindow->y != y
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1766
        || statusWindow->width != xwa.width
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1767
        || statusWindow->height != xwa.height){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1768
        statusWindow->x = x;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1769
        statusWindow->y = y;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1770
        statusWindow->height = xwa.height;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1771
        statusWindow->width = xwa.width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1772
        x = statusWindow->x - statusWindow->off_x;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1773
        y = statusWindow->y + statusWindow->height + statusWindow->off_y;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1774
        if (x < 0 ){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1775
            x = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1776
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1777
        if (statusWindow->peTextW > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1778
            width = statusWindow->statusW + statusWindow->peTextW + BORDER_MARGIN + 1;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1779
            if (x + width > statusWindow->rootW){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1780
                x = statusWindow->rootW - width;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1781
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1782
        } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1783
            if (x + statusWindow->statusW > statusWindow->rootW){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1784
                x = statusWindow->rootW - statusWindow->statusW;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1785
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1786
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1787
        if (y + statusWindow->statusH > statusWindow->rootH){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1788
            y = statusWindow->rootH - statusWindow->statusH;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1789
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1790
        XMoveWindow(dpy, statusWindow->w, x, y);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1791
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1792
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1793
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1794
static void arrange_window_stack(StatusWindow* statusWindow)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1795
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1796
    XWindowChanges xwc;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1797
    int value_make = CWSibling|CWStackMode;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1798
    Window root, parent, *children;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1799
    unsigned int nchildren;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1800
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1801
    if (NULL == statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1802
    if (XQueryTree(dpy, statusWindow->parent,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1803
                       &root, &parent, &children, &nchildren)){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1804
        XFree(children);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1805
        xwc.sibling = parent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1806
        while(XQueryTree(dpy, xwc.sibling, &root, &parent, &children, &nchildren)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1807
            XFree(children);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1808
            if (root != parent) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1809
                xwc.sibling = parent;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1810
            } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1811
                break;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1812
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1813
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1814
        xwc.stack_mode = Above;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1815
        XConfigureWindow(dpy, statusWindow->w, value_make, &xwc);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1816
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1817
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1818
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1819
static int count_missing_fonts(char **charset_list, int charset_count)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1820
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1821
    int i,j;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1822
    if (charset_count > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1823
        j=charset_count;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1824
        for(i=0; i < charset_count; i++) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1825
            if ((strstr(charset_list[i], "IBM-udc")) ||
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1826
                (strstr(charset_list[i], "IBM-sbd")) ||
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1827
                (strstr(charset_list[i], "IBM-ucdTW")))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1828
                j--;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1829
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1830
        return j;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1831
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1832
    else
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1833
        return 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1834
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1835
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1836
static XFontSet create_fontset_name(char * font_name, Bool force)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1837
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1838
    XFontSet fontset = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1839
    char **charset_list;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1840
    int charset_count;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1841
    char *def_string;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1842
    int missing_fonts;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1843
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1844
    fontset = XCreateFontSet(dpy, font_name,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1845
                &charset_list, &charset_count, &def_string);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1846
    if (charset_count > 0) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1847
        missing_fonts = count_missing_fonts(charset_list,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1848
                                            charset_count);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1849
        XFreeStringList(charset_list);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1850
        if (fontset && (missing_fonts > 0)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1851
            if (!force) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1852
                XFreeFontSet(dpy, fontset);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1853
                fontset = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1854
            }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1855
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1856
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1857
    return fontset;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1858
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1859
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1860
static XFontSet create_fontset()
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1861
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1862
    XFontSet fontset = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1863
    int i;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1864
    static char * fontlist[] = {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1865
        "-dt-interface user-medium-r-normal-S*-*-*-*-*-*-*-*-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1866
        "-*-*-medium-r-normal-*-14-*-*-*-c-*-*-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1867
        "-*-*-medium-r-normal-*-14-*-*-*-m-*-*-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1868
        "-*-*-medium-r-normal--14-0-0-0-m-*-*-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1869
        "-monotype-sansmonowt-medium-r-normal--14-*-*-*-m-*-*-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1870
        "-*--14-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1871
        "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1872
        "-*--16-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1873
        "-*--17-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1874
        "-*--18-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1875
        "-*--19-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1876
        "-*--20-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1877
        "-*--24-*",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1878
        NULL};
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1879
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1880
    for (i=0; fontlist[i] != NULL && fontset==NULL; i++)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1881
        fontset = create_fontset_name(fontlist[i], False);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1882
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1883
    if (!fontset)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1884
        fprintf(stdout, "Cannot load fonts for IMF.\n");
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1885
    return  fontset;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1886
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1887
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1888
static Window get_current_focus(XIC ic) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1889
    Window w = 0;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1890
    if (ic != NULL)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1891
        XGetICValues(ic, XNFocusWindow, &w, NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1892
    return w;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1893
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
Java_sun_awt_X11_XInputMethod_openXIMNative(JNIEnv *env,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1897
                                            jobject this,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1898
                                            jlong display)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
    Bool registered;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1904
    dpy = (Display *)jlong_to_ptr(display);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1906
    if (X11im == NULL) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1907
        X11im = XOpenIM(dpy, NULL, NULL, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
Java_sun_awt_X11_XInputMethod_createXICNative(JNIEnv *env,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1917
                                              jobject this,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1918
                                              jlong window)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
    X11InputMethodData *pX11IMData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
    jobject globalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
    XIC ic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1926
    if (!window) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
        JNU_ThrowNullPointerException(env, "NullPointerException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
    pX11IMData = (X11InputMethodData *) calloc(1, sizeof(X11InputMethodData));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
    if (pX11IMData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
        THROW_OUT_OF_MEMORY_ERROR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
    globalRef = (*env)->NewGlobalRef(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
    pX11IMData->x11inputmethod = globalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
    pX11IMData->statusWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1943
    setX11InputMethodData(env, this, pX11IMData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1945
    if (createXIC(env, pX11IMData, (Window)window) == False) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
        destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
        pX11IMData = (X11InputMethodData *) NULL;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1948
        setX11InputMethodData(env, this, pX11IMData);
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1949
        if ((*env)->ExceptionCheck(env)) {
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1950
            goto finally;
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1951
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
24130
db72fc72f87b 8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings
pchelko
parents: 18135
diff changeset
  1954
finally:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
    return (pX11IMData != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env,
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1961
                                                jobject this,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1962
                                                jlong w,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1963
                                                jboolean req,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1964
                                                jboolean active)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
    X11InputMethodData *pX11IMData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
    pX11IMData = getX11InputMethodData(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
    if (pX11IMData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
    if (req) {
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1975
        if (!w) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
        }
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1979
        pX11IMData->isActiveClient = active;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
        pX11IMData->current_ic = active ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
                        pX11IMData->ic_active : pX11IMData->ic_passive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
         * On Solaris2.6, setXICWindowFocus() has to be invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
         * before setting focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
         */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1986
        get_current_focus(pX11IMData->current_ic); /* workaround for kinput2 and SCIM */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1987
        if (currentFocusWindow != w) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1988
            setXICWindowFocus(pX11IMData->current_ic, w);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1989
            setXICFocus(pX11IMData->current_ic, req);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1990
            currentX11InputMethodInstance = pX11IMData->x11inputmethod;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1991
            currentFocusWindow =  w;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1992
        } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1993
            setXICFocus(pX11IMData->current_ic, req);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1994
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1995
        if ((active || pX11IMData->passiveStatusWindow)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  1996
            && (pX11IMData->statusWindow && pX11IMData->statusWindow->on))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
            onoffStatusWindow(pX11IMData, w, True);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
        currentX11InputMethodInstance = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
        currentFocusWindow = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
        onoffStatusWindow(pX11IMData, 0, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
        if (pX11IMData->current_ic != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
        setXICFocus(pX11IMData->current_ic, req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        pX11IMData->current_ic = (XIC)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
    XFlush(dpy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2012
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2013
 * Class:     sun_awt_X11InputMethodBase
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2014
 * Method:    initIDs
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2015
 * Signature: ()V
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2016
 * This function gets called from the static initializer for
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2017
 * X11InputMethod.java to initialize the fieldIDs for fields
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2018
 * that may be accessed from C
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2019
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2020
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_initIDs
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2021
  (JNIEnv *env, jclass cls)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
{
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2023
    x11InputMethodIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2024
}
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2025
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2026
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2027
 * Class:     sun_awt_X11InputMethodBase
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2028
 * Method:    turnoffStatusWindow
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2029
 * Signature: ()V
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2030
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2031
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_turnoffStatusWindow
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2032
  (JNIEnv *env, jobject this)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2033
{
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
    X11InputMethodData *pX11IMData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
    StatusWindow *statusWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
    if (NULL == currentX11InputMethodInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
        || NULL == (pX11IMData = getX11InputMethodData(env,currentX11InputMethodInstance))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
        || NULL == (statusWindow = pX11IMData->statusWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
        || !statusWindow->on ){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
    onoffStatusWindow(pX11IMData, 0, False);
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2047
    statusWindow->on = False;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2052
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2053
 * Class:     sun_awt_X11InputMethodBase
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2054
 * Method:    disposeXIC
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2055
 * Signature: ()V
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2056
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2057
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_disposeXIC
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2058
  (JNIEnv *env, jobject this)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
    X11InputMethodData *pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
    pX11IMData = getX11InputMethodData(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
    if (pX11IMData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
    setX11InputMethodData(env, this, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
    if (pX11IMData->x11inputmethod == currentX11InputMethodInstance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
        currentX11InputMethodInstance = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
        currentFocusWindow = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
    destroyX11InputMethodData(env, pX11IMData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2079
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2080
 * Class:     sun_awt_X11InputMethodBase
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2081
 * Method:    resetXIC
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2082
 * Signature: ()Ljava/lang/String;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2083
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2084
JNIEXPORT jstring JNICALL Java_sun_awt_X11InputMethodBase_resetXIC
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2085
  (JNIEnv *env, jobject this)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
    X11InputMethodData *pX11IMData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
    char *xText = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
    jstring jText = (jstring)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
    pX11IMData = getX11InputMethodData(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
    if (pX11IMData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
        return jText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2098
    if (pX11IMData->current_ic) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2099
        if (!isPreeditStateActive(pX11IMData->current_ic)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2100
            xText = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2101
        } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2102
            if (!(pX11IMData->forceReset))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2103
                setXICFocus(pX11IMData->current_ic, FALSE);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2104
            xText = XmbResetIC(pX11IMData->current_ic);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2105
            if (!(pX11IMData->forceReset))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2106
                setXICFocus(pX11IMData->current_ic, TRUE);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2107
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2108
    } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
         * If there is no reference to the current XIC, try to reset both XICs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
         */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2112
        if (!isPreeditStateActive(pX11IMData->ic_active))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2113
            xText = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2114
        else
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
        xText = XmbResetIC(pX11IMData->ic_active);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
        /*it may also means that the real client component does
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
          not have focus -- has been deactivated... its xic should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
          not have the focus, bug#4284651 showes reset XIC for htt
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
          may bring the focus back, so de-focus it again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
        setXICFocus(pX11IMData->ic_active, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
        if (pX11IMData->ic_active != pX11IMData->ic_passive) {
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2123
            char *tmpText;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2124
            if (!isPreeditStateActive(pX11IMData->ic_passive))
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2125
                tmpText = NULL;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2126
            else
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2127
                tmpText = XmbResetIC(pX11IMData->ic_passive);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
            setXICFocus(pX11IMData->ic_passive, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
            if (xText == (char *)NULL && tmpText)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
                xText = tmpText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
    if (xText != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
        jText = JNU_NewStringPlatform(env, (const char *)xText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
        XFree((void *)xText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2138
    /* workaround
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2139
     * Some IME do not call PreeditDoneCallback routine even
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2140
     * when XmbResetIC is called. I force to reset the preedit string.
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2141
     */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2142
    if (!pX11IMData->isActiveClient) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2143
        resetPassivePreeditText(pX11IMData->statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2144
        shrink_status(pX11IMData->statusWindow);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2145
    } else {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2146
        JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2147
                             "clearComposedText",
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2148
                             "()V");
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2149
        if ((*env)->ExceptionOccurred(env)) {
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2150
            (*env)->ExceptionDescribe(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2151
            (*env)->ExceptionClear(env);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2152
        }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2153
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2154
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
    return jText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
/*
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2160
 * Class:     sun_awt_X11InputMethodBase
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
 * Method:    setCompositionEnabledNative
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2162
 * Signature: (Z)Z
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
 * This method tries to set the XNPreeditState attribute associated with the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
 * XIC to the passed in 'enable' state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
 * Return JNI_TRUE if XNPreeditState attribute is successfully changed to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
 * 'enable' state; Otherwise, if XSetICValues fails to set this attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
 * java.lang.UnsupportedOperationException will be thrown. JNI_FALSE is returned if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
 * method fails due to other reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
 */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2172
JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_setCompositionEnabledNative
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
  (JNIEnv *env, jobject this, jboolean enable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
    X11InputMethodData *pX11IMData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
    char * ret = NULL;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2177
    XVaNestedList pr_atrb;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
    pX11IMData = getX11InputMethodData(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
    if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2187
    pr_atrb = XVaCreateNestedList(0, XNPreeditState,
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2188
                  (enable ? XIMPreeditEnable : XIMPreeditDisable), NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2189
    ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2190
    XFree((void *)pr_atrb);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2193
    if ((ret != 0) &&
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2194
        ((strcmp(ret, XNPreeditAttributes) == 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2195
         || (strcmp(ret, XNPreeditState) == 0))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
    return (jboolean)(ret == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
/*
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2203
 * Class:     sun_awt_X11InputMethodBase
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
 * Method:    isCompositionEnabledNative
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2205
 * Signature: ()Z
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
 * This method tries to get the XNPreeditState attribute associated with the current XIC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
 * Return JNI_TRUE if the XNPreeditState is successfully retrieved. Otherwise, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
 * XGetICValues fails to get this attribute, java.lang.UnsupportedOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
 * will be thrown. JNI_FALSE is returned if this method fails due to other reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
 */
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2213
JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledNative
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
  (JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
    X11InputMethodData *pX11IMData = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
    char * ret = NULL;
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2218
    XIMPreeditState state = XIMPreeditUnKnown;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2219
    XVaNestedList   pr_atrb;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
    pX11IMData = getX11InputMethodData(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
    if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2229
    pr_atrb = XVaCreateNestedList(0, XNPreeditState, &state, NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2230
    ret = XGetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2231
    XFree((void *)pr_atrb);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2234
    if ((ret != 0) &&
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2235
        ((strcmp(ret, XNPreeditAttributes) == 0)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2236
         || (strcmp(ret, XNPreeditState) == 0))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
    return (jboolean)(state == XIMPreeditEnable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
  (JNIEnv *env, jobject this, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
{
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2247
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
}
50350
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2249
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2250
/*
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2251
 * Class:     sun_awt_X11InputMethod
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2252
 * Method:    setStatusAreaVisible
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2253
 * Signature: (ZJ)V
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2254
 */
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2255
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethod_setStatusAreaVisible
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2256
  (JNIEnv *env, jobject this, jboolean value, jlong data)
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2257
{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2258
    X11InputMethodData *pX11IMData;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2259
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2260
    pX11IMData = getX11InputMethodData(env, this);
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2261
    if (NULL == pX11IMData) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2262
    if (NULL == pX11IMData->statusWindow) return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2263
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2264
    if ((int)value){
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2265
        pX11IMData->statusWindow->on = True;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2266
    }else{
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2267
        pX11IMData->statusWindow->on = False;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2268
    }
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2269
    return;
668463f93ec0 8201429: Support AIX Input Method Editor (IME) for AWT Input Method Framework (IMF)
clanger
parents: 47216
diff changeset
  2270
}