aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/dialog.cpp9
-rw-r--r--gui/gui-manager.cpp26
-rw-r--r--gui/gui-manager.h2
3 files changed, 20 insertions, 17 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 2ec8641257..9f18baec9e 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -75,7 +75,6 @@ int Dialog::runModal() {
}
void Dialog::open() {
-
_result = 0;
_visible = true;
g_gui.openDialog(this);
@@ -87,6 +86,10 @@ void Dialog::open() {
}
setFocusWidget(w);
+#ifdef ENABLE_KEYMAPPER
+ g_gui.initKeymap();
+ g_gui.pushKeymap();
+#endif
}
void Dialog::close() {
@@ -98,6 +101,10 @@ void Dialog::close() {
}
releaseFocus();
g_gui.closeTopDialog();
+#ifdef ENABLE_KEYMAPPER
+ g_gui.popKeymap();
+#endif
+
}
void Dialog::reflowLayout() {
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 212d68430c..0910d06fb2 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -107,11 +107,11 @@ void GuiManager::initKeymap() {
Keymapper *mapper = _system->getEventManager()->getKeymapper();
// Do not try to recreate same keymap over again
- if (mapper->getKeymap("gui", tmp) != 0)
+ if (mapper->getKeymap(kGuiKeymapName, tmp) != 0)
return;
Action *act;
- Keymap *guiMap = new Keymap("gui");
+ Keymap *guiMap = new Keymap(kGuiKeymapName);
act = new Action(guiMap, "CLOS", _("Close"), kGenericActionType, kStartKeyType);
act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
@@ -127,6 +127,14 @@ void GuiManager::initKeymap() {
mapper->addGlobalKeymap(guiMap);
}
+
+void GuiManager::pushKeymap() {
+ _system->getEventManager()->getKeymapper()->pushKeymap(Common::kGuiKeymapName);
+}
+
+void GuiManager::popKeymap() {
+ _system->getEventManager()->getKeymapper()->popKeymap();
+}
#endif
bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx, bool forced) {
@@ -270,16 +278,6 @@ void GuiManager::runLoop() {
uint32 lastRedraw = 0;
const uint32 waitTime = 1000 / 45;
-#ifdef ENABLE_KEYMAPPER
- // Due to circular reference with event manager and GUI
- // we cannot init keymap on the GUI creation. Thus, let's
- // try to do it on every launch, checking whether the
- // map is already existing
- initKeymap();
-
- eventMan->getKeymapper()->pushKeymap("gui");
-#endif
-
bool tooltipCheck = false;
while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
@@ -391,10 +389,6 @@ void GuiManager::runLoop() {
_system->delayMillis(10);
}
-#ifdef ENABLE_KEYMAPPER
- eventMan->getKeymapper()->popKeymap();
-#endif
-
if (didSaveState) {
_theme->disable();
restoreState();
diff --git a/gui/gui-manager.h b/gui/gui-manager.h
index 10f9e6a29f..addd2e6611 100644
--- a/gui/gui-manager.h
+++ b/gui/gui-manager.h
@@ -126,6 +126,8 @@ protected:
byte _cursor[2048];
void initKeymap();
+ void pushKeymap();
+ void popKeymap();
void saveState();
void restoreState();