X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FScreen.cc;h=43ab26b9d3b121ae5c9f8bec905d002f9b45d5d6;hb=e5685e3cfd3a44a6ac633617ca527a9f3173ccd4;hp=368a6e8f14d79e6a08d04ed63411072261d65459;hpb=3dcebcf56c6dd3a3707291e757af485bb55df7a6;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 368a6e8f..43ab26b9 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -49,12 +49,19 @@ #include "Window.h" #include "Workspace.h" #include "Workspacemenu.h" +#include "Util.h" -#ifdef STDC_HEADERS +#ifdef HAVE_STDLIB_H # include +#endif // HAVE_STDLIB_H + +#ifdef HAVE_STRING_H # include +#endif // HAVE_STRING_H + +#ifdef HAVE_SYS_TYPES_H # include -#endif // STDC_HEADERS +#endif // HAVE_SYS_TYPES_H #ifdef HAVE_CTYPE_H # include @@ -93,6 +100,7 @@ #define FONT_ELEMENT_SIZE 50 #endif // FONT_ELEMENT_SIZE +#include #include #include @@ -179,7 +187,9 @@ static const char *getFontSize(const char *pattern, int *size) { } -BScreen::BScreen(Openbox &ob, int scrn) : ScreenInfo(ob, scrn), openbox(ob) { +BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), + openbox(ob), config(conf) +{ event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask; @@ -201,14 +211,14 @@ BScreen::BScreen(Openbox &ob, int scrn) : ScreenInfo(ob, scrn), openbox(ob) { rootmenu = 0; resource.mstyle.t_fontset = resource.mstyle.f_fontset = - resource.tstyle.fontset = resource.wstyle.fontset = (XFontSet) 0; + resource.tstyle.fontset = resource.wstyle.fontset = NULL; resource.mstyle.t_font = resource.mstyle.f_font = resource.tstyle.font = - resource.wstyle.font = (XFontStruct *) 0; - resource.root_command = NULL; + resource.wstyle.font = NULL; -#ifdef HAVE_STRFTIME - resource.strftime_format = 0; -#endif // HAVE_STRFTIME +#ifdef SLIT + slit = NULL; +#endif // SLIT + toolbar = NULL; #ifdef HAVE_GETPID pid_t bpid = getpid(); @@ -234,10 +244,7 @@ BScreen::BScreen(Openbox &ob, int scrn) : ScreenInfo(ob, scrn), openbox(ob) { image_control->installRootColormap(); root_colormap_installed = True; - openbox.load_rc(this); - - image_control->setDither(resource.image_dither); - + load(); // load config options from Resources LoadStyle(); XGCValues gcv; @@ -390,16 +397,18 @@ BScreen::BScreen(Openbox &ob, int scrn) : ScreenInfo(ob, scrn), openbox(ob) { iconmenu = new Iconmenu(*this); configmenu = new Configmenu(*this); - Workspace *wkspc = (Workspace *) 0; + Workspace *wkspc = NULL; if (resource.workspaces != 0) { for (int i = 0; i < resource.workspaces; ++i) { wkspc = new Workspace(*this, workspacesList->count()); workspacesList->insert(wkspc); + saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); } } else { wkspc = new Workspace(*this, workspacesList->count()); workspacesList->insert(wkspc); + saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); } @@ -410,10 +419,10 @@ BScreen::BScreen(Openbox &ob, int scrn) : ScreenInfo(ob, scrn), openbox(ob) { current_workspace = workspacesList->first(); workspacemenu->setItemSelected(2, True); - toolbar = new Toolbar(*this); + toolbar = new Toolbar(*this, config); #ifdef SLIT - slit = new Slit(*this); + slit = new Slit(*this, config); #endif // SLIT InitMenu(); @@ -581,6 +590,108 @@ BScreen::~BScreen(void) { resource.tstyle.b_pic_gc); } + +Rect BScreen::availableArea() const { + // the following code is temporary and will be taken care of by Screen in the + // future (with the NETWM 'strut') + Rect space(0, 0, size().w(), size().h()); + if (!resource.full_max) { +#ifdef SLIT + int slit_x = slit->autoHide() ? slit->hiddenOrigin().x() : slit->area().x(), + slit_y = slit->autoHide() ? slit->hiddenOrigin().y() : slit->area().y(); + int tbarh = resource.hide_toolbar ? 0 : + toolbar->getExposedHeight() + resource.border_width * 2; + bool tbartop; + switch (toolbar->placement()) { + case Toolbar::TopLeft: + case Toolbar::TopCenter: + case Toolbar::TopRight: + tbartop = true; + break; + case Toolbar::BottomLeft: + case Toolbar::BottomCenter: + case Toolbar::BottomRight: + tbartop = false; + break; + default: + ASSERT(false); // unhandled placement + } + if ((slit->direction() == Slit::Horizontal && + (slit->placement() == Slit::TopLeft || + slit->placement() == Slit::TopRight)) || + slit->placement() == Slit::TopCenter) { + // exclude top + if (tbartop && slit_y + slit->area().h() < tbarh) { + space.setY(space.y() + tbarh); + space.setH(space.h() - tbarh); + } else { + space.setY(space.y() + (slit_y + slit->area().h() + + resource.border_width * 2)); + space.setH(space.h() - (slit_y + slit->area().h() + + resource.border_width * 2)); + if (!tbartop) + space.setH(space.h() - tbarh); + } + } else if ((slit->direction() == Slit::Vertical && + (slit->placement() == Slit::TopRight || + slit->placement() == Slit::BottomRight)) || + slit->placement() == Slit::CenterRight) { + // exclude right + space.setW(space.w() - (size().w() - slit_x)); + if (tbartop) + space.setY(space.y() + tbarh); + space.setH(space.h() - tbarh); + } else if ((slit->direction() == Slit::Horizontal && + (slit->placement() == Slit::BottomLeft || + slit->placement() == Slit::BottomRight)) || + slit->placement() == Slit::BottomCenter) { + // exclude bottom + if (!tbartop && (size().h() - slit_y) < tbarh) { + space.setH(space.h() - tbarh); + } else { + space.setH(space.h() - (size().h() - slit_y)); + if (tbartop) { + space.setY(space.y() + tbarh); + space.setH(space.h() - tbarh); + } + } + } else {// if ((slit->direction() == Slit::Vertical && + // (slit->placement() == Slit::TopLeft || + // slit->placement() == Slit::BottomLeft)) || + // slit->placement() == Slit::CenterLeft) + // exclude left + space.setX(slit_x + slit->area().w() + + resource.border_width * 2); + space.setW(space.w() - (slit_x + slit->area().w() + + resource.border_width * 2)); + if (tbartop) + space.setY(space.y() + tbarh); + space.setH(space.h() - tbarh); + } +#else // !SLIT + int tbarh = resource.hide_toolbar() ? 0 : + toolbar->getExposedHeight() + resource.border_width * 2; + switch (toolbar->placement()) { + case Toolbar::TopLeft: + case Toolbar::TopCenter: + case Toolbar::TopRight: + space.setY(toolbar->getExposedHeight()); + space.setH(space.h() - toolbar->getExposedHeight()); + break; + case Toolbar::BottomLeft: + case Toolbar::BottomCenter: + case Toolbar::BottomRight: + space.setH(space.h() - tbarh); + break; + default: + ASSERT(false); // unhandled placement + } +#endif // SLIT + } + return space; +} + + void BScreen::readDatabaseTexture(const char *rname, const char *rclass, BTexture *texture, unsigned long default_pixel) @@ -816,7 +927,466 @@ XFontSet BScreen::createFontSet(const char *fontname) { } +void BScreen::setSloppyFocus(bool b) { + resource.sloppy_focus = b; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".focusModel" << ends; + config.setValue(s.str(), + (resource.sloppy_focus ? + (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") + : "ClickToFocus")); + s.rdbuf()->freeze(0); +} + + +void BScreen::setAutoRaise(bool a) { + resource.auto_raise = a; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".focusModel" << ends; + config.setValue(s.str(), + (resource.sloppy_focus ? + (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") + : "ClickToFocus")); + s.rdbuf()->freeze(0); +} + + +void BScreen::setImageDither(bool d, bool reconfig) { + resource.image_dither = d; + image_control->setDither(d); + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".imageDither" << ends; + config.setValue(s.str(), resource.image_dither); + s.rdbuf()->freeze(0); + if (reconfig) + reconfigure(); +} + + +void BScreen::setOpaqueMove(bool o) { + resource.opaque_move = o; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends; + config.setValue(s.str(), resource.opaque_move); + s.rdbuf()->freeze(0); +} + + +void BScreen::setFullMax(bool f) { + resource.full_max = f; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends; + config.setValue(s.str(), resource.full_max); + s.rdbuf()->freeze(0); +} + + +void BScreen::setFocusNew(bool f) { + resource.focus_new = f; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends; + config.setValue(s.str(), resource.focus_new); + s.rdbuf()->freeze(0); +} + + +void BScreen::setFocusLast(bool f) { + resource.focus_last = f; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends; + config.setValue(s.str(), resource.focus_last); + s.rdbuf()->freeze(0); +} + + +void BScreen::setWindowZones(int z) { + resource.zones = z; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".windowZones" << ends; + config.setValue(s.str(), resource.zones); + s.rdbuf()->freeze(0); +} + + +void BScreen::setWorkspaceCount(int w) { + resource.workspaces = w; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".workspaces" << ends; + config.setValue(s.str(), resource.workspaces); + s.rdbuf()->freeze(0); +} + + +void BScreen::setPlacementPolicy(int p) { + resource.placement_policy = p; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".windowPlacement" << ends; + const char *placement; + switch (resource.placement_policy) { + case CascadePlacement: placement = "CascadePlacement"; break; + case BestFitPlacement: placement = "BestFitPlacement"; break; + case ColSmartPlacement: placement = "ColSmartPlacement"; break; + default: + case RowSmartPlacement: placement = "RowSmartPlacement"; break; + } + config.setValue(s.str(), placement); + s.rdbuf()->freeze(0); +} + + +void BScreen::setEdgeSnapThreshold(int t) { + resource.edge_snap_threshold = t; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends; + config.setValue(s.str(), resource.edge_snap_threshold); + s.rdbuf()->freeze(0); +} + + +void BScreen::setRowPlacementDirection(int d) { + resource.row_direction = d; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".rowPlacementDirection" << + ends; + config.setValue(s.str(), + resource.row_direction == LeftRight ? + "LeftToRight" : "RightToLeft"); + s.rdbuf()->freeze(0); +} + + +void BScreen::setColPlacementDirection(int d) { + resource.col_direction = d; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".colPlacementDirection" << + ends; + config.setValue(s.str(), + resource.col_direction == TopBottom ? + "TopToBottom" : "BottomToTop"); + s.rdbuf()->freeze(0); +} + + +void BScreen::setRootCommand(const char *cmd) { +if (resource.root_command != NULL) + delete [] resource.root_command; + if (cmd != NULL) + resource.root_command = bstrdup(cmd); + else + resource.root_command = NULL; + // this doesn't save to the Resources config because it can't be changed + // inside Openbox, and this way we dont add an empty command which would over- + // ride the styles command when none has been specified +} + + +#ifdef HAVE_STRFTIME +void BScreen::setStrftimeFormat(const char *f) { + if (resource.strftime_format != NULL) + delete [] resource.strftime_format; + + resource.strftime_format = bstrdup(f); + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends; + config.setValue(s.str(), resource.strftime_format); + s.rdbuf()->freeze(0); +} + +#else // !HAVE_STRFTIME +void BScreen::setDateFormat(int f) { + resource.date_format = f; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".dateFormat" << ends; + config.setValue(s.str(), resource.date_format == B_EuropeanDate ? + "European" : "American"); + s.rdbuf()->freeze(0); +} + +void BScreen::setClock24Hour(Bool c) { + resource.clock24hour = c; + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".clockFormat" << ends; + config.setValue(s.str(), resource.clock24hour ? 24 : 12); + s.rdbuf()->freeze(0); +} +#endif // HAVE_STRFTIME + +void BScreen::setHideToolbar(bool b) { + resource.hide_toolbar = b; + if (resource.hide_toolbar) + getToolbar()->unMapToolbar(); + else + getToolbar()->mapToolbar(); + std::ostrstream s; + s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends; + config.setValue(s.str(), resource.hide_toolbar ? "True" : "False"); + s.rdbuf()->freeze(0); +} + +void BScreen::saveWorkspaceNames() { + std::ostrstream rc, names; + + for (int i = 0; i < resource.workspaces; i++) { + Workspace *w = getWorkspace(i); + if (w != NULL) { + names << w->getName(); + if (i < resource.workspaces-1) + names << ','; + } + } + names << ends; + + rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends; + config.setValue(rc.str(), names.str()); + rc.rdbuf()->freeze(0); + names.rdbuf()->freeze(0); +} + +void BScreen::save() { + setSloppyFocus(resource.sloppy_focus); + setAutoRaise(resource.auto_raise); + setImageDither(resource.image_dither, false); + setOpaqueMove(resource.opaque_move); + setFullMax(resource.full_max); + setFocusNew(resource.focus_new); + setFocusLast(resource.focus_last); + setWindowZones(resource.zones); + setWorkspaceCount(resource.workspaces); + setPlacementPolicy(resource.placement_policy); + setEdgeSnapThreshold(resource.edge_snap_threshold); + setRowPlacementDirection(resource.row_direction); + setColPlacementDirection(resource.col_direction); + setRootCommand(resource.root_command); +#ifdef HAVE_STRFTIME + // it deletes the current value before setting the new one, so we have to + // duplicate the current value. + std::string s = resource.strftime_format; + setStrftimeFormat(s.c_str()); +#else // !HAVE_STRFTIME + setDateFormat(resource.date_format); + setClock24Hour(resource.clock24hour); +#endif // HAVE_STRFTIME + setHideToolbar(resource.hide_toolbar); +} + +void BScreen::load() { + std::ostrstream rscreen, rname, rclass; + std::string s; + bool b; + long l; + rscreen << "session.screen" << getScreenNumber() << '.' << ends; + + rname << rscreen.str() << "hideToolbar" << ends; + rclass << rscreen.str() << "HideToolbar" << ends; + if (config.getValue(rname.str(), rclass.str(), b)) + resource.hide_toolbar = b; + else + resource.hide_toolbar = false; + Toolbar *t = getToolbar(); + if (t != NULL) { + if (resource.hide_toolbar) + t->unMapToolbar(); + else + t->mapToolbar(); + } + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "fullMaximization" << ends; + rclass << rscreen.str() << "FullMaximization" << ends; + if (config.getValue(rname.str(), rclass.str(), b)) + resource.full_max = b; + else + resource.full_max = false; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "focusNewWindows" << ends; + rclass << rscreen.str() << "FocusNewWindows" << ends; + if (config.getValue(rname.str(), rclass.str(), b)) + resource.focus_new = b; + else + resource.focus_new = false; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "focusLastWindow" << ends; + rclass << rscreen.str() << "FocusLastWindow" << ends; + if (config.getValue(rname.str(), rclass.str(), b)) + resource.focus_last = b; + else + resource.focus_last = false; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "rowPlacementDirection" << ends; + rclass << rscreen.str() << "RowPlacementDirection" << ends; + if (config.getValue(rname.str(), rclass.str(), s)) { + if (0 == strncasecmp(s.c_str(), "RightToLeft", s.length())) + resource.row_direction = RightLeft; + else if (0 == strncasecmp(s.c_str(), "LeftToRight", s.length())) + resource.row_direction = LeftRight; + } else + resource.row_direction = LeftRight; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "colPlacementDirection" << ends; + rclass << rscreen.str() << "ColPlacementDirection" << ends; + if (config.getValue(rname.str(), rclass.str(), s)) { + if (0 == strncasecmp(s.c_str(), "BottomToTop", s.length())) + resource.col_direction = BottomTop; + else if (0 == strncasecmp(s.c_str(), "TopToBottom", s.length())) + resource.col_direction = TopBottom; + } else + resource.col_direction = TopBottom; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "workspaces" << ends; + rclass << rscreen.str() << "Workspaces" << ends; + if (config.getValue(rname.str(), rclass.str(), l)) + resource.workspaces = l; + else + resource.workspaces = 1; + + removeWorkspaceNames(); + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "workspaceNames" << ends; + rclass << rscreen.str() << "WorkspaceNames" << ends; + if (config.getValue(rname.str(), rclass.str(), s)) { + std::string::const_iterator it = s.begin(), end = s.end(); + while(1) { + std::string::const_iterator tmp = it;// current string.begin() + it = std::find(tmp, end, ','); // look for comma between tmp and end + std::string name(tmp, it); // name = s[tmp:it] + addWorkspaceName(name.c_str()); + if (it == end) + break; + ++it; + } + } + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "focusModel" << ends; + rclass << rscreen.str() << "FocusModel" << ends; + if (config.getValue(rname.str(), rclass.str(), s)) { + if (0 == strncasecmp(s.c_str(), "ClickToFocus", s.length())) { + resource.auto_raise = false; + resource.sloppy_focus = false; + } else if (0 == strncasecmp(s.c_str(), "AutoRaiseSloppyFocus", + s.length())) { + resource.sloppy_focus = true; + resource.auto_raise = true; + } else if (0 == strncasecmp(s.c_str(), "SloppyFocus", s.length())) { + resource.sloppy_focus = true; + resource.auto_raise = false; + } + } else { + resource.sloppy_focus = true; + resource.auto_raise = false; + } + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "windowZones" << ends; + rclass << rscreen.str() << "WindowZones" << ends; + if (config.getValue(rname.str(), rclass.str(), l)) + resource.zones = (l == 1 || l == 2 || l == 4) ? l : 1; + else + resource.zones = 4; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "windowPlacement" << ends; + rclass << rscreen.str() << "WindowPlacement" << ends; + if (config.getValue(rname.str(), rclass.str(), s)) { + if (0 == strncasecmp(s.c_str(), "RowSmartPlacement", s.length())) + resource.placement_policy = RowSmartPlacement; + else if (0 == strncasecmp(s.c_str(), "ColSmartPlacement", s.length())) + resource.placement_policy = ColSmartPlacement; + else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length())) + resource.placement_policy = BestFitPlacement; + else if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length())) + resource.placement_policy = CascadePlacement; + } else + resource.placement_policy = CascadePlacement; + +#ifdef HAVE_STRFTIME + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "strftimeFormat" << ends; + rclass << rscreen.str() << "StrftimeFormat" << ends; + + if (resource.strftime_format != NULL) + delete [] resource.strftime_format; + + if (config.getValue(rname.str(), rclass.str(), s)) + resource.strftime_format = bstrdup(s.c_str()); + else + resource.strftime_format = bstrdup("%I:%M %p"); +#else // !HAVE_STRFTIME + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "dateFormat" << ends; + rclass << rscreen.str() << "DateFormat" << ends; + if (config.getValue(rname.str(), rclass.str(), s)) { + if (strncasecmp(s.c_str(), "European", s.length())) + resource.date_format = B_EuropeanDate; + else if (strncasecmp(s.c_str(), "American", s.length())) + resource.date_format = B_AmericanDate; + } else + resource.date_format = B_AmericanDate; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "clockFormat" << ends; + rclass << rscreen.str() << "ClockFormat" << ends; + if (config.getValue(rname.str(), rclass.str(), l)) { + if (clock == 24) + resource.clock24hour = true; + else if (clock == 12) + resource.clock24hour = false; + } else + resource.clock24hour = false; +#endif // HAVE_STRFTIME + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "edgeSnapThreshold" << ends; + rclass << rscreen.str() << "EdgeSnapThreshold" << ends; + if (config.getValue(rname.str(), rclass.str(), l)) + resource.edge_snap_threshold = l; + else + resource.edge_snap_threshold = 4; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "imageDither" << ends; + rclass << rscreen.str() << "ImageDither" << ends; + if (config.getValue(rname.str(), rclass.str(), b)) + resource.image_dither = b; + else + resource.image_dither = true; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "rootCommand" << ends; + rclass << rscreen.str() << "RootCommand" << ends; + + if (resource.root_command != NULL) + delete [] resource.root_command; + + if (config.getValue(rname.str(), rclass.str(), s)) + resource.root_command = bstrdup(s.c_str()); + else + resource.root_command = NULL; + + rname.seekp(0); rclass.seekp(0); + rname << rscreen.str() << "opaqueMove" << ends; + rclass << rscreen.str() << "OpaqueMove" << ends; + if (config.getValue(rname.str(), rclass.str(), b)) + resource.opaque_move = b; + else + resource.opaque_move = false; + + rscreen.rdbuf()->freeze(0); + rname.rdbuf()->freeze(0); + rclass.rdbuf()->freeze(0); +} + void BScreen::reconfigure(void) { + load(); + toolbar->load(); +#ifdef SLIT + slit->load(); +#endif // SLIT LoadStyle(); XGCValues gcv; @@ -985,15 +1555,20 @@ void BScreen::rereadMenu(void) { void BScreen::removeWorkspaceNames(void) { while (workspaceNames->count()) - delete [] workspaceNames->remove(0); + delete [] workspaceNames->remove(0); } void BScreen::LoadStyle(void) { - obResource &conf = resource.styleconfig; + Resource &conf = resource.styleconfig; - conf.setFile(openbox.getStyleFilename()); - if (!conf.load()) { + const char *sfile = openbox.getStyleFilename(); + bool loaded = false; + if (sfile != NULL) { + conf.setFile(sfile); + loaded = conf.load(); + } + if (!loaded) { conf.setFile(DEFAULTSTYLE); if (!conf.load()) { fprintf(stderr, i18n->getMessage(ScreenSet, ScreenDefaultStyleLoadFail, @@ -1252,7 +1827,7 @@ void BScreen::LoadStyle(void) { // load bevel, border and handle widths if (conf.getValue("handleWidth", "HandleWidth", l)) { - if (l <= getWidth() / 2 && l != 0) + if (l <= size().w() / 2 && l != 0) resource.handle_width = l; else resource.handle_width = 6; @@ -1265,7 +1840,7 @@ void BScreen::LoadStyle(void) { resource.border_width = 1; if (conf.getValue("bevelWidth", "BevelWidth", l)) { - if (l <= getWidth() / 2 && l != 0) + if (l <= size().w() / 2 && l != 0) resource.bevel_width = l; else resource.bevel_width = 3; @@ -1273,7 +1848,7 @@ void BScreen::LoadStyle(void) { resource.bevel_width = 3; if (conf.getValue("frameWidth", "FrameWidth", l)) { - if (l <= getWidth() / 2) + if (l <= size().w() / 2) resource.frame_width = l; else resource.frame_width = resource.bevel_width; @@ -1332,13 +1907,14 @@ OpenboxWindow *BScreen::getIcon(int index) { if (index >= 0 && index < iconList->count()) return iconList->find(index); - return (OpenboxWindow *) 0; + return NULL; } int BScreen::addWorkspace(void) { Workspace *wkspc = new Workspace(*this, workspacesList->count()); workspacesList->insert(wkspc); + saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu(), wkspc->getWorkspaceID() + 2); @@ -1390,7 +1966,7 @@ void BScreen::changeWorkspaceID(int id) { openbox.getFocusedWindow()->getScreen() == this && (! openbox.getFocusedWindow()->isStuck())) { current_workspace->setLastFocusedWindow(openbox.getFocusedWindow()); - openbox.setFocusedWindow((OpenboxWindow *) 0); + openbox.setFocusedWindow(NULL); } current_workspace = getWorkspace(id); @@ -1535,11 +2111,11 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) { *(session_stack + i++) = tmp->getWindowID(); *(session_stack + i++) = rootmenu->getWindowID(); - if (toolbar->isOnTop()) + if (toolbar->onTop()) *(session_stack + i++) = toolbar->getWindowID(); #ifdef SLIT - if (slit->isOnTop()) + if (slit->onTop()) *(session_stack + i++) = slit->getWindowID(); #endif // SLIT @@ -1552,23 +2128,12 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) { } -#ifdef HAVE_STRFTIME -void BScreen::saveStrftimeFormat(const char *format) { - if (resource.strftime_format) - delete [] resource.strftime_format; - - resource.strftime_format = bstrdup(format); -} -#endif // HAVE_STRFTIME - - void BScreen::addWorkspaceName(const char *name) { workspaceNames->insert(bstrdup(name)); } - char* BScreen::getNameOfWorkspace(int id) { - char *name = (char *) 0; + char *name = NULL; if (id >= 0 && id < workspaceNames->count()) { char *wkspc_name = workspaceNames->find(id); @@ -1760,7 +2325,7 @@ void BScreen::InitMenu(void) { rootmenu->insert(i18n->getMessage(ScreenSet, ScreenExit, "Exit"), BScreen::Exit); } else { - openbox.saveMenuFilename(openbox.getMenuFilename()); + openbox.setMenuFilename(openbox.getMenuFilename()); } } @@ -1961,7 +2526,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { if (! feof(submenufile)) { if (! parseMenuFile(submenufile, menu)) - openbox.saveMenuFilename(newfile); + openbox.setMenuFilename(newfile); fclose(submenufile); } @@ -2120,7 +2685,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { rootmenuList->insert(stylesmenu); } - openbox.saveMenuFilename(stylesdir); + openbox.setMenuFilename(stylesdir); } else { fprintf(stderr, i18n->getMessage(ScreenSet, ScreenSTYLESDIRErrorNotDir, @@ -2187,8 +2752,8 @@ void BScreen::shutdown(void) { 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); + (size().w() - geom_w) / 2, + (size().h() - geom_h) / 2, geom_w, geom_h); XMapWindow(getBaseDisplay().getXDisplay(), geom_window); XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window); @@ -2221,8 +2786,8 @@ void BScreen::showPosition(int x, int y) { void BScreen::showGeometry(unsigned int gx, unsigned int gy) { if (! geom_visible) { XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window, - (getWidth() - geom_w) / 2, - (getHeight() - geom_h) / 2, geom_w, geom_h); + (size().w() - geom_w) / 2, + (size().h() - geom_h) / 2, geom_w, geom_h); XMapWindow(getBaseDisplay().getXDisplay(), geom_window); XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window); @@ -2251,7 +2816,6 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { } } - void BScreen::hideGeometry(void) { if (geom_visible) { XUnmapWindow(getBaseDisplay().getXDisplay(), geom_window);