From bccb185cd9e4efd1db2e5244ba1a1956f750f9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Mon, 25 Jul 2016 17:47:42 +0200 Subject: reconfigTheme's on loading a new style Also reconfigure menus (recursively) on style load The most critical call is the shape update - the menus often become cut-off, preventing mouse interaction with lower items, but also colors are not applied correctly to menus w/o updating them. BUG 1022 is most likely this and only a misinterpretation (for the mentioned items are those with lacking color updates on style updates) BUG: 1146 BUG: 1017 CCBUG: 1022 --- src/FbCommands.cc | 1 + src/Screen.hh | 1 + src/fluxbox.cc | 30 ++++++++++++++++++++++++++++++ src/fluxbox.hh | 1 + 4 files changed, 33 insertions(+) diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 89b8eaf..bc4b1e9 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -250,6 +250,7 @@ SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) { void SetStyleCmd::execute() { if (FbTk::ThemeManager::instance().load(m_filename, Fluxbox::instance()->getStyleOverlayFilename())) { + Fluxbox::instance()->reconfigThemes(); Fluxbox::instance()->saveStyleFilename(m_filename.c_str()); Fluxbox::instance()->save_rc(); } diff --git a/src/Screen.hh b/src/Screen.hh index 1aeac91..ae279f3 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -248,6 +248,7 @@ public: FbTk::ThemeProxy &menuTheme() { return *m_menutheme.get(); } const FbTk::ThemeProxy &menuTheme() const { return *m_menutheme.get(); } const FbTk::ThemeProxy &rootTheme() const { return *m_root_theme.get(); } + FbTk::ThemeProxy &rootTheme() { return *m_root_theme.get(); } FbTk::ThemeProxy &focusedWinButtonTheme() { return *m_focused_winbutton_theme.get(); } const FbTk::ThemeProxy &focusedWinButtonTheme() const { return *m_focused_winbutton_theme.get(); } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 492b64d..3907d29 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -56,6 +56,7 @@ #include "FbTk/Compose.hh" #include "FbTk/KeyUtil.hh" #include "FbTk/MemFun.hh" +#include "FbTk/MenuItem.hh" #ifdef USE_EWMH #include "Ewmh.hh" @@ -1261,6 +1262,35 @@ void Fluxbox::reconfigure() { m_reconfig_timer.start(); } +// TODO: once c++11 is required, make this a local var and a closure +static std::list s_seenMenus; +static void rec_reconfigMenu(FbTk::Menu *menu) { + if (!menu || std::find(s_seenMenus.begin(), s_seenMenus.end(), menu) != s_seenMenus.end()) + return; + s_seenMenus.push_back(menu); + menu->reconfigure(); + for (size_t i = 0; i < menu->numberOfItems(); ++i) + rec_reconfigMenu(menu->find(i)->submenu()); +} + + +void Fluxbox::reconfigThemes() { + for (ScreenList::iterator it = m_screens.begin(), end = m_screens.end(); it != end; ++it) { + (*it)->focusedWinFrameTheme()->reconfigTheme(); + (*it)->unfocusedWinFrameTheme()->reconfigTheme(); + (*it)->menuTheme()->reconfigTheme(); + (*it)->rootTheme()->reconfigTheme(); + (*it)->focusedWinButtonTheme()->reconfigTheme(); + (*it)->unfocusedWinButtonTheme()->reconfigTheme(); + (*it)->pressedWinButtonTheme()->reconfigTheme(); + + rec_reconfigMenu(&(*it)->rootMenu()); + rec_reconfigMenu(&(*it)->configMenu()); + rec_reconfigMenu(&(*it)->windowMenu()); + rec_reconfigMenu(&(*it)->workspaceMenu()); + s_seenMenus.clear(); + } +} void Fluxbox::real_reconfigure() { diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 2d2e670..86c3103 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -151,6 +151,7 @@ public: void removeGroupSearch(Window win); void restart(const char *command = 0); void reconfigure(); + void reconfigThemes(); /// todo, remove this. just temporary void updateFrameExtents(FluxboxWindow &win); -- cgit v0.11.2