aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-02-11 10:57:23 (GMT)
committerfluxgen <fluxgen>2002-02-11 10:57:23 (GMT)
commite65ae97a3c154579c3f12e23f37a71cfb96c6f0c (patch)
treea203328d58b2ddd04f24dff894d19a5d249da754
parent022b9ccd519e7cd5080171a1b68d12804f50e4d9 (diff)
downloadfluxbox-e65ae97a3c154579c3f12e23f37a71cfb96c6f0c.zip
fluxbox-e65ae97a3c154579c3f12e23f37a71cfb96c6f0c.tar.bz2
moved to stl list
-rw-r--r--src/BaseDisplay.cc87
1 files changed, 44 insertions, 43 deletions
diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc
index 3e4ec86..fae87f6 100644
--- a/src/BaseDisplay.cc
+++ b/src/BaseDisplay.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: BaseDisplay.cc,v 1.5 2002/01/27 13:08:53 fluxgen Exp $ 25// $Id: BaseDisplay.cc,v 1.6 2002/02/11 10:57:23 fluxgen Exp $
26 26
27// use some GNU extensions 27// use some GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -87,6 +87,10 @@
87# include <process.h> 87# include <process.h>
88#endif // HAVE_PROCESS_H __EMX__ 88#endif // HAVE_PROCESS_H __EMX__
89 89
90#ifdef DEBUG
91#include <iostream>
92using namespace std;
93#endif
90// X error handler to handle any and all X errors while the application is 94// X error handler to handle any and all X errors while the application is
91// running 95// running
92static Bool internal_error = False; 96static Bool internal_error = False;
@@ -384,34 +388,21 @@ m_server_grabs(0)
384 388
385 XSetErrorHandler((XErrorHandler) handleXErrors); 389 XSetErrorHandler((XErrorHandler) handleXErrors);
386 390
387 timerList = new LinkedList<BTimer>;
388
389 screenInfoList = new LinkedList<ScreenInfo>;
390 int i; 391 int i;
391 for (i = 0; i < number_of_screens; i++) { 392 for (i = 0; i < number_of_screens; i++) {
392 ScreenInfo *screeninfo = new ScreenInfo(this, i); 393 ScreenInfo *screeninfo = new ScreenInfo(this, i);
393 screenInfoList->insert(screeninfo); 394 screenInfoList.push_back(screeninfo);
394 } 395 }
395} 396}
396 397
397 398
398BaseDisplay::~BaseDisplay(void) { 399BaseDisplay::~BaseDisplay(void) {
399 400
400 while (screenInfoList->count()) { 401 ScreenInfoList::iterator it = screenInfoList.begin();
401 ScreenInfo *si = screenInfoList->first(); 402 ScreenInfoList::iterator it_end = screenInfoList.end();
402 403 for (; it != it_end; ++it) {
403 screenInfoList->remove(si); 404 delete (*it);
404 delete si;
405 } 405 }
406
407
408 delete screenInfoList;
409
410 // we don't create the BTimers, we don't delete them
411 while (timerList->count())
412 timerList->remove(0);
413
414 delete timerList;
415 406
416 XCloseDisplay(m_display); 407 XCloseDisplay(m_display);
417} 408}
@@ -450,12 +441,12 @@ void BaseDisplay::eventLoop(void) {
450 FD_ZERO(&rfds); 441 FD_ZERO(&rfds);
451 FD_SET(xfd, &rfds); 442 FD_SET(xfd, &rfds);
452 443
453 if (timerList->count()) { 444 if (timerList.size() > 0) {
454 gettimeofday(&now, 0); 445 gettimeofday(&now, 0);
455 446
456 tm.tv_sec = tm.tv_usec = 0l; 447 tm.tv_sec = tm.tv_usec = 0l;
457 448
458 BTimer *timer = timerList->first(); 449 BTimer *timer = timerList.front();
459 450
460 tm.tv_sec = timer->getStartTime().tv_sec + 451 tm.tv_sec = timer->getStartTime().tv_sec +
461 timer->getTimeout().tv_sec - now.tv_sec; 452 timer->getTimeout().tv_sec - now.tv_sec;
@@ -485,24 +476,33 @@ void BaseDisplay::eventLoop(void) {
485 // check for timer timeout 476 // check for timer timeout
486 gettimeofday(&now, 0); 477 gettimeofday(&now, 0);
487 478
488 LinkedListIterator<BTimer> it(timerList); 479 TimerList::iterator it = timerList.begin();
489 for(; it.current(); it++) { 480 //must check end ...the timer might remove
490 tm.tv_sec = it.current()->getStartTime().tv_sec + 481 //it self from the list (should be fixed in the future)
491 it.current()->getTimeout().tv_sec; 482 for(; it != timerList.end(); ++it) {
492 tm.tv_usec = it.current()->getStartTime().tv_usec + 483
493 it.current()->getTimeout().tv_usec; 484 tm.tv_sec = (*it)->getStartTime().tv_sec +
485 (*it)->getTimeout().tv_sec;
486 tm.tv_usec = (*it)->getStartTime().tv_usec +
487 (*it)->getTimeout().tv_usec;
494 488
495 if ((now.tv_sec < tm.tv_sec) || 489 if ((now.tv_sec < tm.tv_sec) ||
496 (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec)) 490 (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
497 break; 491 break;
498 492
499 it.current()->fireTimeout(); 493 (*it)->fireTimeout();
500 494
501 // restart the current timer so that the start time is updated 495 // restart the current timer so that the start time is updated
502 if (! it.current()->doOnce()) 496 if (! (*it)->doOnce())
503 it.current()->start(); 497 (*it)->start();
504 else 498 else {
505 it.current()->stop(); 499 (*it)->stop();
500 // must do this because the stupid cyclic dep
501 // between BaseDisplay and BTimer, the timer removes
502 // it self from the list
503 it--;
504 }
505
506 } 506 }
507 } 507 }
508 } 508 }
@@ -535,23 +535,24 @@ void BaseDisplay::ungrab(void) {
535 535
536 536
537void BaseDisplay::addTimer(BTimer *timer) { 537void BaseDisplay::addTimer(BTimer *timer) {
538 if (! timer) return; 538 assert(timer);
539 539
540 LinkedListIterator<BTimer> it(timerList); 540 TimerList::iterator it = timerList.begin();
541 TimerList::iterator it_end = timerList.end();
541 int index = 0; 542 int index = 0;
542 for (; it.current(); it++, index++) { 543 for (; it != it_end; ++it, ++index) {
543 if ((it.current()->getTimeout().tv_sec > timer->getTimeout().tv_sec) || 544 if (((*it)->getTimeout().tv_sec > timer->getTimeout().tv_sec) ||
544 ((it.current()->getTimeout().tv_sec == timer->getTimeout().tv_sec) && 545 (((*it)->getTimeout().tv_sec == timer->getTimeout().tv_sec) &&
545 (it.current()->getTimeout().tv_usec >= timer->getTimeout().tv_usec))) 546 ((*it)->getTimeout().tv_usec >= timer->getTimeout().tv_usec))) {
546 break; 547 break;
548 }
547 } 549 }
548 550 timerList.insert(it, timer);
549 timerList->insert(timer, index);
550} 551}
551 552
552 553
553void BaseDisplay::removeTimer(BTimer *timer) { 554void BaseDisplay::removeTimer(BTimer *timer) {
554 timerList->remove(timer); 555 timerList.remove(timer);
555} 556}
556 557
557 558
@@ -592,10 +593,10 @@ ScreenInfo::ScreenInfo(BaseDisplay *d, int num) {
592 XFree(vinfo_return); 593 XFree(vinfo_return);
593 } 594 }
594 595
595 if (visual) 596 if (visual) {
596 colormap = XCreateColormap(basedisplay->getXDisplay(), root_window, 597 colormap = XCreateColormap(basedisplay->getXDisplay(), root_window,
597 visual, AllocNone); 598 visual, AllocNone);
598 else { 599 } else {
599 visual = DefaultVisual(basedisplay->getXDisplay(), screen_number); 600 visual = DefaultVisual(basedisplay->getXDisplay(), screen_number);
600 colormap = DefaultColormap(basedisplay->getXDisplay(), screen_number); 601 colormap = DefaultColormap(basedisplay->getXDisplay(), screen_number);
601 } 602 }