From be2f29dee6e33ce53a1e6a243273d977dfcb4595 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 11 Jan 2004 16:08:57 +0000 Subject: hide menus on click --- src/IconButton.cc | 27 +++++++++++++++++++-------- src/Toolbar.cc | 6 ++++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/IconButton.cc b/src/IconButton.cc index 6c5e3e4..5733e2c 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -1,5 +1,5 @@ // IconButton.cc -// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) +// Copyright (c) 2003 - 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) // and Simon Bowden (rathnor at users.sourceforge.net) // // Permission is hereby granted, free of charge, to any person obtaining a @@ -20,18 +20,23 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconButton.cc,v 1.13 2003/11/27 14:27:48 fluxgen Exp $ +// $Id: IconButton.cc,v 1.14 2004/01/11 16:08:07 fluxgen Exp $ #include "IconButton.hh" -#include "FbTk/App.hh" -#include "FbTk/EventManager.hh" #include "fluxbox.hh" #include "Screen.hh" #include "Window.hh" #include "WinClient.hh" -#include "SimpleCommand.hh" + +#include "FbTk/SimpleCommand.hh" +#include "FbTk/App.hh" +#include "FbTk/EventManager.hh" +#include "FbTk/MacroCommand.hh" +#include "FbTk/Command.hh" +#include "FbTk/RefCount.hh" + #ifdef HAVE_CONFIG_H #include "config.h" @@ -48,6 +53,7 @@ class ShowMenu: public FbTk::Command { public: explicit ShowMenu(FluxboxWindow &win):m_win(win) { } void execute() { + m_win.screen().hideMenus(); // get last button pos const XEvent &event = Fluxbox::instance()->lastEvent(); int x = event.xbutton.x_root - (m_win.menu().width() / 2); @@ -70,9 +76,14 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, m_use_pixmap(true) { FbTk::RefCount focus(new FbTk::SimpleCommand(m_win, &FluxboxWindow::raiseAndFocus)); - FbTk::RefCount menu(new ::ShowMenu(m_win)); - setOnClick(focus, 1); - setOnClick(menu, 3); + FbTk::RefCount hidemenus(new FbTk::SimpleCommand(win.screen(), &BScreen::hideMenus)); + FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand(); + focus_macro->add(hidemenus); + focus_macro->add(focus); + FbTk::RefCount focus_cmd(focus_macro); + FbTk::RefCount menu_cmd(new ::ShowMenu(m_win)); + setOnClick(focus_cmd, 1); + setOnClick(menu_cmd, 3); m_win.hintSig().attach(this); FbTk::EventManager::instance()->add(*this, m_icon_window); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 732be39..e804aed 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -1,5 +1,5 @@ // Toolbar.cc for Fluxbox -// Copyright (c) 2002 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) +// Copyright (c) 2002 - 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // Toolbar.cc for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) @@ -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.134 2003/12/20 19:05:42 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.135 2004/01/11 16:08:57 fluxgen Exp $ #include "Toolbar.hh" @@ -471,6 +471,8 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) { if (be.button != 3) return; + screen().hideMenus(); + if (! menu().isVisible()) { int x, y; -- cgit v0.11.2