This patch makes the toolbar look like "Workspace + Icons" in fluxbox 0.9, but it is less buggy and currently does not highlight active window. Tomas Janousek diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/IconBar.cc fluxbox-0.1.14/src/IconBar.cc --- fluxbox-0.1.14-orig/src/IconBar.cc 2002-12-07 16:33:43.000000000 +0100 +++ fluxbox-0.1.14/src/IconBar.cc 2004-08-17 14:46:23.000000000 +0200 @@ -73,14 +73,15 @@ // icons. // returns window to iconobj //-------------------------------------------- -Window IconBar::addIcon(FluxboxWindow *fluxboxwin) { +Window IconBar::addIcon(FluxboxWindow *fluxboxwin, bool repos) { Window iconwin = createIconWindow(fluxboxwin, m_parent); decorate(iconwin); //add window object to list m_iconlist.push_back(new IconBarObj(fluxboxwin, iconwin)); //reposition all icons to fit windowbar - repositionIcons(); + if (repos) + repositionIcons(); XMapSubwindows(m_display, iconwin); XMapWindow(m_display, iconwin); @@ -94,7 +95,7 @@ // Return X Window of the removed iconobj // returns None if no window was found //--------------------------------------- -Window IconBar::delIcon(FluxboxWindow *fluxboxwin) { +Window IconBar::delIcon(FluxboxWindow *fluxboxwin, bool repos) { Window retwin = None; IconBarObj *obj = findIcon(fluxboxwin); if (obj) { @@ -105,7 +106,8 @@ retwin = obj->getIconWin(); delete obj; XDestroyWindow(m_display, retwin); - repositionIcons(); + if (repos) + repositionIcons(); } } return retwin; @@ -264,15 +266,19 @@ unsigned int title_text_w; title_text_w = m_screen->getWindowStyle()->font.textWidth( - fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); + (fluxboxwin->isIconic())?(fluxboxwin->getIconTitle().c_str()): + (fluxboxwin->getTitle().c_str()), (fluxboxwin->isIconic())? + (fluxboxwin->getIconTitle().size()):(fluxboxwin->getTitle().size())); int l = title_text_w; - unsigned int dlen=fluxboxwin->getIconTitle().size(); + unsigned int dlen=(fluxboxwin->isIconic())?(fluxboxwin->getIconTitle().size()): + (fluxboxwin->getTitle().size()); unsigned int bevel_w = m_screen->getBevelWidth(); int dx=bevel_w*2; for (; dlen >= 0; dlen--) { l = m_screen->getWindowStyle()->tab.font.textWidth( - fluxboxwin->getIconTitle().c_str(), dlen); + (fluxboxwin->isIconic())?(fluxboxwin->getIconTitle().c_str()): + (fluxboxwin->getTitle().c_str()), dlen); l += (bevel_w * 4); if (l < width) @@ -297,8 +303,10 @@ m_screen->getWindowStyle()->tab.font.drawText( iconwin, m_screen->getScreenNumber(), + (fluxboxwin->isIconic())?m_screen->getWindowStyle()->tab.l_text_unfocus_gc: m_screen->getWindowStyle()->tab.l_text_focus_gc, - fluxboxwin->getIconTitle().c_str(), dlen, + (fluxboxwin->isIconic())?fluxboxwin->getIconTitle().c_str(): + fluxboxwin->getTitle().c_str(), dlen, dx, 1+ m_screen->getWindowStyle()->tab.font.ascent(), false); diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/IconBar.hh fluxbox-0.1.14/src/IconBar.hh --- fluxbox-0.1.14-orig/src/IconBar.hh 2002-12-07 15:13:57.000000000 +0100 +++ fluxbox-0.1.14/src/IconBar.hh 2004-08-17 14:47:19.000000000 +0200 @@ -56,8 +56,8 @@ ~IconBar(); void draw(); //TODO void reconfigure(); - Window addIcon(FluxboxWindow *fluxboxwin); - Window delIcon(FluxboxWindow *fluxboxwin); + Window addIcon(FluxboxWindow *fluxboxwin, bool repos = true); + Window delIcon(FluxboxWindow *fluxboxwin, bool repos = true); void buttonPressEvent(XButtonEvent *be); FluxboxWindow *findWindow(Window w); IconBarObj *findIcon(FluxboxWindow * const fluxboxwin); diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/Screen.cc fluxbox-0.1.14/src/Screen.cc --- fluxbox-0.1.14-orig/src/Screen.cc 2004-06-29 16:19:54.000000000 +0200 +++ fluxbox-0.1.14/src/Screen.cc 2004-08-17 14:55:05.000000000 +0200 @@ -645,7 +645,6 @@ m_iconmenu->insert(w->getIconTitle().c_str()); m_iconmenu->update(); - m_toolbar->addIcon(w); } @@ -666,7 +665,6 @@ m_iconmenu->remove(w->getWindowNumber()); m_iconmenu->update(); - m_toolbar->delIcon(w); Icons::iterator it = iconList.begin(); Icons::iterator it_end = iconList.end(); @@ -779,8 +777,24 @@ Fluxbox::instance()->setFocusedWindow(0); // set focused window to none } + // remove icons + it = wins.begin(); + for (; it != wins.end(); ++it) { + m_toolbar->delIcon(*it, false); + } + // set new workspace current_workspace = getWorkspace(id); + + // add icons + wksp = getCurrentWorkspace(); + wins = wksp->getWindowList(); + it = wins.begin(); + for (; it != wins.end(); ++it) { + m_toolbar->addIcon(*it, false); + } + + m_toolbar->reconfigure(); workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); m_toolbar->redrawWorkspaceLabel(true); diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/Toolbar.cc fluxbox-0.1.14/src/Toolbar.cc --- fluxbox-0.1.14-orig/src/Toolbar.cc 2002-12-08 04:41:57.000000000 +0100 +++ fluxbox-0.1.14/src/Toolbar.cc 2004-08-17 14:53:54.000000000 +0200 @@ -193,14 +193,14 @@ } -void Toolbar::addIcon(FluxboxWindow *w) { +void Toolbar::addIcon(FluxboxWindow *w, bool repos) { if (m_iconbar.get() != 0) - Fluxbox::instance()->saveToolbarSearch(m_iconbar->addIcon(w), this); + Fluxbox::instance()->saveToolbarSearch(m_iconbar->addIcon(w, repos), this); } -void Toolbar::delIcon(FluxboxWindow *w) { +void Toolbar::delIcon(FluxboxWindow *w, bool repos) { if (m_iconbar.get() != 0) - Fluxbox::instance()->removeToolbarSearch(m_iconbar->delIcon(w)); + Fluxbox::instance()->removeToolbarSearch(m_iconbar->delIcon(w, repos)); } void Toolbar::reconfigure() { @@ -499,10 +499,18 @@ BScreen::Icons::iterator it = l.begin(); BScreen::Icons::iterator it_end = l.end(); for(; it != it_end; ++it) { - addIcon(*it); + addIcon(*it, false); } } + Workspace *wksp = screen()->getCurrentWorkspace(); + Workspace::Windows wins = wksp->getWindowList(); + Workspace::Windows::iterator it = wins.begin(); + for (; it != wins.end(); ++it) { + addIcon(*it, false); + } + + m_iconbar->reconfigure(); } else m_iconbar->reconfigure(); } else if (m_iconbar.get() != 0) { @@ -510,7 +518,14 @@ BScreen::Icons::iterator it = l.begin(); BScreen::Icons::iterator it_end = l.end(); for(; it != it_end; ++it) - delIcon(*it); + delIcon(*it, false); + + Workspace *wksp = screen()->getCurrentWorkspace(); + Workspace::Windows wins = wksp->getWindowList(); + Workspace::Windows::iterator wit = wins.begin(); + for (; wit != wins.end(); ++wit) { + delIcon(*wit, false); + } m_iconbar.reset(0); // destroy iconbar } @@ -807,8 +822,14 @@ else if (be->window == frame.nwbutton) redrawNextWindowButton(true, true); else if ( m_iconbar.get() != 0 ) { - if ( (fluxboxwin = m_iconbar->findWindow(be->window)) ) - fluxboxwin->deiconify(); + if ( (fluxboxwin = m_iconbar->findWindow(be->window)) ) { + if (fluxboxwin->isIconic()) { + fluxboxwin->deiconify(); + } else { + m_screen->getWorkspace(fluxboxwin->getWorkspaceNumber())->raiseWindow(fluxboxwin); + fluxboxwin->setInputFocus(); + } + } } #ifndef HAVE_STRFTIME else if (be->window == frame.clock) { diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/Toolbar.hh fluxbox-0.1.14/src/Toolbar.hh --- fluxbox-0.1.14-orig/src/Toolbar.hh 2002-12-07 15:15:25.000000000 +0100 +++ fluxbox-0.1.14/src/Toolbar.hh 2004-08-17 14:47:35.000000000 +0200 @@ -101,9 +101,9 @@ virtual ~Toolbar(); /// add icon to iconbar - void addIcon(FluxboxWindow *w); + void addIcon(FluxboxWindow *w, bool repos = true); /// remove icon from iconbar - void delIcon(FluxboxWindow *w); + void delIcon(FluxboxWindow *w, bool repos = true); inline const Toolbarmenu &menu() const { return m_toolbarmenu; } /// are we in workspacename editing? diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/Window.cc fluxbox-0.1.14/src/Window.cc --- fluxbox-0.1.14-orig/src/Window.cc 2004-06-29 16:21:30.000000000 +0200 +++ fluxbox-0.1.14/src/Window.cc 2004-08-17 15:46:39.000000000 +0200 @@ -413,8 +413,10 @@ Workspace *workspace = screen->getWorkspace(workspace_number); if (workspace) workspace->removeWindow(this); - } else //it's iconic + } else { //it's iconic screen->removeIcon(this); + screen->getToolbar()->delIcon(this); + } if (tab != 0) { delete tab; @@ -1674,6 +1676,7 @@ } } + updateIcon(); } @@ -1716,6 +1719,8 @@ if (tab) tab->raise(); } + + updateIcon(); } void FluxboxWindow::save_on_close() { @@ -2761,8 +2766,7 @@ if (! iconic) screen->getWorkspace(workspace_number)->update(); - else - updateIcon(); + updateIcon(); break; diff -aur --exclude '*.Po' --exclude 'Makefile*' --exclude nls --exclude doc fluxbox-0.1.14-orig/src/Workspace.cc fluxbox-0.1.14/src/Workspace.cc --- fluxbox-0.1.14-orig/src/Workspace.cc 2002-12-08 04:46:09.000000000 +0100 +++ fluxbox-0.1.14/src/Workspace.cc 2004-06-29 20:23:23.000000000 +0200 @@ -151,6 +151,9 @@ raiseWindow(w); + if (screen->getCurrentWorkspace() == this && !screen->getToolbar()->iconBar()->findIcon(w)) + screen->getToolbar()->addIcon(w); + return w->getWindowNumber(); } @@ -218,6 +221,9 @@ if (lastfocus == w || m_windowlist.empty()) lastfocus = 0; + if (! w->isIconic()) + screen->getToolbar()->delIcon(w); + return m_windowlist.size(); }