close menus when they lose focus, instead of on [exec] commands
markt markt
3 files changed,
6 insertions(+),
12 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -1,6 +1,8 @@
(Format: Year/Month/Day) Changes for 1.0.1: *07/12/13: + * Close menus only when they lose focus (Mark) + MenuCreator.cc FbTk/Menu.cc * Moved command parsing code all over the place -- expect any patches that add new commands to be broken (Mark, Simon) Added FbTk/CommandRegistry.cc/hh
M
src/FbTk/Menu.cc
→
src/FbTk/Menu.cc
@@ -815,6 +815,8 @@ void Menu::handleEvent(XEvent &event) {
if (event.type == FocusOut) { if (s_focused == this) s_focused = 0; + if (shown == this && !m_torn) + hide(); // I don't know why, but I get a FocusIn event when closing the menu with // the mouse over it -- probably an xorg bug, but it's easy to address here } else if (event.type == FocusIn && m_visible) {
M
src/MenuCreator.cc
→
src/MenuCreator.cc
@@ -256,21 +256,11 @@ } else if (str_key == "exec") {
// execute and hide menu using namespace FbTk; RefCount<Command> exec_cmd(FbTk::CommandRegistry::instance().parseLine("exec " + str_cmd)); - RefCount<Command> hide_menu(FbTk::CommandRegistry::instance().parseLine("hidemenus")); - MacroCommand *exec_and_hide = new FbTk::MacroCommand(); - exec_and_hide->add(hide_menu); - exec_and_hide->add(exec_cmd); - RefCount<Command> exec_and_hide_cmd(exec_and_hide); - menu.insert(str_label, exec_and_hide_cmd); + menu.insert(str_label, exec_cmd); } else if (str_key == "macrocmd") { using namespace FbTk; RefCount<Command> macro_cmd(FbTk::CommandRegistry::instance().parseLine("macrocmd " + str_cmd)); - RefCount<Command> hide_menu(FbTk::CommandRegistry::instance().parseLine("hidemenus")); - MacroCommand *exec_and_hide = new FbTk::MacroCommand(); - exec_and_hide->add(hide_menu); - exec_and_hide->add(macro_cmd); - RefCount<Command> exec_and_hide_cmd(exec_and_hide); - menu.insert(str_label, exec_and_hide_cmd); + menu.insert(str_label, macro_cmd); } else if (str_key == "style") { // style menu.insert(new StyleMenuItem(str_label, str_cmd)); } else if (str_key == "config") {