[immodule-qt] Re: [SCIM] scim-qtimm 0.7 released

YamaKen yamaken at bp.iij4u.or.jp
Mon Sep 6 19:07:53 EEST 2004


Hi Kazuki, Cougar, thank you for the efforts.

I've not tracked the problem details, but I've found and fixed a
event compression bug which is possibly the source of the
problem. Try my patch in last of this mail, without any
postIMEvent() modification that uses sendEvent() (i.e. revert to
original code of unified patch 20040819).

In my opinion, mixture of postEvent() and sendEvent() may cause
complex problem and costs us boring development/maintaining
effort, as I said first. So I don't use sendEvent(). Consider
it.

http://freedesktop.org/pipermail/immodule-qt/2004-July/000058.html

In addition, QApplication::postIMEvent() is inappropriate place
to implement such functionality. The implementation violates
abstract event queue interface and prevents the possible change
of internal event queue implementation. Keep in mind following
issues to modify Qt.

- What is proper way?
- What is intention of author?
- Which part of code is responsible for the functionality?

At Mon, 6 Sep 2004 15:39:23 +0900,
mover at hct.zaq.ne.jp wrote:
> More refactored version is here.
> This code is based on the code of QApplication::notify.
> I think this code is more cleaner.
> 
> void QApplication::postIMEvent( QObject *receiver, QIMEvent *event )
> {
>     if( event->type() == QEvent::IMCompose )
>         postEvent( receiver, event );
>     else {
>         if (receiver->postedEvents) {
>             //get rid of IMCompose event posted before
>             QPostEventList * l = receiver->postedEvents;
>             QPostEvent * pe;
>             l->first();
>             while( ( pe = l->current()) != 0 ) {
>                 if ( pe->event && pe->receiver == receiver &&
>                     pe->event->type() == QEvent::IMCompose ) {
>                     pe->event->posted = FALSE;
>                     delete pe->event;
>                     pe->event = 0;
>                     l->remove();
>                     continue;
>                 }
>                 l->next();
>             }
>             sendEvent( receiver, event );
>             delete event;
>         }
>     }
> }
> 
> On Monday 06 September 2004 12:34, LiuCougar wrote:
> > On Mon, 6 Sep 2004 11:27:26 +0800, Zhe Su <james.su at gmail.com> wrote:
> > > Hi,
> > >   I just read though this new code, and found that there is no exit
> > > point in the for (;;) {...} loop. Is it correct?
> >
> > Oops, sorry about that, the rectified version is:
> > void QApplication::postIMEvent( QObject *receiver, QIMEvent *event )
> > {
> >     if( event->type() == QEvent::IMCompose )
> >         postEvent( receiver, event );
> >     else {
> >         QPostEventList * l = receiver->postedEvents;
> >
> >         //get rid of IMCompose event posted before
> >         if ( event->type() == QEvent::IMCompose ) {
> >             l->first();
> >             QPostEvent * cur = 0;
> >             for ( ;; ) {
> >                 while ( (cur=l->current()) != 0 &&
> >                         ( cur->receiver != receiver ||
> >                           cur->event == 0 ||
> >                           cur->event->type() != event->type() ) )
> >                     l->next();
> >                 if ( l->current() != 0 ) {
> >                     if ( cur->event->type() == QEvent::IMCompose ) {
> >                         delete cur->event;
> >                         l->remove(cur);
> >                     }
> >                 } else
> >                   break;
> >             }
> >         }
> >         sendEvent( receiver, event );
> >         delete event;
> >     }
> > }
> >
> > Thanks for correcting me ;)


Index: src/kernel/qapplication.cpp
===================================================================
--- src/kernel/qapplication.cpp	(revision 106)
+++ src/kernel/qapplication.cpp	(working copy)
@@ -3112,8 +3112,7 @@
 	 event->type() == QEvent::LayoutHint ||
 	 event->type() == QEvent::Resize ||
 	 event->type() == QEvent::Move ||
-	 event->type() == QEvent::LanguageChange ||
-	 event->type() == QEvent::IMCompose ) {
+	 event->type() == QEvent::LanguageChange ) {
 	l->first();
 	QPostEvent * cur = 0;
 	for ( ;; ) {
@@ -3147,6 +3146,29 @@
 		} else if ( cur->event->type() == QEvent::LanguageChange ) {
 		    delete event;
 		    return;
+		}
+	    }
+	    break;
+	};
+    }
+
+#if !defined(QT_NO_IM)
+    // if this is one of the compressible IM events, do compression
+    if ( event->type() == QEvent::IMCompose ) {
+	l->last();
+	QPostEvent * cur = 0;
+	for ( ;; ) {
+	    while ( (cur=l->current()) != 0 &&
+		    ( cur->receiver != receiver ||
+		      cur->event == 0 ||
+		      cur->event->type() != event->type() || 
+		      cur->event->type() != QEvent::IMStart ) )
+		l->prev();
+	    if ( l->current() != 0 ) {
+		// IMCompose must not be compressed with another one
+		// beyond its IMStart boundary
+		if ( cur->event->type() == QEvent::IMStart ) {
+		    break;
 		} else if ( cur->event->type() == QEvent::IMCompose ) {
 		    QIMComposeEvent * e = (QIMComposeEvent *)(cur->event);
 		    *e = *(QIMComposeEvent *)event;
@@ -3157,6 +3179,7 @@
 	    break;
 	};
     }
+#endif
 
     // if no compression could be done, just append something
     event->posted = TRUE;


-------------------------------
YamaKen  yamaken at bp.iij4u.or.jp



More information about the immodule-qt mailing list