From d757c08e006dea8147d8219ea2e0ca1c84c9cf7e Mon Sep 17 00:00:00 2001 From: rathnor Date: Wed, 19 Nov 2003 12:57:27 +0000 Subject: some menu tweaking --- ChangeLog | 9 +++++++++ src/FbTk/Menu.cc | 13 +++++++------ src/IconButton.cc | 15 ++------------- src/Window.cc | 30 +++++++++++++++++++++--------- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27c64da..e54c639 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ (Format: Year/Month/Day) +Changes for 0.9.7: +*03/11/19: + * Fix menu draw bug for empty submenus (Simon) + Menu.cc + * Fix menu placement for iconbar and titlebar activation, including + xinerama awareness (Simon) + Window.cc IconButton.cc + * Fix win menu hide straight after show when right click icon (Simon) + Menu.cc Changes for 0.9.6: *03/11/16: * Fixed sstream and strstream header check (Henrik) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 8b4a91e..8b4ddd2 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.40 2003/11/01 00:12:53 rathnor Exp $ +// $Id: Menu.cc,v 1.41 2003/11/19 12:57:27 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -425,11 +425,12 @@ void Menu::update(int active_index) { if (! menu.width) menu.width = menu.item_w; menu.frame_h = (menu.item_h * menu.persub); - if (menu.frame_h < 1) - menu.frame_h = 1; + if (menu.frame_h < 0) + menu.frame_h = 0; - menu.height = (title_vis ? menu.title_h + menu.title.borderWidth() : 0) + - menu.frame_h; + menu.height = menu.frame_h; + if (title_vis) + menu.height += menu.title_h + ((menu.frame_h>0)?menu.title.borderWidth():0); if (menu.height < 1) menu.height = 1; @@ -554,7 +555,7 @@ void Menu::show() { raise(); visible = true; - if (! m_parent) { + if (! m_parent && shown != this) { if (shown && (! shown->torn)) shown->hide(); diff --git a/src/IconButton.cc b/src/IconButton.cc index bc0c9d5..20fca8a 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconButton.cc,v 1.11 2003/10/31 20:02:49 rathnor Exp $ +// $Id: IconButton.cc,v 1.12 2003/11/19 12:57:27 rathnor Exp $ #include "IconButton.hh" @@ -53,18 +53,7 @@ public: int x = event.xbutton.x_root - (m_win.menu().width() / 2); int y = event.xbutton.y_root - (m_win.menu().height() / 2); - if (x < 0) - x = 0; - else if (x + m_win.menu().width() > m_win.screen().width()) - x = m_win.screen().width() - m_win.menu().width(); - - if (y < 0) - y = 0; - else if (y + m_win.menu().height() > m_win.screen().height()) - y = m_win.screen().height() - m_win.menu().height(); - - m_win.menu().move(x, y); - m_win.menu().show(); + m_win.showMenu(x, y); } private: FluxboxWindow &m_win; diff --git a/src/Window.cc b/src/Window.cc index cce7d16..90d4b19 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.243 2003/10/28 02:17:02 rathnor Exp $ +// $Id: Window.cc,v 1.244 2003/11/19 12:57:27 rathnor Exp $ #include "Window.hh" @@ -1885,8 +1885,22 @@ void FluxboxWindow::restoreAttributes() { /** Show the window menu at pos mx, my */ -void FluxboxWindow::showMenu(int mx, int my) { - m_windowmenu.move(mx, my); +void FluxboxWindow::showMenu(int menu_x, int menu_y) { + // move menu directly under titlebar + + int head = screen().getHead(menu_x, menu_y); + + // but not under screen + if (menu_y + m_windowmenu.height() >= screen().maxBottom(head)) + menu_y = screen().maxBottom(head) - m_windowmenu.height() - 1 - m_windowmenu.fbwindow().borderWidth(); + + if (menu_x < static_cast(screen().maxLeft(head))) + menu_x = screen().maxLeft(head); + else if (menu_x + static_cast(m_windowmenu.width()) >= static_cast(screen().maxRight(head))) + menu_x = screen().maxRight(head) - m_windowmenu.width() - 1; + + + m_windowmenu.move(menu_x, menu_y); m_windowmenu.show(); m_windowmenu.raise(); } @@ -1900,14 +1914,12 @@ void FluxboxWindow::popupMenu() { m_windowmenu.hide(); return; } - // move menu directly under titlebar - int diff_y = frame().titlebar().height() + frame().titlebar().borderWidth(); + + int menu_y = frame().titlebar().height() + frame().titlebar().borderWidth(); if (!decorations.titlebar) // if we don't have any titlebar - diff_y = 0; + menu_y = 0; - m_windowmenu.move(m_last_button_x, frame().y() + diff_y); - m_windowmenu.show(); - m_windowmenu.raise(); + showMenu(m_last_button_x, menu_y + frame().y()); } /** -- cgit v0.11.2