From 698a4af938737295494dade50950d1aeebc8b55d Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 15 Aug 2011 23:03:57 +0200 Subject: Move declarations of Resource enums to a separate file The reason for this is that I need to access those enums from fluxbox-update_configs and I don't want to #include and link everything in src. I also merged Slit::Placement, Toolbar::Placement and FbWinFrame::TabPlacement into one enum. --- src/ClientMenu.cc | 2 +- src/ColSmartPlacement.cc | 6 +- src/Ewmh.cc | 28 ++++----- src/FbWinFrame.cc | 34 +++++------ src/FbWinFrame.hh | 12 ---- src/FocusControl.cc | 27 +-------- src/FocusControl.hh | 13 +---- src/FocusModelMenuItem.hh | 8 +-- src/IconbarTool.cc | 14 +---- src/Layer.hh | 46 +++++---------- src/LayerMenu.cc | 12 ++-- src/Makefile.am | 2 +- src/MenuCreator.cc | 6 +- src/MinOverlapPlacement.cc | 24 ++++---- src/Resources.cc | 137 +++++++++++++++++++++++++++++++++------------ src/Resources.hh | 100 +++++++++++++++++++++++++++++++++ src/RowSmartPlacement.cc | 8 +-- src/Screen.cc | 87 +++++++++------------------- src/Screen.hh | 9 +-- src/ScreenPlacement.cc | 34 +---------- src/ScreenPlacement.hh | 19 +------ src/SendToMenu.cc | 2 +- src/Slit.cc | 73 +++++++++--------------- src/Slit.hh | 16 +----- src/Toolbar.cc | 75 +++++++++---------------- src/Toolbar.hh | 18 +----- src/WinButton.cc | 44 +++++++-------- src/WinButton.hh | 7 +-- src/Window.cc | 64 ++++++++++----------- src/Window.hh | 2 +- src/WindowState.hh | 2 +- src/WorkspaceCmd.cc | 2 +- src/WorkspaceMenu.cc | 2 +- src/fluxbox.cc | 2 +- src/fluxbox.hh | 7 +-- 35 files changed, 445 insertions(+), 499 deletions(-) create mode 100644 src/Resources.hh diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc index 96527ec..c2413e3 100644 --- a/src/ClientMenu.cc +++ b/src/ClientMenu.cc @@ -90,7 +90,7 @@ private: ClientMenu::ClientMenu(BScreen &screen, Focusables &clients, bool listen_for_iconlist_changes): FbMenu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager().getLayer(ResourceLayer::MENU)), + *screen.layerManager().getLayer(LAYERMENU)), m_list(clients) { if (listen_for_iconlist_changes) { diff --git a/src/ColSmartPlacement.cc b/src/ColSmartPlacement.cc index b0bcf68..304deca 100644 --- a/src/ColSmartPlacement.cc +++ b/src/ColSmartPlacement.cc @@ -53,8 +53,8 @@ bool ColSmartPlacement::placeWindow(const FluxboxWindow &win, int head, int next_x, next_y; const ScreenPlacement &screen_placement = win.screen().placementStrategy(); - bool top_bot = screen_placement.colDirection() == ScreenPlacement::TOPBOTTOM; - bool left_right = screen_placement.rowDirection() == ScreenPlacement::LEFTRIGHT; + bool top_bot = screen_placement.colDirection() == TOPBOTTOMDIRECTION; + bool left_right = screen_placement.rowDirection() == LEFTRIGHTDIRECTION; int test_x; @@ -70,7 +70,7 @@ bool ColSmartPlacement::placeWindow(const FluxboxWindow &win, int head, test_x = head_right - win_w; int change_y = 1; - if (screen_placement.colDirection() == ScreenPlacement::BOTTOMTOP) + if (screen_placement.colDirection() == BOTTOMTOPDIRECTION) change_y = -1; while (!placed && diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 291c39b..be3b1bb 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -993,9 +993,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() == ResourceLayer::BOTTOM) + if (win.layerNum() == LAYERBOTTOM) state.push_back(m_net->wm_state_below); - if (win.layerNum() == ResourceLayer::ABOVE_DOCK) + if (win.layerNum() == LAYERABOVE_DOCK) state.push_back(m_net->wm_state_above); if (win.isIconic()) state.push_back(m_net->wm_state_hidden); @@ -1347,14 +1347,14 @@ 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(ResourceLayer::BOTTOM); - else if (win.layerNum() > ResourceLayer::NORMAL) - win.moveToLayer(ResourceLayer::NORMAL); + win.moveToLayer(LAYERBOTTOM); + else if (win.layerNum() > LAYERNORMAL) + win.moveToLayer(LAYERNORMAL); } else if (state == m_net->wm_state_above) { // above layer if (value) - win.moveToLayer(ResourceLayer::ABOVE_DOCK); - else if (win.layerNum() < ResourceLayer::NORMAL) - win.moveToLayer(ResourceLayer::NORMAL); + win.moveToLayer(LAYERABOVE_DOCK); + else if (win.layerNum() < LAYERNORMAL) + win.moveToLayer(LAYERNORMAL); } else if (state == m_net->wm_state_demands_attention) { if (value) { // if add attention Fluxbox::instance()->attentionHandler().addAttention(client); @@ -1387,16 +1387,16 @@ void Ewmh::toggleState(FluxboxWindow &win, Atom state, WinClient &client) { } else if (state == m_net->wm_state_skip_taskbar) { // taskbar win.setIconHidden(!win.isIconHidden()); } else if (state == m_net->wm_state_below) { // bottom layer - if (win.layerNum() == ResourceLayer::BOTTOM) - win.moveToLayer(ResourceLayer::NORMAL); + if (win.layerNum() == LAYERBOTTOM) + win.moveToLayer(LAYERNORMAL); else - win.moveToLayer(ResourceLayer::BOTTOM); + win.moveToLayer(LAYERBOTTOM); } else if (state == m_net->wm_state_above) { // top layer - if (win.layerNum() == ResourceLayer::ABOVE_DOCK) - win.moveToLayer(ResourceLayer::NORMAL); + if (win.layerNum() == LAYERABOVE_DOCK) + win.moveToLayer(LAYERNORMAL); else - win.moveToLayer(ResourceLayer::ABOVE_DOCK); + win.moveToLayer(LAYERABOVE_DOCK); } else if (state == m_net->wm_state_modal) { // modal client.setStateModal(!client.isStateModal()); } diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index a76df66..7927cd7 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -59,7 +59,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, unsigned int client_depth, client_depth, InputOutput, ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().visual() : CopyFromParent), ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().colormap() : CopyFromParent)), - m_layeritem(window(), *screen.layerManager().getLayer(ResourceLayer::NORMAL)), + m_layeritem(window(), *screen.layerManager().getLayer(LAYERNORMAL)), m_titlebar(m_window, 0, 0, 100, 16, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | @@ -269,8 +269,8 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh switch(*m_screen.getTabPlacementResource()) { case LEFTTOP: case RIGHTTOP: - case LEFT: - case RIGHT: + case LEFTCENTER: + case RIGHTCENTER: case LEFTBOTTOM: case RIGHTBOTTOM: m_tab_container.setMaxTotalSize(height); @@ -294,8 +294,8 @@ void FbWinFrame::quietMoveResize(int x, int y, switch(*m_screen.getTabPlacementResource()) { case LEFTTOP: case RIGHTTOP: - case LEFT: - case RIGHT: + case LEFTCENTER: + case RIGHTCENTER: case LEFTBOTTOM: case RIGHTBOTTOM: m_tab_container.setMaxTotalSize(height); @@ -329,7 +329,7 @@ void FbWinFrame::alignTabs() { tabx = x(); taby = y() - yOffset(); break; - case TOP: + case TOPCENTER: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); m_tab_container.setAlignment(FbTk::Container::CENTER); @@ -353,7 +353,7 @@ void FbWinFrame::alignTabs() { tabx = x() - xOffset(); taby = y(); break; - case LEFT: + case LEFTCENTER: if (orig_orient != FbTk::ROT270) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT270); m_tab_container.setAlignment(FbTk::Container::CENTER); @@ -377,7 +377,7 @@ void FbWinFrame::alignTabs() { tabx = x() + width() + m_window.borderWidth(); taby = y(); break; - case RIGHT: + case RIGHTCENTER: if (orig_orient != FbTk::ROT90) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT90); m_tab_container.setAlignment(FbTk::Container::CENTER); @@ -401,7 +401,7 @@ void FbWinFrame::alignTabs() { tabx = x(); taby = y() + height() + m_window.borderWidth(); break; - case BOTTOM: + case BOTTOMCENTER: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); m_tab_container.setAlignment(FbTk::Container::CENTER); @@ -912,10 +912,10 @@ void FbWinFrame::reconfigure() { unsigned int neww, newh; switch (*m_screen.getTabPlacementResource()) { case TOPLEFT: - case TOP: + case TOPCENTER: case TOPRIGHT: case BOTTOMLEFT: - case BOTTOM: + case BOTTOMCENTER: case BOTTOMRIGHT: neww = m_tab_container.width(); newh = buttonHeight(); @@ -1643,8 +1643,8 @@ int FbWinFrame::widthOffset() const { switch (*m_screen.getTabPlacementResource()) { case LEFTTOP: case RIGHTTOP: - case LEFT: - case RIGHT: + case LEFTCENTER: + case RIGHTCENTER: case LEFTBOTTOM: case RIGHTBOTTOM: return m_tab_container.width() + m_window.borderWidth(); @@ -1661,10 +1661,10 @@ int FbWinFrame::heightOffset() const { switch (*m_screen.getTabPlacementResource()) { case TOPLEFT: - case TOP: + case TOPCENTER: case TOPRIGHT: case BOTTOMLEFT: - case BOTTOM: + case BOTTOMCENTER: case BOTTOMRIGHT: return m_tab_container.height() + m_window.borderWidth(); break; @@ -1680,7 +1680,7 @@ int FbWinFrame::xOffset() const { switch (*m_screen.getTabPlacementResource()) { case LEFTTOP: - case LEFT: + case LEFTCENTER: case LEFTBOTTOM: return m_tab_container.width() + m_window.borderWidth(); break; @@ -1696,7 +1696,7 @@ int FbWinFrame::yOffset() const { switch (*m_screen.getTabPlacementResource()) { case TOPLEFT: - case TOP: + case TOPCENTER: case TOPRIGHT: return m_tab_container.height() + m_window.borderWidth(); break; diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 347a668..b11c44a 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -57,18 +57,6 @@ public: // STRICTINTERNAL means it doesn't go external automatically when no titlebar enum TabMode { NOTSET = 0, INTERNAL = 1, EXTERNAL }; - /// Toolbar placement on the screen - enum TabPlacement{ - // top and bottom placement - TOPLEFT = 1, TOP, TOPRIGHT, - BOTTOMLEFT, BOTTOM, BOTTOMRIGHT, - // left and right placement - LEFTBOTTOM, LEFT, LEFTTOP, - RIGHTBOTTOM, RIGHT, RIGHTTOP, - - DEFAULT = TOPLEFT - }; - /// create a top level window FbWinFrame(BScreen &screen, unsigned int client_depth, WindowState &state, FocusableTheme &theme); diff --git a/src/FocusControl.cc b/src/FocusControl.cc index d8aca85..61e2645 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -494,12 +494,12 @@ void FocusControl::revertFocus(BScreen &screen) { FbTk::Menu::shownMenu()->grabInputFocus(); else { switch (screen.focusControl().focusModel()) { - case FocusControl::MOUSEFOCUS: - case FocusControl::STRICTMOUSEFOCUS: + case MOUSEFOCUS: + case STRICTMOUSEFOCUS: XSetInputFocus(screen.rootWindow().display(), PointerRoot, None, CurrentTime); break; - case FocusControl::CLICKFOCUS: + case CLICKFOCUS: screen.rootWindow().setInputFocus(RevertToPointerRoot, CurrentTime); break; @@ -591,24 +591,3 @@ void FocusControl::setFocusedWindow(WinClient *client) { if (old_screen && screen != old_screen) old_screen->focusedWindowSig().emit(*old_screen, s_focused_fbwindow, s_focused_window); } - -////////////////////// FocusControl RESOURCES -namespace FbTk { - -template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "MouseFocus", FocusControl::MOUSEFOCUS }, - { "StrictMouseFocus", FocusControl::STRICTMOUSEFOCUS }, - { "ClickFocus", FocusControl::CLICKFOCUS }, - { NULL, FocusControl::CLICKFOCUS } -}; - -template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "SloppyTabFocus", FocusControl::MOUSETABFOCUS }, - { "ClickToTabFocus", FocusControl::CLICKTABFOCUS }, - { NULL, FocusControl::CLICKTABFOCUS } -}; - -} // end namespace FbTk - diff --git a/src/FocusControl.hh b/src/FocusControl.hh index 19059da..8a8c96f 100644 --- a/src/FocusControl.hh +++ b/src/FocusControl.hh @@ -26,6 +26,7 @@ #include "FbTk/Resource.hh" #include "FocusableList.hh" +#include "Resources.hh" class ClientPattern; class WinClient; @@ -40,18 +41,6 @@ class BScreen; class FocusControl { public: typedef std::list Focusables; - /// main focus model - enum FocusModel { - MOUSEFOCUS = 0, ///< focus follows mouse, but only when the mouse is moving - CLICKFOCUS, ///< focus on click - STRICTMOUSEFOCUS ///< focus always follows mouse, even when stationary - }; - /// focus model for tabs - enum TabFocusModel { - MOUSETABFOCUS = 0, ///< tab focus follows mouse - CLICKTABFOCUS ///< tab focus on click - }; - /// focus direction for windows enum FocusDir { FOCUSUP, ///< window is above diff --git a/src/FocusModelMenuItem.hh b/src/FocusModelMenuItem.hh index 7541659..6ac2c93 100644 --- a/src/FocusModelMenuItem.hh +++ b/src/FocusModelMenuItem.hh @@ -36,7 +36,7 @@ template class Command; class FocusModelMenuItem : public FbTk::RadioMenuItem { public: FocusModelMenuItem(const FbTk::FbString &label, FocusControl &focus_control, - FocusControl::FocusModel model, + FocusModel model, FbTk::RefCount > &cmd): FbTk::RadioMenuItem(label, cmd), m_focus_control(focus_control), @@ -53,14 +53,14 @@ public: private: FocusControl &m_focus_control; - FocusControl::FocusModel m_focusmodel; + FocusModel m_focusmodel; }; class TabFocusModelMenuItem : public FbTk::RadioMenuItem { public: TabFocusModelMenuItem(const FbTk::FbString &label, FocusControl &focus_control, - FocusControl::TabFocusModel model, + TabFocusModel model, FbTk::RefCount > &cmd): FbTk::RadioMenuItem(label, cmd), m_focus_control(focus_control), @@ -77,7 +77,7 @@ public: private: FocusControl &m_focus_control; - FocusControl::TabFocusModel m_tabfocusmodel; + TabFocusModel m_tabfocusmodel; }; diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 621a8a1..64378e4 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -65,18 +65,6 @@ using std::string; using std::list; using std::endl; -namespace FbTk { - -template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "Left", Container::LEFT }, - { "Right", Container::RIGHT }, - { "Relative", Container::RELATIVE }, - { NULL, Container::RELATIVE } -}; - -} // end namespace FbTk - class IconbarTool::ToolbarModeMenuItem : public FbTk::RadioMenuItem { public: ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, @@ -231,7 +219,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, screen.name() + ".iconbar.iconTextPadding"), m_rc_use_pixmap(screen.resourceManager(), true, screen.name() + ".iconbar.usePixmap"), m_menu(new FbMenu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager().getLayer(ResourceLayer::MENU)) ), + *screen.layerManager().getLayer(LAYERMENU)) ), m_alpha(255) { // setup mode menu diff --git a/src/Layer.hh b/src/Layer.hh index 34dd350..4cc0282 100644 --- a/src/Layer.hh +++ b/src/Layer.hh @@ -23,6 +23,7 @@ #define RESOURCE_LAYER_HH #include "FbTk/StringUtil.hh" +#include "Resources.hh" /** * (This is not the layer->raise/lower handling stuff, @see FbTk::Layer) @@ -32,23 +33,6 @@ */ class ResourceLayer { public: - enum Type { - MENU = 0, - LAYER1 = 1, - ABOVE_DOCK = 2, - LAYER3 = 3, - DOCK = 4, - LAYER5 = 5, - TOP = 6, - LAYER7 = 7, - NORMAL = 8, - LAYER9 = 9, - BOTTOM = 10, - LAYER11 = 11, - DESKTOP = 12, - NUM_LAYERS = 13 - }; - explicit ResourceLayer(int i) : m_num(i) {}; static int getNumFromString(const std::string &str) { @@ -57,37 +41,37 @@ public: if (FbTk::StringUtil::extractNumber(str, tempnum)) return tempnum; if (v == "menu") - return ::ResourceLayer::MENU; + return LAYERMENU; if (v == "abovedock") - return ::ResourceLayer::ABOVE_DOCK; + return LAYERABOVE_DOCK; if (v == "dock") - return ::ResourceLayer::DOCK; + return LAYERDOCK; if (v == "top") - return ::ResourceLayer::TOP; + return LAYERTOP; if (v == "normal") - return ::ResourceLayer::NORMAL; + return LAYERNORMAL; if (v == "bottom") - return ::ResourceLayer::BOTTOM; + return LAYERBOTTOM; if (v == "desktop") - return ::ResourceLayer::DESKTOP; + return LAYERDESKTOP; return -1; } static std::string getString(int num) { switch (num) { - case ::ResourceLayer::MENU: + case LAYERMENU: return std::string("Menu"); - case ::ResourceLayer::ABOVE_DOCK: + case LAYERABOVE_DOCK: return std::string("AboveDock"); - case ::ResourceLayer::DOCK: + case LAYERDOCK: return std::string("Dock"); - case ::ResourceLayer::TOP: + case LAYERTOP: return std::string("Top"); - case ::ResourceLayer::NORMAL: + case LAYERNORMAL: return std::string("Normal"); - case ::ResourceLayer::BOTTOM: + case LAYERBOTTOM: return std::string("Bottom"); - case ::ResourceLayer::DESKTOP: + case LAYERDESKTOP: return std::string("Desktop"); default: return FbTk::StringUtil::number2String(num); diff --git a/src/LayerMenu.cc b/src/LayerMenu.cc index 94a6622..fda3da2 100644 --- a/src/LayerMenu.cc +++ b/src/LayerMenu.cc @@ -42,12 +42,12 @@ LayerMenu::LayerMenu(FbTk::ThemeProxy &tm, int layernum; } layer_menuitems[] = { //TODO: nls - {0, 0, _FB_XTEXT(Layer, AboveDock, "Above Dock", "Layer above dock"), ResourceLayer::ABOVE_DOCK}, - {0, 0, _FB_XTEXT(Layer, Dock, "Dock", "Layer dock"), ResourceLayer::DOCK}, - {0, 0, _FB_XTEXT(Layer, Top, "Top", "Layer top"), ResourceLayer::TOP}, - {0, 0, _FB_XTEXT(Layer, Normal, "Normal", "Layer normal"), ResourceLayer::NORMAL}, - {0, 0, _FB_XTEXT(Layer, Bottom, "Bottom", "Layer bottom"), ResourceLayer::BOTTOM}, - {0, 0, _FB_XTEXT(Layer, Desktop, "Desktop", "Layer desktop"), ResourceLayer::DESKTOP}, + {0, 0, _FB_XTEXT(Layer, AboveDock, "Above Dock", "Layer above dock"), LAYERABOVE_DOCK}, + {0, 0, _FB_XTEXT(Layer, Dock, "Dock", "Layer dock"), LAYERDOCK}, + {0, 0, _FB_XTEXT(Layer, Top, "Top", "Layer top"), LAYERTOP}, + {0, 0, _FB_XTEXT(Layer, Normal, "Normal", "Layer normal"), LAYERNORMAL}, + {0, 0, _FB_XTEXT(Layer, Bottom, "Bottom", "Layer bottom"), LAYERBOTTOM}, + {0, 0, _FB_XTEXT(Layer, Desktop, "Desktop", "Layer desktop"), LAYERDESKTOP}, }; FbTk::RefCount > saverc_cmd(new FbCommands::SaveResources()); diff --git a/src/Makefile.am b/src/Makefile.am index 335a090..3f33f78 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -145,7 +145,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ FocusModelMenuItem.hh \ ToggleMenu.hh \ HeadArea.hh HeadArea.cc \ - Resources.cc \ + Resources.hh Resources.cc \ WindowCmd.hh WindowCmd.cc \ FocusControl.hh FocusControl.cc \ PlacementStrategy.hh \ diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 56b90c0..536a5bc 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -343,7 +343,7 @@ FbMenu *MenuCreator::createMenu(const string &label, int screen_number) { FbMenu *menu = new FbMenu(screen->menuTheme(), screen->imageControl(), - *screen->layerManager().getLayer(ResourceLayer::MENU)); + *screen->layerManager().getLayer(LAYERMENU)); if (!label.empty()) menu->setLabel(label); @@ -462,7 +462,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, return false; RefMenu submenu( new AlphaMenu(screen->menuTheme(), screen->imageControl(), - *screen->layerManager().getLayer(ResourceLayer::MENU)) ); + *screen->layerManager().getLayer(LAYERMENU)) ); submenu->disableTitle(); menu.insert(label.empty() ? _FB_XTEXT(Configmenu, Transparency, "Transparency", "Menu containing various transparency options"): label, @@ -488,7 +488,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, RefMenu submenu( new LayerMenu(screen->menuTheme(), screen->imageControl(), - *screen->layerManager().getLayer(ResourceLayer::MENU), + *screen->layerManager().getLayer(LAYERMENU), &context, false) ); submenu->disableTitle(); diff --git a/src/MinOverlapPlacement.cc b/src/MinOverlapPlacement.cc index 78cadb4..12928c6 100644 --- a/src/MinOverlapPlacement.cc +++ b/src/MinOverlapPlacement.cc @@ -52,19 +52,19 @@ public: // do all STL set implementations use this for sorting? bool operator <(const Area &o) const { switch (s_policy) { - case ScreenPlacement::ROWMINOVERLAPPLACEMENT: + case ROWMINOVERLAPPLACEMENT: // if we're making rows, y-value is most important if (y != o.y) - return ((y < o.y) ^ (s_col_dir == ScreenPlacement::BOTTOMTOP)); + return ((y < o.y) ^ (s_col_dir == BOTTOMTOPDIRECTION)); if (x != o.x) - return ((x < o.x) ^ (s_row_dir == ScreenPlacement::RIGHTLEFT)); + return ((x < o.x) ^ (s_row_dir == RIGHTLEFTDIRECTION)); return (corner < o.corner); - case ScreenPlacement::COLMINOVERLAPPLACEMENT: + case COLMINOVERLAPPLACEMENT: // if we're making columns, x-value is most important if (x != o.x) - return ((x < o.x) ^ (s_row_dir == ScreenPlacement::RIGHTLEFT)); + return ((x < o.x) ^ (s_row_dir == RIGHTLEFTDIRECTION)); if (y != o.y) - return ((y < o.y) ^ (s_col_dir == ScreenPlacement::BOTTOMTOP)); + return ((y < o.y) ^ (s_col_dir == BOTTOMTOPDIRECTION)); return (corner < o.corner); default: return false; @@ -74,14 +74,14 @@ public: // position where the top left corner of the window will be placed int x, y; - static ScreenPlacement::RowDirection s_row_dir; - static ScreenPlacement::ColumnDirection s_col_dir; - static ScreenPlacement::PlacementPolicy s_policy; + static RowDirection s_row_dir; + static ColumnDirection s_col_dir; + static PlacementPolicy s_policy; }; -ScreenPlacement::RowDirection Area::s_row_dir = ScreenPlacement::LEFTRIGHT; -ScreenPlacement::ColumnDirection Area::s_col_dir = ScreenPlacement::TOPBOTTOM; -ScreenPlacement::PlacementPolicy Area::s_policy = ScreenPlacement::ROWMINOVERLAPPLACEMENT; +RowDirection Area::s_row_dir = LEFTRIGHTDIRECTION; +ColumnDirection Area::s_col_dir = TOPBOTTOMDIRECTION; +PlacementPolicy Area::s_policy = ROWMINOVERLAPPLACEMENT; } // end of anonymous namespace diff --git a/src/Resources.cc b/src/Resources.cc index cf09543..3b9f5ee 100644 --- a/src/Resources.cc +++ b/src/Resources.cc @@ -21,14 +21,12 @@ // holds main resource functions +#include "Resources.hh" + +#include "FbTk/Container.hh" #include "FbTk/StringUtil.hh" #include "FbTk/Resource.hh" #include "FbTk/Luamm.hh" -#include "WinButton.hh" - -#include "fluxbox.hh" - -#include "Layer.hh" #include #include @@ -42,45 +40,114 @@ using std::string; using std::vector; -//----------------------------------------------------------------- -//---- accessors for int, bool, and some enums with Resource ------ -//----------------------------------------------------------------- +//-------------------------------------------------- +//---- accessors for some enums with Resource ------ +//-------------------------------------------------- namespace FbTk { template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "Shade", WinButton::SHADE }, - { "Minimize", WinButton::MINIMIZE }, - { "Maximize", WinButton::MAXIMIZE }, - { "Close", WinButton::CLOSE }, - { "Stick", WinButton::STICK }, - { "MenuIcon", WinButton::MENUICON }, - { NULL, WinButton::MENUICON } +const EnumTraits::Pair EnumTraits::s_map[] = { + { "Shade", SHADEBUTTON }, + { "Minimize", MINIMIZEBUTTON }, + { "Maximize", MAXIMIZEBUTTON }, + { "Close", CLOSEBUTTON }, + { "Stick", STICKBUTTON }, + { "MenuIcon", MENUICONBUTTON }, + { NULL, MENUICONBUTTON } +}; + +template<> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "Titlebar", ATTACH_AREA_TITLEBAR }, + { "Window", ATTACH_AREA_WINDOW }, + { NULL, ATTACH_AREA_WINDOW } +}; + +template<> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "Menu", LAYERMENU }, + { "1", LAYER1 }, + { "AboveDock",LAYERABOVE_DOCK }, + { "3", LAYER3 }, + { "Dock", LAYERDOCK }, + { "5", LAYER5 }, + { "Top", LAYERTOP }, + { "7", LAYER7 }, + { "Normal", LAYERNORMAL }, + { "9", LAYER9 }, + { "Bottom", LAYERBOTTOM }, + { "11", LAYER11 }, + { "Desktop", LAYERDESKTOP }, + { NULL, LAYERDESKTOP } +}; + +template<> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "Left", Container::LEFT }, + { "Right", Container::RIGHT }, + { "Relative", Container::RELATIVE }, + { NULL, Container::RELATIVE } +}; + +template<> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "TopLeft", TOPLEFT }, + { "TopCenter", TOPCENTER }, + { "TopRight", TOPRIGHT }, + { "BottomLeft", BOTTOMLEFT }, + { "BottomCenter", BOTTOMCENTER }, + { "BottomRight", BOTTOMRIGHT }, + { "LeftBottom", LEFTBOTTOM }, + { "LeftCenter", LEFTCENTER }, + { "LeftTop", LEFTTOP }, + { "RightBottom", RIGHTBOTTOM }, + { "RightCenter", RIGHTCENTER }, + { "RightTop", RIGHTTOP }, + { "Top", TOPCENTER }, + { "Bottom", BOTTOMCENTER }, + { "Left", LEFTCENTER }, + { "Right", RIGHTCENTER }, + { NULL, RIGHTTOP } +}; + +template <> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "RowSmartPlacement", ROWSMARTPLACEMENT }, + { "ColSmartPlacement", COLSMARTPLACEMENT }, + { "RowMinOverlapPlacement", ROWMINOVERLAPPLACEMENT }, + { "ColMinOverlapPlacement", COLMINOVERLAPPLACEMENT }, + { "UnderMousePlacement", UNDERMOUSEPLACEMENT }, + { "CascadePlacement", CASCADEPLACEMENT }, + { NULL, CASCADEPLACEMENT } +}; + +template <> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "LeftToRight", LEFTRIGHTDIRECTION }, + { "RightToLeft", RIGHTLEFTDIRECTION }, + { NULL, RIGHTLEFTDIRECTION }, +}; + +template <> +const EnumTraits::Pair EnumTraits::s_map[] = { + { "TopToBottom", TOPBOTTOMDIRECTION }, + { "BottomToTop", BOTTOMTOPDIRECTION }, + { NULL, BOTTOMTOPDIRECTION }, }; template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "Titlebar", Fluxbox::ATTACH_AREA_TITLEBAR }, - { "Window", Fluxbox::ATTACH_AREA_WINDOW }, - { NULL, Fluxbox::ATTACH_AREA_WINDOW } +const EnumTraits::Pair EnumTraits::s_map[] = { + { "MouseFocus", MOUSEFOCUS }, + { "StrictMouseFocus", STRICTMOUSEFOCUS }, + { "ClickFocus", CLICKFOCUS }, + { NULL, CLICKFOCUS } }; template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "Menu", ResourceLayer::MENU }, - { "1", ResourceLayer::LAYER1 }, - { "AboveDock",ResourceLayer::ABOVE_DOCK }, - { "3", ResourceLayer::LAYER3 }, - { "Dock", ResourceLayer::DOCK }, - { "5", ResourceLayer::LAYER5 }, - { "Top", ResourceLayer::TOP }, - { "7", ResourceLayer::LAYER7 }, - { "Normal", ResourceLayer::NORMAL }, - { "9", ResourceLayer::LAYER9 }, - { "Bottom", ResourceLayer::BOTTOM }, - { "11", ResourceLayer::LAYER11 }, - { "Desktop", ResourceLayer::DESKTOP }, - { NULL, ResourceLayer::DESKTOP } +const EnumTraits::Pair EnumTraits::s_map[] = { + { "SloppyTabFocus", MOUSETABFOCUS }, + { "ClickToTabFocus", CLICKTABFOCUS }, + { NULL, CLICKTABFOCUS } }; } // end namespace FbTk diff --git a/src/Resources.hh b/src/Resources.hh new file mode 100644 index 0000000..3481a66 --- /dev/null +++ b/src/Resources.hh @@ -0,0 +1,100 @@ +// Resources.hh for Fluxbox Window Manager +// Copyright (c) 2011 Pavel Labath (pavelo at centrum dot sk) +// +// 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 RESOURCES_HH +#define RESOURCES_HH + +#include "FbTk/Resource.hh" + +enum Placement { + // top and bottom placement + TOPLEFT = 1, TOPCENTER, TOPRIGHT, + BOTTOMLEFT, BOTTOMCENTER, BOTTOMRIGHT, + // left and right placement + LEFTBOTTOM, LEFTCENTER, LEFTTOP, + RIGHTBOTTOM, RIGHTCENTER, RIGHTTOP, +}; + +enum PlacementPolicy { + ROWSMARTPLACEMENT, + COLSMARTPLACEMENT, + COLMINOVERLAPPLACEMENT, + ROWMINOVERLAPPLACEMENT, + CASCADEPLACEMENT, + UNDERMOUSEPLACEMENT +}; + +enum RowDirection { + LEFTRIGHTDIRECTION, ///< from left to right + RIGHTLEFTDIRECTION ///< from right to left +}; + +enum ColumnDirection { + TOPBOTTOMDIRECTION, ///< from top to bottom + BOTTOMTOPDIRECTION ///< from bottom to top +}; + +/// main focus model +enum FocusModel { + MOUSEFOCUS = 0, ///< focus follows mouse, but only when the mouse is moving + CLICKFOCUS, ///< focus on click + STRICTMOUSEFOCUS ///< focus always follows mouse, even when stationary +}; + +/// focus model for tabs +enum TabFocusModel { + MOUSETABFOCUS = 0, ///< tab focus follows mouse + CLICKTABFOCUS ///< tab focus on click +}; + +/// draw type for the WinButtons +enum WinButtonType { + MAXIMIZEBUTTON, + MINIMIZEBUTTON, + SHADEBUTTON, + STICKBUTTON, + CLOSEBUTTON, + MENUICONBUTTON +}; + +/// obsolete +enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR}; + +enum LayerType { + LAYERMENU = 0, + LAYER1 = 1, + LAYERABOVE_DOCK = 2, + LAYER3 = 3, + LAYERDOCK = 4, + LAYER5 = 5, + LAYERTOP = 6, + LAYER7 = 7, + LAYERNORMAL = 8, + LAYER9 = 9, + LAYERBOTTOM = 10, + LAYER11 = 11, + LAYERDESKTOP = 12, + NUM_LAYERS = 13 +}; + +typedef FbTk::Resource > PlacementResource; + +#endif /* RESOURCES_HH */ diff --git a/src/RowSmartPlacement.cc b/src/RowSmartPlacement.cc index 79b42bb..3b17aa1 100644 --- a/src/RowSmartPlacement.cc +++ b/src/RowSmartPlacement.cc @@ -55,16 +55,16 @@ bool RowSmartPlacement::placeWindow(const FluxboxWindow &win, int head, const ScreenPlacement &screen_placement = win.screen().placementStrategy(); bool top_bot = - screen_placement.colDirection() == ScreenPlacement::TOPBOTTOM; + screen_placement.colDirection() == TOPBOTTOMDIRECTION; bool left_right = - screen_placement.rowDirection() == ScreenPlacement::LEFTRIGHT; + screen_placement.rowDirection() == LEFTRIGHTDIRECTION; int change_x = 1, change_y = 1; - if (screen_placement.colDirection() == ScreenPlacement::BOTTOMTOP) + if (screen_placement.colDirection() == BOTTOMTOPDIRECTION) change_y = -1; - if (screen_placement.rowDirection() == ScreenPlacement::RIGHTLEFT) + if (screen_placement.rowDirection() == RIGHTLEFTDIRECTION) change_x = -1; int win_w = win.width() + win.fbWindow().borderWidth()*2 + win.widthOffset(); diff --git a/src/Screen.cc b/src/Screen.cc index a051941..98cc782 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -31,7 +31,6 @@ #include "Workspace.hh" #include "Layer.hh" -#include "FocusControl.hh" #include "ScreenPlacement.hh" // menu items @@ -184,7 +183,7 @@ int calcSquareDistance(int x1, int y1, int x2, int y2) { class TabPlacementMenuItem: public FbTk::RadioMenuItem { public: TabPlacementMenuItem(const FbTk::FbString & label, BScreen &screen, - FbWinFrame::TabPlacement place): + Placement place): FbTk::RadioMenuItem(label), m_screen(screen), m_place(place) { @@ -200,42 +199,12 @@ public: private: BScreen &m_screen; - FbWinFrame::TabPlacement m_place; + Placement m_place; }; -struct TabPlacementString { - FbWinFrame::TabPlacement placement; - const char* str; -}; - - - } // end anonymous namespace - -namespace FbTk { - -template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "TopLeft", FbWinFrame::TOPLEFT }, - { "Top", FbWinFrame::TOP }, - { "TopRight", FbWinFrame::TOPRIGHT }, - { "BottomLeft", FbWinFrame::BOTTOMLEFT }, - { "Bottom", FbWinFrame::BOTTOM }, - { "BottomRight", FbWinFrame::BOTTOMRIGHT }, - { "LeftBottom", FbWinFrame::LEFTBOTTOM }, - { "Left", FbWinFrame::LEFT }, - { "LeftTop", FbWinFrame::LEFTTOP }, - { "RightBottom", FbWinFrame::RIGHTBOTTOM }, - { "Right", FbWinFrame::RIGHT }, - { "RightTop", FbWinFrame::RIGHTTOP }, - { NULL, FbWinFrame::RIGHTTOP } -}; - -} // end namespace FbTk - - BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm, const string &scrname): workspace_names(rm, std::vector(), scrname + ".workspaceNames", @@ -250,7 +219,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm, auto_raise(rm, true, scrname+".autoRaise"), click_raises(rm, true, scrname+".clickRaises"), default_deco(rm, "NORMAL", scrname+".defaultDeco"), - tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement"), + tab_placement(rm, TOPLEFT, scrname+".tab.placement"), windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu.lua"), scrname+".windowMenu"), typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay"), workspaces(rm, 4, scrname+".workspaces"), @@ -460,7 +429,7 @@ BScreen::BScreen(FbTk::ResourceManager_base &rm, changeWorkspaceID(first_desktop); #ifdef SLIT - m_slit.reset(new Slit(*this, *layerManager().getLayer(ResourceLayer::DESKTOP))); + m_slit.reset(new Slit(*this, *layerManager().getLayer(LAYERDESKTOP))); #endif // SLIT XFlush(disp); @@ -539,7 +508,7 @@ void BScreen::initWindows() { #ifdef USE_TOOLBAR m_toolbar.reset(new Toolbar(*this, - *layerManager().getLayer(::ResourceLayer::NORMAL))); + *layerManager().getLayer(LAYERNORMAL))); #endif // USE_TOOLBAR unsigned int nchild; @@ -796,7 +765,7 @@ void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) { FbMenu *BScreen::createMenu(const string &label) { FbMenu *menu = new FbMenu(menuTheme(), imageControl(), - *layerManager().getLayer(ResourceLayer::MENU)); + *layerManager().getLayer(LAYERMENU)); if (!label.empty()) menu->setLabel(label); @@ -806,7 +775,7 @@ FbMenu *BScreen::createMenu(const string &label) { FbMenu *BScreen::createToggleMenu(const string &label) { FbMenu *menu = new ToggleMenu(menuTheme(), imageControl(), - *layerManager().getLayer(ResourceLayer::MENU)); + *layerManager().getLayer(LAYERMENU)); if (!label.empty()) menu->setLabel(label); @@ -1462,24 +1431,24 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { _FOCUSITEM(Configmenu, ClickFocus, "Click To Focus", "Click to focus", - FocusControl::CLICKFOCUS); + CLICKFOCUS); _FOCUSITEM(Configmenu, MouseFocus, "Mouse Focus (Keyboard Friendly)", "Mouse Focus (Keyboard Friendly)", - FocusControl::MOUSEFOCUS); + MOUSEFOCUS); _FOCUSITEM(Configmenu, StrictMouseFocus, "Mouse Focus (Strict)", "Mouse Focus (Strict)", - FocusControl::STRICTMOUSEFOCUS); + STRICTMOUSEFOCUS); #undef _FOCUSITEM focus_menu->insert(new FbTk::MenuSeparator()); focus_menu->insert(new TabFocusModelMenuItem(_FB_XTEXT(Configmenu, ClickTabFocus, "ClickTabFocus", "Click tab to focus windows"), - focusControl(), FocusControl::CLICKTABFOCUS, reconf_cmd)); + focusControl(), CLICKTABFOCUS, reconf_cmd)); focus_menu->insert(new TabFocusModelMenuItem(_FB_XTEXT(Configmenu, MouseTabFocus, "MouseTabFocus", "Hover over tab to focus windows"), - focusControl(), FocusControl::MOUSETABFOCUS, reconf_cmd)); + focusControl(), MOUSETABFOCUS, reconf_cmd)); focus_menu->insert(new FbTk::MenuSeparator()); try { @@ -1560,25 +1529,25 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { // menu is 3 wide, 5 down struct PlacementP { const FbTk::FbString label; - FbWinFrame::TabPlacement placement; + Placement placement; }; static const PlacementP place_menu[] = { - { _FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT}, - { _FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP}, - { _FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), FbWinFrame::LEFT}, - { _FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM}, - { _FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT}, - { _FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), FbWinFrame::TOP}, - { "", FbWinFrame::TOPLEFT}, - { "", FbWinFrame::TOPLEFT}, - { "", FbWinFrame::TOPLEFT}, - { _FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), FbWinFrame::BOTTOM}, - { _FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT}, - { _FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP}, - { _FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), FbWinFrame::RIGHT}, - { _FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM}, - { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT} + { _FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), TOPLEFT}, + { _FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), LEFTTOP}, + { _FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), LEFTCENTER}, + { _FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), LEFTBOTTOM}, + { _FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), BOTTOMLEFT}, + { _FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), TOPCENTER}, + { "", TOPLEFT}, + { "", TOPLEFT}, + { "", TOPLEFT}, + { _FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), BOTTOMCENTER}, + { _FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), TOPRIGHT}, + { _FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), RIGHTTOP}, + { _FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), RIGHTCENTER}, + { _FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), RIGHTBOTTOM}, + { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), BOTTOMRIGHT} }; tabplacement_menu->setMinimumColumns(3); diff --git a/src/Screen.hh b/src/Screen.hh index c776566..ffa9303 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -28,6 +28,7 @@ #include "FbMenu.hh" #include "FbWinFrame.hh" #include "FbRootWindow.hh" +#include "Resources.hh" #include "RootTheme.hh" #include "WinButtonTheme.hh" #include "FbWinFrameTheme.hh" @@ -88,10 +89,6 @@ public: typedef std::vector WorkspaceNames; typedef std::list > > ExtraMenus; - typedef FbTk::Resource< - FbWinFrame::TabPlacement, FbTk::EnumTraits - > TabPlacementResource; - BScreen(FbTk::ResourceManager_base &rm, const std::string &screenname, int scrn, int number_of_layers); @@ -123,7 +120,7 @@ public: ExtraMenus &extraWindowMenus() { return m_extramenus; } const ExtraMenus &extraWindowMenus() const { return m_extramenus; } - TabPlacementResource &getTabPlacementResource() { return resource.tab_placement; } + PlacementResource &getTabPlacementResource() { return resource.tab_placement; } unsigned int noFocusWhileTypingDelay() const { return *resource.typing_delay; } const bool allowRemoteActions() const { return *resource.allow_remote_actions; } @@ -517,7 +514,7 @@ private: max_ignore_inc, max_disable_move, max_disable_resize, workspace_warping, show_window_pos, auto_raise, click_raises; FbTk::StringResource default_deco; - TabPlacementResource tab_placement; + PlacementResource tab_placement; FbTk::StringResource windowmenufile; FbTk::UIntResource typing_delay; FbTk::IntResource workspaces, edge_snap_threshold, focused_alpha, diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc index 0da61cd..619cca3 100644 --- a/src/ScreenPlacement.cc +++ b/src/ScreenPlacement.cc @@ -44,9 +44,9 @@ using std::cerr; using std::endl; ScreenPlacement::ScreenPlacement(BScreen &screen): - m_row_direction(screen.resourceManager(), LEFTRIGHT, + m_row_direction(screen.resourceManager(), LEFTRIGHTDIRECTION, screen.name()+".rowPlacementDirection"), - m_col_direction(screen.resourceManager(), TOPBOTTOM, + m_col_direction(screen.resourceManager(), TOPBOTTOMDIRECTION, screen.name()+".colPlacementDirection"), m_placement_policy(screen.resourceManager(), ROWMINOVERLAPPLACEMENT, screen.name()+".windowPlacement"), @@ -174,33 +174,3 @@ void ScreenPlacement::placeAndShowMenu(FbTk::Menu& menu, int x, int y, bool resp menu.show(); menu.grabInputFocus(); } - -////////////////////// Placement Resources -namespace FbTk { - -template <> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "RowSmartPlacement", ScreenPlacement::ROWSMARTPLACEMENT }, - { "ColSmartPlacement", ScreenPlacement::COLSMARTPLACEMENT }, - { "RowMinOverlapPlacement", ScreenPlacement::ROWMINOVERLAPPLACEMENT }, - { "ColMinOverlapPlacement", ScreenPlacement::COLMINOVERLAPPLACEMENT }, - { "UnderMousePlacement", ScreenPlacement::UNDERMOUSEPLACEMENT }, - { "CascadePlacement", ScreenPlacement::CASCADEPLACEMENT }, - { NULL, ScreenPlacement::CASCADEPLACEMENT } -}; - -template <> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "LeftToRight", ScreenPlacement::LEFTRIGHT }, - { "RightToLeft", ScreenPlacement::RIGHTLEFT }, - { NULL, ScreenPlacement::RIGHTLEFT }, -}; - -template <> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "TopToBottom", ScreenPlacement::TOPBOTTOM }, - { "BottomToTop", ScreenPlacement::BOTTOMTOP }, - { NULL, ScreenPlacement::BOTTOMTOP }, -}; - -} // end namespace FbTk diff --git a/src/ScreenPlacement.hh b/src/ScreenPlacement.hh index cbe1528..4751e3d 100644 --- a/src/ScreenPlacement.hh +++ b/src/ScreenPlacement.hh @@ -23,6 +23,7 @@ #define SCREENPLACEMENT_HH #include "PlacementStrategy.hh" +#include "Resources.hh" #include "FbTk/Resource.hh" #include @@ -42,24 +43,6 @@ class BScreen; */ class ScreenPlacement: public PlacementStrategy { public: - enum PlacementPolicy { - ROWSMARTPLACEMENT, - COLSMARTPLACEMENT, - COLMINOVERLAPPLACEMENT, - ROWMINOVERLAPPLACEMENT, - CASCADEPLACEMENT, - UNDERMOUSEPLACEMENT - }; - - enum RowDirection { - LEFTRIGHT, ///< from left to right - RIGHTLEFT ///< from right to left - }; - enum ColumnDirection { - TOPBOTTOM, ///< from top to bottom - BOTTOMTOP ///< from bottom to top - }; - explicit ScreenPlacement(BScreen &screen); virtual ~ScreenPlacement() {} diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc index afdc854..881129e 100644 --- a/src/SendToMenu.cc +++ b/src/SendToMenu.cc @@ -49,7 +49,7 @@ private: SendToMenu::SendToMenu(BScreen &screen): FbMenu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager().getLayer(ResourceLayer::MENU)) { + *screen.layerManager().getLayer(LAYERMENU)) { // listen to: // workspace count signal // workspace names signal diff --git a/src/Slit.cc b/src/Slit.cc index 9fc4ef1..1cf13cf 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -89,27 +89,6 @@ using std::endl; using std::hex; using std::dec; -namespace FbTk { - -template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "TopLeft", Slit::TOPLEFT }, - { "LeftCenter", Slit::LEFTCENTER }, - { "BottomLeft", Slit::BOTTOMLEFT }, - { "TopCenter", Slit::TOPCENTER }, - { "BottomCenter", Slit::BOTTOMCENTER }, - { "TopRight", Slit::TOPRIGHT }, - { "RightCenter", Slit::RIGHTCENTER }, - { "BottomRight", Slit::BOTTOMRIGHT }, - { "LeftTop", Slit::LEFTTOP }, - { "RightTop", Slit::RIGHTTOP }, - { "LeftBottom", Slit::LEFTBOTTOM }, - { "RightBottom", Slit::RIGHTBOTTOM }, - { NULL, Slit::RIGHTBOTTOM }, -}; - -} // end namespace FbTk - namespace { class SlitClientMenuItem: public FbTk::MenuItem{ @@ -145,7 +124,7 @@ private: class PlaceSlitMenuItem: public FbTk::RadioMenuItem { public: - PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Slit::Placement place, FbTk::RefCount > &cmd): + PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Placement place, FbTk::RefCount > &cmd): FbTk::RadioMenuItem(label, cmd), m_slit(slit), m_place(place) { setCloseOnClick(false); } @@ -156,7 +135,7 @@ public: } private: Slit &m_slit; - Slit::Placement m_place; + Placement m_place; }; } // End anonymous namespace @@ -231,10 +210,10 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer) m_screen(scr), m_clientlist_menu(new FbMenu(scr.menuTheme(), scr.imageControl(), - *scr.layerManager().getLayer(ResourceLayer::MENU)) ), + *scr.layerManager().getLayer(LAYERMENU)) ), m_slitmenu(new FbMenu(scr.menuTheme(), scr.imageControl(), - *scr.layerManager().getLayer(ResourceLayer::MENU)) ), + *scr.layerManager().getLayer(LAYERMENU)) ), #ifdef XINERAMA m_xineramaheadmenu(0), #endif // XINERAMA @@ -258,7 +237,7 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer) m_rc_placement(scr.resourceManager(), RIGHTBOTTOM, scr.name() + ".slit.placement"), m_rc_alpha(scr.resourceManager(), 255, scr.name() + ".slit.alpha"), m_rc_on_head(scr.resourceManager(), 0, scr.name() + ".slit.onhead"), - m_rc_layernum(scr.resourceManager(), ResourceLayer::DOCK, scr.name() + ".slit.layer") { + m_rc_layernum(scr.resourceManager(), LAYERDOCK, scr.name() + ".slit.layer") { _FB_USES_NLS; @@ -298,7 +277,7 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer) m_layermenu.reset(new LayerMenu(scr.menuTheme(), scr.imageControl(), *scr.layerManager(). - getLayer(ResourceLayer::MENU), + getLayer(LAYERMENU), this, true)); m_layermenu->setLabel(_FB_XTEXT(Slit, Layer, "Slit Layer", "Title of Slit Layer Menu")); @@ -1114,7 +1093,7 @@ void Slit::setupMenu() { FbTk::RefCount placement_menu( new FbMenu(m_screen.menuTheme(), m_screen.imageControl(), - *m_screen.layerManager().getLayer(::ResourceLayer::MENU)) ); + *m_screen.layerManager().getLayer(LAYERMENU)) ); // setup base menu @@ -1129,7 +1108,7 @@ void Slit::setupMenu() { if (screen().hasXinerama()) { m_xineramaheadmenu.reset( new XineramaHeadMenu( screen().menuTheme(), screen(), screen().imageControl(), - *screen().layerManager().getLayer(::ResourceLayer::MENU), *this, + *screen().layerManager().getLayer(LAYERMENU), *this, _FB_XTEXT(Slit, OnHead, "Slit on Head", "Title of Slits On Head menu")) ); m_slitmenu->insert(_FB_XTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"), FbTk::RefCount(m_xineramaheadmenu)); @@ -1167,32 +1146,32 @@ void Slit::setupMenu() { placement_menu->setLabel(_FB_XTEXT(Slit, Placement, "Slit Placement", "Slit Placement")); placement_menu->setMinimumColumns(3); - typedef pair PlacementP; + typedef pair PlacementP; typedef list Placements; Placements place_menu; // menu is 3 wide, 5 down - place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), Slit::TOPLEFT)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), Slit::LEFTTOP)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), Slit::LEFTCENTER)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), Slit::LEFTBOTTOM)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), Slit::BOTTOMLEFT)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), Slit::TOPCENTER)); - place_menu.push_back(PlacementP("", Slit::TOPLEFT)); - place_menu.push_back(PlacementP("", Slit::TOPLEFT)); - place_menu.push_back(PlacementP("", Slit::TOPLEFT)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), Slit::BOTTOMCENTER)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), Slit::TOPRIGHT)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), Slit::RIGHTTOP)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), Slit::RIGHTCENTER)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), Slit::RIGHTBOTTOM)); - place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), Slit::BOTTOMRIGHT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), TOPLEFT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), LEFTTOP)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), LEFTCENTER)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), LEFTBOTTOM)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), BOTTOMLEFT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), TOPCENTER)); + place_menu.push_back(PlacementP("", TOPLEFT)); + place_menu.push_back(PlacementP("", TOPLEFT)); + place_menu.push_back(PlacementP("", TOPLEFT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), BOTTOMCENTER)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), TOPRIGHT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), RIGHTTOP)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), RIGHTCENTER)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), RIGHTBOTTOM)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), BOTTOMRIGHT)); // create items in sub menu for (size_t i=0; i<15; ++i) { const FbTk::FbString &str = place_menu.front().first; - Slit::Placement placement = place_menu.front().second; + Placement placement = place_menu.front().second; if (str == "") { placement_menu->insert(""); @@ -1212,7 +1191,7 @@ void Slit::setupMenu() { void Slit::moveToLayer(int layernum) { m_layeritem->moveToLayer(layernum); - *m_rc_layernum = static_cast(layernum); + *m_rc_layernum = static_cast(layernum); } void Slit::saveOnHead(int head) { diff --git a/src/Slit.hh b/src/Slit.hh index d6ba08f..78bcf60 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -25,6 +25,7 @@ #ifndef SLIT_HH #define SLIT_HH +#include "Resources.hh" #include "SlitTheme.hh" #include "LayerMenu.hh" #include "Layer.hh" @@ -56,17 +57,6 @@ class Slit: public FbTk::EventHandler, public LayerObject, private FbTk::SignalT { public: typedef std::list SlitClients; - /** - Placement on screen - */ - enum Placement { - // top and bottom placement - TOPLEFT = 1, TOPCENTER, TOPRIGHT, - BOTTOMLEFT, BOTTOMCENTER, BOTTOMRIGHT, - // left and right placement - LEFTBOTTOM, LEFTCENTER, LEFTTOP, - RIGHTBOTTOM, RIGHTCENTER, RIGHTTOP - }; Slit(BScreen &screen, FbTk::Layer &layer); virtual ~Slit(); @@ -206,9 +196,9 @@ private: SlitClientsRes m_client_list; FbTk::BoolResource m_rc_kde_dockapp, m_rc_auto_hide, m_rc_maximize_over; - FbTk::Resource > m_rc_placement; + PlacementResource m_rc_placement; FbTk::IntResource 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 3919a19..ccd9fbb 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -84,33 +84,12 @@ using std::list; using FbTk::STLUtil::forAll; -namespace FbTk { - -template<> -const EnumTraits::Pair EnumTraits::s_map[] = { - { "TopLeft", Toolbar::TOPLEFT }, - { "TopCenter", Toolbar::TOPCENTER }, - { "TopRight", Toolbar::TOPRIGHT }, - { "BottomLeft", Toolbar::BOTTOMLEFT }, - { "BottomCenter", Toolbar::BOTTOMCENTER }, - { "BottomRight", Toolbar::BOTTOMRIGHT }, - { "LeftBottom", Toolbar::LEFTBOTTOM }, - { "LeftCenter", Toolbar::LEFTCENTER }, - { "LeftTop", Toolbar::LEFTTOP }, - { "RightBottom", Toolbar::RIGHTBOTTOM }, - { "RightCenter", Toolbar::RIGHTCENTER }, - { "RightTop", Toolbar::RIGHTTOP }, - { NULL, Toolbar::RIGHTTOP } -}; - -} // end namespace FbTk - namespace { class PlaceToolbarMenuItem: public FbTk::RadioMenuItem { public: PlaceToolbarMenuItem(const FbTk::FbString &label, Toolbar &toolbar, - Toolbar::Placement place): + Placement place): FbTk::RadioMenuItem(label), m_toolbar(toolbar), m_place(place) { setCloseOnClick(false); } @@ -123,7 +102,7 @@ public: } private: Toolbar &m_toolbar; - Toolbar::Placement m_place; + Placement m_place; }; } // end anonymous @@ -160,15 +139,15 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width): m_layeritem(frame.window, layer), m_layermenu(new LayerMenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(ResourceLayer::MENU), + *scrn.layerManager().getLayer(LAYERMENU), this, true)), m_placementmenu(new FbMenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(ResourceLayer::MENU))), + *scrn.layerManager().getLayer(LAYERMENU))), m_toolbarmenu(new FbMenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(ResourceLayer::MENU))), + *scrn.layerManager().getLayer(LAYERMENU))), #ifdef XINERAMA m_xineramaheadmenu(0), #endif // XINERAMA @@ -180,9 +159,9 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width): m_rc_visible(scrn.resourceManager(), true, scrn.name() + ".toolbar.visible"), m_rc_width_percent(scrn.resourceManager(), 100, scrn.name() + ".toolbar.widthPercent"), m_rc_alpha(scrn.resourceManager(), 255, scrn.name() + ".toolbar.alpha"), - m_rc_layernum(scrn.resourceManager(), ResourceLayer::DOCK, scrn.name() + ".toolbar.layer"), + m_rc_layernum(scrn.resourceManager(), LAYERDOCK, scrn.name() + ".toolbar.layer"), m_rc_on_head(scrn.resourceManager(), 1, scrn.name() + ".toolbar.onhead"), - m_rc_placement(scrn.resourceManager(), Toolbar::BOTTOMCENTER, + m_rc_placement(scrn.resourceManager(), BOTTOMCENTER, scrn.name() + ".toolbar.placement"), m_rc_height(scrn.resourceManager(), 0, scrn.name() + ".toolbar.height"), m_rc_tools(scrn.resourceManager(), "prevworkspace, workspacename, nextworkspace, iconbar, systemtray, clock", @@ -423,7 +402,7 @@ void Toolbar::reconfigure() { frame.window.setBackgroundColor(theme()->toolbar().color()); } else { FbTk::Orientation orient = FbTk::ROT0; - Toolbar::Placement where = *m_rc_placement; + Placement where = *m_rc_placement; if (where == LEFTCENTER || where == LEFTTOP || where == LEFTBOTTOM) orient = FbTk::ROT270; if (where == RIGHTCENTER || where == RIGHTTOP || where == RIGHTBOTTOM) @@ -554,7 +533,7 @@ void Toolbar::handleEvent(XEvent &event) { */ } -void Toolbar::setPlacement(Toolbar::Placement where) { +void Toolbar::setPlacement(Placement where) { // disable vertical toolbar *m_rc_placement = where; @@ -732,7 +711,7 @@ void Toolbar::toggleHidden() { void Toolbar::moveToLayer(int layernum) { m_layeritem.moveToLayer(layernum); - *m_rc_layernum = static_cast(layernum); + *m_rc_layernum = static_cast(layernum); } void Toolbar::setupMenus(bool skip_new_placement) { @@ -788,7 +767,7 @@ void Toolbar::setupMenus(bool skip_new_placement) { if (screen().hasXinerama()) { m_xineramaheadmenu.reset( new XineramaHeadMenu(screen().menuTheme(), screen(), screen().imageControl(), - *screen().layerManager().getLayer(::ResourceLayer::MENU), *this, + *screen().layerManager().getLayer(LAYERMENU), *this, _FB_XTEXT(Toolbar, OnHead, "Toolbar on Head", "Title of toolbar on head menu"))); menu()->insert(_FB_XTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"), @@ -801,25 +780,25 @@ void Toolbar::setupMenus(bool skip_new_placement) { if (!skip_new_placement) { struct PlacementP { const FbTk::FbString label; - Toolbar::Placement placement; + Placement placement; }; static const PlacementP place_menu[] = { - { _FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), Toolbar::TOPLEFT}, - { _FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), Toolbar::LEFTTOP}, - { _FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), Toolbar::LEFTCENTER}, - { _FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), Toolbar::LEFTBOTTOM}, - { _FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), Toolbar::BOTTOMLEFT}, - { _FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), Toolbar::TOPCENTER}, - { "", Toolbar::TOPLEFT}, - { "", Toolbar::TOPLEFT}, - { "", Toolbar::TOPLEFT}, - { _FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), Toolbar::BOTTOMCENTER}, - { _FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), Toolbar::TOPRIGHT}, - { _FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), Toolbar::RIGHTTOP}, - { _FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), Toolbar::RIGHTCENTER}, - { _FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), Toolbar::RIGHTBOTTOM}, - { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), Toolbar::BOTTOMRIGHT} + { _FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), TOPLEFT}, + { _FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), LEFTTOP}, + { _FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), LEFTCENTER}, + { _FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), LEFTBOTTOM}, + { _FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), BOTTOMLEFT}, + { _FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), TOPCENTER}, + { "", TOPLEFT}, + { "", TOPLEFT}, + { "", TOPLEFT}, + { _FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), BOTTOMCENTER}, + { _FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), TOPRIGHT}, + { _FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), RIGHTTOP}, + { _FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), RIGHTCENTER}, + { _FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), RIGHTBOTTOM}, + { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), BOTTOMRIGHT} }; placementMenu()->setMinimumColumns(3); diff --git a/src/Toolbar.hh b/src/Toolbar.hh index b0aeb60..4453af2 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -27,6 +27,7 @@ #include "ToolbarTheme.hh" #include "LayerMenu.hh" +#include "Resources.hh" #include "ToolFactory.hh" #include "ToolTheme.hh" #include "Layer.hh" @@ -60,19 +61,6 @@ class Shape; class Toolbar: public FbTk::EventHandler, public LayerObject { public: - - /// Toolbar placement on the screen - enum Placement { - // top and bottom placement - TOPLEFT = 1, TOPCENTER, TOPRIGHT, - BOTTOMLEFT, BOTTOMCENTER, BOTTOMRIGHT, - // left and right placement - LEFTBOTTOM, LEFTCENTER, LEFTTOP, - RIGHTBOTTOM, RIGHTCENTER, RIGHTTOP, - - DEFAULT = BOTTOMRIGHT - }; - /// Create a toolbar on the screen with specific width Toolbar(BScreen &screen, FbTk::Layer &layer, size_t width = 200); @@ -187,9 +175,9 @@ private: FbTk::BoolResource m_rc_auto_hide, m_rc_maximize_over, m_rc_visible; FbTk::IntResource m_rc_width_percent; FbTk::IntResource m_rc_alpha; - FbTk::Resource > m_rc_layernum; + FbTk::Resource > m_rc_layernum; FbTk::IntResource m_rc_on_head; - FbTk::Resource > m_rc_placement; + PlacementResource m_rc_placement; FbTk::IntResource m_rc_height; FbTk::StringResource m_rc_tools; std::auto_ptr m_shape; diff --git a/src/WinButton.cc b/src/WinButton.cc index 703820d..3af0f1d 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -36,7 +36,7 @@ WinButton::WinButton(FluxboxWindow &listen_to, FbTk::ThemeProxy &theme, FbTk::ThemeProxy &pressed, - Type buttontype, const FbTk::FbWindow &parent, + WinButtonType buttontype, const FbTk::FbWindow &parent, int x, int y, unsigned int width, unsigned int height): FbTk::Button(parent, x, y, width, height), @@ -47,7 +47,7 @@ WinButton::WinButton(FluxboxWindow &listen_to, join(theme.reconfigSig(), FbTk::MemFun(*this, &WinButton::updateAll)); - if (buttontype == MENUICON) + if (buttontype == MENUICONBUTTON) updateAll(); } @@ -116,26 +116,26 @@ void WinButton::setPressedColor(const FbTk::Color &color) { Pixmap WinButton::getBackgroundPixmap() const { switch(m_type) { - case MAXIMIZE: + case MAXIMIZEBUTTON: return m_theme->maximizePixmap().pixmap().drawable(); break; - case MINIMIZE: + case MINIMIZEBUTTON: return m_theme->iconifyPixmap().pixmap().drawable(); break; - case STICK: + case STICKBUTTON: if (m_listen_to.isStuck()) return m_theme->stuckPixmap().pixmap().drawable(); return m_theme->stickPixmap().pixmap().drawable(); break; - case CLOSE: + case CLOSEBUTTON: return m_theme->closePixmap().pixmap().drawable(); break; - case SHADE: + case SHADEBUTTON: if (m_listen_to.isShaded()) return m_theme->unshadePixmap().pixmap().drawable(); return m_theme->shadePixmap().pixmap().drawable(); break; - case MENUICON: + case MENUICONBUTTON: if (m_icon_pixmap.drawable()) return m_theme->titlePixmap().pixmap().drawable(); return m_theme->menuiconPixmap().pixmap().drawable(); @@ -146,20 +146,20 @@ Pixmap WinButton::getBackgroundPixmap() const { Pixmap WinButton::getPressedPixmap() const { switch(m_type) { - case MAXIMIZE: + case MAXIMIZEBUTTON: return m_pressed_theme->maximizePixmap().pixmap().drawable(); - case MINIMIZE: + case MINIMIZEBUTTON: return m_pressed_theme->iconifyPixmap().pixmap().drawable(); - case STICK: + case STICKBUTTON: return m_pressed_theme->stickPixmap().pixmap().drawable(); - case CLOSE: + case CLOSEBUTTON: return m_pressed_theme->closePixmap().pixmap().drawable(); - case SHADE: + case SHADEBUTTON: if (m_listen_to.isShaded()) return m_pressed_theme->unshadePixmap().pixmap().drawable(); else return m_pressed_theme->shadePixmap().pixmap().drawable(); - case MENUICON: + case MENUICONBUTTON: if (m_icon_pixmap.drawable()) return m_theme->titlePixmap().pixmap().drawable(); else @@ -185,7 +185,7 @@ void WinButton::drawType() { // otherwise draw old style imagery switch (m_type) { - case MAXIMIZE: + case MAXIMIZEBUTTON: // if no pixmap was used, use old style if (gc() == 0) // must have valid graphic context return; @@ -195,10 +195,10 @@ void WinButton::drawType() { drawLine(gc(), 2, 3, width() - 3, 3); break; - case MINIMIZE: + case MINIMIZEBUTTON: drawRectangle(gc(), 2, height() - 5, width() - 5, 2); break; - case STICK: + case STICKBUTTON: // width/4 != width/2, so we use /4*2 so that it's properly centred if (m_listen_to.isStuck()) { fillRectangle(gc(), @@ -210,7 +210,7 @@ void WinButton::drawType() { width()/10*2 + oddW, height()/10*2 + oddH); } break; - case CLOSE: + case CLOSEBUTTON: drawLine(gc(), 2, 2, width() - 3, height() - 3); @@ -229,7 +229,7 @@ void WinButton::drawType() { 2, height() - 3, width() - 3, 2); break; - case SHADE: + case SHADEBUTTON: { int size = width() - 5 - oddW; @@ -246,7 +246,7 @@ void WinButton::drawType() { break; } - case MENUICON: + case MENUICONBUTTON: if (m_icon_pixmap.drawable()) { if (m_icon_mask.drawable()) { @@ -282,7 +282,7 @@ void WinButton::clear() { void WinButton::updateAll() { // update the menu icon - if (m_type == MENUICON && !m_listen_to.empty()) { + if (m_type == MENUICONBUTTON && !m_listen_to.empty()) { Display* display = m_listen_to.fbWindow().display(); int screen = m_listen_to.screen().screenNumber(); @@ -308,7 +308,7 @@ void WinButton::updateAll() { setBackgroundPixmap(my_pm); // incorrect, pressed_pixmap is stateful in shade, so we'll do oneoff for now - if (m_type == SHADE) { + if (m_type == SHADEBUTTON) { Pixmap p_pm = getPressedPixmap(); if (p_pm != None) setPressedPixmap(p_pm); diff --git a/src/WinButton.hh b/src/WinButton.hh index 80fc4b1..af3efef 100644 --- a/src/WinButton.hh +++ b/src/WinButton.hh @@ -25,6 +25,7 @@ #include "FbTk/Button.hh" #include "FbTk/FbPixmap.hh" #include "FbTk/Signal.hh" +#include "Resources.hh" class FluxboxWindow; class WinButtonTheme; @@ -37,12 +38,10 @@ template class ThemeProxy; /// draws and handles basic window button graphic class WinButton:public FbTk::Button, public FbTk::SignalTracker { public: - /// draw type for the button - enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON}; WinButton(FluxboxWindow &listen_to, FbTk::ThemeProxy &theme, FbTk::ThemeProxy &pressed, - Type buttontype, const FbTk::FbWindow &parent, int x, int y, + WinButtonType buttontype, const FbTk::FbWindow &parent, int x, int y, unsigned int width, unsigned int height); /// override for drawing void exposeEvent(XExposeEvent &event); @@ -59,7 +58,7 @@ public: void updateAll(); private: void drawType(); - Type m_type; ///< the button type + WinButtonType m_type; ///< the button type FluxboxWindow &m_listen_to; FbTk::ThemeProxy &m_theme, &m_pressed_theme; diff --git a/src/Window.cc b/src/Window.cc index e8b1c31..a8e4534 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -251,8 +251,8 @@ private: int m_mode; }; -typedef FbTk::VectorTraits > WinButtonsTraits; -typedef FbTk::Resource, WinButtonsTraits> WinButtonsResource; +typedef FbTk::VectorTraits > WinButtonsTraits; +typedef FbTk::Resource, WinButtonsTraits> WinButtonsResource; } @@ -489,7 +489,7 @@ void FluxboxWindow::init() { m_workspace_number = m_client->transientFor()->fbwindow()->workspaceNumber(); } else // if no parent then set default layer - moveToLayer(m_state.layernum, m_state.layernum != ::ResourceLayer::NORMAL); + moveToLayer(m_state.layernum, m_state.layernum != LAYERNORMAL); fbdbg<<"FluxboxWindow::init("<transientFor()<getOnHead() || (foc->winClient().isTransient() && foc->winClient().transientFor()->fbwindow() == this)) { - moveToLayer(::ResourceLayer::ABOVE_DOCK); + moveToLayer(LAYERABOVE_DOCK); } else { - moveToLayer(::ResourceLayer::DESKTOP); + moveToLayer(LAYERDESKTOP); } stateSig().emit(*this); @@ -1686,10 +1686,10 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) { fbdbg<<"FluxboxWindow("<= ::ResourceLayer::NUM_LAYERS) - layernum = ::ResourceLayer::NUM_LAYERS - 1; + if (layernum <= LAYERMENU) + layernum = LAYERMENU + 1; + else if (layernum >= NUM_LAYERS) + layernum = NUM_LAYERS - 1; if (!m_initialized) m_state.layernum = layernum; @@ -1761,7 +1761,7 @@ void FluxboxWindow::setFocusFlag(bool focus) { } if (m_state.fullscreen && focus) { - moveToLayer(::ResourceLayer::ABOVE_DOCK); + moveToLayer(LAYERABOVE_DOCK); leave(screen().focusedWindowSig()); } @@ -3208,10 +3208,10 @@ void FluxboxWindow::attachTo(int x, int y, bool interrupted) { inside_titlebar = client->fbwindow()->hasTitlebar() && client->fbwindow()->y() + static_cast(client->fbwindow()->titlebarHeight()) > dest_y; - Fluxbox::TabsAttachArea area= Fluxbox::instance()->getTabsAttachArea(); - if (area == Fluxbox::ATTACH_AREA_WINDOW) + TabsAttachArea area= Fluxbox::instance()->getTabsAttachArea(); + if (area == ATTACH_AREA_WINDOW) attach_to_win = client->fbwindow(); - else if (area == Fluxbox::ATTACH_AREA_TITLEBAR && inside_titlebar) { + else if (area == ATTACH_AREA_TITLEBAR && inside_titlebar) { attach_to_win = client->fbwindow(); } } @@ -3460,18 +3460,18 @@ void FluxboxWindow::setupWindow() { if (titlebar_side[i] != 0) continue; // find next resource too - WinButton::Type titlebar_left[] = { - WinButton::STICK + WinButtonType titlebar_left[] = { + STICKBUTTON }; - WinButton::Type titlebar_right[] = { - WinButton::MINIMIZE, - WinButton::MAXIMIZE, - WinButton::CLOSE + WinButtonType titlebar_right[] = { + MINIMIZEBUTTON, + MAXIMIZEBUTTON, + CLOSEBUTTON }; - WinButton::Type *begin = 0; - WinButton::Type *end = 0; + WinButtonType *begin = 0; + WinButtonType *end = 0; if (i == 0) { begin = titlebar_left; @@ -3544,7 +3544,7 @@ void FluxboxWindow::updateButtons() { for (size_t c = 0; c < 2 ; c++) { // get titlebar configuration for current side - const vector &dir = *(*titlebar_side[c]); + const vector &dir = *(*titlebar_side[c]); m_titlebar_buttons[c] = dir; for (size_t i=0; i < dir.size(); ++i) { @@ -3552,17 +3552,17 @@ void FluxboxWindow::updateButtons() { WinButton *winbtn = 0; switch (dir[i]) { - case WinButton::MINIMIZE: + case MINIMIZEBUTTON: if (isIconifiable() && (m_state.deco_mask & WindowState::DECORM_ICONIFY)) { winbtn = new WinButton(*this, m_button_theme, screen().pressedWinButtonTheme(), - WinButton::MINIMIZE, + MINIMIZEBUTTON, frame().titlebar(), 0, 0, 10, 10); winbtn->setOnClick(iconify_cmd); } break; - case WinButton::MAXIMIZE: + case MAXIMIZEBUTTON: if (isMaximizable() && (m_state.deco_mask & WindowState::DECORM_MAXIMIZE) ) { winbtn = new WinButton(*this, m_button_theme, screen().pressedWinButtonTheme(), @@ -3575,7 +3575,7 @@ void FluxboxWindow::updateButtons() { } break; - case WinButton::CLOSE: + case CLOSEBUTTON: if (m_client->isClosable() && (m_state.deco_mask & WindowState::DECORM_CLOSE)) { winbtn = new WinButton(*this, m_button_theme, screen().pressedWinButtonTheme(), @@ -3588,7 +3588,7 @@ void FluxboxWindow::updateButtons() { FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll)); } break; - case WinButton::STICK: + case STICKBUTTON: if (m_state.deco_mask & WindowState::DECORM_STICKY) { winbtn = new WinButton(*this, m_button_theme, screen().pressedWinButtonTheme(), @@ -3601,7 +3601,7 @@ void FluxboxWindow::updateButtons() { winbtn->setOnClick(stick_cmd); } break; - case WinButton::SHADE: + case SHADEBUTTON: if (m_state.deco_mask & WindowState::DECORM_SHADE) { winbtn = new WinButton(*this, m_button_theme, screen().pressedWinButtonTheme(), @@ -3613,7 +3613,7 @@ void FluxboxWindow::updateButtons() { winbtn->setOnClick(shade_cmd); } break; - case WinButton::MENUICON: + case MENUICONBUTTON: winbtn = new WinButton(*this, m_button_theme, screen().pressedWinButtonTheme(), dir[i], @@ -3790,7 +3790,7 @@ void FluxboxWindow::setWindowType(WindowState::WindowType type) { setMouseFocus(false); setClickFocus(false); setDecorationMask(WindowState::DECOR_NONE); - moveToLayer(::ResourceLayer::DOCK); + moveToLayer(LAYERDOCK); break; case WindowState::TYPE_DESKTOP: /* @@ -3803,7 +3803,7 @@ void FluxboxWindow::setWindowType(WindowState::WindowType type) { setIconHidden(true); setFocusNew(false); setMouseFocus(false); - moveToLayer(::ResourceLayer::DESKTOP); + moveToLayer(LAYERDESKTOP); setDecorationMask(WindowState::DECOR_NONE); setTabable(false); setMovable(false); @@ -3838,7 +3838,7 @@ void FluxboxWindow::setWindowType(WindowState::WindowType type) { */ setDecorationMask(WindowState::DECOR_TOOL); setIconHidden(true); - moveToLayer(::ResourceLayer::ABOVE_DOCK); + moveToLayer(LAYERABOVE_DOCK); break; case WindowState::TYPE_NORMAL: default: diff --git a/src/Window.hh b/src/Window.hh index 5c2e595..6117d48 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -561,7 +561,7 @@ private: maximize:1, close:1, menu:1, sticky:1, shade:1, tab:1, enabled:1; } decorations; - std::vector m_titlebar_buttons[2]; + std::vector m_titlebar_buttons[2]; bool m_toggled_decos; struct { diff --git a/src/WindowState.hh b/src/WindowState.hh index 58664fa..a8ecfa4 100644 --- a/src/WindowState.hh +++ b/src/WindowState.hh @@ -113,7 +113,7 @@ public: focused(false), shaded(false), fullscreen(false), stuck(false), iconic(false), focus_hidden(false), icon_hidden(false), - maximized(0), layernum(ResourceLayer::NORMAL), + maximized(0), layernum(LAYERNORMAL), x(0), y(0), width(1), height(1) { } void saveGeometry(int x, int y, unsigned int width, unsigned int height, diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index 34c8f9a..43ba57c 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc @@ -509,7 +509,7 @@ void ShowDesktopCmd::execute() { for (; it != it_end; ++it) { if (!(*it)->fbwindow()->isIconic() && ((*it)->fbwindow()->isStuck() || (*it)->fbwindow()->workspaceNumber() == space) && - (*it)->fbwindow()->layerNum() < ResourceLayer::DESKTOP) { + (*it)->fbwindow()->layerNum() < LAYERDESKTOP) { (*it)->fbwindow()->iconify(); count++; } diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index 0b563aa..732da9d 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -68,7 +68,7 @@ void add_workspaces(WorkspaceMenu& menu, BScreen& screen) { WorkspaceMenu::WorkspaceMenu(BScreen &screen): FbMenu(screen.menuTheme(), screen.imageControl(), - *screen.layerManager().getLayer(ResourceLayer::MENU)) { + *screen.layerManager().getLayer(LAYERMENU)) { init(screen); } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 5254296..d0069b9 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -396,7 +396,7 @@ Fluxbox::Fluxbox(int argc, char **argv, std::string sc_nr = FbTk::StringUtil::number2String(screens[s]); BScreen *screen = new BScreen(m_resourcemanager, std::string("screen") + sc_nr, - screens[s], ::ResourceLayer::NUM_LAYERS); + screens[s], NUM_LAYERS); // already handled if (! screen->isScreenManaged()) { diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 00a2e7d..ba4c29c 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -32,6 +32,7 @@ #include "FbTk/Signal.hh" #include "AttentionNoticeHandler.hh" +#include "Resources.hh" #include @@ -109,14 +110,10 @@ public: void addAtomHandler(AtomHandler *atomh); void removeAtomHandler(AtomHandler *atomh); - /// obsolete - enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR}; - - bool getIgnoreBorder() const { return *m_rc_ignoreborder; } FbTk::BoolResource &getPseudoTransResource() { return m_rc_pseudotrans; } - Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_rc_tabs_attach_area; } + TabsAttachArea getTabsAttachArea() const { return *m_rc_tabs_attach_area; } FbTk::StringResource &getStyleResource() { return m_rc_stylefile; } const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; } -- cgit v0.11.2