all repos — fluxbox @ 6ea3678d0221914a3f54a78bbe8b8b282c4ce8e7

custom fork of the fluxbox windowmanager

Fixed resources
fluxgen fluxgen
commit

6ea3678d0221914a3f54a78bbe8b8b282c4ce8e7

parent

aaa0c6d0780ceb021a3306e2f0c3ae965541eff6

2 files changed, 201 insertions(+), 124 deletions(-)

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

@@ -99,6 +99,8 @@ #define FONT_ELEMENT_SIZE 50

#endif // FONT_ELEMENT_SIZE #include <iostream> +#include <memory> + using namespace std; static Bool running = True;

@@ -125,15 +127,113 @@ static int dcmp(const void *one, const void *two) {

return (strcmp((*(char **) one), (*(char **) two))); } -BScreen::BScreen(Fluxbox *b, int scrn) : ScreenInfo(b, scrn), -rootcommand("") +//---------- resource manipulators --------- +template<> +void Resource<Tab::Alignment>:: +setFromString(const char *strval) { + m_value = Tab::getTabAlignmentNum(strval); +} + +template<> +void Resource<Tab::Placement>:: +setFromString(const char *strval) { + m_value = Tab::getTabPlacementNum(strval); +} + +template<> +void Resource<Toolbar::Placement>:: +setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Toolbar::TOPLEFT; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Toolbar::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Toolbar::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Toolbar::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Toolbar::TOPRIGHT; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Toolbar::BOTTOMRIGHT; + else + setDefaultValue(); +} + +//--------- resource accessors -------------- +template<> +string Resource<Tab::Alignment>:: +getString() { + return Tab::getTabAlignmentString(m_value); +} + +template<> +string Resource<Tab::Placement>:: +getString() { + return Tab::getTabPlacementString(m_value); +} + +template<> +string Resource<Toolbar::Placement>:: +getString() { + switch (m_value) { + case Toolbar::TOPLEFT: + return string("TopLeft"); + break; + case Toolbar::BOTTOMLEFT: + return string("BottomLeft"); + break; + case Toolbar::TOPCENTER: + return string("TopCenter"); + break; + case Toolbar::BOTTOMCENTER: + return string("BottomCenter"); + break; + case Toolbar::TOPRIGHT: + return string("TopRight"); + break; + case Toolbar::BOTTOMRIGHT: + return string("BottomRight"); + break; + } + //default string + return string("BottomCenter"); +} + + +BScreen::ScreenResource::ScreenResource(ResourceManager &rm, + const std::string &scrname, const std::string &altscrname): +toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"), +toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"), +image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), +opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"), +full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"), +max_over_slit(rm, true, scrname+".maxOverSlit",altscrname+".MaxOverSlit"), +tab_rotate_vertical(rm, true, scrname+".tab.rotatevertical", altscrname+".Tab.RotateVertical"), +sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"), +rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), +workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), +toolbar_width_percent(rm, 65, scrname+".toolbar.widthPercent", altscrname+".Toolbar.WidthPercent"), +edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), +tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"), +tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"), +tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), +tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), +toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") { - theme = 0; + +}; + +BScreen::BScreen(ResourceManager &rm, Fluxbox *b, + const string &screenname, const string &altscreenname, + int scrn) : ScreenInfo(b, scrn), +theme(0), +resource(rm, screenname, altscreenname) +{ fluxbox = b; event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | - SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask; + SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask; XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask);

@@ -149,11 +249,11 @@

