aboutsummaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc27
1 files changed, 19 insertions, 8 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 @@
1// IconButton.cc 1// IconButton.cc
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2003 - 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net) 3// and Simon Bowden (rathnor at users.sourceforge.net)
4// 4//
5// Permission is hereby granted, free of charge, to any person obtaining a 5// Permission is hereby granted, free of charge, to any person obtaining a
@@ -20,18 +20,23 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: IconButton.cc,v 1.13 2003/11/27 14:27:48 fluxgen Exp $ 23// $Id: IconButton.cc,v 1.14 2004/01/11 16:08:07 fluxgen Exp $
24 24
25#include "IconButton.hh" 25#include "IconButton.hh"
26 26
27#include "FbTk/App.hh"
28#include "FbTk/EventManager.hh"
29 27
30#include "fluxbox.hh" 28#include "fluxbox.hh"
31#include "Screen.hh" 29#include "Screen.hh"
32#include "Window.hh" 30#include "Window.hh"
33#include "WinClient.hh" 31#include "WinClient.hh"
34#include "SimpleCommand.hh" 32
33#include "FbTk/SimpleCommand.hh"
34#include "FbTk/App.hh"
35#include "FbTk/EventManager.hh"
36#include "FbTk/MacroCommand.hh"
37#include "FbTk/Command.hh"
38#include "FbTk/RefCount.hh"
39
35 40
36#ifdef HAVE_CONFIG_H 41#ifdef HAVE_CONFIG_H
37#include "config.h" 42#include "config.h"
@@ -48,6 +53,7 @@ class ShowMenu: public FbTk::Command {
48public: 53public:
49 explicit ShowMenu(FluxboxWindow &win):m_win(win) { } 54 explicit ShowMenu(FluxboxWindow &win):m_win(win) { }
50 void execute() { 55 void execute() {
56 m_win.screen().hideMenus();
51 // get last button pos 57 // get last button pos
52 const XEvent &event = Fluxbox::instance()->lastEvent(); 58 const XEvent &event = Fluxbox::instance()->lastEvent();
53 int x = event.xbutton.x_root - (m_win.menu().width() / 2); 59 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,
70 m_use_pixmap(true) { 76 m_use_pixmap(true) {
71 77
72 FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus)); 78 FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus));
73 FbTk::RefCount<FbTk::Command> menu(new ::ShowMenu(m_win)); 79 FbTk::RefCount<FbTk::Command> hidemenus(new FbTk::SimpleCommand<BScreen>(win.screen(), &BScreen::hideMenus));
74 setOnClick(focus, 1); 80 FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand();
75 setOnClick(menu, 3); 81 focus_macro->add(hidemenus);
82 focus_macro->add(focus);
83 FbTk::RefCount<FbTk::Command> focus_cmd(focus_macro);
84 FbTk::RefCount<FbTk::Command> menu_cmd(new ::ShowMenu(m_win));
85 setOnClick(focus_cmd, 1);
86 setOnClick(menu_cmd, 3);
76 m_win.hintSig().attach(this); 87 m_win.hintSig().attach(this);
77 88
78 FbTk::EventManager::instance()->add(*this, m_icon_window); 89 FbTk::EventManager::instance()->add(*this, m_icon_window);