#include "qdebug.h"
#include "qximinputcontext_p.h"
#include "qplatformdefs.h"
#include "qapplication.h"
#include "qwidget.h"
#include "qstring.h"
#include "qlist.h"
#include "qtextcodec.h"
#include "qevent.h"
#include "qtextformat.h"
#include "qx11info_x11.h"
#include <stdlib.h>
#include <limits.h>
Include dependency graph for qximinputcontext_x11.cpp:

Go to the source code of this file.
Defines | |
| #define | XIM_DEBUG if (0) qDebug |
Functions | |
| static int | xic_start_callback (XIC, XPointer client_data, XPointer) |
| static int | xic_draw_callback (XIC, XPointer client_data, XPointer call_data) |
| static int | xic_done_callback (XIC, XPointer client_data, XPointer) |
| static XFontSet | getFontSet (const QFont &f) |
Variables | |
| XIMStyle | qt_xim_preferred_style |
| char * | qt_ximServer |
| int | qt_ximComposingKeycode |
| QTextCodec * | qt_input_mapper |
| static const XIMStyle | xim_default_style = XIMPreeditCallbacks | XIMStatusNothing |
| static XFontSet | fontsetCache [8] = { 0, 0, 0, 0, 0, 0, 0, 0 } |
| static int | fontsetRefCount = 0 |
| static const char *const | fontsetnames [] |
| #define XIM_DEBUG if (0) qDebug |
Definition at line 64 of file qximinputcontext_x11.cpp.
Referenced by QXIMInputContext::mouseHandler(), xic_done_callback(), xic_draw_callback(), and xic_start_callback().
| static XFontSet getFontSet | ( | const QFont & | f | ) | [static] |
Definition at line 291 of file qximinputcontext_x11.cpp.
References QFont::bold(), fontsetCache, fontsetnames, i, QFont::italic(), QFont::pointSize(), and X11.
Referenced by QXIMInputContext::createICData(), and QXIMInputContext::update().
00292 { 00293 int i = 0; 00294 if (f.italic()) 00295 i |= 1; 00296 if (f.bold()) 00297 i |= 2; 00298 00299 if (f.pointSize() > 20) 00300 i += 4; 00301 00302 if (!fontsetCache[i]) { 00303 Display* dpy = X11->display; 00304 int missCount; 00305 char** missList; 00306 fontsetCache[i] = XCreateFontSet(dpy, fontsetnames[i], &missList, &missCount, 0); 00307 if(missCount > 0) 00308 XFreeStringList(missList); 00309 if (!fontsetCache[i]) { 00310 fontsetCache[i] = XCreateFontSet(dpy, "-*-fixed-*-*-*-*-16-*", &missList, &missCount, 0); 00311 if(missCount > 0) 00312 XFreeStringList(missList); 00313 if (!fontsetCache[i]) 00314 fontsetCache[i] = (XFontSet)-1; 00315 } 00316 } 00317 return (fontsetCache[i] == (XFontSet)-1) ? 0 : fontsetCache[i]; 00318 }
Here is the call graph for this function:

