make a new autoRaiseDelay value take effect without having to restart
authorDana Jansens <danakj@orodu.net>
Thu, 16 May 2002 09:24:40 +0000 (09:24 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 16 May 2002 09:24:40 +0000 (09:24 +0000)
CHANGELOG
src/BaseDisplay.cc
src/Slit.cc
src/Timer.cc
src/Toolbar.cc
src/Window.cc

index b401d8d..e2030f2 100644 (file)
--- 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)
index 28742e9..c99b2b1 100644 (file)
@@ -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);
 }
 
index f6c87aa..66cdc58 100644 (file)
@@ -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;
 
index 917bc33..8cd4714 100644 (file)
@@ -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) {
index 8a3ea6b..8e621bd 100644 (file)
@@ -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;
   
index 7cf8ec1..59b6409 100644 (file)
@@ -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());
 }