From 5e9b6453f0d71c64f18e8082d53f9a42e2b3ae66 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 3 Dec 2003 00:33:30 +0000 Subject: removed ToolbarHandler --- src/Makefile.am | 2 +- src/Toolbar.cc | 42 ++++++++++++++++++++++++------------------ src/Toolbar.hh | 9 +++++---- src/fluxbox.cc | 20 ++++++++++++++++---- src/fluxbox.hh | 5 ++++- 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 92f0626..a468961 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,7 +60,7 @@ REGEXP_SOURCE = RegExp.hh RegExp.cc ClientPattern.hh ClientPattern.cc endif endif if TOOLBAR_SRC -TOOLBAR_SOURCE = Toolbar.hh Toolbar.cc ToolbarHandler.hh ToolbarHandler.cc \ +TOOLBAR_SOURCE = Toolbar.hh Toolbar.cc \ ToolbarTheme.hh ToolbarTheme.cc ToolbarItem.hh ToolbarItem.cc \ ClockTool.hh ClockTool.cc \ WorkspaceNameTool.hh WorkspaceNameTool.cc WorkspaceNameTheme.hh \ diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 9b76ed6..23aab97 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.126 2003/10/31 10:37:09 rathnor Exp $ +// $Id: Toolbar.cc,v 1.127 2003/12/03 00:32:13 fluxgen Exp $ #include "Toolbar.hh" @@ -186,21 +186,23 @@ Toolbar::Frame::~Frame() { evm.remove(window); } -Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t width): +Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): m_hidden(false), frame(*this, scrn.screenNumber()), m_window_pm(0), m_screen(scrn), - m_toolbarmenu(menu), - m_placementmenu(*scrn.menuTheme(), - scrn.screenNumber(), scrn.imageControl(), - *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), m_layermenu(*scrn.menuTheme(), scrn.screenNumber(), scrn.imageControl(), *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), this, true), + m_placementmenu(*scrn.menuTheme(), + scrn.screenNumber(), scrn.imageControl(), + *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + m_toolbarmenu(*scrn.menuTheme(), + scrn.screenNumber(), scrn.imageControl(), + *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), m_theme(scrn.screenNumber()), m_layeritem(frame.window, layer), m_tool_factory(scrn), @@ -270,6 +272,10 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi Toolbar::~Toolbar() { FbTk::EventManager::instance()->remove(window()); + // remove menu items before we delete tools so we dont end up + // with dangling pointers to old submenu items (internal menus) + // from the tools + menu().removeAll(); deleteItems(); clearStrut(); @@ -445,7 +451,7 @@ void Toolbar::reconfigure() { rearrangeItems(); - m_toolbarmenu.reconfigure(); + menu().reconfigure(); // we're done with all resizing and stuff now we can request a new // area to be reserved on screen updateStrut(); @@ -458,26 +464,26 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) { if (be.button != 3) return; - if (! m_toolbarmenu.isVisible()) { + if (! menu().isVisible()) { int x, y; - x = be.x_root - (m_toolbarmenu.width() / 2); - y = be.y_root - (m_toolbarmenu.height() / 2); + x = be.x_root - (menu().width() / 2); + y = be.y_root - (menu().height() / 2); if (x < 0) x = 0; - else if (x + m_toolbarmenu.width() > screen().width()) - x = screen().width() - m_toolbarmenu.width(); + else if (x + menu().width() > screen().width()) + x = screen().width() - menu().width(); if (y < 0) y = 0; - else if (y + m_toolbarmenu.height() > screen().height()) - y = screen().height() - m_toolbarmenu.height(); + else if (y + menu().height() > screen().height()) + y = screen().height() - menu().height(); - m_toolbarmenu.move(x, y); - m_toolbarmenu.show(); + menu().move(x, y); + menu().show(); } else - m_toolbarmenu.hide(); + menu().hide(); } @@ -512,7 +518,7 @@ void Toolbar::leaveNotifyEvent(XCrossingEvent ¬_used) { if (isHidden()) { if (m_hide_timer.isTiming()) m_hide_timer.stop(); - } else if (! m_toolbarmenu.isVisible() && ! m_hide_timer.isTiming()) + } else if (! menu().isVisible() && ! m_hide_timer.isTiming()) m_hide_timer.start(); } diff --git a/src/Toolbar.hh b/src/Toolbar.hh index 3fa042f..a25077c 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.hh,v 1.48 2003/10/13 23:49:12 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.49 2003/12/03 00:31:40 fluxgen Exp $ #ifndef TOOLBAR_HH #define TOOLBAR_HH @@ -71,7 +71,7 @@ public: }; /// Create a toolbar on the screen with specific width - Toolbar(BScreen &screen, FbTk::XLayer &layer, FbTk::Menu &menu, size_t width = 200); + Toolbar(BScreen &screen, FbTk::XLayer &layer, size_t width = 200); virtual ~Toolbar(); @@ -162,9 +162,10 @@ private: BScreen &m_screen; ///< screen connection FbTk::Timer m_hide_timer; ///< timer to for auto hide toolbar - FbTk::Menu &m_toolbarmenu; - FbMenu m_placementmenu; + LayerMenu m_layermenu; + FbMenu m_placementmenu, m_toolbarmenu; + // themes ToolbarTheme m_theme; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 7b6f0b8..e63a121 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.201 2003/10/28 02:17:03 rathnor Exp $ +// $Id: fluxbox.cc,v 1.202 2003/12/03 00:30:22 fluxgen Exp $ #include "fluxbox.hh" @@ -68,7 +68,8 @@ #endif // REMEMBER #ifdef USE_TOOLBAR #include "Toolbar.hh" -#include "ToolbarHandler.hh" +#else +class Toolbar { }; #endif // USE_TOOLBAR // X headers @@ -552,7 +553,8 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile m_screen_list.push_back(screen); #ifdef USE_TOOLBAR - m_atomhandler.push_back(new ToolbarHandler(*screen)); + m_toolbars.push_back(new Toolbar(*screen, + *screen->layerManager().getLayer(Fluxbox::instance()->getNormalLayer()))); #endif // USE_TOOLBAR // attach screen signals to this @@ -565,9 +567,12 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile for (size_t atomh=0; atomhinitForScreen(*screen); } + revertFocus(*screen, false); // make sure focus style is correct - } + } // end init screens + + m_keyscreen = m_mousescreen = m_screen_list.front(); if (m_screen_list.size() == 0) { @@ -605,12 +610,19 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile Fluxbox::~Fluxbox() { + // destroy toolbars + while (!m_toolbars.empty()) { + delete m_toolbars.back(); + m_toolbars.pop_back(); + } + // destroy atomhandlers while (!m_atomhandler.empty()) { delete m_atomhandler.back(); m_atomhandler.pop_back(); } + clearMenuFilenames(); } diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 5fc01e0..fe20625 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.74 2003/10/05 06:28:47 rathnor Exp $ +// $Id: fluxbox.hh,v 1.75 2003/12/03 00:29:39 fluxgen Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH @@ -65,6 +65,7 @@ class WinClient; class Keys; class BScreen; class FbAtoms; +class Toolbar; /// main class for the window manager. @@ -310,6 +311,8 @@ private: static Fluxbox::Titlebar s_titlebar_left[], s_titlebar_right[]; static Fluxbox *s_singleton; std::vector m_atomhandler; + std::vector m_toolbars; + bool m_starting; bool m_shutdown; int m_server_grabs; -- cgit v0.11.2