From ae093dba2fb97124bb4af3eaf4070b46f07dfd74 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 16 May 2002 09:24:40 +0000 Subject: [PATCH] make a new autoRaiseDelay value take effect without having to restart --- CHANGELOG | 7 ++++++- src/BaseDisplay.cc | 17 +++++++++++------ src/Slit.cc | 4 +++- src/Timer.cc | 10 ++++++++-- src/Toolbar.cc | 4 +++- src/Window.cc | 3 +++ 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b401d8dc..e2030f2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,12 @@ Changelog for Openbox: 1.3.0: - * fix for loading autoRaiseDelay value. (Ben Jansens) + * make reconfigure reset the timeout values for + windows, the slit, and the toolbar, so that a new + autoRaiseDelay value will take effect without having + to restart. (Ben Jansens) + + * fix for loading the autoRaiseDelay value. (Ben Jansens) 1.2.0: * fix off-by-one window resizing bug. (Ben Jansens) diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc index 28742e98..c99b2b16 100644 --- a/src/BaseDisplay.cc +++ b/src/BaseDisplay.cc @@ -462,10 +462,10 @@ void BaseDisplay::eventLoop(void) { gettimeofday(&now, 0); TimerList::iterator it; - for (it = timerList.begin(); it != timerList.end(); ) { + for (it = timerList.begin(); it != timerList.end(); ++it) { BTimer *timer = *it; - ++it; // the timer may be removed from the list, so move ahead now ASSERT(timer != NULL); + tm.tv_sec = timer->getStartTime().tv_sec + timer->getTimeout().tv_sec; tm.tv_usec = timer->getStartTime().tv_usec + @@ -478,12 +478,16 @@ void BaseDisplay::eventLoop(void) { timer->fireTimeout(); // restart the current timer so that the start time is updated - if (! timer->doOnce()) + if (! timer->doOnce()) { + // reorder + removeTimer(timer); + addTimer(timer); timer->start(); - else { + } else timer->stop(); -// delete timer; // USE THIS? - } + it = timerList.begin(); // we no longer have any idea if the iterator is + // valid, but what was at the front() is no + // longer. } } } @@ -531,6 +535,7 @@ void BaseDisplay::addTimer(BTimer *timer) { void BaseDisplay::removeTimer(BTimer *timer) { + ASSERT(timer != (BTimer *) 0); timerList.remove(timer); } diff --git a/src/Slit.cc b/src/Slit.cc index f6c87aa9..66cdc583 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -54,7 +54,7 @@ Slit::Slit(BScreen &scr, Resource &conf) : openbox(scr.getOpenbox()), frame.window = frame.pixmap = None; timer = new BTimer(openbox, *this); - timer->setTimeout(openbox.getAutoRaiseDelay()); + // the time out is set in ::reconfigure() timer->fireOnce(True); slitmenu = new Slitmenu(*this); @@ -326,6 +326,8 @@ void Slit::load() { } void Slit::reconfigure(void) { + timer->setTimeout(openbox.getAutoRaiseDelay()); + frame.area.setSize(0, 0); slitClientList::const_iterator it; diff --git a/src/Timer.cc b/src/Timer.cc index 917bc337..8cd4714e 100644 --- a/src/Timer.cc +++ b/src/Timer.cc @@ -46,6 +46,10 @@ void BTimer::setTimeout(long t) { _timeout.tv_usec = t; _timeout.tv_usec -= (_timeout.tv_sec * 1000); _timeout.tv_usec *= 1000; + if (timing) { + display.removeTimer(this); + display.addTimer(this); // reorder the display + } } void BTimer::setTimeout(timeval t) { @@ -63,9 +67,11 @@ void BTimer::start(void) { } void BTimer::stop(void) { - timing = False; + if (timing) { + timing = False; - display.removeTimer(this); + display.removeTimer(this); + } } void BTimer::fireTimeout(void) { diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 8a3ea6b2..8e621bdf 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -80,7 +80,7 @@ Toolbar::Toolbar(BScreen &scrn, Resource &conf) : openbox(scrn.getOpenbox()), hide_handler.toolbar = this; hide_timer = new BTimer(openbox, hide_handler); - hide_timer->setTimeout(openbox.getAutoRaiseDelay()); + // the time out is set in ::reconfigure() hide_timer->fireOnce(True); image_ctrl = screen.getImageControl(); @@ -321,6 +321,8 @@ void Toolbar::load() { } void Toolbar::reconfigure() { + hide_timer->setTimeout(openbox.getAutoRaiseDelay()); + frame.bevel_w = screen.getBevelWidth(); frame.width = screen.size().w() * m_width_percent / 100; diff --git a/src/Window.cc b/src/Window.cc index 7cf8ec1b..59b64095 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -845,6 +845,9 @@ void OpenboxWindow::reconfigure(void) { windowmenu->move(windowmenu->getX(), frame.y + frame.title_h); windowmenu->reconfigure(); } + + // re-get the timeout delay + timer->setTimeout(openbox.getAutoRaiseDelay()); } -- 2.45.2