From 369b4e1b92491aa57b0bf430b89bf732b80fa6a4 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 20 Feb 2006 21:04:35 +0000 Subject: moved class Layer from class Fluxbox and thus reduces some dependecies --- src/Ewmh.cc | 32 ++++++++++++++--------------- src/Gnome.cc | 22 +++++++++++--------- src/IconMenu.cc | 4 ++-- src/IconbarTool.cc | 9 ++++---- src/Layer.hh | 52 ++++++++++++++++++++++++++++++++++++++++++++++ src/LayerMenu.cc | 20 ++++++++---------- src/MenuCreator.cc | 42 +++++++++++++++++++++++++------------ src/Remember.cc | 15 +++++++------- src/Resources.cc | 58 ++++++++++++++++++++++++++++------------------------ src/Screen.cc | 12 +++++------ src/SendToMenu.cc | 5 +++-- src/Slit.cc | 13 ++++++------ src/Slit.hh | 5 +++-- src/Toolbar.cc | 39 ++++++++++++++++++++--------------- src/Toolbar.hh | 4 ++-- src/Window.cc | 13 ++++++------ src/Workspace.cc | 4 ++-- src/WorkspaceMenu.cc | 5 ++--- src/fluxbox.cc | 3 ++- src/fluxbox.hh | 20 ------------------ 20 files changed, 218 insertions(+), 159 deletions(-) create mode 100644 src/Layer.hh diff --git a/src/Ewmh.cc b/src/Ewmh.cc index dc772e3..911c919 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -27,8 +27,8 @@ #include "Window.hh" #include "WinClient.hh" #include "Workspace.hh" -#include "fluxbox.hh" - +#include "Layer.hh" +#include "FbTk/App.hh" #include "FbTk/FbWindow.hh" #include "FbTk/I18n.hh" @@ -194,7 +194,7 @@ void Ewmh::setupFrame(FluxboxWindow &win) { &data); if (data) { Atom *atoms = (unsigned long *)data; - for (unsigned long l=0; lgetDesktopLayer()); + win.moveToLayer(Layer::DESKTOP); win.setDecorationMask(0); win.setTabable(false); win.setMovable(false); @@ -534,9 +534,9 @@ void Ewmh::updateState(FluxboxWindow &win) { state.push_back(m_net_wm_state_sticky); if (win.isShaded()) state.push_back(m_net_wm_state_shaded); - if (win.layerNum() == Fluxbox::instance()->getBottomLayer()) + if (win.layerNum() == Layer::BOTTOM) state.push_back(m_net_wm_state_below); - if (win.layerNum() == Fluxbox::instance()->getAboveDockLayer()) + if (win.layerNum() == Layer::ABOVE_DOCK) state.push_back(m_net_wm_state_above); if (win.isIconic()) state.push_back(m_net_wm_state_hidden); @@ -889,15 +889,15 @@ void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) { win.setIconHidden(value); } else if (state == m_net_wm_state_below) { // bottom layer if (value) - win.moveToLayer(Fluxbox::instance()->getBottomLayer()); + win.moveToLayer(Layer::BOTTOM); else - win.moveToLayer(Fluxbox::instance()->getNormalLayer()); + win.moveToLayer(Layer::NORMAL); } else if (state == m_net_wm_state_above) { // above layer if (value) - win.moveToLayer(Fluxbox::instance()->getAboveDockLayer()); + win.moveToLayer(Layer::ABOVE_DOCK); else - win.moveToLayer(Fluxbox::instance()->getNormalLayer()); + win.moveToLayer(Layer::NORMAL); } } @@ -916,16 +916,16 @@ void Ewmh::toggleState(FluxboxWindow &win, Atom state) { } else if (state == m_net_wm_state_skip_taskbar) { win.setIconHidden(!win.isIconHidden()); } else if (state == m_net_wm_state_below) { // bottom layer - if (win.layerNum() == Fluxbox::instance()->getBottomLayer()) - win.moveToLayer(Fluxbox::instance()->getNormalLayer()); + if (win.layerNum() == Layer::BOTTOM) + win.moveToLayer(Layer::NORMAL); else - win.moveToLayer(Fluxbox::instance()->getBottomLayer()); + win.moveToLayer(Layer::BOTTOM); } else if (state == m_net_wm_state_above) { // top layer - if (win.layerNum() == Fluxbox::instance()->getAboveDockLayer()) - win.moveToLayer(Fluxbox::instance()->getNormalLayer()); + if (win.layerNum() == Layer::ABOVE_DOCK) + win.moveToLayer(Layer::NORMAL); else - win.moveToLayer(Fluxbox::instance()->getAboveDockLayer()); + win.moveToLayer(Layer::ABOVE_DOCK); } } diff --git a/src/Gnome.cc b/src/Gnome.cc index c91d514..95cf08e 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -23,13 +23,15 @@ #include "Gnome.hh" -#include "fluxbox.hh" +#include "App.hh" #include "Window.hh" #include "Screen.hh" #include "WinClient.hh" #include "Workspace.hh" +#include "Layer.hh" #include "FbTk/I18n.hh" + #include #include using namespace std; @@ -279,7 +281,7 @@ void Gnome::updateState(FluxboxWindow &win) { void Gnome::updateLayer(FluxboxWindow &win) { //TODO - map from flux layers to gnome ones // our layers are in the opposite direction to GNOME - long layernum = Fluxbox::instance()->getDesktopLayer() - win.layerNum(); + long layernum = Layer::DESKTOP - win.layerNum(); FluxboxWindow::ClientList::iterator client_it = win.clientList().begin(); FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); @@ -418,47 +420,47 @@ void Gnome::setLayer(FluxboxWindow *win, int layer) { #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_DESKTOP)"<getDesktopLayer(); + layer = Layer::DESKTOP; break; case WIN_LAYER_BELOW: #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_BELOW)"<getBottomLayer(); + layer = Layer::BOTTOM; break; case WIN_LAYER_NORMAL: #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_NORMAL)"<getNormalLayer(); + layer = Layer::NORMAL; break; case WIN_LAYER_ONTOP: #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_ONTOP)"<getTopLayer(); + layer = Layer::TOP; break; case WIN_LAYER_DOCK: #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_DOCK)"<getDockLayer(); + layer = Layer::DOCK; break; case WIN_LAYER_ABOVE_DOCK: #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_ABOVE_DOCK)"<getAboveDockLayer(); + layer = Layer::ABOVE_DOCK; break; case WIN_LAYER_MENU: #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_MENU)"<getMenuLayer(); + layer = Layer::MENU; break; default: // our windows are in the opposite direction to gnome - layer = Fluxbox::instance()->getDesktopLayer() - layer; + layer = Layer::DESKTOP - layer; #ifdef DEBUG cerr<<"Gnome::setLayer("<title()<<", "< @@ -47,7 +47,7 @@ IconMenu::IconMenu(BScreen &screen): FbMenu(screen.menuTheme(), screen.imageControl(), *screen.layerManager(). - getLayer(Fluxbox::instance()->getMenuLayer())) { + getLayer(Layer::MENU)) { _FB_USES_NLS; setLabel(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title")); diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 61ac45d..e860ce2 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -29,12 +29,13 @@ #include "Window.hh" #include "IconButton.hh" #include "Workspace.hh" -#include "fluxbox.hh" #include "FbMenu.hh" #include "BoolMenuItem.hh" #include "CommandParser.hh" #include "WinClient.hh" #include "FocusControl.hh" +#include "FbCommands.hh" +#include "Layer.hh" #include "FbTk/I18n.hh" #include "FbTk/Menu.hh" @@ -236,9 +237,7 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { menu.setLabel(_FBTEXT(Toolbar, IconbarMode, "Iconbar Mode", "Menu title - chooses which set of icons are shown in the iconbar")); - RefCount saverc_cmd(new SimpleCommand( - *Fluxbox::instance(), - &Fluxbox::save_rc)); + RefCount saverc_cmd(new FbCommands::SaveResources()); menu.insert(new ToolbarModeMenuItem(_FBTEXT(Toolbar, IconbarModeNone, @@ -382,7 +381,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr m_rc_use_pixmap(screen.resourceManager(), true, screen.name() + ".iconbar.usePixmap", screen.altName() + ".Iconbar.UsePixmap"), m_menu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) { + *screen.layerManager().getLayer(Layer::MENU)) { // setup mode menu setupModeMenu(m_menu, *this); diff --git a/src/Layer.hh b/src/Layer.hh new file mode 100644 index 0000000..e0c0134 --- /dev/null +++ b/src/Layer.hh @@ -0,0 +1,52 @@ +// Layer.hh for Fluxbox Window Manager +// Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#ifndef LAYER_HH +#define LAYER_HH + +/** + * (This is not the layer->raise/lower handling stuff, @see FbTk::Layer) + * Class to store layer numbers (special Resource type) + * we have a special resource type because we need to be able to name certain layers + * a Resource wouldn't allow this + */ +class Layer { +public: + enum { + MENU = 0, + ABOVE_DOCK = 2, + DOCK = 4, + TOP = 6, + NORMAL = 8, + BOTTOM = 10, + DESKTOP = 12 + }; + + explicit Layer(int i) : m_num(i) {}; + int getNum() const { return m_num; } + + Layer &operator=(int num) { m_num = num; return *this; } + +private: + int m_num; +}; + +#endif // LAYER_HH diff --git a/src/LayerMenu.cc b/src/LayerMenu.cc index afcd4ac..cec0c59 100644 --- a/src/LayerMenu.cc +++ b/src/LayerMenu.cc @@ -1,6 +1,7 @@ #include "LayerMenu.hh" -#include "fluxbox.hh" +#include "FbCommands.hh" +#include "Layer.hh" #include "FbTk/RefCount.hh" #include "FbTk/SimpleCommand.hh" @@ -11,7 +12,6 @@ LayerMenu::LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, ToggleMenu(tm, imgctrl, layer) { _FB_USES_NLS; - Fluxbox *fluxbox = Fluxbox::instance(); struct { int set; @@ -20,17 +20,15 @@ LayerMenu::LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, int layernum; } layer_menuitems[] = { //TODO: nls - {0, 0, _FBTEXT(Layer, AboveDock, "Above Dock", "Layer above dock"), fluxbox->getAboveDockLayer()}, - {0, 0, _FBTEXT(Layer, Dock, "Dock", "Layer dock"), fluxbox->getDockLayer()}, - {0, 0, _FBTEXT(Layer, Top, "Top", "Layer top"), fluxbox->getTopLayer()}, - {0, 0, _FBTEXT(Layer, Normal, "Normal", "Layer normal"), fluxbox->getNormalLayer()}, - {0, 0, _FBTEXT(Layer, Bottom, "Bottom", "Layer bottom"), fluxbox->getBottomLayer()}, - {0, 0, _FBTEXT(Layer, Desktop, "Desktop", "Layer desktop"), fluxbox->getDesktopLayer()}, + {0, 0, _FBTEXT(Layer, AboveDock, "Above Dock", "Layer above dock"), Layer::ABOVE_DOCK}, + {0, 0, _FBTEXT(Layer, Dock, "Dock", "Layer dock"), Layer::DOCK}, + {0, 0, _FBTEXT(Layer, Top, "Top", "Layer top"), Layer::TOP}, + {0, 0, _FBTEXT(Layer, Normal, "Normal", "Layer normal"), Layer::NORMAL}, + {0, 0, _FBTEXT(Layer, Bottom, "Bottom", "Layer bottom"), Layer::BOTTOM}, + {0, 0, _FBTEXT(Layer, Desktop, "Desktop", "Layer desktop"), Layer::DESKTOP}, }; - FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand( - *Fluxbox::instance(), - &Fluxbox::save_rc)); + FbTk::RefCount saverc_cmd(new FbCommands::SaveResources()); for (size_t i=0; i < 6; ++i) { // TODO: fetch nls string diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 4ea83a8..9d2b4fa 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -36,6 +36,7 @@ #include "WorkspaceMenu.hh" #include "LayerMenu.hh" #include "SendToMenu.hh" +#include "Layer.hh" #include "FbMenuParser.hh" #include "StyleMenuItem.hh" @@ -364,8 +365,7 @@ FbTk::Menu *MenuCreator::createMenu(const std::string &label, int screen_number) FbTk::Menu *menu = new FbMenu(screen->menuTheme(), screen->imageControl(), - *screen->layerManager(). - getLayer(Fluxbox::instance()->getMenuLayer())); + *screen->layerManager().getLayer(Layer::MENU)); if (!label.empty()) menu->setLabel(label.c_str()); @@ -511,24 +511,41 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, menu.insert(maximize_item); } else if (type == "iconify") { RefCmd iconify_cmd(new WindowCmd(&FluxboxWindow::iconify)); - menu.insert(label.empty()?_FBTEXT(Windowmenu, Iconify, "Iconify", "Iconify the window"):label.c_str(), iconify_cmd); + menu.insert(label.empty() ? + _FBTEXT(Windowmenu, Iconify, + "Iconify", "Iconify the window") : + label.c_str(), iconify_cmd); } else if (type == "close") { RefCmd close_cmd(new WindowCmd(&FluxboxWindow::close)); - menu.insert(label.empty()?_FBTEXT(Windowmenu, Close, "Close", "Close the window"):label.c_str(), close_cmd); + menu.insert(label.empty() ? + _FBTEXT(Windowmenu, Close, + "Close", "Close the window") : + label.c_str(), close_cmd); } else if (type == "kill" || type == "killwindow") { RefCmd kill_cmd(new WindowCmd(&FluxboxWindow::kill)); - menu.insert(label.empty()?_FBTEXT(Windowmenu, Kill, "Kill", "Kill the window"):label.c_str(), kill_cmd); + menu.insert(label.empty() ? + _FBTEXT(Windowmenu, Kill, + "Kill", "Kill the window"): + label.c_str(), kill_cmd); } else if (type == "lower") { RefCmd lower_cmd(new WindowCmd(&FluxboxWindow::lower)); - menu.insert(label.empty()?_FBTEXT(Windowmenu, Lower, "Lower", "Lower the window"):label.c_str(), lower_cmd); + menu.insert( label.empty() ? + _FBTEXT(Windowmenu, Lower, + "Lower", "Lower the window"): + label.c_str(), lower_cmd); } else if (type == "raise") { RefCmd raise_cmd(new WindowCmd(&FluxboxWindow::raise)); - menu.insert(label.empty()?_FBTEXT(Windowmenu, Raise, "Raise", "Raise the window"):label.c_str(), raise_cmd); + menu.insert(label.empty() ? + _FBTEXT(Windowmenu, Raise, + "Raise", "Raise the window"): + label.c_str(), raise_cmd); } else if (type == "stick") { RefCmd stick_cmd(new WindowCmd(&FluxboxWindow::stick)); - menu.insert(label.empty()?_FBTEXT(Windowmenu, Stick, "Stick", "Stick the window"):label.c_str(), stick_cmd); - } - else if (type == "extramenus") { + menu.insert(label.empty() ? + _FBTEXT(Windowmenu, Stick, + "Stick", "Stick the window"): + label.c_str(), stick_cmd); + } else if (type == "extramenus") { BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); BScreen::ExtraMenus::iterator it = screen->extraWindowMenus().begin(); BScreen::ExtraMenus::iterator it_end = screen->extraWindowMenus().end(); @@ -540,7 +557,7 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, } else if (type == "sendto") { menu.insert(label.empty() ? _FBTEXT(Windowmenu, SendTo, "Send To...", "Send to menu item name"): label.c_str(), new SendToMenu(*Fluxbox::instance()->findScreen(menu.screenNumber()))); - }else if (type == "layer") { + } else if (type == "layer") { BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); if (screen == 0) return false; @@ -549,8 +566,7 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, FbTk::Menu *submenu = new LayerMenu(screen->menuTheme(), screen->imageControl(), - *screen->layerManager(). - getLayer(Fluxbox::instance()->getMenuLayer()), + *screen->layerManager().getLayer(Layer::MENU), &context, false); submenu->disableTitle(); diff --git a/src/Remember.cc b/src/Remember.cc index f28d89a..273bd2a 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -32,6 +32,7 @@ #include "FbCommands.hh" #include "fluxbox.hh" #include "WindowCmd.hh" +#include "Layer.hh" #include "FbTk/I18n.hh" #include "FbTk/StringUtil.hh" @@ -345,19 +346,19 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) { } else if (str_key == "Layer") { unsigned int l; if (str_label == "DESKTOP") { - l = Fluxbox::instance()->getDesktopLayer(); + l = Layer::DESKTOP; } else if (str_label == "BOTTOM") { - l = Fluxbox::instance()->getBottomLayer(); + l = Layer::BOTTOM; } else if (str_label == "NORMAL") { - l = Fluxbox::instance()->getNormalLayer(); + l = Layer::NORMAL; } else if (str_label == "TOP") { - l = Fluxbox::instance()->getTopLayer(); + l = Layer::TOP; } else if (str_label == "DOCK") { - l = Fluxbox::instance()->getDockLayer(); + l = Layer::DOCK; } else if (str_label == "ABOVEDOCK") { - l = Fluxbox::instance()->getAboveDockLayer(); + l = Layer::ABOVE_DOCK; } else if (str_label == "MENU") { - l = Fluxbox::instance()->getMenuLayer(); + l = Layer::MENU; } else { FbTk_istringstream iss(str_label.c_str()); iss >> l; diff --git a/src/Resources.cc b/src/Resources.cc index 7ecb017..fbf6a24 100644 --- a/src/Resources.cc +++ b/src/Resources.cc @@ -24,8 +24,11 @@ // holds main resource functions -#include "fluxbox.hh" #include "FbTk/StringUtil.hh" +#include "FbTk/Resource.hh" +#include "fluxbox.hh" + +#include "Layer.hh" #include #include @@ -188,54 +191,55 @@ getString() const { } template<> -void FbTk::Resource:: +void FbTk::Resource:: setFromString(const char *strval) { int tempnum = 0; if (sscanf(strval, "%d", &tempnum) == 1) m_value = tempnum; else if (strcasecmp(strval, "Menu") == 0) - m_value = Fluxbox::instance()->getMenuLayer(); + m_value = ::Layer::MENU; else if (strcasecmp(strval, "AboveDock") == 0) - m_value = Fluxbox::instance()->getAboveDockLayer(); + m_value = ::Layer::ABOVE_DOCK; else if (strcasecmp(strval, "Dock") == 0) - m_value = Fluxbox::instance()->getDockLayer(); + m_value = ::Layer::DOCK; else if (strcasecmp(strval, "Top") == 0) - m_value = Fluxbox::instance()->getTopLayer(); + m_value = ::Layer::TOP; else if (strcasecmp(strval, "Normal") == 0) - m_value = Fluxbox::instance()->getNormalLayer(); + m_value = ::Layer::NORMAL; else if (strcasecmp(strval, "Bottom") == 0) - m_value = Fluxbox::instance()->getBottomLayer(); + m_value = ::Layer::BOTTOM; else if (strcasecmp(strval, "Desktop") == 0) - m_value = Fluxbox::instance()->getDesktopLayer(); + m_value = ::Layer::DESKTOP; else setDefaultValue(); } template<> -string FbTk::Resource:: +std::string FbTk::Resource:: getString() const { - - if (m_value.getNum() == Fluxbox::instance()->getMenuLayer()) - return string("Menu"); - else if (m_value.getNum() == Fluxbox::instance()->getAboveDockLayer()) - return string("AboveDock"); - else if (m_value.getNum() == Fluxbox::instance()->getDockLayer()) - return string("Dock"); - else if (m_value.getNum() == Fluxbox::instance()->getTopLayer()) - return string("Top"); - else if (m_value.getNum() == Fluxbox::instance()->getNormalLayer()) - return string("Normal"); - else if (m_value.getNum() == Fluxbox::instance()->getBottomLayer()) - return string("Bottom"); - else if (m_value.getNum() == Fluxbox::instance()->getDesktopLayer()) - return string("Desktop"); - else { + switch (m_value.getNum()) { + case Layer::MENU: + return std::string("Menu"); + case Layer::ABOVE_DOCK: + return std::string("AboveDock"); + case Layer::DOCK: + return std::string("Dock"); + case Layer::TOP: + return std::string("Top"); + case Layer::NORMAL: + return std::string("Normal"); + case Layer::BOTTOM: + return std::string("Bottom"); + case Layer::DESKTOP: + return std::string("Desktop"); + default: char tmpstr[128]; sprintf(tmpstr, "%d", m_value.getNum()); - return string(tmpstr); + return std::string(tmpstr); } } + template<> void FbTk::Resource:: setFromString(const char *strval) { diff --git a/src/Screen.cc b/src/Screen.cc index 2d58a01..8ed5f41 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -362,7 +362,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, *resource.gc_join_style); #ifdef SLIT - m_slit.reset(new Slit(*this, *layerManager().getLayer(fluxbox->getDesktopLayer()), + m_slit.reset(new Slit(*this, *layerManager().getLayer(Layer::DESKTOP), fluxbox->getSlitlistFilename().c_str())); #endif // SLIT @@ -458,8 +458,6 @@ void BScreen::initWindows() { Display *disp = FbTk::App::instance()->display(); XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild); - Fluxbox *fluxbox = Fluxbox::instance(); - // preen the window list of all icon windows... for better dockapp support for (unsigned int i = 0; i < nchild; i++) { @@ -486,6 +484,8 @@ void BScreen::initWindows() { } + Fluxbox *fluxbox = Fluxbox::instance(); + // manage shown windows // complexity: O(n^2) if we have lots of transients to transient_for // but usually O(n) @@ -617,7 +617,7 @@ void BScreen::update(FbTk::Subject *subj) { FbTk::Menu *BScreen::createMenu(const std::string &label) { FbTk::Menu *menu = new FbMenu(menuTheme(), imageControl(), - *layerManager().getLayer(Fluxbox::instance()->getMenuLayer())); + *layerManager().getLayer(Layer::MENU)); if (!label.empty()) menu->setLabel(label.c_str()); @@ -1235,7 +1235,7 @@ FluxboxWindow *BScreen::createWindow(Window client) { else { win = new FluxboxWindow(*winclient, winFrameTheme(), - *layerManager().getLayer(Fluxbox::instance()->getNormalLayer())); + *layerManager().getLayer(Layer::NORMAL)); if (!win->isManaged()) { delete win; @@ -1274,7 +1274,7 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) { FluxboxWindow *win = new FluxboxWindow(client, winFrameTheme(), - *layerManager().getLayer(Fluxbox::instance()->getNormalLayer())); + *layerManager().getLayer(Layer::NORMAL)); #ifdef SLIT if (win->initialState() == WithdrawnState && slit() != 0) { diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc index 6c6f53c..1cf99b0 100644 --- a/src/SendToMenu.cc +++ b/src/SendToMenu.cc @@ -26,9 +26,10 @@ #include "Window.hh" #include "Screen.hh" -#include "fluxbox.hh" #include "Workspace.hh" #include "WindowCmd.hh" +#include "fluxbox.hh" +#include "Layer.hh" #include "FbTk/MultiButtonMenuItem.hh" #include "FbTk/Command.hh" @@ -50,7 +51,7 @@ private: SendToMenu::SendToMenu(BScreen &screen): FbMenu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) { + *screen.layerManager().getLayer(Layer::MENU)) { // listen to: // workspace count signal // workspace names signal diff --git a/src/Slit.cc b/src/Slit.cc index 0436769..d8f886b 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -44,7 +44,6 @@ #include "MacroCommand.hh" #include "FbCommands.hh" #include "LayerMenu.hh" -#include "fluxbox.hh" #include "XLayer.hh" #include "RootTheme.hh" #include "FbTk/Theme.hh" @@ -252,13 +251,13 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) m_screen(scr), m_slitmenu(scr.menuTheme(), scr.imageControl(), - *scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + *scr.layerManager().getLayer(Layer::MENU)), m_placement_menu(scr.menuTheme(), scr.imageControl(), - *scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + *scr.layerManager().getLayer(Layer::MENU)), m_clientlist_menu(scr.menuTheme(), scr.imageControl(), - *scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + *scr.layerManager().getLayer(Layer::MENU)), frame(scr.rootWindow()), //For KDE dock applets m_kwm1_dockwindow(XInternAtom(FbTk::App::instance()->display(), @@ -284,7 +283,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) scr.name() + ".slit.alpha", scr.altName() + ".Slit.Alpha"), m_rc_on_head(scr.resourceManager(), 0, scr.name() + ".slit.onhead", scr.altName() + ".Slit.onHead"), - m_rc_layernum(scr.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDockLayer()), + m_rc_layernum(scr.resourceManager(), Layer(Layer::DOCK), scr.name() + ".slit.layer", scr.altName() + ".Slit.Layer") { _FB_USES_NLS; @@ -317,7 +316,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) m_layermenu.reset(new LayerMenu(scr.menuTheme(), scr.imageControl(), *scr.layerManager(). - getLayer(Fluxbox::instance()->getMenuLayer()), + getLayer(Layer::MENU), this, true)); m_layermenu->setLabel(_FBTEXT(Slit, Layer, "Slit Layer", "Title of Slit Layer Menu")); @@ -1240,7 +1239,7 @@ void Slit::setupMenu() { screen().menuTheme(), screen(), screen().imageControl(), - *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + *screen().layerManager().getLayer(Layer::MENU), *this, _FBTEXT(Slit, OnHead, "Slit on Head", "Title of Slits On Head menu") )); diff --git a/src/Slit.hh b/src/Slit.hh index e540023..da52793 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -29,7 +29,7 @@ #include "LayerMenu.hh" -#include "fluxbox.hh" +#include "Layer.hh" #include "FbTk/Menu.hh" #include "FbTk/FbWindow.hh" @@ -49,6 +49,7 @@ class SlitClient; class BScreen; class FbMenu; class Strut; +class Layer; /// Handles dock apps class Slit: public FbTk::EventHandler, public FbTk::Observer, public LayerObject { @@ -176,7 +177,7 @@ private: FbTk::Resource m_rc_placement; FbTk::Resource m_rc_direction; FbTk::Resource m_rc_alpha, m_rc_on_head; - FbTk::Resource m_rc_layernum; + FbTk::Resource m_rc_layernum; }; diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 5f046d6..a735188 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -33,13 +33,13 @@ #include "ToolbarTheme.hh" #include "FbTk/I18n.hh" -#include "fluxbox.hh" #include "Screen.hh" #include "IntResMenuItem.hh" #include "BoolMenuItem.hh" #include "Xinerama.hh" #include "Strut.hh" #include "CommandParser.hh" +#include "Layer.hh" #include "FbTk/ImageControl.hh" #include "FbTk/MacroCommand.hh" @@ -198,15 +198,15 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): m_layeritem(frame.window, layer), m_layermenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + *scrn.layerManager().getLayer(Layer::MENU), this, true), m_placementmenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + *scrn.layerManager().getLayer(Layer::MENU)), m_toolbarmenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + *scrn.layerManager().getLayer(Layer::MENU)), m_theme(scrn.screenNumber()), m_tool_factory(scrn), m_strut(0), @@ -220,7 +220,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"), m_rc_alpha(scrn.resourceManager(), 255, scrn.name() + ".toolbar.alpha", scrn.altName() + ".Toolbar.Alpha"), - m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()), + m_rc_layernum(scrn.resourceManager(), Layer(Layer::DESKTOP), scrn.name() + ".toolbar.layer", scrn.altName() + ".Toolbar.Layer"), m_rc_on_head(scrn.resourceManager(), 0, scrn.name() + ".toolbar.onhead", scrn.altName() + ".Toolbar.onHead"), @@ -799,7 +799,8 @@ void Toolbar::setupMenus() { visible_macro->add(reconfig_toolbar); visible_macro->add(save_resources); RefCommand toggle_visible_cmd(visible_macro); - menu().insert(new BoolMenuItem(_FBTEXT(Common, Visible, "Visible", "Whether this item is visible"), + menu().insert(new BoolMenuItem(_FBTEXT(Common, Visible, + "Visible", "Whether this item is visible"), *m_rc_visible, toggle_visible_cmd)); menu().insert(new BoolMenuItem(_FBTEXT(Common, AutoHide, @@ -807,27 +808,33 @@ void Toolbar::setupMenus() { *m_rc_auto_hide, reconfig_toolbar_and_save_resource)); - MenuItem *toolbar_menuitem = new IntResMenuItem(_FBTEXT(Toolbar, WidthPercent, "Toolbar width percent", "Percentage of screen width taken by toolbar"), - m_rc_width_percent, - 0, 100, menu()); // min/max value + MenuItem *toolbar_menuitem = + new IntResMenuItem(_FBTEXT(Toolbar, WidthPercent, + "Toolbar width percent", + "Percentage of screen width taken by toolbar"), + m_rc_width_percent, + 0, 100, menu()); // min/max value toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource); menu().insert(toolbar_menuitem); - menu().insert(new BoolMenuItem(_FBTEXT(Common, MaximizeOver,"Maximize Over", "Maximize over this thing when maximizing"), + menu().insert(new BoolMenuItem(_FBTEXT(Common, MaximizeOver, + "Maximize Over", + "Maximize over this thing when maximizing"), *m_rc_maximize_over, reconfig_toolbar_and_save_resource)); menu().insert(_FBTEXT(Menu, Layer, "Layer...", "Title of Layer menu"), &layerMenu()); if (screen().hasXinerama()) { menu().insert(_FBTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"), - new XineramaHeadMenu(screen().menuTheme(), - screen(), - screen().imageControl(), - *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), - *this, - _FBTEXT(Toolbar, OnHead, "Toolbar on Head", "Title of toolbar on head menu"))); + new XineramaHeadMenu(screen().menuTheme(), + screen(), + screen().imageControl(), + *screen().layerManager().getLayer(::Layer::MENU), + *this, + _FBTEXT(Toolbar, OnHead, "Toolbar on Head", + "Title of toolbar on head menu"))); } typedef pair PlacementP; diff --git a/src/Toolbar.hh b/src/Toolbar.hh index fb4aacd..7fde897 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -31,7 +31,7 @@ #include "LayerMenu.hh" #include "ToolFactory.hh" #include "ToolTheme.hh" -#include "fluxbox.hh" +#include "Layer.hh" #include "FbTk/Timer.hh" #include "FbTk/Resource.hh" @@ -183,7 +183,7 @@ private: FbTk::Resource m_rc_auto_hide, m_rc_maximize_over, m_rc_visible; FbTk::Resource m_rc_width_percent; FbTk::Resource m_rc_alpha; - FbTk::Resource m_rc_layernum; + FbTk::Resource m_rc_layernum; FbTk::Resource m_rc_on_head; FbTk::Resource m_rc_placement; FbTk::Resource m_rc_height; diff --git a/src/Window.cc b/src/Window.cc index e6db450..fbec829 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -41,6 +41,7 @@ #include "MenuCreator.hh" #include "StringUtil.hh" #include "FocusControl.hh" +#include "Layer.hh" #include "FbTk/TextButton.hh" #include "FbTk/Compose.hh" @@ -1595,7 +1596,7 @@ void FluxboxWindow::setFullscreen(bool flag) { // be xinerama aware moveResize(screen().getHeadX(head), screen().getHeadY(head), screen().getHeadWidth(head), screen().getHeadHeight(head)); - moveToLayer(Fluxbox::instance()->getAboveDockLayer()); + moveToLayer(::Layer::ABOVE_DOCK); fullscreen = true; @@ -1612,7 +1613,7 @@ void FluxboxWindow::setFullscreen(bool flag) { moveToLayer(m_old_layernum); m_old_decoration_mask = 0; - m_old_layernum = Fluxbox::instance()->getNormalLayer(); + m_old_layernum = ::Layer::NORMAL; stateSig().notify(); } @@ -1886,7 +1887,7 @@ void FluxboxWindow::tempRaise() { void FluxboxWindow::raiseLayer() { // don't let it up to menu layer - if (layerNum() == (Fluxbox::instance()->getMenuLayer()+1)) + if (layerNum() == ::Layer::MENU + 1) return; if (!isInitialized()) { @@ -1968,11 +1969,9 @@ void FluxboxWindow::moveToLayer(int layernum) { cerr<<"FluxboxWindow("<getMenuLayer()) { - layernum = fluxbox->getMenuLayer() + 1; + if (layernum <= ::Layer::MENU) { + layernum = ::Layer::MENU + 1; } if (!isInitialized()) { diff --git a/src/Workspace.cc b/src/Workspace.cc index 7d53381..b874391 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -26,7 +26,6 @@ #include "Workspace.hh" -#include "fluxbox.hh" #include "Screen.hh" #include "Window.hh" #include "WinClient.hh" @@ -34,6 +33,7 @@ #include "WindowCmd.hh" #include "FocusControl.hh" #include "PlacementStrategy.hh" +#include "Layer.hh" #include "FbTk/I18n.hh" #include "FbTk/MenuItem.hh" @@ -136,7 +136,7 @@ Workspace::Workspace(BScreen &scrn, FbTk::MultLayers &layermanager, m_screen(scrn), m_lastfocus(0), m_clientmenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), + *scrn.layerManager().getLayer(Layer::MENU)), m_layermanager(layermanager), m_name(name), m_id(id) { diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index 1e3dc40..c3dfd9a 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -24,12 +24,12 @@ #include "WorkspaceMenu.hh" #include "Screen.hh" -#include "fluxbox.hh" #include "Workspace.hh" #include "WorkspaceCmd.hh" #include "MenuCreator.hh" #include "CommandParser.hh" #include "FbCommands.hh" +#include "Layer.hh" #include "FbTk/I18n.hh" #include "FbTk/SimpleCommand.hh" @@ -57,8 +57,7 @@ WorkspaceMenu::WorkspaceMenu(BScreen &screen): FbMenu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager(). - getLayer(Fluxbox::instance()->getMenuLayer())) { + *screen.layerManager().getLayer(Layer::MENU)) { init(screen); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index d2759d0..75a4765 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -35,6 +35,7 @@ #include "Keys.hh" #include "FbAtoms.hh" #include "FocusControl.hh" +#include "Layer.hh" #include "defaults.hh" @@ -491,7 +492,7 @@ int Fluxbox::initScreen(int scrnr) { #ifdef USE_TOOLBAR m_toolbars.push_back(new Toolbar(*screen, *screen->layerManager(). - getLayer(Fluxbox::instance()->getNormalLayer()))); + getLayer(::Layer::NORMAL))); #endif // USE_TOOLBAR // must do this after toolbar is created diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 40b0379..ad75957 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -136,26 +136,6 @@ public: // we have a special resource type because we need to be able to name certain layers // a Resource wouldn't allow this - class Layer { - public: - explicit Layer(int i) : m_num(i) {}; - int getNum() const { return m_num; } - - Layer &operator=(int num) { m_num = num; return *this; } - - private: - int m_num; - }; - - // TODO these probably should be configurable - int getMenuLayer() const { return 0; } - int getAboveDockLayer() const { return 2; } - int getDockLayer() const { return 4; } - int getTopLayer() const { return 6; } - int getNormalLayer() const { return 8; } - int getBottomLayer() const { return 10; } - int getDesktopLayer() const { return 12; } - time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; } -- cgit v0.11.2