fprintf(stderr, i18n-> getMessage( -#ifdef NLS + #ifdef NLS ScreenSet, ScreenManagingScreen, -#else // !NLS + #else // !NLS 0, 0, -#endif // NLS + #endif // NLS "BScreen::BScreen: managing screen %d " "using visual 0x%lx, depth %d\n"), getScreenNumber(), XVisualIDFromVisual(getVisual()),

@@ -161,22 +261,22 @@ getDepth());

rootmenu = 0; -#ifdef HAVE_STRFTIME + #ifdef HAVE_STRFTIME resource.strftime_format = 0; -#endif // HAVE_STRFTIME + #endif // HAVE_STRFTIME -#ifdef HAVE_GETPID + #ifdef HAVE_GETPID pid_t bpid = getpid(); XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(), fluxbox->getFluxboxPidAtom(), XA_CARDINAL, sizeof(pid_t) * 8, PropModeReplace, (unsigned char *) &bpid, 1); -#endif // HAVE_GETPID + #endif // HAVE_GETPID XDefineCursor(getBaseDisplay()->getXDisplay(), getRootWindow(), - fluxbox->getSessionCursor()); + fluxbox->getSessionCursor()); workspaceNames = new LinkedList<char>; workspacesList = new LinkedList<Workspace>;

@@ -192,40 +292,41 @@ root_colormap_installed = True;

fluxbox->load_rc(this); - image_control->setDither(resource.image_dither); + image_control->setDither(*resource.image_dither); theme = new Theme(getBaseDisplay()->getXDisplay(), getRootWindow(), getColormap(), getScreenNumber(), image_control, fluxbox->getStyleFilename(), getRootCommand().c_str()); -#ifdef GNOME + #ifdef GNOME /* create the GNOME window */ - Window gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(), - getRootWindow(), 0, 0, 5, 5, 0, 0, 0); + Window gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(), + getRootWindow(), 0, 0, 5, 5, 0, 0, 0); - /* supported WM check */ - XChangeProperty(getBaseDisplay()->getXDisplay(), - getRootWindow(), getBaseDisplay()->getGnomeSupportingWMCheckAtom(), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); + /* supported WM check */ + XChangeProperty(getBaseDisplay()->getXDisplay(), + getRootWindow(), getBaseDisplay()->getGnomeSupportingWMCheckAtom(), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); - XChangeProperty(getBaseDisplay()->getXDisplay(), gnome_win, + XChangeProperty(getBaseDisplay()->getXDisplay(), gnome_win, getBaseDisplay()->getGnomeSupportingWMCheckAtom(), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); Atom gnomeatomlist[1] = {getBaseDisplay()->getGnomeWorkspaceAtom()}; - XChangeProperty(getBaseDisplay()->getXDisplay(), + XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(), getBaseDisplay()->getGnomeProtAtom(), XA_ATOM, 32, PropModeReplace, (unsigned char *)gnomeatomlist, 1); -#endif + #endif const char *s = i18n->getMessage( -#ifdef NLS - ScreenSet, ScreenPositionLength, -#else // !NLS - 0, 0, -#endif // NLS - "0: 0000 x 0: 0000"); + #ifdef NLS + ScreenSet, ScreenPositionLength, + #else // !NLS + 0, 0, + #endif // NLS + "0: 0000 x 0: 0000"); + int l = strlen(s); if (i18n->multibyte()) {

@@ -236,7 +337,7 @@

geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height; } else { geom_h = theme->getWindowStyle().font.fontstruct->ascent + - theme->getWindowStyle().font.fontstruct->descent; + theme->getWindowStyle().font.fontstruct->descent; geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l); }

@@ -287,8 +388,8 @@ iconmenu = new Iconmenu(this);

