From 0a316695e88299dfbcfa88c1f07786581e1cfb0f Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 7 Jul 2007 01:59:38 +0000 Subject: save workspace names, and some fixes for menu behavior --- src/FbTk/Menu.cc | 28 +++++++++++++++------------- src/FbTk/Menu.hh | 3 +-- src/Screen.cc | 8 ++++++++ src/Screen.hh | 2 ++ src/Workspace.cc | 2 +- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index cf735d6..8f795ac 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -356,13 +356,6 @@ void Menu::enterSubmenu() { submenu->cycleItems(false); } -void Menu::enterParent() { - internal_hide(); - // return focus to parent - if (parent()) - parent()->grabInputFocus(); -} - void Menu::disableTitle() { setTitleVisibility(false); } @@ -583,11 +576,11 @@ void Menu::redrawFrame(FbDrawable &drawable) { } -void Menu::internal_hide() { +void Menu::internal_hide(bool first) { if (validIndex(m_which_sub)) { MenuItem *tmp = menuitems[m_which_sub]; - tmp->submenu()->internal_hide(); + tmp->submenu()->internal_hide(false); } // if we have an active index we need to redraw it @@ -596,12 +589,20 @@ void Menu::internal_hide() { m_active_index = -1; clearItem(old); // clear old area from highlight - if (shown && shown->menu.window == menu.window) - shown = (Menu *) 0; + if (shown && shown->menu.window == menu.window) { + if (m_parent && m_parent->isVisible()) + shown = m_parent; + else + shown = (Menu *) 0; + } m_torn = m_visible = false; m_which_sub = -1; + if (first && m_parent && m_parent->isVisible() && + s_focused && !s_focused->isVisible()) + m_parent->grabInputFocus(); + menu.window.hide(); } @@ -1023,7 +1024,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { break; case XK_Left: // enter parent if we have one resetTypeAhead(); - enterParent(); + internal_hide(); break; case XK_Right: // enter submenu if we have one resetTypeAhead(); @@ -1031,11 +1032,12 @@ void Menu::keyPressEvent(XKeyEvent &event) { break; case XK_Escape: // close menu m_type_ahead.reset(); + m_torn = false; hide(); break; case XK_BackSpace: if (m_type_ahead.stringSize() == 0) { - enterParent(); + internal_hide(); break; } diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 20562de..8d112ca 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -92,7 +92,6 @@ public: /// cycle through menuitems void cycleItems(bool reverse); void enterSubmenu(); - void enterParent(); void disableTitle(); void enableTitle(); @@ -192,7 +191,7 @@ protected: virtual void redrawTitle(FbDrawable &pm); virtual void redrawFrame(FbDrawable &pm); - virtual void internal_hide(); + virtual void internal_hide(bool first = true); virtual void update(FbTk::Subject *); diff --git a/src/Screen.cc b/src/Screen.cc index 4d3944c..9a7d433 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1106,6 +1106,14 @@ void BScreen::rereadMenu() { m_rootmenu->reconfigure(); } +void BScreen::updateWorkspaceName(unsigned int w) { + Workspace *space = getWorkspace(w); + if (space) { + m_workspace_names[w] = space->name(); + updateWorkspaceNamesAtom(); + Fluxbox::instance()->save_rc(); + } +} void BScreen::removeWorkspaceNames() { m_workspace_names.clear(); diff --git a/src/Screen.hh b/src/Screen.hh index 9e5b7a8..91dcf15 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -355,6 +355,8 @@ public: */ void leftWorkspace(int delta); + /// update workspace name for given workspace + void updateWorkspaceName(unsigned int w); /// remove all workspace names void removeWorkspaceNames(); /// update the workspace name atom diff --git a/src/Workspace.cc b/src/Workspace.cc index a52a211..2933ab5 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -182,7 +182,7 @@ void Workspace::setName(const string &name) { m_name = tname; } - screen().updateWorkspaceNamesAtom(); + screen().updateWorkspaceName(m_id); menu().setLabel(m_name); menu().updateMenu(); -- cgit v0.11.2