diff options
author | fluxgen <fluxgen> | 2003-08-24 16:24:19 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-24 16:24:19 (GMT) |
commit | 67898ededb895bc7027a0517b009f546d57936ed (patch) | |
tree | 36e782aed1c35fc617873ee05e09972362856233 /src | |
parent | 6610e1c2101e42f351cf592987bc892a0c72c896 (diff) | |
download | fluxbox_pavel-67898ededb895bc7027a0517b009f546d57936ed.zip fluxbox_pavel-67898ededb895bc7027a0517b009f546d57936ed.tar.bz2 |
fixed menu
Diffstat (limited to 'src')
-rw-r--r-- | src/IconButton.cc | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc index a1e8cf0..1ca20b7 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc | |||
@@ -20,13 +20,15 @@ | |||
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.6 2003/08/19 16:13:25 fluxgen Exp $ | 23 | // $Id: IconButton.cc,v 1.7 2003/08/24 16:24:19 fluxgen Exp $ |
24 | 24 | ||
25 | #include "IconButton.hh" | 25 | #include "IconButton.hh" |
26 | 26 | ||
27 | #include "FbTk/App.hh" | 27 | #include "FbTk/App.hh" |
28 | #include "FbTk/EventManager.hh" | 28 | #include "FbTk/EventManager.hh" |
29 | 29 | ||
30 | #include "fluxbox.hh" | ||
31 | #include "Screen.hh" | ||
30 | #include "Window.hh" | 32 | #include "Window.hh" |
31 | #include "WinClient.hh" | 33 | #include "WinClient.hh" |
32 | #include "SimpleCommand.hh" | 34 | #include "SimpleCommand.hh" |
@@ -40,6 +42,36 @@ | |||
40 | #include <X11/extensions/shape.h> | 42 | #include <X11/extensions/shape.h> |
41 | #endif // SHAPE | 43 | #endif // SHAPE |
42 | 44 | ||
45 | namespace { | ||
46 | |||
47 | class ShowMenu: public FbTk::Command { | ||
48 | public: | ||
49 | explicit ShowMenu(FluxboxWindow &win):m_win(win) { } | ||
50 | void execute() { | ||
51 | // get last button pos | ||
52 | const XEvent &event = Fluxbox::instance()->lastEvent(); | ||
53 | int x = event.xbutton.x_root - (m_win.menu().width() / 2); | ||
54 | int y = event.xbutton.y_root - (m_win.menu().height() / 2); | ||
55 | |||
56 | if (x < 0) | ||
57 | x = 0; | ||
58 | else if (x + m_win.menu().width() > m_win.screen().width()) | ||
59 | x = m_win.screen().width() - m_win.menu().width(); | ||
60 | |||
61 | if (y < 0) | ||
62 | y = 0; | ||
63 | else if (y + m_win.menu().height() > m_win.screen().height()) | ||
64 | y = m_win.screen().height() - m_win.menu().height(); | ||
65 | |||
66 | m_win.menu().move(x, y); | ||
67 | m_win.menu().show(); | ||
68 | } | ||
69 | private: | ||
70 | FluxboxWindow &m_win; | ||
71 | }; | ||
72 | |||
73 | } // end anonymous namespace | ||
74 | |||
43 | IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, | 75 | IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, |
44 | FluxboxWindow &win): | 76 | FluxboxWindow &win): |
45 | FbTk::TextButton(parent, font, win.winClient().title()), | 77 | FbTk::TextButton(parent, font, win.winClient().title()), |
@@ -48,8 +80,9 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, | |||
48 | ExposureMask | ButtonPressMask | ButtonReleaseMask) { | 80 | ExposureMask | ButtonPressMask | ButtonReleaseMask) { |
49 | 81 | ||
50 | FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus)); | 82 | FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus)); |
51 | setOnClick(focus); | 83 | FbTk::RefCount<FbTk::Command> menu(new ::ShowMenu(m_win)); |
52 | 84 | setOnClick(focus, 1); | |
85 | setOnClick(menu, 3); | ||
53 | m_win.hintSig().attach(this); | 86 | m_win.hintSig().attach(this); |
54 | 87 | ||
55 | FbTk::EventManager::instance()->add(*this, m_icon_window); | 88 | FbTk::EventManager::instance()->add(*this, m_icon_window); |