Make sure the remapping keycode is reset to NoSymbol.

Previously the dtor of AutoTypePlatformX11 wasn't called.
This commit is contained in:
Felix Geyer 2013-12-01 23:32:53 +01:00
parent 23f338b0c3
commit 2a416d1f1d
5 changed files with 41 additions and 9 deletions

View File

@ -57,11 +57,16 @@ AutoType::AutoType(QObject* parent, bool test)
if (!pluginPath.isEmpty()) {
loadPlugin(pluginPath);
}
connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin()));
}
AutoType::~AutoType()
{
delete m_executor;
if (m_executor) {
delete m_executor;
m_executor = Q_NULLPTR;
}
}
void AutoType::loadPlugin(const QString& pluginPath)
@ -215,6 +220,19 @@ void AutoType::resetInAutoType()
m_inAutoType = false;
}
void AutoType::unloadPlugin()
{
if (m_executor) {
delete m_executor;
m_executor = Q_NULLPTR;
}
if (m_plugin) {
m_plugin->unload();
m_plugin = Q_NULLPTR;
}
}
bool AutoType::registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers)
{
Q_ASSERT(key);

View File

@ -59,6 +59,7 @@ Q_SIGNALS:
private Q_SLOTS:
void performAutoTypeFromGlobal(Entry* entry, const QString& sequence);
void resetInAutoType();
void unloadPlugin();
private:
explicit AutoType(QObject* parent = Q_NULLPTR, bool test = false);

View File

@ -33,6 +33,7 @@ public:
virtual void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) = 0;
virtual int platformEventFilter(void* event) = 0;
virtual int initialTimeout() = 0;
virtual void unload() {}
virtual AutoTypeExecutor* createExecutor() = 0;

View File

@ -49,16 +49,26 @@ AutoTypePlatformX11::AutoTypePlatformX11()
m_specialCharacterKeycode = 0;
m_modifierMask = ControlMask | ShiftMask | Mod1Mask | Mod4Mask;
m_loaded = true;
updateKeymap();
}
/*
* Restore the KeyboardMapping to its original state.
*/
AutoTypePlatformX11::~AutoTypePlatformX11() {
void AutoTypePlatformX11::unload()
{
// Restore the KeyboardMapping to its original state.
AddKeysym(NoSymbol);
}
if (m_keysymTable) {
XFree(m_keysymTable);
}
if (m_xkb) {
XkbFreeKeyboard(m_xkb, XkbAllComponentsMask, True);
}
m_loaded = false;
}
QStringList AutoTypePlatformX11::windowTitles()
{
@ -168,13 +178,14 @@ int AutoTypePlatformX11::platformEventFilter(void* event)
&& m_currentGlobalKey
&& xevent->xkey.keycode == m_currentGlobalKeycode
&& (xevent->xkey.state & m_modifierMask) == m_currentGlobalNativeModifiers
&& !QApplication::focusWidget()) {
&& !QApplication::focusWidget()
&& m_loaded) {
if (xevent->type == KeyPress) {
Q_EMIT globalShortcutTriggered();
}
return 1;
}
if (xevent->type == MappingNotify) {
if (xevent->type == MappingNotify && m_loaded) {
XRefreshKeyboardMapping(reinterpret_cast<XMappingEvent*>(xevent));
updateKeymap();
}

View File

@ -42,7 +42,7 @@ class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
public:
AutoTypePlatformX11();
~AutoTypePlatformX11();
void unload() Q_DECL_OVERRIDE;
QStringList windowTitles();
WId activeWindow();
QString activeWindowTitle();
@ -109,6 +109,7 @@ private:
/* dedicated 'special character' keycode */
int m_specialCharacterKeycode;
KeyCode m_modifier_keycode[N_MOD_INDICES];
bool m_loaded;
};
class AutoTypeExecturorX11 : public AutoTypeExecutor