[immodule-qt] QInputContext Implementation

manish.s.sharma at nokia.com manish.s.sharma at nokia.com
Sun Aug 31 21:18:49 PDT 2008


Hi,

Thanks for the reply. Yeah you are right there should be some other
solution. I just saw some difference between x11 and windows
implementation of qapplication_x11.cpp and qapplication_win.cpp. If you
see qapplication_x11.cpp implementation you can find
QApplication::x11ProcessEvent have the required implementation to pass
the events to appropriate widget's inputcontext below is the code for
that:

int QApplication::x11ProcessEvent(XEvent* event)
{
.
.
.
.

#ifndef QT_NO_IM
    // Filtering input events by the input context. It has to be taken
    // place before any other key event consumers such as eventfilters
    // and accelerators because some input methods require quite
    // various key combination and sequences. It often conflicts with
    // accelerators and so on, so we must give the input context the
    // filtering opportunity first to ensure all input methods work
    // properly regardless of application design.

    if(keywidget && keywidget->isEnabled() &&
keywidget->testAttribute(Qt::WA_InputMethodEnabled)) {
        // block user interaction during session management
	if((event->type==XKeyPress || event->type==XKeyRelease) &&
qt_sm_blockUserInput)
	    return true;

        // for XIM handling
	QInputContext *qic = keywidget->inputContext();
	if(qic && qic->x11FilterEvent(keywidget, event))
	    return true;

	// filterEvent() accepts QEvent *event rather than preexpanded
	// key event attribute values. This is intended to pass other
	// QInputEvent in future. Other non IM-related events should
	// not be forwarded to input contexts to prevent weird event
	// handling.
	if ((event->type == XKeyPress || event->type == XKeyRelease)) {
	    int code = -1;
	    int count = 0;
	    Qt::KeyboardModifiers modifiers;
	    QEvent::Type type;
	    QString text;
            KeySym keySym;

            qt_keymapper_private()->translateKeyEventInternal(keywidget,
event, keySym, count,
                                                              text,
modifiers, code, type, false);

	    // both key press/release is required for some complex
	    // input methods. don't eliminate anything.
	    QKeyEventEx keyevent(type, code, modifiers, text, false,
qMax(qMax(count, 1), text.length()),
                                 event->xkey.keycode, keySym,
event->xkey.state);
	    if(qic && qic->filterEvent(&keyevent))
		return true;
	}
    } else
#endif // QT_NO_IM
        {
            if (XFilterEvent(event, XNone))
                return true;
        }




}




And similar implementation is not there in windows port
(qapplication_win.cpp). Just wondering is there anything wrong in
windows port. Or there is a different way to do the same. Please let me
know if you have some information on the same.

Thanks & Regards,
Manish







>-----Original Message-----
>From: ext Daisuke Kameda [mailto:kaminmat at cc.rim.or.jp] 
>Sent: Saturday, August 30, 2008 10:54 AM
>To: Sharma Manish.S (Nokia-D-MSW/Bangalore)
>Cc: immodule-qt at lists.freedesktop.org
>Subject: Re: [immodule-qt] QInputContext Implementation
>
>Hi,
>
>I'm sorry I was late to reply.
>
>manish.s.sharma at nokia.com wrote:
>> Hi,
>> 
>> Thanks for the reply.
>> My goal is to write a plugin for a text widget.
>> Plugin will do some kind of pre-processing on the key & 
>mouse presses 
>> on the text widget.
>[snip]
> > With above changes i am able to get the events in 
>filterEvent functions.
> > But i am not sure that whethere this is the correct 
>approach, if it is  > the correct approach then 
>QTextControlPrivate implementation is not  > complete. Please 
>correct me if I am wrong. If possible please explain me  > the 
>architecture.
>
>Did you read the Trolltech's document about Input Method?
>e.g. http://doc.trolltech.com/4.4/qinputcontext.html .
>
>QInputContext isn't plugin mechanism for text widget.
>And, QInputContext::filterEvent() is used in toplevel of 
>application, for example QApplication::x11ProcessEvent().
>
>QTextEdit and QLineEdit are also good sample about use case of 
>QInputContext in widget.
>
>I propose looking for another technical solution for the purpose.
>
>
>--
>Daisuke Kameda
>    Japan KDE Users' Group:  President
>      mailto:daisuke at kde.gr.jp  http://www.kde.gr.jp/~daisuke/
>    immodule for Qt Project:  Project Maintainer
>      http://www.freedesktop.org/wiki/Software_2fimmodule_2dqt
>    SMG Co., Ltd.:  Engineering Creator
>      mailto:kameda at smg.co.jp  http://www.smg.co.jp/
>      http://www.smg.co.jp/opensource/CommonDesktopInfrastructure/
>


More information about the immodule-qt mailing list