aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Slit.cc74
-rw-r--r--src/Slit.hh1
-rw-r--r--src/Toolbar.cc68
-rw-r--r--src/Toolbar.hh2
4 files changed, 67 insertions, 78 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index b628d18..7eb7dea 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -272,8 +272,8 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer, const char *filename)
272 // setup timer 272 // setup timer
273 m_timer.setTimeout(200L * FbTk::FbTime::IN_MILLISECONDS); // default timeout 273 m_timer.setTimeout(200L * FbTk::FbTime::IN_MILLISECONDS); // default timeout
274 m_timer.fireOnce(true); 274 m_timer.fireOnce(true);
275 FbTk::RefCount<FbTk::Command<void> > toggle_hidden(new FbTk::SimpleCommand<Slit>(*this, &Slit::toggleHidden)); 275 FbTk::RefCount<FbTk::Command<void> > ucs(new FbTk::SimpleCommand<Slit>(*this, &Slit::updateCrossingState));
276 m_timer.setCommand(toggle_hidden); 276 m_timer.setCommand(ucs);
277 277
278 278
279 FbTk::EventManager::instance()->add(*this, frame.window); 279 FbTk::EventManager::instance()->add(*this, frame.window);
@@ -958,45 +958,47 @@ void Slit::buttonPressEvent(XButtonEvent &be) {
958} 958}
959 959
960 960
961void Slit::enterNotifyEvent(XCrossingEvent &) { 961void Slit::updateCrossingState() {
962 if (m_rc_auto_raise) 962 Window wr, wc;
963 m_layeritem->moveToLayer(ResourceLayer::ABOVE_DOCK); 963 int rx, ry, x, y;
964 964 unsigned int mask;
965 if (! doAutoHide()) 965 const int bw = -theme()->borderWidth();
966 return; 966 bool hovered = false;
967 967 if (XQueryPointer(Fluxbox::instance()->display(), window().window(), &wr, &wc, &rx, &ry, &x, &y, &mask))
968 if (isHidden()) { 968 hovered = x >= bw && y >= bw && x < int(width()) && y < int(height());
969 if (! m_timer.isTiming()) 969
970 m_timer.start(); 970 if (hovered) {
971 if (m_rc_auto_raise)
972 m_layeritem->moveToLayer(ResourceLayer::ABOVE_DOCK);
973 if (m_rc_auto_hide && isHidden())
974 toggleHidden();
971 } else { 975 } else {
972 if (m_timer.isTiming()) 976 if (m_rc_auto_hide && !isHidden())
973 m_timer.stop(); 977 toggleHidden();
978 if (m_rc_auto_raise)
979 m_layeritem->moveToLayer(m_rc_layernum->getNum());
974 } 980 }
975} 981}
976 982
983void Slit::enterNotifyEvent(XCrossingEvent &ce) {
984 if (!m_rc_auto_hide && isHidden()) {
985 toggleHidden();
986 }
977 987
978void Slit::leaveNotifyEvent(XCrossingEvent &ev) { 988 if (!m_timer.isTiming() && (m_rc_auto_hide && isHidden()) ||
979 if (m_rc_auto_raise) 989 (m_rc_auto_raise && m_layeritem->getLayerNum() != ResourceLayer::ABOVE_DOCK))
980 m_layeritem->moveToLayer(m_rc_layernum->getNum()); 990 m_timer.start();
991}
981 992
982 if (! doAutoHide()) 993void Slit::leaveNotifyEvent(XCrossingEvent &event) {
994 if (m_slitmenu.isVisible())
983 return; 995 return;
984 996
985 if (isHidden()) { 997 if (!m_timer.isTiming() && (m_rc_auto_hide && !isHidden()) ||
986 if (m_timer.isTiming()) 998 (m_rc_auto_raise && m_layeritem->getLayerNum() != m_rc_layernum->getNum()))
987 m_timer.stop(); 999 m_timer.start();
988 } else {
989 if (! m_timer.isTiming()) {
990 // the menu is open, keep it firing until it closes
991 if (m_slitmenu.isVisible())
992 m_timer.fireOnce(false);
993 m_timer.start();
994 }
995 }
996
997} 1000}
998 1001
999
1000void Slit::configureRequestEvent(XConfigureRequestEvent &event) { 1002void Slit::configureRequestEvent(XConfigureRequestEvent &event) {
1001 bool reconf = false; 1003 bool reconf = false;
1002 XWindowChanges xwc; 1004 XWindowChanges xwc;
@@ -1050,16 +1052,6 @@ void Slit::clearWindow() {
1050} 1052}
1051 1053
1052void Slit::toggleHidden() { 1054void Slit::toggleHidden() {
1053 if (doAutoHide()) {
1054 if (!m_slitmenu.isVisible()) {
1055 m_timer.fireOnce(true);
1056 } else {
1057 return;
1058 }
1059 //} else if (!isHidden()) {
1060 // return;
1061 }
1062
1063 m_hidden = ! m_hidden; // toggle hidden state 1055 m_hidden = ! m_hidden; // toggle hidden state
1064 if (isHidden()) 1056 if (isHidden())
1065 frame.window.move(frame.x_hidden, frame.y_hidden); 1057 frame.window.move(frame.x_hidden, frame.y_hidden);
diff --git a/src/Slit.hh b/src/Slit.hh
index 0b476b5..d882309 100644
--- a/src/Slit.hh
+++ b/src/Slit.hh
@@ -134,6 +134,7 @@ private:
134 void screenSizeChanged(BScreen &screen); 134 void screenSizeChanged(BScreen &screen);
135 135
136 void updateAlpha(); 136 void updateAlpha();
137 void updateCrossingState();
137 void clearWindow(); 138 void clearWindow();
138 void setupMenu(); 139 void setupMenu();
139 140
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
diff --git a/src/Toolbar.hh b/src/Toolbar.hh
index 47569f6..c31a85f 100644
--- a/src/Toolbar.hh
+++ b/src/Toolbar.hh
@@ -143,6 +143,8 @@ private:
143 void updateStrut(); 143 void updateStrut();
144 void updateAlpha(); 144 void updateAlpha();
145 145
146 void updateCrossingState();
147
146 /// Called when the screen changed property. 148 /// Called when the screen changed property.
147 void screenChanged(BScreen &screen); 149 void screenChanged(BScreen &screen);
148 150