configmenu = new Configmenu(this); Workspace *wkspc = (Workspace *) 0; - if (resource.workspaces != 0) { - for (int i = 0; i < resource.workspaces; ++i) { + if (*resource.workspaces != 0) { + for (int i = 0; i < *resource.workspaces; ++i) { wkspc = new Workspace(this, workspacesList->count()); workspacesList->insert(wkspc); workspacemenu->insert(wkspc->getName(), wkspc->getMenu());

@@ -1597,8 +1698,8 @@

void BScreen::showPosition(int x, int y) { if (! geom_visible) { XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, - (getWidth() - geom_w) / 2, - (getHeight() - geom_h) / 2, geom_w, geom_h); + (getWidth() - geom_w) / 2, + (getHeight() - geom_h) / 2, geom_w, geom_h); XMapWindow(getBaseDisplay()->getXDisplay(), geom_window); XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window);
M src/Screen.hhsrc/Screen.hh

@@ -22,7 +22,7 @@ // 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.9 2002/01/11 10:20:00 fluxgen Exp $ +// $Id: Screen.hh,v 1.10 2002/01/20 02:17:23 fluxgen Exp $ #ifndef _SCREEN_HH_ #define _SCREEN_HH_

@@ -87,50 +87,39 @@ #include <string>

class BScreen : public ScreenInfo { public: - BScreen(Fluxbox *, int); - ~BScreen(void); + BScreen(ResourceManager &rm, Fluxbox *b, + const string &screenname, const string &altscreenname, + int scrn); + ~BScreen(); - inline const Bool &isToolbarOnTop(void) const - { return resource.toolbar_on_top; } - inline const Bool &doToolbarAutoHide(void) const - { return resource.toolbar_auto_hide; } - inline const Bool &isSloppyFocus(void) const - { return resource.sloppy_focus; } - inline const Bool &isSemiSloppyFocus(void) const - { return resource.semi_sloppy_focus; } - inline const Bool &isRootColormapInstalled(void) const - { return root_colormap_installed; } - inline const Bool &isScreenManaged(void) const { return managed; } - inline const Bool &isTabRotateVertical(void) const - { return resource.tab_rotate_vertical; } - inline const Bool &isSloppyWindowGrouping(void) const - { return resource.sloppy_window_grouping; } - inline const Bool &doAutoRaise(void) const { return resource.auto_raise; } - inline const Bool &doImageDither(void) const - { return resource.image_dither; } - inline const Bool &doOrderedDither(void) const - { return resource.ordered_dither; } - inline const Bool &doMaxOverSlit(void) const { return resource.max_over_slit; } - inline const Bool &doOpaqueMove(void) const { return resource.opaque_move; } - inline const Bool &doFullMax(void) const { return resource.full_max; } - inline const Bool &doFocusNew(void) const { return resource.focus_new; } - inline const Bool &doFocusLast(void) const { return resource.focus_last; } + inline const bool isToolbarOnTop(void) { return *resource.toolbar_on_top; } + inline const bool doToolbarAutoHide(void) { return *resource.toolbar_auto_hide; } + inline const bool isSloppyFocus(void) { return resource.sloppy_focus; } + inline const bool isSemiSloppyFocus(void) { return resource.semi_sloppy_focus; } + inline const bool isRootColormapInstalled(void) { return root_colormap_installed; } + inline const bool isScreenManaged(void) { return managed; } + inline const bool isTabRotateVertical(void) { return *resource.tab_rotate_vertical; } + inline const bool isSloppyWindowGrouping(void) { return *resource.sloppy_window_grouping; } + inline const bool doAutoRaise(void) { return resource.auto_raise; } + inline const bool doImageDither(void) { return *resource.image_dither; } + inline const bool doMaxOverSlit(void) { return *resource.max_over_slit; } + inline const bool doOpaqueMove(void) { return *resource.opaque_move; } + inline const bool doFullMax(void) { return *resource.full_max; } + inline const bool doFocusNew(void) { return resource.focus_new; } + inline const bool doFocusLast(void) { return resource.focus_last; } inline const GC &getOpGC() const { return theme->getOpGC(); } - + inline const BColor *getBorderColor(void) { return &theme->getBorderColor(); } inline BImageControl *getImageControl(void) { return image_control; } inline Rootmenu *getRootmenu(void) { return rootmenu; } - inline std::string &getRootCommand(void) { return rootcommand; } + inline std::string &getRootCommand(void) { return *resource.rootcommand; } #ifdef SLIT inline const Bool &isSlitOnTop(void) const { return resource.slit_on_top; } - inline const Bool &doSlitAutoHide(void) const - { return resource.slit_auto_hide; } + inline const Bool &doSlitAutoHide(void) const { return resource.slit_auto_hide; } inline Slit *getSlit(void) { return slit; } - inline const int &getSlitPlacement(void) const - { return resource.slit_placement; } - inline const int &getSlitDirection(void) const - { return resource.slit_direction; } + inline const int &getSlitPlacement(void) const { return resource.slit_placement; } + inline const int &getSlitDirection(void) const { return resource.slit_direction; } inline void saveSlitPlacement(int p) { resource.slit_placement = p; } inline void saveSlitDirection(int d) { resource.slit_direction = d; } inline void saveSlitOnTop(Bool t) { resource.slit_on_top = t; }

@@ -144,61 +133,41 @@ inline Workspace *getCurrentWorkspace(void) { return current_workspace; }

inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; } - inline const unsigned int getHandleWidth(void) const - { return theme->getHandleWidth(); } - inline const unsigned int getBevelWidth(void) const - { return theme->getBevelWidth(); } - inline const unsigned int getFrameWidth(void) const - { return theme->getFrameWidth(); } - inline const unsigned int getBorderWidth(void) const - { return theme->getBorderWidth(); } - inline const unsigned int getBorderWidth2x(void) const - { return theme->getBorderWidth()*2; } - - inline const int getCurrentWorkspaceID() - { return current_workspace->getWorkspaceID(); } + inline const unsigned int getHandleWidth(void) const { return theme->getHandleWidth(); } + inline const unsigned int getBevelWidth(void) const { return theme->getBevelWidth(); } + inline const unsigned int getFrameWidth(void) const { return theme->getFrameWidth(); } + inline const unsigned int getBorderWidth(void) const { return theme->getBorderWidth(); } + inline const unsigned int getBorderWidth2x(void) const { return theme->getBorderWidth()*2; } + inline const int getCurrentWorkspaceID() { return current_workspace->getWorkspaceID(); } inline const int getCount(void) { return workspacesList->count(); } inline const int getIconCount(void) { return iconList->count(); } inline LinkedList<FluxboxWindow> *getIconList(void) { return iconList; } - inline const int &getNumberOfWorkspaces(void) const - { return resource.workspaces; } - inline const int &getToolbarPlacement(void) const - { return resource.toolbar_placement; } - inline const int &getToolbarWidthPercent(void) const - { return resource.toolbar_width_percent; } - inline const int &getPlacementPolicy(void) const - { return resource.placement_policy; } - inline const int &getEdgeSnapThreshold(void) const - { return resource.edge_snap_threshold; } - inline const int &getRowPlacementDirection(void) const - { return resource.row_direction; } - inline const int &getColPlacementDirection(void) const - { return resource.col_direction; } - inline const unsigned int &getTabWidth(void) const - { return resource.tab_width; } - inline const unsigned int &getTabHeight(void) const - { return resource.tab_height; } - inline const int getTabPlacement(void) - { return resource.tab_placement; } - inline const int getTabAlignment(void) - { return resource.tab_alignment; } + inline const int getNumberOfWorkspaces(void) { return *resource.workspaces; } + inline const Toolbar::Placement getToolbarPlacement(void) { return *resource.toolbar_placement; } + inline const int getToolbarWidthPercent(void) { return *resource.toolbar_width_percent; } + inline const int getPlacementPolicy(void) const { return resource.placement_policy; } + inline const int getEdgeSnapThreshold(void) { return *resource.edge_snap_threshold; } + inline const int getRowPlacementDirection(void) const { return resource.row_direction; } + inline const int getColPlacementDirection(void) const { return resource.col_direction; } + inline const unsigned int getTabWidth(void) { return *resource.tab_width; } + inline const unsigned int getTabHeight(void) { return *resource.tab_height; } + inline const Tab::Placement getTabPlacement(void) { return *resource.tab_placement; } + inline const Tab::Alignment getTabAlignment(void) { return *resource.tab_alignment; } inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; } - inline void saveRootCommand(std::string rootcmd) { rootcommand = rootcmd; } + inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; } inline void saveSemiSloppyFocus(Bool s) { resource.semi_sloppy_focus = s; } inline void saveAutoRaise(Bool a) { resource.auto_raise = a; } inline void saveWorkspaces(int w) { resource.workspaces = w; } inline void saveToolbarOnTop(Bool r) { resource.toolbar_on_top = r; } inline void saveToolbarAutoHide(Bool r) { resource.toolbar_auto_hide = r; } - inline void saveToolbarWidthPercent(int w) - { resource.toolbar_width_percent = w; } - inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; } + inline void saveToolbarWidthPercent(int w) { resource.toolbar_width_percent = w; } + inline void saveToolbarPlacement(Toolbar::Placement p) { *resource.toolbar_placement = p; } 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 saveEdgeSnapThreshold(int t) { resource.edge_snap_threshold = t; } inline void saveImageDither(Bool d) { resource.image_dither = d; } inline void saveMaxOverSlit(Bool m) { resource.max_over_slit = m; } inline void saveOpaqueMove(Bool o) { resource.opaque_move = o; }

