X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FScreen.cc;h=8779733cbcd1a90129847e188ead7e52093751e6;hb=f0c2fa18bef6a0f74d607eb390b98ccfbd8d778f;hp=2f7e684f8e1c0a9092d478e35ac0486494f8264e;hpb=0305cbdc3ae8525c74b2bb9b23884035549e3407;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 2f7e684f..8779733c 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -21,9 +21,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H +#include "../config.h" extern "C" { #include @@ -68,8 +66,11 @@ extern "C" { #endif // HAVE_STDARG_H } +#include + #include #include +#include using std::string; #include "i18n.hh" @@ -86,6 +87,7 @@ using std::string; #include "Window.hh" #include "Workspace.hh" #include "Workspacemenu.hh" +#include "XAtom.hh" #ifndef FONT_ELEMENT_SIZE #define FONT_ELEMENT_SIZE 50 @@ -110,6 +112,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { blackbox = bb; screenstr = (string)"session.screen" + itostring(scrn) + '.'; config = blackbox->getConfig(); + xatom = blackbox->getXAtom(); event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask; @@ -135,13 +138,10 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { resource.mstyle.t_font = resource.mstyle.f_font = resource.tstyle.font = resource.wstyle.font = (XFontStruct *) 0; + xatom->setSupported(this); // set-up netwm support #ifdef HAVE_GETPID - pid_t bpid = getpid(); - - XChangeProperty(blackbox->getXDisplay(), getRootWindow(), - blackbox->getBlackboxPidAtom(), XA_CARDINAL, - sizeof(pid_t) * 8, PropModeReplace, - (unsigned char *) &bpid, 1); + xatom->setValue(getRootWindow(), XAtom::blackbox_pid, XAtom::cardinal, + (unsigned long) getpid()); #endif // HAVE_GETPID XDefineCursor(blackbox->getXDisplay(), getRootWindow(), @@ -231,11 +231,18 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { workspacesList.push_back(wkspc); workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); } + saveWorkspaceNames(); + + updateNetizenWorkspaceCount(); workspacemenu->insert(i18n(IconSet, IconIcons, "Icons"), iconmenu); workspacemenu->update(); current_workspace = workspacesList.front(); + + xatom->setValue(getRootWindow(), XAtom::net_current_desktop, + XAtom::cardinal, 0); //first workspace + workspacemenu->setItemSelected(2, True); toolbar = new Toolbar(this); @@ -407,6 +414,16 @@ void BScreen::saveFocusLast(bool f) { } +void BScreen::saveHideToolbar(bool h) { + resource.hide_toolbar = h; + if (resource.hide_toolbar) + toolbar->unmapToolbar(); + else + toolbar->mapToolbar(); + config->setValue(screenstr + "hideToolbar", resource.hide_toolbar); +} + + void BScreen::saveWorkspaces(unsigned int w) { resource.workspaces = w; config->setValue(screenstr + "workspaces", resource.workspaces); @@ -472,10 +489,15 @@ void BScreen::saveClock24Hour(Bool c) { void BScreen::saveWorkspaceNames() { - string save_string = getWorkspace(0)->getName(); - for (unsigned int i = 1; i < getWorkspaceCount(); ++i) - save_string += ',' + getWorkspace(i)->getName(); - config->setValue(screenstr + "workspaceNames", save_string); + string names; + WorkspaceList::iterator it; + WorkspaceList::iterator last = workspacesList.end() - 1; + for (it = workspacesList.begin(); it != workspacesList.end(); ++it) { + names += (*it)->getName(); + if (it != last) + names += ','; + } + config->setValue(screenstr + "workspaceNames", names); } @@ -487,6 +509,7 @@ void BScreen::save_rc(void) { saveFullMax(resource.full_max); saveFocusNew(resource.focus_new); saveFocusLast(resource.focus_last); + saveHideToolbar(resource.hide_toolbar); saveWorkspaces(resource.workspaces); savePlacementPolicy(resource.placement_policy); saveEdgeSnapThreshold(resource.edge_snap_threshold); @@ -523,6 +546,9 @@ void BScreen::load_rc(void) { if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move)) resource.opaque_move = false; + if (! config->getValue(screenstr + "hideToolbar", resource.hide_toolbar)) + resource.hide_toolbar = false; + if (! config->getValue(screenstr + "imageDither", b)) b = true; image_control->setDither(b); @@ -658,11 +684,31 @@ void BScreen::reconfigure(void) { workspacemenu->reconfigure(); iconmenu->reconfigure(); - int remember_sub = rootmenu->getCurrentSubmenu(); + typedef std::vector SubList; + SubList remember_subs; + + // save the current open menus + Basemenu *menu = rootmenu; + int submenu; + while ((submenu = menu->getCurrentSubmenu()) >= 0) { + remember_subs.push_back(submenu); + menu = menu->find(submenu)->submenu(); + assert(menu); + } + InitMenu(); raiseWindows(0, 0); rootmenu->reconfigure(); - rootmenu->drawSubmenu(remember_sub); + + // reopen the saved menus + menu = rootmenu; + const SubList::iterator subs_end = remember_subs.end(); + for (SubList::iterator it = remember_subs.begin(); it != subs_end; ++it) { + menu->drawSubmenu(*it); + menu = menu->find(*it)->submenu(); + if (! menu) + break; + } configmenu->reconfigure(); @@ -943,7 +989,7 @@ BlackboxWindow *BScreen::getIcon(unsigned int index) { unsigned int BScreen::addWorkspace(void) { Workspace *wkspc = new Workspace(this, workspacesList.size()); workspacesList.push_back(wkspc); - saveWorkspaces(getWorkspaceCount() + 1); + saveWorkspaces(getWorkspaceCount()); saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu(), @@ -975,7 +1021,7 @@ unsigned int BScreen::removeLastWorkspace(void) { workspacesList.pop_back(); delete wkspc; - saveWorkspaces(getWorkspaceCount() - 1); + saveWorkspaces(getWorkspaceCount()); saveWorkspaceNames(); toolbar->reconfigure(); @@ -996,13 +1042,17 @@ void BScreen::changeWorkspaceID(unsigned int id) { if (blackbox->getFocusedWindow() && blackbox->getFocusedWindow()->getScreen() == this && - (! blackbox->getFocusedWindow()->isStuck())) { + ! blackbox->getFocusedWindow()->isStuck()) { current_workspace->setLastFocusedWindow(blackbox->getFocusedWindow()); blackbox->setFocusedWindow((BlackboxWindow *) 0); } current_workspace = getWorkspace(id); + xatom->setValue(getRootWindow(), XAtom::net_current_desktop, + XAtom::cardinal, id); + printf("%d\n", id); + workspacemenu->setItemSelected(current_workspace->getID() + 2, True); toolbar->redrawWorkspaceLabel(True); @@ -1050,6 +1100,13 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) { removeNetizen(w->getClientWindow()); + /* + some managed windows can also be window group controllers. when + unmanaging such windows, we should also delete the window group. + */ + BWindowGroup *group = blackbox->searchGroup(w->getClientWindow()); + delete group; + delete w; } @@ -1090,6 +1147,9 @@ void BScreen::updateNetizenCurrentWorkspace(void) { void BScreen::updateNetizenWorkspaceCount(void) { + xatom->setValue(getRootWindow(), XAtom::net_number_of_desktops, + XAtom::cardinal, workspacesList.size()); + std::for_each(netizenList.begin(), netizenList.end(), std::mem_fun(&Netizen::sendWorkspaceCount)); } @@ -1921,6 +1981,18 @@ void BScreen::buttonPressEvent(XButtonEvent *xbutton) { blackbox->checkMenu(); rootmenu->show(); } + // mouse wheel up + } else if (xbutton->button == 4) { + if (getCurrentWorkspaceID() >= getWorkspaceCount() - 1) + changeWorkspaceID(0); + else + changeWorkspaceID(getCurrentWorkspaceID() + 1); + // mouse wheel down + } else if (xbutton->button == 5) { + if (getCurrentWorkspaceID() == 0) + changeWorkspaceID(getWorkspaceCount() - 1); + else + changeWorkspaceID(getCurrentWorkspaceID() - 1); } }