all repos — fluxbox @ 448d9fa7220291df30366b7e1f10e65cbc8a273e

custom fork of the fluxbox windowmanager

moved focus enum to BScreen, change window placement resource to FbTk Resource
fluxgen fluxgen
commit

448d9fa7220291df30366b7e1f10e65cbc8a273e

parent

32edca09d7f9a5d94b433749560959cc9fea3e4c

2 files changed, 187 insertions(+), 83 deletions(-)

jump to
M src/Screen.ccsrc/Screen.cc

@@ -22,20 +22,16 @@ // 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. -// $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,20 +39,24 @@ #include "WinButtonTheme.hh"

#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

@@ -136,7 +136,7 @@

class FocusModelMenuItem : public FbTk::MenuItem { public: FocusModelMenuItem(const char *label, BScreen &screen, - Fluxbox::FocusModel model, + BScreen::FocusModel model, FbTk::RefCount<FbTk::Command> &cmd): FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) { }

@@ -148,11 +148,101 @@ }

private: BScreen &m_screen; - Fluxbox::FocusModel m_focusmodel; + BScreen::FocusModel m_focusmodel; }; -}; // End anonymous namespace +} // End anonymous namespace + +template <> +void FbTk::Resource<BScreen::PlacementPolicy>::setDefaultValue() { + *(*this) = BScreen::ROWSMARTPLACEMENT; +} + +template <> +void FbTk::Resource<BScreen::PlacementPolicy>::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<BScreen::PlacementPolicy>::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<BScreen::RowDirection>::setDefaultValue() { + *(*this) = BScreen::LEFTRIGHT; +} + +template <> +void FbTk::Resource<BScreen::RowDirection>::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<BScreen::RowDirection>::getString() { + switch (*(*this)) { + case BScreen::LEFTRIGHT: + return "LeftToRight"; + case BScreen::RIGHTLEFT: + return "RightToLeft"; + } + + return "LeftToRight"; +} + + +template <> +void FbTk::Resource<BScreen::ColumnDirection>::setDefaultValue() { + *(*this) = BScreen::TOPBOTTOM; +} + +template <> +void FbTk::Resource<BScreen::ColumnDirection>::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<BScreen::ColumnDirection>::getString() { + switch (*(*this)) { + case BScreen::TOPBOTTOM: + return "TopToBottom"; + case BScreen::BOTTOMTOP: + return "BottomToTop"; + } + + return "TopToBottom"; +} template <> void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setDefaultValue() {

@@ -180,13 +270,47 @@ else

setDefaultValue(); } +template<> +std::string FbTk::Resource<BScreen::FocusModel>:: +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<BScreen::FocusModel>:: +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<FbTk::Command>

@@ -227,9 +351,8 @@

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 @@ auto_raise(rm, false, scrname+".autoRaise", altscrname+".AutoRaise"),

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,

@@ -798,13 +924,6 @@ }

// the client could be on icon menu so we update it updateIconMenu(); -} - -FluxboxWindow *BScreen::getIcon(unsigned int index) { - if (index < m_icon_list.size()) - return m_icon_list[index]; - - return 0; } void BScreen::setAntialias(bool value) {

@@ -1935,21 +2054,21 @@ focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet,

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,
M src/Screen.hhsrc/Screen.hh

@@ -22,20 +22,21 @@ // 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. -// $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 <X11/Xlib.h> #include <X11/Xresource.h>

@@ -45,7 +46,9 @@ #include <list>

#include <vector> #include <fstream> #include <memory> +#include <map> +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 @@ Create workspaces, handles switching between workspaces and windows

*/ 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<FluxboxWindow *> Icons; + typedef std::list<WinClient *> FocusedWindows; typedef std::vector<Workspace *> Workspaces; typedef std::vector<std::string> WorkspaceNames;

@@ -77,8 +88,8 @@ const std::string &screenname, const std::string &altscreenname,

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 @@ inline bool doShowWindowPos() const { return *resource.show_window_pos; }

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 @@ inline Workspace *getWorkspace(unsigned int w) { return ( w < m_workspaces_list.size() ? m_workspaces_list[w] : 0); }

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 @@

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<FluxboxWindow *> Icons; - typedef std::list<WinClient *> FocusedWindows; /// @return number of workspaces inline unsigned int getCount() const { return m_workspaces_list.size(); }

@@ -168,39 +177,22 @@

/// @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 @@

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 @@ void nextFocus(int options);

void raiseFocus(); void setFocusedWindow(WinClient &winclient); - enum FocusDir { FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT }; + void dirFocus(FluxboxWindow &win, FocusDir dir); void reconfigure();

@@ -334,8 +325,7 @@

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 @@ focus_last, focus_new,

antialias, auto_raise, click_raises; FbTk::Resource<std::string> rootcommand; FbTk::Resource<std::string> resizemode; - FbTk::Resource<Fluxbox::FocusModel> focus_model; + FbTk::Resource<FocusModel> focus_model; bool ordered_dither; FbTk::Resource<int> workspaces, edge_snap_threshold, menu_alpha, menu_delay, menu_delay_close; FbTk::Resource<FbTk::MenuTheme::MenuMode> menu_mode; - - int placement_policy, row_direction, col_direction; - - std::string strftime_format; - - bool clock24hour; - int date_format; - + FbTk::Resource<PlacementPolicy> placement_policy; + FbTk::Resource<RowDirection> row_direction; + FbTk::Resource<ColumnDirection> col_direction; } resource;