From 453e220df91fabd80a2f8e5992ad1a3a73f4efbe Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 16 Feb 2003 15:12:08 +0000 Subject: Add layer menu to window menu --- ChangeLog | 3 +++ src/Screen.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- src/Window.cc | 3 ++- src/Window.hh | 7 +++++-- src/fluxbox.hh | 15 ++++++++------- 5 files changed, 67 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3a530e..38eff68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.1.15: +*03/02/16: + * Added layer submenu to window menu + small fix (Simon) + Screen.cc Window.hh/cc fluxbox.hh *03/02/15: * Added Style menu and fixed theme listeners for FbWinFrame, Menu and Toolbar (Henrik) ToolbarTheme.hh/cc, Toolbar.hh/cc, FbTk Menu.hh/cc, FbTk MenuTheme.hh/cc, diff --git a/src/Screen.cc b/src/Screen.cc index 66512ea..ccff0d0 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.106 2003/02/16 13:55:49 fluxgen Exp $ +// $Id: Screen.cc,v 1.107 2003/02/16 15:12:08 rathnor Exp $ #include "Screen.hh" @@ -137,8 +137,24 @@ FbTk::Menu *createMenuFromScreen(BScreen &screen) { *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())); return menu; } + +class WindowLayerMenuItem : public FbTk::MenuItem { +public: + WindowLayerMenuItem(const char *label, FluxboxWindow &win, int layernum): + FbTk::MenuItem(label), m_window(win), m_layernum(layernum) { + } + bool isEnabled() const { return m_window.getLayerNum() != m_layernum; } + void click(int button, int time) { + m_window.moveToLayer(m_layernum); + } + +private: + FluxboxWindow &m_window; + int m_layernum; }; +}; // End anonymous namespace + //---------- resource manipulators --------- template<> void Resource:: @@ -1107,7 +1123,7 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { CommandRef close_cmd(new WindowCmd(win, &FluxboxWindow::close)); CommandRef shade_cmd(new WindowCmd(win, &FluxboxWindow::shade)); CommandRef raise_cmd(new WindowCmd(win, &FluxboxWindow::raise)); - CommandRef lower_cmd(new WindowCmd(win, &FluxboxWindow::raise)); + CommandRef lower_cmd(new WindowCmd(win, &FluxboxWindow::lower)); CommandRef stick_cmd(new WindowCmd(win, &FluxboxWindow::stick)); CommandRef show_menu_cmd(new WindowCmd(win, &FluxboxWindow::popupMenu)); @@ -1117,7 +1133,7 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { // get titlebar configuration const vector *dir = &Fluxbox::instance()->getTitlebarLeft(); for (char c=0; c<2; c++) { - for (int i=0; i< dir->size(); ++i) { + for (unsigned int i=0; i< dir->size(); ++i) { //create new buttons FbTk::Button *newbutton = 0; if (win.isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) { @@ -1175,13 +1191,41 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { frame.setOnClickTitlebar(raise_cmd, 1, false, true); // on press with button 1 frame.setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1 frame.setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3 - frame.setOnClickTitlebar(lower_cmd, 3, false, true); // on press with button 3 + frame.setOnClickTitlebar(lower_cmd, 2, false, true); // on press with button 2 frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); // setup menu FbTk::Menu &menu = win.getWindowmenu(); menu.removeAll(); // clear old items menu.disableTitle(); // not titlebar + // check and setup layer menu + FbTk::Menu &layer_menu = win.getLayermenu(); + // if it hasn't already been setup (no need to reset it) + if (layer_menu.numberOfItems() == 0) { + Fluxbox *fluxbox = Fluxbox::instance(); + struct { + int set; + int base; + const char *default_str; + int layernum; + } layer_menuitems[] = { + //TODO: nls + {0, 0, "Above Slit", fluxbox->getAboveSlitLayer()}, + {0, 0, "Slit", fluxbox->getSlitLayer()}, + {0, 0, "Top", fluxbox->getTopLayer()}, + {0, 0, "Normal", fluxbox->getNormalLayer()}, + {0, 0, "Bottom", fluxbox->getBottomLayer()}, + {0, 0, "Desktop", fluxbox->getDesktopLayer()}, + }; + + for (size_t i=0; i < 6; ++i) { + // TODO: fetch nls string + layer_menu.insert(new WindowLayerMenuItem(layer_menuitems[i].default_str, + win, layer_menuitems[i].layernum)); + }; + layer_menu.update(); + } + // set new menu items menu.insert("Shade", shade_cmd); menu.insert("Stick", stick_cmd); @@ -1191,6 +1235,7 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { menu.insert("Iconify", iconify_cmd); menu.insert("Raise", raise_cmd); menu.insert("Lower", lower_cmd); + menu.insert("Layer...", &layer_menu); menu.insert("ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"); menu.insert("Close", close_cmd); diff --git a/src/Window.cc b/src/Window.cc index a8be66f..a8d3f8a 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.115 2003/02/09 14:11:13 rathnor Exp $ +// $Id: Window.cc,v 1.116 2003/02/16 15:12:07 rathnor Exp $ #include "Window.hh" @@ -112,6 +112,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, display(0), lastButtonPressTime(0), m_windowmenu(menutheme, screen_num, imgctrl), + m_layermenu(menutheme, screen_num, imgctrl), old_decoration(DECOR_NORMAL), tab(0), m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100), diff --git a/src/Window.hh b/src/Window.hh index 21959d5..3a19c56 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.45 2003/02/09 14:11:13 rathnor Exp $ +// $Id: Window.hh,v 1.46 2003/02/16 15:12:08 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -220,6 +220,9 @@ public: FbTk::Menu &getWindowmenu() { return m_windowmenu; } const FbTk::Menu &getWindowmenu() const { return m_windowmenu; } + + FbTk::Menu &getLayermenu() { return m_layermenu; } + const FbTk::Menu &getLayermenu() const { return m_layermenu; } const std::string &getTitle() const { return client.title; } const std::string &getIconTitle() const { return client.icon_title; } @@ -333,7 +336,7 @@ private: BaseDisplay::BlackboxAttributes blackbox_attrib; Time lastButtonPressTime; - FbTk::Menu m_windowmenu; + FbTk::Menu m_windowmenu, m_layermenu; timeval lastFocusTime; diff --git a/src/fluxbox.hh b/src/fluxbox.hh index ea89257..7ab5428 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.40 2003/02/02 16:32:40 rathnor Exp $ +// $Id: fluxbox.hh,v 1.41 2003/02/16 15:12:08 rathnor Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH @@ -114,12 +114,13 @@ public: inline int getNumberOfLayers() const { return *m_rc_numlayers; } // TODO there probably should be configurable - inline int getDesktopLayer() const { return 12; } - inline int getBottomLayer() const { return 10; } - inline int getNormalLayer() const { return 8; } - inline int getTopLayer() const { return 2; } - inline int getSlitLayer() const { return 4; } - inline int getMenuLayer() const { return 0; } + inline int getDesktopLayer() const { return 12; } + inline int getBottomLayer() const { return 10; } + inline int getNormalLayer() const { return 8; } + inline int getTopLayer() const { return 6; } + inline int getSlitLayer() const { return 4; } + inline int getAboveSlitLayer() const { return 2; } + inline int getMenuLayer() const { return 0; } inline const timeval &getAutoRaiseDelay() const { return resource.auto_raise_delay; } -- cgit v0.11.2