aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-08-14 11:42:27 (GMT)
committerMathias Gumz <akira@fluxbox.org>2016-08-26 06:06:47 (GMT)
commit10a957473803e87f119c363dc19efe92ea938a1d (patch)
tree42dc0c55521d6a8736e1cde00374e503ca15c3df /src/Toolbar.cc
parentfe8ff8729299a4fd4371394d3ca9102ece22fefb (diff)
downloadfluxbox-10a957473803e87f119c363dc19efe92ea938a1d.zip
fluxbox-10a957473803e87f119c363dc19efe92ea938a1d.tar.bz2
Fix autohiding/raising timer logics
Trying to control a timer bound to an unconditional toggle, caused by opposing events does not work. <- That's a period. The toolbar implementation would act too seldom, the slit to often. Instead, fire the timer whenever the state does not match the event and bind it to a function that queries the pointer position and acts accordingly.
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc68
1 files changed, 31 insertions, 37 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 23a8244..2920925 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -250,8 +250,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width):
250 250
251 // setup hide timer 251 // setup hide timer
252 m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay() * FbTk::FbTime::IN_MILLISECONDS); 252 m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay() * FbTk::FbTime::IN_MILLISECONDS);
253 FbTk::RefCount<FbTk::Command<void> > toggle_hidden(new FbTk::SimpleCommand<Toolbar>(*this, &Toolbar::toggleHidden)); 253 FbTk::RefCount<FbTk::Command<void> > ucs(new FbTk::SimpleCommand<Toolbar>(*this, &Toolbar::updateCrossingState));
254 m_hide_timer.setCommand(toggle_hidden); 254 m_hide_timer.setCommand(ucs);
255 m_hide_timer.fireOnce(true); 255 m_hide_timer.fireOnce(true);
256 256
257 257
@@ -523,55 +523,49 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
523 .placeAndShowMenu(menu(), be.x_root, be.y_root, false); 523 .placeAndShowMenu(menu(), be.x_root, be.y_root, false);
524} 524}
525 525
526void Toolbar::enterNotifyEvent(XCrossingEvent &ce) { 526void Toolbar::updateCrossingState() {
527 if (m_rc_auto_raise) 527 Window wr, wc;
528 m_layeritem.moveToLayer(ResourceLayer::ABOVE_DOCK); 528 int rx, ry, x, y;
529 529 unsigned int mask;
530 Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, 530 const int bw = -theme()->border().width();
531 Keys::ON_TOOLBAR); 531 bool hovered = false;
532 532 if (XQueryPointer(Fluxbox::instance()->display(), window().window(), &wr, &wc, &rx, &ry, &x, &y, &mask))
533 if (! doAutoHide()) { 533 hovered = x >= bw && y >= bw && x < int(width()) && y < int(height());
534 if (isHidden()) 534 if (hovered) {
535 if (m_rc_auto_raise)
536 m_layeritem.moveToLayer(ResourceLayer::ABOVE_DOCK);
537 if (m_rc_auto_hide && isHidden())
535 toggleHidden(); 538 toggleHidden();
536 return;
537 }
538
539 if (isHidden()) {
540 if (! m_hide_timer.isTiming())
541 m_hide_timer.start();
542 } else { 539 } else {
543 if (m_hide_timer.isTiming()) 540 if (m_rc_auto_hide && !isHidden())
544 m_hide_timer.stop(); 541 toggleHidden();
542 if (m_rc_auto_raise)
543 m_layeritem.moveToLayer(m_rc_layernum->getNum());
545 } 544 }
546} 545}
547 546
548void Toolbar::leaveNotifyEvent(XCrossingEvent &event) { 547void Toolbar::enterNotifyEvent(XCrossingEvent &ce) {
548 Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, Keys::ON_TOOLBAR);
549 549
550 // in autoHide mode we'll receive a leaveNotifyEvent when activating 550 if (!m_rc_auto_hide && isHidden()) {
551 // the toolbar. so check if we are still inside the toolbar area. 551 toggleHidden();
552 // event.subwindow gets != None if we really left the window (eg the Slit
553 // was entered ontop of the toolbar)
554 if (event.x_root > x() && event.x_root <= (int)(x() + width()) &&
555 event.y_root > y() && event.y_root <= (int)(y() + height()) &&
556 event.subwindow == None ) {
557 return;
558 } 552 }
559 553
560 if (m_rc_auto_raise) 554 if ((m_rc_auto_hide || m_rc_auto_raise) && !m_hide_timer.isTiming())
561 m_layeritem.moveToLayer(m_rc_layernum->getNum()); 555 m_hide_timer.start();
556}
562 557
563 Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, 558void Toolbar::leaveNotifyEvent(XCrossingEvent &event) {
564 Keys::ON_TOOLBAR);
565 559
566 if (! doAutoHide()) 560 if (menu().isVisible())
567 return; 561 return;
568 562
569 if (isHidden()) { 563 if (!m_hide_timer.isTiming() && (m_rc_auto_hide && !isHidden()) ||
570 if (m_hide_timer.isTiming()) 564 (m_rc_auto_raise && m_layeritem.getLayerNum() != m_rc_layernum->getNum()))
571 m_hide_timer.stop();
572 } else if (! menu().isVisible() && ! m_hide_timer.isTiming())
573 m_hide_timer.start(); 565 m_hide_timer.start();
574 566
567 if (!isHidden())
568 Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, Keys::ON_TOOLBAR);
575} 569}
576 570
577 571