@@ -207,8 +176,8 @@ inline void saveFocusNew(Bool f) { resource.focus_new = f; }

inline void saveFocusLast(Bool f) { resource.focus_last = f; } inline void saveTabWidth(unsigned int w) { resource.tab_width = w; } inline void saveTabHeight(unsigned int h) { resource.tab_height = h; } - inline void saveTabPlacement(unsigned int p) { resource.tab_placement = p; } - inline void saveTabAlignment(unsigned int a) { resource.tab_alignment = a; } + inline void saveTabPlacement(Tab::Placement p) { *resource.tab_placement = p; } + inline void saveTabAlignment(Tab::Alignment a) { *resource.tab_alignment = a; } inline void saveTabRotateVertical(Bool r) { resource.tab_rotate_vertical = r; } inline void saveSloppyWindowGrouping(Bool s)

@@ -254,7 +223,7 @@ void reassociateWindow(FluxboxWindow *, int, Bool);

void prevFocus(void); void nextFocus(void); void raiseFocus(void); - void reconfigure(void); + void reconfigure(void); void rereadMenu(void); void shutdown(void); void showPosition(int, int);

@@ -280,7 +249,6 @@ WINDOWLOWER, WINDOWSTICK, WINDOWKILL, SETSTYLE, WINDOWTAB};

