diff options
author | Thomas Lübking <thomas.luebking@gmail.com> | 2016-08-14 11:42:27 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2016-08-26 06:06:47 (GMT) |
commit | 10a957473803e87f119c363dc19efe92ea938a1d (patch) | |
tree | 42dc0c55521d6a8736e1cde00374e503ca15c3df /src/Slit.cc | |
parent | fe8ff8729299a4fd4371394d3ca9102ece22fefb (diff) | |
download | fluxbox-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/Slit.cc')
-rw-r--r-- | src/Slit.cc | 74 |
1 files changed, 33 insertions, 41 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 | ||
961 | void Slit::enterNotifyEvent(XCrossingEvent &) { | 961 | void 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 | ||
983 | void Slit::enterNotifyEvent(XCrossingEvent &ce) { | ||
984 | if (!m_rc_auto_hide && isHidden()) { | ||
985 | toggleHidden(); | ||
986 | } | ||
977 | 987 | ||
978 | void 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()) | 993 | void 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 | |||
1000 | void Slit::configureRequestEvent(XConfigureRequestEvent &event) { | 1002 | void 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 | ||
1052 | void Slit::toggleHidden() { | 1054 | void 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); |