1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/* vim:set noet ts=4: */
/*
* ibus - The Input Bus
*
* Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
#ifndef __IBUS_CLIENT_H_
#define __IBUS_CLIENT_H_
#include <QObject>
#include <QList>
#include <QHash>
#include <QInputContext>
#include <QFileSystemWatcher>
#include <QDBusMessage>
class QDBusConnection;
class IBusInputContext;
class IBusClient : public QObject {
Q_OBJECT
public:
IBusClient ();
~IBusClient ();
public:
#ifndef Q_WS_X11
bool filterEvent (IBusInputContext *ctx, const QEvent *event);
#endif
bool isComposing (IBusInputContext const *ctx);
void mouseHandler (IBusInputContext *ctx, int x, QMouseEvent *event);
void widgetDestroyed (IBusInputContext *ctx, QWidget *widget);
#ifdef Q_WS_X11
bool x11FilterEvent (IBusInputContext *ctx, QWidget *keywidget, XEvent *xevent);
#endif
public:
QInputContext *createInputContext ();
void releaseInputContext (IBusInputContext *ctx);
void setCursorLocation (IBusInputContext *ctx, QRect &rect);
void focusIn (IBusInputContext *ctx);
void focusOut (IBusInputContext *ctx);
void reset (IBusInputContext *ctx);
void setCapabilities (IBusInputContext *ctx, int caps);
private slots:
void slotDirectoryChanged (const QString &path);
// void slotFileChanged (const QString &path);
void slotIBusDisconnected ();
void slotCommitString (QString ic, QString text);
// void slotUpdatePreedit (QString ic, QString text, QVariant attrs, int cursor_pos, bool show);
void slotUpdatePreedit (QDBusMessage message);
void slotShowPreedit (QDBusMessage message);
void slotHidePreedit (QDBusMessage message);
private:
bool connectToBus ();
void disconnectFromBus ();
QString createInputContextRemote ();
void findYenBarKeys ();
QDBusConnection *ibus;
QFileSystemWatcher watcher;
QList <IBusInputContext *> context_list;
QHash <QString, IBusInputContext *>context_dict;
QString username;
QString session;
QString ibus_path;
QString ibus_addr;
/* hack japan keyboard */
unsigned int japan_groups;
QVector <unsigned int> japan_yen_bar_keys;
};
#endif // __IBUS_CLIENT_H_
|