56 #include "qplatformdefs.h" 60 #if !defined(QT_NO_IM) 64 #if !defined(QT_NO_XIM) 67 #include "qplatformdefs.h" 85 #define XIM_DEBUG qDebug 87 #define XIM_DEBUG if (0) qDebug 104 static void xim_create_callback(XIM ,
113 static void xim_destroy_callback(XIM ,
121 (XIMProc) xim_create_callback, reinterpret_cast<char *>(qic));
123 #endif // USE_X11R6_XIM 133 XIM_DEBUG(
"xic_start_callback: no ic data");
152 XIM_DEBUG(
"xic_draw_callback: no ic data");
163 XIMPreeditDrawCallbackStruct *drawstruct = (XIMPreeditDrawCallbackStruct *) call_data;
164 XIMText *
text = (XIMText *) drawstruct->text;
165 int cursor = drawstruct->caret, sellen = 0, selstart = 0;
167 if (!drawstruct->caret && !drawstruct->chg_first && !drawstruct->chg_length && !text) {
184 if (text->encoding_is_wchar) {
185 int l = wcstombs(NULL, text->string.wide_char, text->length);
187 str =
new char[l + 1];
188 wcstombs(str, text->string.wide_char, l);
192 str = text->string.multi_byte;
199 if (text->encoding_is_wchar)
202 if (drawstruct->chg_length < 0)
205 data->
text.
replace(drawstruct->chg_first, drawstruct->chg_length, s);
216 for (
int x = 0; x < text->length; ++x)
218 (text->feedback ? (text->feedback[x] & XIMReverse) : 0));
221 bool started =
false;
235 if (drawstruct->chg_length == 0)
236 drawstruct->chg_length = -1;
238 data->
text.
remove(drawstruct->chg_first, drawstruct->chg_length);
240 if (qt_compose_emptied) {
253 XIM_DEBUG(
"sending compose: '%s', cursor=%d, sellen=%d",
262 if (selstart + sellen < data->text.length())
264 selstart + sellen, data->
text.
length() - selstart - sellen,
297 return ximData.value(w->effectiveWinId());
308 "-*-fixed-medium-r-*-*-16-*,-*-*-medium-r-*-*-16-*",
309 "-*-fixed-medium-i-*-*-16-*,-*-*-medium-i-*-*-16-*",
310 "-*-fixed-bold-r-*-*-16-*,-*-*-bold-r-*-*-16-*",
311 "-*-fixed-bold-i-*-*-16-*,-*-*-bold-i-*-*-16-*",
312 "-*-fixed-medium-r-*-*-24-*,-*-*-medium-r-*-*-24-*",
313 "-*-fixed-medium-i-*-*-24-*,-*-*-medium-i-*-*-24-*",
314 "-*-fixed-bold-r-*-*-24-*,-*-*-bold-r-*-*-24-*",
315 "-*-fixed-bold-i-*-*-24-*,-*-*-bold-i-*-*-24-*" 335 XFreeStringList(missList);
337 fontsetCache[i] = XCreateFontSet(dpy,
"-*-fixed-*-*-*-*-16-*", &missList, &missCount, 0);
339 XFreeStringList(missList);
364 if (!XSupportsLocale())
366 qWarning(
"Qt: Locale not supported on X server")
370 else if (XSetLocaleModifiers (ximServerName.
constData()) == 0)
374 (XIMProc) xim_create_callback, reinterpret_cast<char *>(
this));
375 #else // !USE_X11R6_XIM 376 else if (XSetLocaleModifiers (
"") == 0)
377 qWarning(
"Qt: Cannot set locale modifiers");
380 #endif // USE_X11R6_XIM 390 ulong bytesAfter = 0;
393 false, XA_STRING, &type, &format, &nitems, &bytesAfter, &data) ==
Success 394 && type == XA_STRING && format == 8 && nitems > 2) {
396 char *names[5] = { 0, 0, 0, 0, 0 };
397 char *p =
reinterpret_cast<char *
>(
data), *
end = p + nitems;
406 for (
int i = 0; i <
qMin(layoutNames.
count(), variantNames.
count()); ++i ) {
408 const int dashPos = variantName.
indexOf(
"-");
432 xim = XOpenIM(
X11->display, 0, 0, 0);
437 destroy.callback = (XIMProc) xim_destroy_callback;
438 destroy.client_data =
XPointer(
this);
440 qWarning(
"Xlib doesn't support destroy callback");
441 #endif // USE_X11R6_XIM 443 XIMStyles *styles = 0;
444 XGetIMValues(
xim, XNQueryInputStyle, &styles, (
char *) 0, (
char *) 0);
447 for (i = 0; !
xim_style && i < styles->count_styles; i++) {
455 for (i = 0; !
xim_style && i < styles->count_styles; i++) {
456 if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) {
457 xim_style = XIMPreeditNothing | XIMStatusNothing;
462 for (i = 0; !
xim_style && i < styles->count_styles; i++) {
463 if (styles->supported_styles[i] == (XIMPreeditNone |
465 xim_style = XIMPreeditNone | XIMStatusNone;
471 XFree((
char *)styles);
478 (XIMProc) xim_create_callback, reinterpret_cast<char *>(
this));
479 #endif // USE_X11R6_XIM 494 for (
int i = 0; i < list.
size(); ++i) {
496 w->d->createTLSysExtra();
501 qWarning(
"No supported input style found." 502 " See InputMethod documentation.");
515 e =
ximData.constEnd(); i != e; ++i) {
518 XDestroyIC(data->
ic);
525 for (
int i = 0; i < 8; i++ ) {
584 char *mb = XmbResetIC(data->
ic);
608 XDestroyIC(data->
ic);
617 XIM_DEBUG(
"QXIMInputContext::mouseHandler pos=%d", pos);
653 if (data && data->
ic)
654 XUnsetICFocus(data->
ic);
667 XSetICFocus(data->
ic);
675 int xkey_keycode =
event->xkey.keycode;
685 if (event->type !=
XKeyPress || event->xkey.keycode != 0)
701 int count = XmbLookupString(data->
ic, &event->xkey,
string.data(),
string.size(),
704 if (status == XBufferOverflow) {
706 count = XmbLookupString(data->
ic, &event->xkey,
string.data(),
string.size(),
711 text = qt_input_mapper->
toUnicode(
string.constData() , count);
743 XVaNestedList preedit_attr = 0;
744 XIMCallback startcallback, drawcallback, donecallback;
753 rect.width = w->
width();
754 rect.height = w->
height();
756 preedit_attr = XVaCreateNestedList(0,
760 }
else if (
xim_style & XIMPreeditPosition) {
765 preedit_attr = XVaCreateNestedList(0,
766 XNSpotLocation, &spot,
769 }
else if (
xim_style & XIMPreeditCallbacks) {
770 startcallback.client_data = (
XPointer)
this;
772 drawcallback.client_data = (
XPointer)
this;
774 donecallback.client_data = (
XPointer)
this;
777 preedit_attr = XVaCreateNestedList(0,
778 XNPreeditStartCallback, &startcallback,
779 XNPreeditDrawCallback, &drawcallback,
780 XNPreeditDoneCallback, &donecallback,
785 data->
ic = XCreateIC(
xim,
788 XNPreeditAttributes, preedit_attr,
792 data->
ic = XCreateIC(
xim,
800 (void) XSetICValues(data->
ic, XNResetState, XIMPreserveState, (
char *) 0);
816 if (!data || !data->
ic)
833 area.width = r.
width();
842 XVaNestedList preedit_attr;
844 preedit_attr = XVaCreateNestedList(0,
845 XNSpotLocation, &spot,
850 preedit_attr = XVaCreateNestedList(0,
851 XNSpotLocation, &spot,
855 XSetICValues(data->
ic, XNPreeditAttributes, preedit_attr, (
char *) 0);
The QVariant class acts like a union for the most common Qt data types.
void clear()
Clears the contents of the bit array and makes it empty.
Qt::LayoutDirection textDirection() const
Returns the text direction of the language.
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
void truncate(int pos)
Truncates the byte array at index position pos.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void setBit(int i)
Sets the bit at index position i to 1.
static const char *const fontsetnames[]
#define QT_END_NAMESPACE
This macro expands to.
Bool XRegisterIMInstantiateCallback(Display *, struct _XrmHashBucketRec *, char *, char *, XIMProc, XPointer)
XIMStyle qt_xim_preferred_style
void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
void mouseHandler(int x, QMouseEvent *event)
This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.
static int xic_start_callback(XIC, XPointer client_data, XPointer)
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
static LibLoadStatus status
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
QByteArray & prepend(char c)
Prepends the character ch to this byte array.
int height() const
Returns the height of the rectangle.
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName)
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
bool qt_use_rtl_extensions
static const XIMStyle xim_default_style
static int xic_draw_callback(XIC, XPointer client_data, XPointer call_data)
static XFontSet fontsetCache[8]
bool x11FilterEvent(QWidget *keywidget, XEvent *event)
This function may be overridden only if input method is depending on X11 and you need raw XEvent...
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual void widgetDestroyed(QWidget *w)
This virtual function is called when the specified widget is destroyed.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QTextCodec * qt_input_mapper
QTextFormat standardFormat(StandardFormat s) const
Returns a QTextFormat object that specifies the format for component s.
const T & at(int i) const
Returns the item at index position i in the list.
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
QString language()
This function must be implemented in any subclasses to return a language code (e. ...
void resize(int size)
Resizes the bit array to size bits.
Q_CORE_EXPORT void qWarning(const char *,...)
void widgetDestroyed(QWidget *w)
This virtual function is called when the specified widget is destroyed.
static const char * data(const QByteArray &arr)
ICData * createICData(QWidget *w)
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
virtual QFont font() const
Returns the font of the current input widget.
bool isComposing() const
This function indicates whether InputMethodStart event had been sent to the current focus widget...
The QMouseEvent class contains parameters that describe a mouse event.
void resize(int size)
Sets the size of the string to size characters.
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
bool bold() const
Returns true if weight() is a value greater than QFont::Normal ; otherwise returns false...
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
uint qstrlen(const char *str)
int right() const
Returns the x-coordinate of the rectangle's right edge.
QHash< WId, ICData * > ximData
The QFont class specifies a font used for drawing text.
int y() const
Returns the y-coordinate of the rectangle's top edge.
static int fontsetRefCount
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.
int x() const
Returns the x-coordinate of the rectangle's left edge.
The QPoint class defines a point in the plane using integer precision.
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of items in the list.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
int y() const
Returns the y coordinate of this point.
static int xic_done_callback(XIC, XPointer client_data, XPointer)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
bool italic() const
Returns true if the style() of the font is not QFont::StyleNormal.
int pointSize() const
Returns the point size of the font.
int x() const
Returns the x coordinate of this point.
static XFontSet getFontSet(const QFont &f)
void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
The QTextCodec class provides conversions between text encodings.
QString identifierName()
This function must be implemented in any subclasses to return the identifier name of the input method...
static const KeyPair *const end
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
void update()
This virtual function is called when a state in the focus widget has changed.
Type type() const
Returns the event type.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
int size() const
Returns the number of bits stored in the bit array.
void clearBit(int i)
Sets the bit at index position i to 0.
int qt_ximComposingKeycode
Bool XUnregisterIMInstantiateCallback(Display *, struct _XrmHashBucketRec *, char *, char *, XIMProc, XPointer)
static int area(const QSize &s)
static XIMStyle xim_style