diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-01 18:29:36 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-01 18:29:36 (GMT) |
commit | 7588fc10a61c141208ccccc423cc7920207b2e89 (patch) | |
tree | ca9acf5c5bb36df5a9a77a4b7ce0f79cb3e054ab /src/fluxbox.cc | |
parent | 72d2f0e48143115aae38b75d5b1bda4cee5d512a (diff) | |
download | fluxbox_pavel-7588fc10a61c141208ccccc423cc7920207b2e89.zip fluxbox_pavel-7588fc10a61c141208ccccc423cc7920207b2e89.tar.bz2 |
fix some flickering on focus change
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r-- | src/fluxbox.cc | 104 |
1 files changed, 43 insertions, 61 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 341fda8..b96b0a2 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -218,7 +218,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile | |||
218 | m_masked(0), | 218 | m_masked(0), |
219 | m_rc_file(rcfilename ? rcfilename : ""), | 219 | m_rc_file(rcfilename ? rcfilename : ""), |
220 | m_argv(argv), m_argc(argc), | 220 | m_argv(argv), m_argc(argc), |
221 | m_revert_screen(0), | ||
222 | m_showing_dialog(false), | 221 | m_showing_dialog(false), |
223 | m_starting(true), | 222 | m_starting(true), |
224 | m_restarting(false), | 223 | m_restarting(false), |
@@ -274,12 +273,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile | |||
274 | m_reconfig_timer.setCommand(reconfig_cmd); | 273 | m_reconfig_timer.setCommand(reconfig_cmd); |
275 | m_reconfig_timer.fireOnce(true); | 274 | m_reconfig_timer.fireOnce(true); |
276 | 275 | ||
277 | // set a timer to revert focus on FocusOut, in case no FocusIn arrives | ||
278 | FbTk::RefCount<FbTk::Command> revert_cmd(new FbTk::SimpleCommand<Fluxbox>(*this, &Fluxbox::revert_focus)); | ||
279 | m_revert_timer.setCommand(revert_cmd); | ||
280 | m_revert_timer.setTimeout(to); | ||
281 | m_revert_timer.fireOnce(true); | ||
282 | |||
283 | // XSynchronize(disp, True); | 276 | // XSynchronize(disp, True); |
284 | 277 | ||
285 | s_singleton = this; | 278 | s_singleton = this; |
@@ -546,7 +539,7 @@ void Fluxbox::eventLoop() { | |||
546 | if (last_bad_window != None && e.xany.window == last_bad_window && | 539 | if (last_bad_window != None && e.xany.window == last_bad_window && |
547 | e.type != DestroyNotify) { // we must let the actual destroys through | 540 | e.type != DestroyNotify) { // we must let the actual destroys through |
548 | if (e.type == FocusOut) | 541 | if (e.type == FocusOut) |
549 | m_revert_timer.start(); | 542 | revertFocus(); |
550 | #ifdef DEBUG | 543 | #ifdef DEBUG |
551 | else | 544 | else |
552 | cerr<<"Fluxbox::eventLoop(): removing bad window from event queue"<<endl; | 545 | cerr<<"Fluxbox::eventLoop(): removing bad window from event queue"<<endl; |
@@ -711,30 +704,6 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
711 | } | 704 | } |
712 | } | 705 | } |
713 | 706 | ||
714 | // we need to check focus out for menus before | ||
715 | // we call FbTk eventhandler | ||
716 | // so we can get FbTk::Menu::focused() before it sets to 0 | ||
717 | if (e->type == FocusOut && | ||
718 | e->xfocus.mode != NotifyGrab && | ||
719 | e->xfocus.detail != NotifyPointer && | ||
720 | e->xfocus.detail != NotifyInferior && | ||
721 | FbTk::Menu::focused() != 0 && | ||
722 | FbTk::Menu::focused()->window() == e->xfocus.window) { | ||
723 | |||
724 | // find screen num | ||
725 | ScreenList::iterator it = m_screen_list.begin(); | ||
726 | ScreenList::iterator it_end = m_screen_list.end(); | ||
727 | for (; it != it_end; ++it) { | ||
728 | if ( (*it)->screenNumber() == | ||
729 | FbTk::Menu::focused()->fbwindow().screenNumber()) { | ||
730 | FocusControl::setFocusedWindow(0); | ||
731 | m_revert_screen = *it; | ||
732 | m_revert_timer.start(); | ||
733 | break; // found the screen, no more search | ||
734 | } | ||
735 | } | ||
736 | } | ||
737 | |||
738 | // try FbTk::EventHandler first | 707 | // try FbTk::EventHandler first |
739 | FbTk::EventManager::instance()->handleEvent(*e); | 708 | FbTk::EventManager::instance()->handleEvent(*e); |
740 | 709 | ||
@@ -903,9 +872,18 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
903 | e->xfocus.detail == NotifyPointer || | 872 | e->xfocus.detail == NotifyPointer || |
904 | e->xfocus.detail == NotifyInferior) | 873 | e->xfocus.detail == NotifyInferior) |
905 | break; | 874 | break; |
875 | |||
876 | if (FbTk::Menu::focused() && | ||
877 | FbTk::Menu::focused()->window() == e->xfocus.window) { | ||
878 | m_keyscreen = findScreen(FbTk::Menu::focused()->screenNumber()); | ||
879 | break; | ||
880 | } | ||
881 | |||
906 | WinClient *winclient = searchWindow(e->xfocus.window); | 882 | WinClient *winclient = searchWindow(e->xfocus.window); |
907 | if (winclient && FocusControl::focusedWindow() != winclient) | 883 | if (!winclient) |
908 | FocusControl::setFocusedWindow(winclient); | 884 | break; |
885 | m_keyscreen = &winclient->screen(); | ||
886 | FocusControl::setFocusedWindow(winclient); | ||
909 | 887 | ||
910 | } break; | 888 | } break; |
911 | case FocusOut:{ | 889 | case FocusOut:{ |
@@ -916,19 +894,11 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
916 | break; | 894 | break; |
917 | 895 | ||
918 | WinClient *winclient = searchWindow(e->xfocus.window); | 896 | WinClient *winclient = searchWindow(e->xfocus.window); |
919 | if (winclient == 0 && FbTk::Menu::focused() == 0) { | 897 | if (winclient && (winclient == FocusControl::focusedWindow() || |
920 | #ifdef DEBUG | 898 | FocusControl::focusedWindow() == 0) && |
921 | cerr<<__FILE__<<"("<<__FUNCTION__<<") Focus out is not a FluxboxWindow !!"<<endl; | ||
922 | #endif // DEBUG | ||
923 | } else if (winclient && (winclient == FocusControl::focusedWindow() || | ||
924 | FocusControl::focusedWindow() == 0) && | ||
925 | (winclient->fbwindow() == 0 | ||
926 | || !winclient->fbwindow()->isMoving())) { | ||
927 | // we don't unfocus a moving window | 899 | // we don't unfocus a moving window |
928 | FocusControl::setFocusedWindow(0); | 900 | (winclient->fbwindow() == 0 || !winclient->fbwindow()->isMoving())) |
929 | m_revert_screen = &winclient->screen(); | 901 | revertFocus(); |
930 | m_revert_timer.start(); | ||
931 | } | ||
932 | } | 902 | } |
933 | break; | 903 | break; |
934 | case ClientMessage: | 904 | case ClientMessage: |
@@ -1166,8 +1136,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) { | |||
1166 | FocusControl::unfocusWindow(*client); | 1136 | FocusControl::unfocusWindow(*client); |
1167 | // make sure nothing else uses this window before focus reverts | 1137 | // make sure nothing else uses this window before focus reverts |
1168 | FocusControl::setFocusedWindow(0); | 1138 | FocusControl::setFocusedWindow(0); |
1169 | m_revert_screen = &screen; | ||
1170 | m_revert_timer.start(); | ||
1171 | } | 1139 | } |
1172 | 1140 | ||
1173 | screen.removeClient(*client); | 1141 | screen.removeClient(*client); |
@@ -1640,22 +1608,36 @@ void Fluxbox::timed_reconfigure() { | |||
1640 | m_reconfigure_wait = m_reread_menu_wait = false; | 1608 | m_reconfigure_wait = m_reread_menu_wait = false; |
1641 | } | 1609 | } |
1642 | 1610 | ||
1643 | void Fluxbox::revert_focus() { | 1611 | void Fluxbox::revertFocus() { |
1644 | if (!m_revert_screen || FocusControl::focusedWindow() || | 1612 | bool revert = m_keyscreen && !m_showing_dialog; |
1645 | FbTk::Menu::focused() || m_showing_dialog) | ||
1646 | return; | ||
1647 | 1613 | ||
1648 | Window win; | 1614 | if (revert) { |
1649 | int revert; | 1615 | // see if there are any more focus events in the queue |
1650 | Display *disp = display(); | 1616 | XEvent ev; |
1617 | while (XCheckMaskEvent(display(), FocusChangeMask, &ev)) { | ||
1618 | handleEvent(&ev); | ||
1619 | revert = false; | ||
1620 | } | ||
1621 | if (!revert) | ||
1622 | return; // already handled | ||
1623 | } | ||
1651 | 1624 | ||
1652 | XGetInputFocus(disp, &win, &revert); | 1625 | if (revert) { |
1626 | Window win; | ||
1627 | int blah; | ||
1628 | XGetInputFocus(display(), &win, &blah); | ||
1629 | |||
1630 | // we only want to revert focus if it's left dangling, as some other | ||
1631 | // application may have set the focus to an unmanaged window | ||
1632 | if (win != None && win != PointerRoot && | ||
1633 | win != m_keyscreen->rootWindow().window()) | ||
1634 | revert = false; | ||
1635 | } | ||
1653 | 1636 | ||
1654 | // we only want to revert focus if it's left dangling, as some other | 1637 | if (revert) |
1655 | // application may have set the focus to an unmanaged window | 1638 | FocusControl::revertFocus(*m_keyscreen); |
1656 | if (win == None || win == PointerRoot || | 1639 | else |
1657 | win == m_revert_screen->rootWindow().window()) | 1640 | FocusControl::setFocusedWindow(0); |
1658 | FocusControl::revertFocus(*m_revert_screen); | ||
1659 | } | 1641 | } |
1660 | 1642 | ||
1661 | bool Fluxbox::validateClient(const WinClient *client) const { | 1643 | bool Fluxbox::validateClient(const WinClient *client) const { |