X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FScreen.cc;h=7338f118ad292948d8cafa5302ef9624e595ef3f;hb=a3a23c28f0fa4ed8b42ccde4a4b99aec60583df5;hp=75f8459af4adf49487dcf6dd9681bb6e959f9ada;hpb=d6c02ad70c42f074a4c3d8c433de5bb2c63dea8e;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 75f8459a..7338f118 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -583,7 +583,7 @@ Rect BScreen::availableArea() const { #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 : + unsigned int tbarh = resource.hide_toolbar ? 0 : toolbar->getExposedHeight() + resource.border_width * 2; bool tbartop; switch (toolbar->placement()) { @@ -1836,7 +1836,7 @@ void BScreen::LoadStyle(void) { // load bevel, border and handle widths if (conf.getValue("handleWidth", "HandleWidth", l)) { - if (l <= size().w() / 2 && l != 0) + if (l <= (signed)size().w() / 2 && l != 0) resource.handle_width = l; else resource.handle_width = 6; @@ -1849,7 +1849,7 @@ void BScreen::LoadStyle(void) { resource.border_width = 1; if (conf.getValue("bevelWidth", "BevelWidth", l)) { - if (l <= size().w() / 2 && l != 0) + if (l <= (signed)size().w() / 2 && l != 0) resource.bevel_width = l; else resource.bevel_width = 3; @@ -1857,7 +1857,7 @@ void BScreen::LoadStyle(void) { resource.bevel_width = 3; if (conf.getValue("frameWidth", "FrameWidth", l)) { - if (l <= size().w() / 2) + if (l <= (signed)size().w() / 2) resource.frame_width = l; else resource.frame_width = resource.bevel_width; @@ -1912,7 +1912,7 @@ void BScreen::removeIcon(OpenboxWindow *w) { OpenboxWindow *BScreen::getIcon(int index) { - if (index < 0 || index >= iconList.size()) + if (index < 0 || index >= (signed)iconList.size()) return (OpenboxWindow *) 0; winList::iterator it = iconList.begin(); @@ -1979,8 +1979,7 @@ void BScreen::changeWorkspaceID(int id) { if (openbox.focusedWindow() && openbox.focusedWindow()->getScreen() == this && (! openbox.focusedWindow()->isStuck())) { - current_workspace->setLastFocusedWindow(openbox.focusedWindow()); - openbox.focusWindow((OpenboxWindow *) 0); + openbox.focusWindow(0); } current_workspace = getWorkspace(id); @@ -1991,9 +1990,9 @@ void BScreen::changeWorkspaceID(int id) { current_workspace->showAll(); - if (resource.focus_last && current_workspace->getLastFocusedWindow()) { + if (resource.focus_last && current_workspace->lastFocusedWindow()) { XSync(openbox.getXDisplay(), False); - current_workspace->getLastFocusedWindow()->setInputFocus(); + current_workspace->lastFocusedWindow()->setInputFocus(); } } @@ -2022,7 +2021,6 @@ void BScreen::addNetizen(Netizen *n) { void BScreen::removeNetizen(Window w) { netList::iterator it; - int i = 0; for (it = netizenList.begin(); it != netizenList.end(); ++it) if ((*it)->getWindowID() == w) { @@ -2148,7 +2146,7 @@ void BScreen::addWorkspaceName(const char *name) { const char *BScreen::getNameOfWorkspace(int id) { - if (id < 0 || id >= workspaceNames.size()) + if (id < 0 || id >= (signed)workspaceNames.size()) return (const char *) 0; return workspaceNames[id].c_str(); } @@ -2267,59 +2265,72 @@ void BScreen::InitMenu(void) { } else { rootmenu = new Rootmenu(*this); } - Bool defaultMenu = True; + bool defaultMenu = true; - if (openbox.getMenuFilename()) { - FILE *menu_file = fopen(openbox.getMenuFilename(), "r"); + FILE *menu_file; + const char *menu_filename = openbox.getMenuFilename(); - if (!menu_file) { - perror(openbox.getMenuFilename()); + if (!(menu_file = fopen(menu_filename, "r"))) { + perror(menu_filename); + menu_filename = (char *) 0; + } + if (menu_filename == (char *) 0) { + // opening the menu file failed, try the DEFAULTMENU + menu_filename = DEFAULTMENU; + if (!(menu_file = fopen(menu_filename, "r"))) { + perror(menu_filename); + menu_filename = (char *) 0; + } + } + + if (menu_filename) { + if (feof(menu_file)) { + fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEmptyMenuFile, + "%s: Empty menu file"), menu_filename); + menu_filename = (char *) 0; } else { - if (feof(menu_file)) { - fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEmptyMenuFile, - "%s: Empty menu file"), - openbox.getMenuFilename()); - } else { - char line[1024], label[1024]; - memset(line, 0, 1024); - memset(label, 0, 1024); - - while (fgets(line, 1024, menu_file) && ! feof(menu_file)) { - if (line[0] != '#') { - int i, key = 0, index = -1, len = strlen(line); - - key = 0; - for (i = 0; i < len; i++) { - if (line[i] == '[') index = 0; - else if (line[i] == ']') break; - else if (line[i] != ' ') - if (index++ >= 0) - key += tolower(line[i]); - } + // successsfully opened a menu file + char line[1024], label[1024]; + memset(line, 0, 1024); + memset(label, 0, 1024); + + while (fgets(line, 1024, menu_file) && ! feof(menu_file)) { + if (line[0] != '#') { + int i, key = 0, index = -1, len = strlen(line); + + key = 0; + for (i = 0; i < len; i++) { + if (line[i] == '[') index = 0; + else if (line[i] == ']') break; + else if (line[i] != ' ') + if (index++ >= 0) + key += tolower(line[i]); + } - if (key == 517) { - index = -1; - for (i = index; i < len; i++) { - if (line[i] == '(') index = 0; - else if (line[i] == ')') break; - else if (index++ >= 0) { - if (line[i] == '\\' && i < len - 1) i++; - label[index - 1] = line[i]; - } - } + if (key == 517) { + index = -1; + for (i = index; i < len; i++) { + if (line[i] == '(') index = 0; + else if (line[i] == ')') break; + else if (index++ >= 0) { + if (line[i] == '\\' && i < len - 1) i++; + label[index - 1] = line[i]; + } + } - if (index == -1) index = 0; - label[index] = '\0'; + if (index == -1) index = 0; + label[index] = '\0'; - rootmenu->setLabel(label); - defaultMenu = parseMenuFile(menu_file, rootmenu); - break; - } - } - } + rootmenu->setLabel(label); + defaultMenu = parseMenuFile(menu_file, rootmenu); + if (!defaultMenu) + openbox.addMenuTimestamp(menu_filename); + break; + } + } } - fclose(menu_file); } + fclose(menu_file); } if (defaultMenu) { @@ -2331,8 +2342,6 @@ void BScreen::InitMenu(void) { BScreen::Restart); rootmenu->insert(i18n->getMessage(ScreenSet, ScreenExit, "Exit"), BScreen::Exit); - } else { - openbox.setMenuFilename(openbox.getMenuFilename()); } } @@ -2532,10 +2541,9 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { } if (! feof(submenufile)) { - if (! parseMenuFile(submenufile, menu)) - openbox.setMenuFilename(newfile); - - fclose(submenufile); + if (!parseMenuFile(submenufile, menu)) + openbox.addMenuTimestamp(newfile); + fclose(submenufile); } } else perror(newfile); @@ -2691,8 +2699,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { menu->insert(label, stylesmenu); rootmenuList.push_back(stylesmenu); } - - openbox.setMenuFilename(stylesdir); + openbox.addMenuTimestamp(stylesdir); } else { fprintf(stderr, i18n->getMessage(ScreenSet, ScreenSTYLESDIRErrorNotDir,