private: Theme *theme; - std::string rootcommand; Bool root_colormap_installed, managed, geom_visible; GC opGC;

@@ -311,18 +279,26 @@ unsigned long event_mask;

LinkedList<char> *workspaceNames; LinkedList<Workspace> *workspacesList; - - struct resource { + + struct ScreenResource { + ScreenResource(ResourceManager &rm, const std::string &scrname, + const std::string &altscrname); - Bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise, - auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max, - focus_new, focus_last, max_over_slit, tab_rotate_vertical, semi_sloppy_focus, + Resource<bool> toolbar_on_top, toolbar_auto_hide, + image_dither, opaque_move, full_max, + max_over_slit, tab_rotate_vertical, sloppy_window_grouping; + Resource<std::string> rootcommand; + bool auto_raise, sloppy_focus, semi_sloppy_focus, focus_new, focus_last, + ordered_dither; + Resource<int> workspaces, toolbar_width_percent, edge_snap_threshold, + tab_width, tab_height; + int placement_policy, row_direction, col_direction; - int workspaces, toolbar_placement, toolbar_width_percent, placement_policy, - edge_snap_threshold, row_direction, col_direction; + Resource<Tab::Placement> tab_placement; + Resource<Tab::Alignment> tab_alignment; + Resource<Toolbar::Placement> toolbar_placement; - unsigned int tab_placement, tab_alignment, tab_width, tab_height; #ifdef SLIT Bool slit_on_top, slit_auto_hide;