Revision: 6363
Author: nogu.dev
Date: Tue May  4 05:58:44 2010
Log: * qt4/chardict/qt4.cpp
  - (KUimCharDict::KUimCharDict, KUimCharDict::~KUimCharDict,
     KUimCharDict::slotCharSelected): Commit characters
    when they are selected. To commit them to an editing widget,
    we don't allow a window to receive input focus.
    We call XSetWMHints() to implement this behavior
    because Qt4 don't have a function similar to
    gtk_window_set_accept_focus() in GTK+ for now
    though Qt 4.7, which hasn't been released yet,
    will have QWidget::setAttribute(Qt::WA_X11DoNotAcceptFocus).
http://code.google.com/p/uim/source/detail?r=6363

Modified:
 /trunk/qt4/chardict/qt4.cpp

=======================================
--- /trunk/qt4/chardict/qt4.cpp Sun Apr  4 20:35:54 2010
+++ /trunk/qt4/chardict/qt4.cpp Tue May  4 05:58:44 2010
@@ -48,10 +48,21 @@
 #include <QtGui/QVBoxLayout>
 #include <QtGui/QStackedWidget>

+#ifdef Q_WS_X11
+#include <QtGui/QX11Info>
+
+#include <X11/Xutil.h>
+#endif
+
 #include <clocale>

+#include <uim/uim.h>
+#include <uim/uim-helper.h>
+
 #include "qtgettext.h"

+static int uim_fd = -1;
+
 int main( int argc, char *argv[] )
 {

@@ -91,14 +102,29 @@
 KUimCharDict::KUimCharDict( QWidget *parent )
         : QWidget( parent )
 {
+#ifdef Q_WS_X11
+    // Don't give input focus to this window.
+    XWMHints *wmhints = XGetWMHints( QX11Info::display(), winId() );
+    if ( !wmhints )
+        wmhints = XAllocWMHints();
+    wmhints->flags = InputHint;
+    wmhints->input = False;
+    XSetWMHints( QX11Info::display(), winId(), wmhints );
+    XFree( wmhints );
+#endif
+
     setupWidgets();

     readConfig();
+
+    uim_fd = uim_helper_init_client_fd( 0 );
 }

 KUimCharDict::~KUimCharDict()
 {
     writeConfig();
+
+    uim_helper_close_client_fd( uim_fd );
 }

 void KUimCharDict::setupWidgets()
@@ -219,4 +245,6 @@
 void KUimCharDict::slotCharSelected( const QString &c )
 {
     m_charLineEdit->setText( m_charLineEdit->text() + c );
-}
+    uim_helper_send_message( uim_fd,
+        ( "commit_string\n" + c + "\n" ).toUtf8().data() );
+}

Reply via email to