From 4993e2f36331299aba6a42df2896e49d4c98b111 Mon Sep 17 00:00:00 2001 From: rathnor Date: Thu, 26 Jun 2003 12:22:43 +0000 Subject: speedups for having lots of stuck windows --- ChangeLog | 3 +++ src/Gnome.cc | 7 +++++-- src/IconBar.cc | 46 ++++++++++++++++++++++++++++++++++------------ src/IconBar.hh | 9 +++++++-- src/Toolbar.cc | 16 +++++++++++++--- src/Toolbar.hh | 9 ++++++--- src/ToolbarHandler.cc | 23 ++++++++++++++++++----- src/Window.cc | 12 +++++++++--- 8 files changed, 95 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4206cf..badc7a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/Gnome.cc b/src/Gnome.cc index 2b12b7f..240c691 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -19,7 +19,7 @@ // 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 @@ void Gnome::updateWorkspaceCount(BScreen &screen) { } 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("<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::exposeEvent(XExposeEvent *ee) { } } +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; diff --git a/src/IconBar.hh b/src/IconBar.hh index ca2bd6d..7f58a12 100644 --- a/src/IconBar.hh +++ b/src/IconBar.hh @@ -19,7 +19,7 @@ // 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,13 +64,16 @@ public: 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; } BScreen &screen() { return m_screen; } @@ -90,6 +93,8 @@ private: unsigned long m_focus_pixel; bool m_vertical; FbTk::Font &m_font; + + int allow_updates; }; #endif // ICONBAR_HH diff --git a/src/Toolbar.cc b/src/Toolbar.cc index a31fbaf..f97f2d2 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // 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 @@ void Toolbar::delIcon(FluxboxWindow *w) { 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) { @@ -421,6 +421,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() { if (m_iconbar.get() != 0) return; // already on diff --git a/src/Toolbar.hh b/src/Toolbar.hh index 87cd223..7a62c8d 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -22,7 +22,7 @@ // 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,13 +71,17 @@ public: 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; } inline FbTk::Menu &placementMenu() { return m_placementmenu; } @@ -111,7 +115,6 @@ public: 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 diff --git a/src/ToolbarHandler.cc b/src/ToolbarHandler.cc index d7cf8f0..317890a 100644 --- a/src/ToolbarHandler.cc +++ b/src/ToolbarHandler.cc @@ -20,7 +20,7 @@ // 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::setMode(ToolbarMode newmode, bool initialise) { 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 @@ void ToolbarHandler::initForScreen(BScreen &screen) { 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 @@ void ToolbarHandler::initForScreen(BScreen &screen) { 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 @@ void ToolbarHandler::initForScreen(BScreen &screen) { } break; } + + if (m_toolbar.get() != 0) + m_toolbar->enableUpdates(); + } void ToolbarHandler::setupWindow(FluxboxWindow &win) { @@ -305,7 +315,7 @@ void ToolbarHandler::updateWindowClose(FluxboxWindow &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 @@ void ToolbarHandler::updateWorkspace(FluxboxWindow &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 @@ void ToolbarHandler::updateCurrentWorkspace(BScreen &screen) { // 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); } diff --git a/src/Window.cc b/src/Window.cc index 464210c..380df19 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // 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::maximizeVertical() { void FluxboxWindow::setWorkspace(int n) { + unsigned int old_wkspc = m_workspace_number; m_workspace_number = n; @@ -1293,10 +1294,12 @@ void FluxboxWindow::setWorkspace(int n) { m_blackbox_attrib.workspace = m_workspace_number; // notify workspace change + if (!stuck && old_wkspc != m_workspace_number) { #ifdef DEBUG - cerr<