summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforminputcontexts/compose
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-10 09:01:47 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-10 21:10:09 +0000
commitd11665b27ce3357fb30bff6ffc1379a4756ec8d1 (patch)
treee9b4dbb1e38ef7081166eda38634f9eda2d91368 /src/plugins/platforminputcontexts/compose
parent1aab68648d3aa38811be38b5bbd3a0704e17ccf8 (diff)
Speed up application startup on X11
Avoid parsing the composition tables on application startup. Instead let's do that on-demand the first time a composition key is pressed. Change-Id: I52feb36246a091b9a84d46e479ba2ad1f5cd1556 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins/platforminputcontexts/compose')
-rw-r--r--src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp32
-rw-r--r--src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h1
2 files changed, 19 insertions, 14 deletions
diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
index 49fa32004e..d1bea9af23 100644
--- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
@@ -80,37 +80,32 @@ static const int composingKeys[] = {
};
QComposeInputContext::QComposeInputContext()
+ : m_tableState(TableGenerator::EmptyTable)
+ , m_compositionTableInitialized(false)
{
- TableGenerator reader;
- m_tableState = reader.tableState();
-
- if ((m_tableState & TableGenerator::NoErrors) == TableGenerator::NoErrors) {
- m_composeTable = reader.composeTable();
- clearComposeBuffer();
- }
+ clearComposeBuffer();
}
bool QComposeInputContext::filterEvent(const QEvent *event)
{
- // if there were errors when generating the compose table input
- // context should not try to filter anything, simply return false
- if ((m_tableState & TableGenerator::NoErrors) != TableGenerator::NoErrors)
- return false;
-
const QKeyEvent *keyEvent = (const QKeyEvent *)event;
// should pass only the key presses
if (keyEvent->type() != QEvent::KeyPress) {
return false;
}
+ // if there were errors when generating the compose table input
+ // context should not try to filter anything, simply return false
+ if (m_compositionTableInitialized && (m_tableState & TableGenerator::NoErrors) != TableGenerator::NoErrors)
+ return false;
+
int keyval = keyEvent->key();
int keysym = 0;
if (ignoreKey(keyval))
return false;
- QString text = keyEvent->text();
- if (!composeKey(keyval) && text.isEmpty())
+ if (!composeKey(keyval) && keyEvent->text().isEmpty())
return false;
keysym = keyEvent->nativeVirtualKey();
@@ -163,6 +158,15 @@ static bool isDuplicate(const QComposeTableElement &lhs, const QComposeTableElem
bool QComposeInputContext::checkComposeTable()
{
+ if (!m_compositionTableInitialized) {
+ TableGenerator reader;
+ m_tableState = reader.tableState();
+
+ if ((m_tableState & TableGenerator::NoErrors) == TableGenerator::NoErrors)
+ m_composeTable = reader.composeTable();
+
+ m_compositionTableInitialized = true;
+ }
QVector<QComposeTableElement>::const_iterator it =
std::lower_bound(m_composeTable.constBegin(), m_composeTable.constEnd(), m_composeBuffer, Compare());
diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h
index 643b93c32d..bdf5a91335 100644
--- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h
@@ -70,6 +70,7 @@ private:
QVector<QComposeTableElement> m_composeTable;
uint m_composeBuffer[QT_KEYSEQUENCE_MAX_LEN + 1];
TableGenerator::TableState m_tableState;
+ bool m_compositionTableInitialized;
};
QT_END_NAMESPACE