From 768d98a39d3640f24ebe13e2c304fac3436a0a0d Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sat, 11 Sep 2004 13:45:16 +0000 Subject: head specific strut, patch from Mathieu De Zutter --- src/Ewmh.cc | 10 +++++--- src/FbTk/Menu.cc | 55 +++++++++++++++++++++++----------------- src/FbTk/Menu.hh | 7 ++++-- src/Makefile.am | 1 + src/Strut.hh | 17 +++++++++---- src/ToolFactory.cc | 30 +++++++++++----------- src/Toolbar.cc | 23 ++++++++--------- src/fluxbox.cc | 74 ++++++++++++++++++++++-------------------------------- 8 files changed, 112 insertions(+), 105 deletions(-) diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 56d11fb..e5bf6b5 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Ewmh.cc,v 1.50 2004/09/10 15:36:04 akir Exp $ +// $Id: Ewmh.cc,v 1.51 2004/09/11 13:34:36 fluxgen Exp $ #include "Ewmh.hh" @@ -829,9 +829,11 @@ void Ewmh::updateStrut(WinClient &winclient) { &ret_type, &fmt, &nitems, &bytes_after, (unsigned char **) &data) && data) { - winclient.setStrut(winclient.screen().requestStrut(data[0], data[1], - data[2], data[3])); - winclient.screen().updateAvailableWorkspaceArea(); + int head = winclient.screen().getHead(winclient); + winclient.setStrut(winclient.screen().requestStrut(head, + data[0], data[1], + data[2], data[3])); + winclient.screen().updateAvailableWorkspaceArea(); } } diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index c784498..a82f441 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.81 2004/09/11 12:33:14 rathnor Exp $ +// $Id: Menu.cc,v 1.82 2004/09/11 13:45:16 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -79,6 +79,8 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): m_theme(tm), m_parent(0), m_image_ctrl(imgctrl), + m_screen_x(0), + m_screen_y(0), m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())), m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), m_alignment(ALIGNDONTCARE), @@ -192,8 +194,6 @@ Menu::~Menu() { if (menu.sel_pixmap) m_image_ctrl.removeImage(menu.sel_pixmap); - FbTk::EventManager &evm = *FbTk::EventManager::instance(); - if (s_focused == this) s_focused = 0; } @@ -236,6 +236,7 @@ int Menu::remove(unsigned int index) { if (item) { menuitems.erase(it); + if (!internal_menu && item->submenu() != 0) { Menu *tmp = item->submenu(); // if menu is interal we should just hide it instead @@ -796,6 +797,8 @@ void Menu::drawSubmenu(unsigned int index) { if (item->submenu()->m_parent != this) item->submenu()->m_parent = this; + + item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); int sbl = index / menu.persub, i = index - (sbl * menu.persub); int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); @@ -821,24 +824,26 @@ void Menu::drawSubmenu(unsigned int index) { height() - item->submenu()->height()); } - if ((new_x + item->submenu()->width()) > m_screen_width) { + int borderw = item->submenu()->fbwindow().borderWidth(); + + if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { new_x = ((shifted) ? menu.x_shift : x()) - item->submenu()->width() - menu.window.borderWidth(); } - if (new_x < 0) - new_x = 0; + if (new_x < m_screen_x) + new_x = m_screen_x; - if ((new_y + item->submenu()->height()) > m_screen_height) { - new_y = m_screen_height - item->submenu()->height() - + if ((new_y + item->submenu()->height()) > m_screen_y + m_screen_height) { + new_y = m_screen_y + m_screen_height - item->submenu()->height() - menu.window.borderWidth() * 2; } item->submenu()->moving = moving; which_sub = index; - if (new_y < 0) - new_y = 0; + if (new_y < m_screen_y) + new_y = m_screen_y; item->submenu()->move(new_x, new_y); if (! moving) @@ -1085,10 +1090,11 @@ void Menu::buttonPressEvent(XButtonEvent &be) { if (item->submenu()) { if (!item->submenu()->isVisible()) drawSubmenu(w); - } else + } else { drawItem(w, true, // clear true); // render transparency + } } } else { @@ -1120,14 +1126,10 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { } } - if (re.x >= 0 && re.x <= (signed) width() && - re.y >= 0 && re.y <= (signed) theme().titleHeight() && - re.button == 3) + if (re.button == 3) hide(); - } else if (re.window == menu.frame && - re.x >= 0 && re.x < (signed) width() && - re.y >= 0 && re.y < (signed) menu.frame_h) { + } else if (re.window == menu.frame) { int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), ix = sbl * menu.item_w, iy = i * theme().itemHeight(), @@ -1140,17 +1142,16 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { re.y > iy && re.y < (signed) (iy + theme().itemHeight())) { menuitems[w]->click(re.button, re.time); itemSelected(re.button, w); - // just redraw this item - drawItem(w, + drawItem(w, true, // clear true); // transparent } + } else { - drawItem(p, + drawItem(p, true, // clear true); // transparent } - } else { drawItem(p, true, // clear @@ -1284,8 +1285,8 @@ void Menu::enterNotifyEvent(XCrossingEvent &ce) { return; menu.x_shift = x(), menu.y_shift = y(); - if (x() + width() > m_screen_width) { - menu.x_shift = m_screen_width - width() - 2*theme().borderWidth(); + if (x() + width() > m_screen_x + m_screen_width) { + menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth(); shifted = true; } else if (x() < 0) { menu.x_shift = 0; //-theme().borderWidth(); @@ -1381,6 +1382,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { } } + void Menu::reconfigure() { @@ -1515,4 +1517,11 @@ void Menu::renderTransp(int x, int y, } +void Menu::setScreen(int x, int y, int w, int h) { + m_screen_x = x; + m_screen_y = y; + m_screen_width = w; + m_screen_height = h; +} + }; // end namespace FbTk diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index d5f6b83..43ca828 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.hh,v 1.39 2004/08/29 12:35:29 rathnor Exp $ +// $Id: Menu.hh,v 1.40 2004/09/11 13:45:16 fluxgen Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH @@ -95,6 +95,8 @@ public: void disableTitle(); void enableTitle(); + void setScreen(int x, int y, int w, int h); + /** @name event handlers */ @@ -200,7 +202,8 @@ private: ImageControl &m_image_ctrl; Menuitems menuitems; - const unsigned int m_screen_width, m_screen_height; + int m_screen_x, m_screen_y; + int m_screen_width, m_screen_height; bool moving; ///< if we're moving/draging or not bool visible; ///< menu visibility bool torn; ///< torn from parent diff --git a/src/Makefile.am b/src/Makefile.am index 28befb8..8f8b950 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -113,6 +113,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ WorkspaceMenu.hh WorkspaceMenu.cc \ FocusModelMenuItem.hh \ ToggleMenu.hh \ + HeadArea.hh HeadArea.cc \ ${newwmspec_SOURCE} ${gnome_SOURCE} \ ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} diff --git a/src/Strut.hh b/src/Strut.hh index 70930fb..bb4595c 100644 --- a/src/Strut.hh +++ b/src/Strut.hh @@ -20,28 +20,35 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Strut.hh,v 1.3 2004/01/19 18:30:59 fluxgen Exp $ +// $Id: Strut.hh,v 1.4 2004/09/11 13:36:03 fluxgen Exp $ #ifndef STRUT_HH #define STRUT_HH class Strut { public: - Strut(int left, int right, - int top, int bottom):m_left(left), m_right(right), - m_top(top), m_bottom(bottom) { } + Strut(int head, int left, int right, + int top, int bottom, Strut* next = 0) + :m_head(head), m_left(left), m_right(right), + m_top(top), m_bottom(bottom), m_next(next) { } + inline int head() const { return m_head; } inline int left() const { return m_left; } inline int right() const { return m_right; } inline int bottom() const { return m_bottom; } inline int top() const { return m_top; } + inline Strut* next() const { return m_next; } bool operator == (const Strut &test) const { - return (left() == test.left() && + return (head() == test.head() && + left() == test.left() && right() == test.right() && top() == test.top() && bottom() == test.bottom()); } private: + Strut():m_head(0), m_left(0), m_right(0), m_top(0), m_bottom(0), m_next(0) {} + int m_head; int m_left, m_right, m_top, m_bottom; + Strut *m_next; ///< link to struts on all heads }; #endif // STRUT_HH diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc index b897e43..6c1d4f8 100644 --- a/src/ToolFactory.cc +++ b/src/ToolFactory.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolFactory.cc,v 1.7 2004/08/27 14:36:12 rathnor Exp $ +// $Id: ToolFactory.cc,v 1.8 2004/09/11 13:40:57 fluxgen Exp $ #include "ToolFactory.hh" @@ -43,6 +43,8 @@ #include "FbTk/FbWindow.hh" +#include + namespace { class ShowMenuAboveToolbar: public FbTk::Command { public: @@ -51,20 +53,18 @@ public: m_tbar.screen().hideMenus(); // get last button pos const XEvent &event = Fluxbox::instance()->lastEvent(); - int x = event.xbutton.x_root - (m_tbar.menu().width() / 2); - int y = event.xbutton.y_root - (m_tbar.menu().height() / 2); - - if (x < 0) - x = 0; - else if (x + m_tbar.menu().width() > m_tbar.screen().width()) - x = m_tbar.screen().width() - m_tbar.menu().width(); - - if (y < 0) - y = 0; - else if (y + m_tbar.menu().height() > m_tbar.screen().height()) - y = m_tbar.screen().height() - m_tbar.menu().height(); - - m_tbar.menu().move(x, y); + int head = m_tbar.screen().getHead(event.xbutton.x_root, event.xbutton.y_root); + std::pair m = + m_tbar.screen().clampToHead( head, + event.xbutton.x_root - (m_tbar.menu().width() / 2), + event.xbutton.y_root - (m_tbar.menu().height() / 2), + m_tbar.menu().width(), + m_tbar.menu().height()); + m_tbar.menu().setScreen(m_tbar.screen().getHeadX(head), + m_tbar.screen().getHeadY(head), + m_tbar.screen().getHeadWidth(head), + m_tbar.screen().getHeadHeight(head)); + m_tbar.menu().move(m.first, m.second); m_tbar.menu().show(); } private: diff --git a/src/Toolbar.cc b/src/Toolbar.cc index d35e872..19e85db 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.153 2004/09/11 13:33:07 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.154 2004/09/11 13:34:01 fluxgen Exp $ #include "Toolbar.hh" @@ -488,17 +488,16 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) { int head = screen().getHead(be.x_root, be.y_root); int borderw = menu().fbwindow().borderWidth(); - pair m = screen().clampToHead( head, - be.x_root - (menu().width() / 2), - be.y_root - (menu().titleWindow().height() / 2), - menu().width() + 2*borderw, - menu().height() + 2*borderw); - - menu().setScreen( - screen().getHeadX(head), - screen().getHeadY(head), - screen().getHeadWidth(head), - screen().getHeadHeight(head)); + pair m = screen().clampToHead(head, + be.x_root - (menu().width() / 2), + be.y_root - (menu().titleWindow().height() / 2), + menu().width() + 2*borderw, + menu().height() + 2*borderw); + + menu().setScreen(screen().getHeadX(head), + screen().getHeadY(head), + screen().getHeadWidth(head), + screen().getHeadHeight(head)); menu().move(m.first, m.second); menu().show(); menu().grabInputFocus(); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 324fb05..320aa93 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.253 2004/09/11 12:33:14 rathnor Exp $ +// $Id: fluxbox.cc,v 1.254 2004/09/11 13:38:58 fluxgen Exp $ #include "fluxbox.hh" @@ -1104,28 +1104,20 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { screen->getRootmenu().hide(); } else if (be.button == 2) { - int mx = be.x_root - - (screen->getWorkspacemenu().width() / 2); - int my = be.y_root - - (screen->getWorkspacemenu().titleWindow().height() / 2); - - if (mx < 0) mx = 0; - if (my < 0) my = 0; - - if (mx + screen->getWorkspacemenu().width() > - screen->width()) { - mx = screen->width()-1 - - screen->getWorkspacemenu().width() - - 2*screen->getWorkspacemenu().fbwindow().borderWidth(); - } - - if (my + screen->getWorkspacemenu().height() > - screen->height()) { - my = screen->height()-1 - - screen->getWorkspacemenu().height() - - 2*screen->getWorkspacemenu().fbwindow().borderWidth(); - } - screen->getWorkspacemenu().move(mx, my); + int borderw = screen->getWorkspacemenu().fbwindow().borderWidth(); + int head = screen->getHead(be.x_root, be.y_root); + + pair m = + screen->clampToHead(head, + be.x_root - (screen->getWorkspacemenu().width() / 2), + be.y_root - (screen->getWorkspacemenu().titleWindow().height() / 2), + screen->getWorkspacemenu().width() + 2*borderw, + screen->getWorkspacemenu().height() + 2*borderw); + screen->getWorkspacemenu().move(m.first, m.second); + screen->getWorkspacemenu().setScreen(screen->getHeadX(head), + screen->getHeadY(head), + screen->getHeadWidth(head), + screen->getHeadHeight(head)); if (! screen->getWorkspacemenu().isVisible()) { screen->getWorkspacemenu().removeParent(); @@ -1135,29 +1127,23 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { } else if (be.button == 3) { //calculate placement of root menu //and show/hide it - int mx = be.x_root - - (screen->getRootmenu().width() / 2); - int my = be.y_root - - (screen->getRootmenu().titleWindow().height() / 2); - int borderw = screen->getRootmenu().fbwindow().borderWidth(); - if (mx < 0) mx = 0; - if (my < 0) my = 0; + int borderw = screen->getRootmenu().fbwindow().borderWidth(); + int head = screen->getHead(be.x_root, be.y_root); + + pair m = + screen->clampToHead(head, + be.x_root - (screen->getRootmenu().width() / 2), + be.y_root - (screen->getRootmenu().titleWindow().height() / 2), + screen->getRootmenu().width() + 2*borderw, + screen->getRootmenu().height() + 2*borderw); + + screen->getRootmenu().move(m.first, m.second); + screen->getRootmenu().setScreen(screen->getHeadX(head), + screen->getHeadY(head), + screen->getHeadWidth(head), + screen->getHeadHeight(head)); - if (mx + screen->getRootmenu().width() + 2*borderw > screen->width()) { - mx = screen->width() - - screen->getRootmenu().width() - - 2*borderw; - } - - if (my + screen->getRootmenu().height() + 2*borderw > - screen->height()) { - my = screen->height() - - screen->getRootmenu().height() - - 2*borderw; - } - screen->getRootmenu().move(mx, my); - if (! screen->getRootmenu().isVisible()) { checkMenu(); screen->getRootmenu().show(); -- cgit v0.11.2