From 448d9fa7220291df30366b7e1f10e65cbc8a273e Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 19 Dec 2003 00:34:23 +0000 Subject: moved focus enum to BScreen, change window placement resource to FbTk Resource --- src/Screen.cc | 181 ++++++++++++++++++++++++++++++++++++++++++++++++---------- src/Screen.hh | 89 ++++++++++++----------------- 2 files changed, 187 insertions(+), 83 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index ec4a395..634e16a 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,20 +22,16 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.252 2003/12/18 21:13:52 fluxgen Exp $ +// $Id: Screen.cc,v 1.253 2003/12/19 00:34:22 fluxgen Exp $ #include "Screen.hh" #include "I18n.hh" #include "fluxbox.hh" -#include "ImageControl.hh" #include "Window.hh" #include "Workspace.hh" -#include "StringUtil.hh" #include "Netizen.hh" -#include "Directory.hh" -#include "SimpleCommand.hh" #include "FbWinFrameTheme.hh" #include "MenuTheme.hh" #include "RootTheme.hh" @@ -43,21 +39,25 @@ #include "FbCommands.hh" #include "BoolMenuItem.hh" #include "IntResMenuItem.hh" -#include "MacroCommand.hh" -#include "XLayerItem.hh" -#include "MultLayers.hh" #include "FbMenu.hh" #include "LayerMenu.hh" #include "WinClient.hh" -#include "Subject.hh" #include "FbWinFrame.hh" #include "FbWindow.hh" #include "Strut.hh" #include "SlitTheme.hh" #include "CommandParser.hh" -#include "MenuTheme.hh" #include "IconMenuItem.hh" +#include "FbTk/Subject.hh" +#include "FbTk/Directory.hh" +#include "FbTk/SimpleCommand.hh" +#include "FbTk/MultLayers.hh" +#include "FbTk/XLayerItem.hh" +#include "FbTk/MacroCommand.hh" +#include "FbTk/StringUtil.hh" +#include "FbTk/ImageControl.hh" + //use GNU extensions #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -136,7 +136,7 @@ int anotherWMRunning(Display *display, XErrorEvent *) { class FocusModelMenuItem : public FbTk::MenuItem { public: FocusModelMenuItem(const char *label, BScreen &screen, - Fluxbox::FocusModel model, + BScreen::FocusModel model, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) { } @@ -148,11 +148,101 @@ public: private: BScreen &m_screen; - Fluxbox::FocusModel m_focusmodel; + BScreen::FocusModel m_focusmodel; }; -}; // End anonymous namespace +} // End anonymous namespace + +template <> +void FbTk::Resource::setDefaultValue() { + *(*this) = BScreen::ROWSMARTPLACEMENT; +} + +template <> +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("RowSmartPlacement", str) == 0) + *(*this) = BScreen::ROWSMARTPLACEMENT; + else if (strcasecmp("", str) == 0) + *(*this) = BScreen::COLSMARTPLACEMENT; + else if (strcasecmp("UnderMousePlacement", str) == 0) + *(*this) = BScreen::UNDERMOUSEPLACEMENT; + else if (strcasecmp("CascadePlacement", str) == 0) + *(*this) = BScreen::CASCADEPLACEMENT; + else + setDefaultValue(); + +} + +string FbTk::Resource::getString() { + switch (*(*this)) { + case BScreen::ROWSMARTPLACEMENT: + return "RowSmartPlacement"; + case BScreen::COLSMARTPLACEMENT: + return "ColSmartPlacement"; + case BScreen::UNDERMOUSEPLACEMENT: + return "UnderMousePlacement"; + case BScreen::CASCADEPLACEMENT: + return "CascadePlacement"; + } + + return "RowSmartPlacement"; +} + +template <> +void FbTk::Resource::setDefaultValue() { + *(*this) = BScreen::LEFTRIGHT; +} + +template <> +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("LeftToRight", str) == 0) + *(*this) = BScreen::LEFTRIGHT; + else if (strcasecmp("RightToLeft", str) == 0) + *(*this) = BScreen::RIGHTLEFT; + else + setDefaultValue(); + +} + +string FbTk::Resource::getString() { + switch (*(*this)) { + case BScreen::LEFTRIGHT: + return "LeftToRight"; + case BScreen::RIGHTLEFT: + return "RightToLeft"; + } + + return "LeftToRight"; +} + + +template <> +void FbTk::Resource::setDefaultValue() { + *(*this) = BScreen::TOPBOTTOM; +} + +template <> +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("TopToBottom", str) == 0) + *(*this) = BScreen::TOPBOTTOM; + else if (strcasecmp("BottomToTop", str) == 0) + *(*this) = BScreen::BOTTOMTOP; + else + setDefaultValue(); + +} + +string FbTk::Resource::getString() { + switch (*(*this)) { + case BScreen::TOPBOTTOM: + return "TopToBottom"; + case BScreen::BOTTOMTOP: + return "BottomToTop"; + } + + return "TopToBottom"; +} template <> void FbTk::Resource::setDefaultValue() { @@ -180,13 +270,47 @@ void FbTk::Resource::setFromString(const char *str) { setDefaultValue(); } +template<> +std::string FbTk::Resource:: +getString() { + switch (m_value) { + case BScreen::SLOPPYFOCUS: + return string("SloppyFocus"); + case BScreen::SEMISLOPPYFOCUS: + return string("SemiSloppyFocus"); + case BScreen::CLICKTOFOCUS: + return string("ClickToFocus"); + } + // default string + return string("ClickToFocus"); +} + +template<> +void FbTk::Resource:: +setFromString(char const *strval) { + // auto raise options here for backwards read compatibility + // they are not supported for saving purposes. Nor does the "AutoRaise" + // part actually do anything + if (strcasecmp(strval, "SloppyFocus") == 0 + || strcasecmp(strval, "AutoRaiseSloppyFocus") == 0) + m_value = BScreen::SLOPPYFOCUS; + else if (strcasecmp(strval, "SemiSloppyFocus") == 0 + || strcasecmp(strval, "AutoRaiseSemiSloppyFocus") == 0) + m_value = BScreen::SEMISLOPPYFOCUS; + else if (strcasecmp(strval, "ClickToFocus") == 0) + m_value = BScreen::CLICKTOFOCUS; + else + setDefaultValue(); +} + namespace { class StyleMenuItem: public FbTk::MenuItem { public: - StyleMenuItem(const std::string &label, const std::string &filename):FbTk::MenuItem(label.c_str()), - m_filename(FbTk::StringUtil:: - expandFilename(filename)) { + StyleMenuItem(const std::string &label, const std::string &filename): + FbTk::MenuItem(label.c_str()), + m_filename(FbTk::StringUtil:: + expandFilename(filename)) { // perform shell style ~ home directory expansion // and insert style FbTk::RefCount @@ -227,9 +351,8 @@ void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) { BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, const std::string &scrname, const std::string &altscrname): - image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), - opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"), + opaque_move(rm, false, scrname + ".opaqueMove", altscrname+".OpaqueMove"), full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"), sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"), @@ -243,15 +366,18 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), resizemode(rm, "", scrname+".resizeMode", altscrname+".ResizeMode"), - focus_model(rm, Fluxbox::CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), + focus_model(rm, CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), menu_alpha(rm, 255, scrname+".menuAlpha", altscrname+".MenuAlpha"), menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"), menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"), - menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode") { + menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"), + placement_policy(rm, ROWSMARTPLACEMENT, scrname+".windowPlacement", altscrname+".WindowPlacement"), + row_direction(rm, LEFTRIGHT, scrname+".rowPlacementDirection", altscrname+".RowPlacementDirection"), + col_direction(rm, TOPBOTTOM, scrname+".colPlacementDirection", altscrname+".ColPlacementDirection") { -}; +} BScreen::BScreen(FbTk::ResourceManager &rm, const string &screenname, const string &altscreenname, @@ -800,13 +926,6 @@ void BScreen::removeClient(WinClient &client) { } -FluxboxWindow *BScreen::getIcon(unsigned int index) { - if (index < m_icon_list.size()) - return m_icon_list[index]; - - return 0; -} - void BScreen::setAntialias(bool value) { if (*resource.antialias == value) return; @@ -1935,21 +2054,21 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { ConfigmenuClickToFocus, "Click To Focus"), *this, - Fluxbox::CLICKTOFOCUS, + CLICKTOFOCUS, save_and_reconfigure)); focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet, ConfigmenuSloppyFocus, "Sloppy Focus"), *this, - Fluxbox::SLOPPYFOCUS, + SLOPPYFOCUS, save_and_reconfigure)); focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet, ConfigmenuSemiSloppyFocus, "Semi Sloppy Focus"), *this, - Fluxbox::SEMISLOPPYFOCUS, + SEMISLOPPYFOCUS, save_and_reconfigure)); focus_menu->insert(new BoolMenuItem(i18n->getMessage(ConfigmenuSet, diff --git a/src/Screen.hh b/src/Screen.hh index 1155998..eaeac91 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,20 +22,21 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.128 2003/12/18 18:03:21 fluxgen Exp $ +// $Id: Screen.hh,v 1.129 2003/12/19 00:34:23 fluxgen Exp $ #ifndef SCREEN_HH #define SCREEN_HH -#include "Resource.hh" -#include "Subject.hh" -#include "MultLayers.hh" + #include "FbRootWindow.hh" -#include "NotCopyable.hh" -#include "Observer.hh" -#include "fluxbox.hh" #include "MenuTheme.hh" +#include "FbTk/Resource.hh" +#include "FbTk/Subject.hh" +#include "FbTk/MultLayers.hh" +#include "FbTk/NotCopyable.hh" +#include "FbTk/Observer.hh" + #include #include @@ -45,7 +46,9 @@ #include #include #include +#include +class FluxboxWindow; class Netizen; class FbWinFrameTheme; class RootTheme; @@ -61,7 +64,7 @@ class ImageControl; class XLayerItem; class FbWindow; class Subject; -}; +} /// Handles screen connection, screen clients and workspaces /** @@ -69,6 +72,14 @@ class Subject; */ class BScreen : public FbTk::Observer, private FbTk::NotCopyable { public: + enum FocusModel { SLOPPYFOCUS=0, SEMISLOPPYFOCUS, CLICKTOFOCUS }; + enum FocusDir { FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT }; + enum PlacementPolicy { ROWSMARTPLACEMENT, COLSMARTPLACEMENT, CASCADEPLACEMENT, UNDERMOUSEPLACEMENT}; + enum RowDirection { LEFTRIGHT, RIGHTLEFT}; + enum ColumnDirection { TOPBOTTOM, BOTTOMTOP}; + + typedef std::vector Icons; + typedef std::list FocusedWindows; typedef std::vector Workspaces; typedef std::vector WorkspaceNames; @@ -77,8 +88,8 @@ public: int scrn, int number_of_layers); ~BScreen(); - inline bool isSloppyFocus() const { return (*resource.focus_model == Fluxbox::SLOPPYFOCUS); } - inline bool isSemiSloppyFocus() const { return (*resource.focus_model == Fluxbox::SEMISLOPPYFOCUS); } + inline bool isSloppyFocus() const { return (*resource.focus_model == SLOPPYFOCUS); } + inline bool isSemiSloppyFocus() const { return (*resource.focus_model == SEMISLOPPYFOCUS); } inline bool isRootColormapInstalled() const { return root_colormap_installed; } inline bool isScreenManaged() const { return managed; } inline bool isSloppyWindowGrouping() const { return *resource.sloppy_window_grouping; } @@ -95,12 +106,12 @@ public: inline bool antialias() const { return *resource.antialias; } inline FbTk::ImageControl &imageControl() { return *m_image_control.get(); } - const FbTk::Menu * const getRootmenu() const { return m_rootmenu.get(); } - FbTk::Menu * const getRootmenu() { return m_rootmenu.get(); } + const FbTk::Menu &getRootmenu() const { return *m_rootmenu.get(); } + FbTk::Menu &getRootmenu() { return *m_rootmenu.get(); } inline const std::string &getRootCommand() const { return *resource.rootcommand; } inline const std::string &getResizeMode() const { return *resource.resizemode; } - inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; } + inline FocusModel getFocusModel() const { return *resource.focus_model; } inline Slit *slit() { return m_slit.get(); } inline const Slit *slit() const { return m_slit.get(); } @@ -109,8 +120,8 @@ public: inline Workspace *currentWorkspace() { return m_current_workspace; } inline const Workspace *currentWorkspace() const { return m_current_workspace; } - const FbTk::Menu *getWorkspacemenu() const { return workspacemenu.get(); } - FbTk::Menu *getWorkspacemenu() { return workspacemenu.get(); } + const FbTk::Menu &getWorkspacemenu() const { return *workspacemenu.get(); } + FbTk::Menu &getWorkspacemenu() { return *workspacemenu.get(); } @@ -127,8 +138,6 @@ public: inline unsigned int width() const { return rootWindow().width(); } inline unsigned int height() const { return rootWindow().height(); } inline unsigned int screenNumber() const { return rootWindow().screenNumber(); } - typedef std::vector Icons; - typedef std::list FocusedWindows; /// @return number of workspaces inline unsigned int getCount() const { return m_workspaces_list.size(); } @@ -168,39 +177,22 @@ public: /// @return the resource value of number of workspace inline int getNumberOfWorkspaces() const { return *resource.workspaces; } - inline int getPlacementPolicy() const { return resource.placement_policy; } + inline PlacementPolicy getPlacementPolicy() const { return *resource.placement_policy; } inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } - inline int getRowPlacementDirection() const { return resource.row_direction; } - inline int getColPlacementDirection() const { return resource.col_direction; } + inline RowDirection getRowPlacementDirection() const { return *resource.row_direction; } + inline ColumnDirection getColPlacementDirection() const { return *resource.col_direction; } inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; } inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } inline void saveResizeMode(std::string resizem) { *resource.resizemode = resizem; } - inline void saveFocusModel(Fluxbox::FocusModel model) { resource.focus_model = model; } + inline void saveFocusModel(FocusModel model) { resource.focus_model = model; } inline void saveWorkspaces(int w) { *resource.workspaces = w; } - - inline void savePlacementPolicy(int p) { resource.placement_policy = p; } - inline void saveRowPlacementDirection(int d) { resource.row_direction = d; } - inline void saveColPlacementDirection(int d) { resource.col_direction = d; } inline void saveEdgeSnapThreshold(int t) { resource.edge_snap_threshold = t; } inline void saveImageDither(bool d) { resource.image_dither = d; } - inline void saveOpaqueMove(bool o) { resource.opaque_move = o; } - inline void saveFullMax(bool f) { resource.full_max = f; } - inline void saveFocusNew(bool f) { resource.focus_new = f; } - inline void saveFocusLast(bool f) { resource.focus_last = f; } - inline void saveSloppyWindowGrouping(bool s) { resource.sloppy_window_grouping = s; } - inline void saveWorkspaceWarping(bool s) { resource.workspace_warping = s; } - inline void saveDesktopWheeling(bool s) { resource.desktop_wheeling = s; } - void setAntialias(bool value); - - inline const char *getStrftimeFormat() { return resource.strftime_format.c_str(); } - inline int getDateFormat() { return resource.date_format; } - inline void saveDateFormat(int f) { resource.date_format = f; } - inline bool isClock24Hour() { return resource.clock24hour; } - inline void saveClock24Hour(bool c) { resource.clock24hour = c; } + void setAntialias(bool value); inline FbWinFrameTheme &winFrameTheme() { return *m_windowtheme.get(); } inline const FbWinFrameTheme &winFrameTheme() const { return *m_windowtheme.get(); } @@ -213,7 +205,6 @@ public: FbRootWindow &rootWindow() { return m_root_window; } const FbRootWindow &rootWindow() const { return m_root_window; } - FluxboxWindow *getIcon(unsigned int index); FbTk::MultLayers &layerManager() { return m_layermanager; } const FbTk::MultLayers &layerManager() const { return m_layermanager; } FbTk::ResourceManager &resourceManager() { return m_resource_manager; } @@ -255,7 +246,7 @@ public: void raiseFocus(); void setFocusedWindow(WinClient &winclient); - enum FocusDir { FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT }; + void dirFocus(FluxboxWindow &win, FocusDir dir); void reconfigure(); @@ -334,8 +325,7 @@ public: bool isShuttingdown() const { return m_shutdown; } - enum { ROWSMARTPLACEMENT = 1, COLSMARTPLACEMENT, CASCADEPLACEMENT, - UNDERMOUSEPLACEMENT, LEFTRIGHT, RIGHTLEFT, TOPBOTTOM, BOTTOMTOP }; + // prevFocus/nextFocus option bits enum { CYCLEGROUPS = 0x01, CYCLESKIPSTUCK = 0x02, CYCLESKIPSHADED = 0x04, @@ -428,18 +418,13 @@ private: antialias, auto_raise, click_raises; FbTk::Resource rootcommand; FbTk::Resource resizemode; - FbTk::Resource focus_model; + FbTk::Resource focus_model; bool ordered_dither; FbTk::Resource workspaces, edge_snap_threshold, menu_alpha, menu_delay, menu_delay_close; FbTk::Resource menu_mode; - - int placement_policy, row_direction, col_direction; - - std::string strftime_format; - - bool clock24hour; - int date_format; - + FbTk::Resource placement_policy; + FbTk::Resource row_direction; + FbTk::Resource col_direction; } resource; -- cgit v0.11.2