Definition at line 250 of file qximinputcontext_x11.cpp.
References XIM_DEBUG.
Referenced by QXIMInputContext::createICData().
00250 { 00251 QXIMInputContext *qic = (QXIMInputContext *) client_data; 00252 if (!qic) 00253 return 0; 00254 00255 XIM_DEBUG("xic_done_callback"); 00256 // Don't send InputMethodEnd here. QXIMInputContext::x11FilterEvent() 00257 // handles InputMethodEnd with commit string. 00258 return 0; 00259 }
Definition at line 121 of file qximinputcontext_x11.cpp.
References QInputMethodEvent::Cursor, data, QString::fromLocal8Bit(), QXIMInputContext::icData(), l, NULL, QInputContext::PreeditFormat, qMin(), s, QInputContext::SelectionFormat, QInputContext::sendEvent(), QInputContext::standardFormat(), QInputMethodEvent::TextFormat, x, and XIM_DEBUG.
Referenced by QXIMInputContext::createICData().
00121 { 00122 QXIMInputContext *qic = (QXIMInputContext *) client_data; 00123 if (!qic) { 00124 XIM_DEBUG("xic_draw_callback: no qic"); 00125 return 0; 00126 } 00127 QXIMInputContext::ICData *data = qic->icData(); 00128 if (!data) { 00129 XIM_DEBUG("xic_draw_callback: no ic data"); 00130 return 0; 00131 } 00132 XIM_DEBUG("xic_draw_callback"); 00133 00134 00135 if(!data->composing) { 00136 data->clear(); 00137 data->composing = true; 00138 } 00139 00140 XIMPreeditDrawCallbackStruct *drawstruct = (XIMPreeditDrawCallbackStruct *) call_data; 00141 XIMText *text = (XIMText *) drawstruct->text; 00142 int cursor = drawstruct->caret, sellen = 0, selstart = 0; 00143 00144 if (!drawstruct->caret && !drawstruct->chg_first && !drawstruct->chg_length && !text) { 00145 if(data->text.isEmpty()) { 00146 XIM_DEBUG("compose emptied"); 00147 // if the composition string has been emptied, we need 00148 // to send an InputMethodEnd event 00149 QInputMethodEvent e; 00150 qic->sendEvent(e); 00151 data->clear(); 00152 00153 // if the commit string has coming after here, InputMethodStart 00154 // will be sent dynamically 00155 } 00156 return 0; 00157 } 00158 00159 if (text) { 00160 char *str = 0; 00161 if (text->encoding_is_wchar) { 00162 int l = wcstombs(NULL, text->string.wide_char, text->length); 00163 if (l != -1) { 00164 str = new char[l + 1]; 00165 wcstombs(str, text->string.wide_char, l); 00166 str[l] = 0; 00167 } 00168 } else 00169 str = text->string.multi_byte; 00170 00171 if (!str) 00172 return 0; 00173 00174 QString s = QString::fromLocal8Bit(str); 00175 00176 if (text->encoding_is_wchar) 00177 delete [] str; 00178 00179 if (drawstruct->chg_length < 0) 00180 data->text.replace(drawstruct->chg_first, INT_MAX, s); 00181 else 00182 data->text.replace(drawstruct->chg_first, drawstruct->chg_length, s); 00183 00184 if (data->selectedChars.size() < data->text.length()) { 00185 // expand the selectedChars array if the compose string is longer 00186 int from = data->selectedChars.size(); 00187 data->selectedChars.resize(data->text.length()); 00188 for (int x = from; x < data->selectedChars.size(); ++x) 00189 data->selectedChars.clearBit(x); 00190 } 00191 00192 // determine if the changed chars are selected based on text->feedback 00193 for (int x = 0; x < text->length; ++x) 00194 data->selectedChars.setBit(x + drawstruct->chg_first, 00195 (text->feedback ? (text->feedback[x] & XIMReverse) : 0)); 00196 00197 // figure out where the selection starts, and how long it is 00198 bool started = false; 00199 for (int x = 0; x < qMin(data->selectedChars.size(), data->text.length()); ++x) { 00200 if (started) { 00201 if (data->selectedChars.testBit(x)) ++sellen; 00202 else break; 00203 } else { 00204 if (data->selectedChars.testBit(x)) { 00205 selstart = x; 00206 started = true; 00207 sellen = 1; 00208 } 00209 } 00210 } 00211 } else { 00212 if (drawstruct->chg_length == 0) 00213 drawstruct->chg_length = -1; 00214 00215 data->text.remove(drawstruct->chg_first, drawstruct->chg_length); 00216 bool qt_compose_emptied = data->text.isEmpty(); 00217 if (qt_compose_emptied) { 00218 XIM_DEBUG("compose emptied 2 text=%s", data->text.toUtf8().constData()); 00219 // if the composition string has been emptied, we need 00220 // to send an InputMethodEnd event 00221 QInputMethodEvent e; 00222 qic->sendEvent(e); 00223 data->clear(); 00224 // if the commit string has coming after here, InputMethodStart 00225 // will be sent dynamically 00226 return 0; 00227 } 00228 } 00229 00230 XIM_DEBUG("sending compose: '%s', cursor=%d, sellen=%d", 00231 data->text.toUtf8().constData(), cursor, sellen); 00232 QList<QInputMethodEvent::Attribute> attrs; 00233 if (selstart > 0) 00234 attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, selstart, 00235 qic->standardFormat(QInputContext::PreeditFormat)); 00236 if (sellen) 00237 attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, selstart, sellen, 00238 qic->standardFormat(QInputContext::SelectionFormat)); 00239 if (selstart + sellen < data->text.length()) 00240 attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 00241 selstart + sellen, data->text.length() - selstart - sellen, 00242 qic->standardFormat(QInputContext::PreeditFormat)); 00243 attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, sellen ? 0 : 1, QVariant()); 00244 QInputMethodEvent e(data->text, attrs); 00245 qic->sendEvent(e); 00246 00247 return 0; 00248 }
Here is the call graph for this function:

Definition at line 102 of file qximinputcontext_x11.cpp.
References data, QXIMInputContext::icData(), and XIM_DEBUG.
Referenced by QXIMInputContext::createICData().
00102 { 00103 QXIMInputContext *qic = (QXIMInputContext *) client_data; 00104 if (!qic) { 00105 XIM_DEBUG("xic_start_callback: no qic"); 00106 return 0; 00107 } 00108 QXIMInputContext::ICData *data = qic->icData(); 00109 if (!data) { 00110 XIM_DEBUG("xic_start_callback: no ic data"); 00111 return 0; 00112 } 00113 XIM_DEBUG("xic_start_callback"); 00114 00115 data->clear(); 00116 data->composing = true; 00117 00118 return 0; 00119 }
Here is the call graph for this function:

XFontSet fontsetCache[8] = { 0, 0, 0, 0, 0, 0, 0, 0 } [static] |
Definition at line 277 of file qximinputcontext_x11.cpp.
Referenced by QXIMInputContext::close_xim(), and getFontSet().
const char* const fontsetnames[] [static] |
Initial value:
{
"-*-fixed-medium-r-*-*-16-*,-*-*-medium-r-*-*-16-*",
"-*-fixed-medium-i-*-*-16-*,-*-*-medium-i-*-*-16-*",
"-*-fixed-bold-r-*-*-16-*,-*-*-bold-r-*-*-16-*",
"-*-fixed-bold-i-*-*-16-*,-*-*-bold-i-*-*-16-*",
"-*-fixed-medium-r-*-*-24-*,-*-*-medium-r-*-*-24-*",
"-*-fixed-medium-i-*-*-24-*,-*-*-medium-i-*-*-24-*",
"-*-fixed-bold-r-*-*-24-*,-*-*-bold-r-*-*-24-*",
"-*-fixed-bold-i-*-*-24-*,-*-*-bold-i-*-*-24-*"
}
Definition at line 280 of file qximinputcontext_x11.cpp.
Referenced by getFontSet().
int fontsetRefCount = 0 [static] |
Definition at line 278 of file qximinputcontext_x11.cpp.
Referenced by QXIMInputContext::close_xim(), and QXIMInputContext::create_xim().
Definition at line 334 of file qapplication_x11.cpp.
Referenced by qt_set_input_encoding(), translateKeySym(), and QXIMInputContext::x11FilterEvent().
| XIMStyle qt_xim_preferred_style |
Referenced by QXIMInputContext::create_xim(), and QXIMInputContext::QXIMInputContext().
Definition at line 333 of file qapplication_x11.cpp.
Referenced by QKeyMapperPrivate::translateKeyEventInternal(), and QXIMInputContext::x11FilterEvent().
| char* qt_ximServer |
Definition at line 257 of file qapplication_x11.cpp.
Referenced by QXIMInputContext::QXIMInputContext().
const XIMStyle xim_default_style = XIMPreeditCallbacks | XIMStatusNothing [static] |
Definition at line 76 of file qximinputcontext_x11.cpp.
Referenced by QXIMInputContext::QXIMInputContext().
1.5.1