all repos — fluxbox @ 4993e2f36331299aba6a42df2896e49d4c98b111

custom fork of the fluxbox windowmanager

speedups for having lots of stuck windows
rathnor rathnor
commit

4993e2f36331299aba6a42df2896e49d4c98b111

parent

a1eb047c00e96295e482564311db9075d05ce034

M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 0.9.4: +*03/06/26: + * Speedups for having many (particularly stuck) windows (Simon) + Toolbar.hh/cc IconBar.hh/cc ToolbarHandler.cc Gnome.cc Window.cc *03/06/25: * Applied toggle max vertical/horizontal patch (Thanks MrChuoi mrchuoi<[aT]>yahoo.com) Window.hh/cc
M src/Gnome.ccsrc/Gnome.cc

@@ -19,7 +19,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: Gnome.cc,v 1.27 2003/06/23 14:16:04 rathnor Exp $ +// $Id: Gnome.cc,v 1.28 2003/06/26 12:22:42 rathnor Exp $ #include "Gnome.hh"

@@ -218,7 +218,10 @@ (unsigned char *)&numworkspaces, 1);

} void Gnome::updateWorkspace(FluxboxWindow &win) { - int val = win.workspaceNumber(); + int val = win.workspaceNumber(); + if (win.isStuck()) { + val = -1; + } #ifdef DEBUG cerr<<__FILE__<<"("<<__LINE__<<"): setting workspace("<<val<< ") for window("<<&win<<")"<<endl;
M src/IconBar.ccsrc/IconBar.cc

@@ -19,7 +19,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: IconBar.cc,v 1.37 2003/06/13 05:02:09 fluxgen Exp $ +// $Id: IconBar.cc,v 1.38 2003/06/26 12:22:42 rathnor Exp $ #include "IconBar.hh"

@@ -84,7 +84,8 @@ m_display(FbTk::App::instance()->display()),

m_parent(parent), m_focus_pm(None), m_vertical(false), - m_font(font) + m_font(font), + allow_updates(0) { }

@@ -103,9 +104,10 @@ 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(); - + XMapSubwindows(m_display, iconwin); XMapWindow(m_display, iconwin);

@@ -139,16 +141,25 @@ /**

* Removes all icons from list * Return X Windows of the removed iconobjs */ -IconBar::WindowList *IconBar::delAllIcons() { +IconBar::WindowList *IconBar::delAllIcons(bool ignore_stuck) { Window retwin = None; WindowList *ret = new WindowList(); - while (!m_iconlist.empty()) { - IconBarObj *obj = m_iconlist.back(); - m_iconlist.pop_back(); - retwin = obj->getIconWin(); - ret->push_back(retwin); - delete obj; - XDestroyWindow(m_display, retwin); + IconList::iterator it = m_iconlist.begin(); + IconList::iterator tmp = m_iconlist.end(); + IconList::iterator it_end = m_iconlist.end(); + while (it != it_end) { + IconBarObj *obj = *it; + if (!ignore_stuck || !obj->getFluxboxWin()->isStuck()) { + retwin = obj->getIconWin(); + ret->push_back(retwin); + tmp = it; + ++it; + m_iconlist.erase(tmp); + delete obj; + XDestroyWindow(m_display, retwin); + } else { + ++it; + } } repositionIcons(); return ret;

@@ -243,11 +254,22 @@

} } +void IconBar::enableUpdates() { + --allow_updates; + if (allow_updates <= 0) + repositionIcons(); + +} + +void IconBar::disableUpdates() { + ++allow_updates; +} + /** Calculates and moves/resizes the icons */ void IconBar::repositionIcons() { - if (m_iconlist.size() == 0) + if (m_iconlist.size() == 0 || allow_updates > 0) return; Window root;
M src/IconBar.hhsrc/IconBar.hh

@@ -19,7 +19,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: IconBar.hh,v 1.14 2003/04/15 12:06:11 fluxgen Exp $ +// $Id: IconBar.hh,v 1.15 2003/06/26 12:22:42 rathnor Exp $ #ifndef ICONBAR_HH #define ICONBAR_HH

@@ -64,12 +64,15 @@ void draw(); //TODO

void reconfigure(); Window addIcon(FluxboxWindow *fluxboxwin); Window delIcon(FluxboxWindow *fluxboxwin); - WindowList *delAllIcons(); + WindowList *delAllIcons(bool ignore_stuck = false); void buttonPressEvent(XButtonEvent *be); FluxboxWindow *findWindow(Window w); IconBarObj *findIcon(FluxboxWindow * const fluxboxwin); const IconBarObj *findIcon(const FluxboxWindow * const fluxboxwin) const; void exposeEvent(XExposeEvent *ee); + + void enableUpdates(); + void disableUpdates(); void draw(const IconBarObj * const obj, int width) const; void setVertical(bool value) { m_vertical = value; }

@@ -90,6 +93,8 @@ Pixmap m_focus_pm;

unsigned long m_focus_pixel; bool m_vertical; FbTk::Font &m_font; + + int allow_updates; }; #endif // ICONBAR_HH
M src/Toolbar.ccsrc/Toolbar.cc

@@ -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: Toolbar.cc,v 1.95 2003/06/25 12:33:28 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.96 2003/06/26 12:22:42 rathnor Exp $ #include "Toolbar.hh"

@@ -404,11 +404,11 @@ if (m_iconbar.get() != 0)

FbTk::EventManager::instance()->remove(m_iconbar->delIcon(w)); } -void Toolbar::delAllIcons() { +void Toolbar::delAllIcons(bool ignore_stuck) { if (m_iconbar.get() == 0) return; - IconBar::WindowList *deleted = m_iconbar->delAllIcons(); + IconBar::WindowList *deleted = m_iconbar->delAllIcons(ignore_stuck); IconBar::WindowList::iterator it = deleted->begin(); IconBar::WindowList::iterator it_end = deleted->end(); for (; it != it_end; ++it) {

@@ -419,6 +419,16 @@ }

bool Toolbar::containsIcon(const FluxboxWindow &win) const { return (m_iconbar->findIcon(&win) != 0); +} + +void Toolbar::enableUpdates() { + if (m_iconbar.get() != 0) + m_iconbar->enableUpdates(); +} + +void Toolbar::disableUpdates() { + if (m_iconbar.get() != 0) + m_iconbar->disableUpdates(); } void Toolbar::enableIconBar() {
M src/Toolbar.hhsrc/Toolbar.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: Toolbar.hh,v 1.35 2003/06/23 13:16:50 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.36 2003/06/26 12:22:42 rathnor Exp $ #ifndef TOOLBAR_HH #define TOOLBAR_HH

@@ -71,12 +71,16 @@ /// add icon to iconbar

void addIcon(FluxboxWindow *w); /// remove icon from iconbar void delIcon(FluxboxWindow *w); + bool containsIcon(const FluxboxWindow &win) const; /// remove all icons - void delAllIcons(); + void delAllIcons(bool ignore_stuck = false); void enableIconBar(); void disableIconBar(); void raise(); void lower(); + + void enableUpdates(); + void disableUpdates(); inline const FbTk::Menu &menu() const { return m_toolbarmenu; } inline FbTk::Menu &menu() { return m_toolbarmenu; }

@@ -111,7 +115,6 @@ inline const IconBar *iconBar() const { return m_iconbar.get(); }

inline const ToolbarTheme &theme() const { return m_theme; } inline ToolbarTheme &theme() { return m_theme; } bool isVertical() const; - bool containsIcon(const FluxboxWindow &win) const; /** @name eventhandlers
M src/ToolbarHandler.ccsrc/ToolbarHandler.cc

@@ -20,7 +20,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: ToolbarHandler.cc,v 1.17 2003/06/24 16:27:18 fluxgen Exp $ +// $Id: ToolbarHandler.cc,v 1.18 2003/06/26 12:22:42 rathnor Exp $ /** * The ToolbarHandler class acts as a rough interface to the toolbar.

@@ -199,6 +199,10 @@

void ToolbarHandler::initForScreen(BScreen &screen) { if (&m_screen != &screen) return; + + if (m_toolbar.get() != 0) + m_toolbar->disableUpdates(); + switch (mode()) { case OFF: break;

@@ -212,6 +216,7 @@ Workspace::Windows &wins = (*workspace_it)->windowList();

Workspace::Windows::iterator wit = wins.begin(); Workspace::Windows::iterator wit_end = wins.end(); for (; wit != wit_end; ++wit) { + if (!m_toolbar->containsIcon(**wit)) m_toolbar->addIcon(*wit); /* FluxboxWindow::ClientList::iterator cit = (*wit)->clientList().begin();

@@ -238,7 +243,8 @@ Workspace::Windows &wins = m_screen.currentWorkspace()->windowList();

Workspace::Windows::iterator wit = wins.begin(); Workspace::Windows::iterator wit_end = wins.end(); for (; wit != wit_end; ++wit) { - m_toolbar->addIcon(*wit); + if (!m_toolbar->containsIcon(**wit)) + m_toolbar->addIcon(*wit); } } // fall through and add icons for this workspace

@@ -255,6 +261,10 @@ }

} break; } + + if (m_toolbar.get() != 0) + m_toolbar->enableUpdates(); + } void ToolbarHandler::setupWindow(FluxboxWindow &win) {

@@ -305,7 +315,7 @@ m_toolbar->delIcon(&win);

} break; case WORKSPACE: - if (win.workspaceNumber() == m_current_workspace) + if (win.isStuck() || win.workspaceNumber() == m_current_workspace) m_toolbar->delIcon(&win); break; case ALLWINDOWS:

@@ -364,7 +374,8 @@ if (!m_toolbar->containsIcon(win))

m_toolbar->addIcon(&win); } else { // relies on the fact that this runs but does nothing if window isn't contained. - m_toolbar->delIcon(&win); + if (!win.isStuck()) + m_toolbar->delIcon(&win); } }

@@ -375,8 +386,10 @@ // if only displaying current workspace, update list

// otherwise ignore it if (mode() != WORKSPACE && mode() != WORKSPACEICONS) return; - m_toolbar->delAllIcons(); + m_toolbar->disableUpdates(); + m_toolbar->delAllIcons(true); initForScreen(m_screen); + m_toolbar->enableUpdates(); m_toolbar->redrawWorkspaceLabel(true); }
M src/Window.ccsrc/Window.cc

@@ -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: Window.cc,v 1.198 2003/06/25 13:37:06 fluxgen Exp $ +// $Id: Window.cc,v 1.199 2003/06/26 12:22:43 rathnor Exp $ #include "Window.hh"

@@ -1286,6 +1286,7 @@ }

void FluxboxWindow::setWorkspace(int n) { + unsigned int old_wkspc = m_workspace_number; m_workspace_number = n;

@@ -1293,10 +1294,12 @@ m_blackbox_attrib.flags |= ATTRIB_WORKSPACE;

m_blackbox_attrib.workspace = m_workspace_number; // notify workspace change + if (!stuck && old_wkspc != m_workspace_number) { #ifdef DEBUG - cerr<<this<<" notify workspace signal"<<endl; + cerr<<this<<" notify workspace signal"<<endl; #endif // DEBUG - m_workspacesig.notify(); + m_workspacesig.notify(); + } } void FluxboxWindow::setLayerNum(int layernum) {

@@ -1354,6 +1357,9 @@

} setState(m_current_state); + // notify since some things consider "stuck" to be a pseudo-workspace + m_workspacesig.notify(); + }