From 8de73d0fd4fde6e6f5349831304fb9a268af8d70 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 17 Jul 2007 21:21:17 +0000 Subject: updated behavior of alt-tab to match pre-devel, fixing bug #1755698 --- src/FbTk/Menu.cc | 1 + src/FocusControl.cc | 90 +++++++++++++++++++++++++++++------------------------ src/FocusControl.hh | 6 ++-- src/Screen.cc | 2 +- src/Window.cc | 4 +-- 5 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index ec0a061..ee17204 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -111,6 +111,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): m_internal_menu = m_moving = + m_closing = m_torn = m_visible = false; diff --git a/src/FocusControl.cc b/src/FocusControl.cc index 4de491a..c333005 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -86,23 +86,27 @@ bool doSkipWindow(const WinClient &winclient, int opts) { ); } -void FocusControl::cycleFocus(FocusedWindows *window_list, int opts, bool cycle_reverse) { +void FocusControl::cycleFocus(FocusedWindows &window_list, int opts, bool cycle_reverse) { if (!m_cycling_list) { if (&m_screen == FbTk::EventManager::instance()->grabbingKeyboard()) // only set this when we're waiting for modifiers - m_cycling_list = window_list; + m_cycling_list = &window_list; m_was_iconic = 0; m_cycling_last = 0; - } else if (m_cycling_list != window_list) - m_cycling_list = window_list; + } else if (m_cycling_list != &window_list) + m_cycling_list = &window_list; + + FocusedWindows::iterator it_begin = window_list.begin(); + FocusedWindows::iterator it_end = window_list.end(); // too many things can go wrong with remembering this - m_cycling_window = find(window_list->begin(),window_list->end(),s_focused_window); + m_cycling_window = find(it_begin, it_end, s_focused_window); FocusedWindows::iterator it = m_cycling_window; - FocusedWindows::iterator it_begin = window_list->begin(); - FocusedWindows::iterator it_end = window_list->end(); + FluxboxWindow *fbwin = 0; + WinClient *last_client = 0; + WinClient *was_iconic = 0; // find the next window in the list that works while (true) { @@ -114,46 +118,50 @@ void FocusControl::cycleFocus(FocusedWindows *window_list, int opts, bool cycle_ cycle_reverse ? --it : ++it; // give up [do nothing] if we reach the current focused again if (it == m_cycling_window) - break; + return; if (it == it_end) continue; - FluxboxWindow *fbwin = (*it)->fbwindow(); - if (fbwin && (fbwin->isStuck() - || fbwin->workspaceNumber() == m_screen.currentWorkspaceID())) { - // either on this workspace, or stuck - - // keep track of the originally selected window in a set - WinClient &last_client = fbwin->winClient(); - - if (! (doSkipWindow(**it, opts) || !fbwin->setCurrentClient(**it)) ) { - // moved onto a new fbwin - if (!m_cycling_last || m_cycling_last->fbwindow() != fbwin) { - if (m_cycling_last) { - // already cycling, so restack to put windows back in - // their proper order - m_screen.layerManager().restack(); - - // set back to orig current Client in that fbwin - m_cycling_last->fbwindow()->setCurrentClient(*m_cycling_last, false); - if (m_was_iconic == m_cycling_last) { - s_reverting = true; // little hack - m_cycling_last->fbwindow()->iconify(); - s_reverting = false; - } - } - m_cycling_last = &last_client; - if (fbwin->isIconic()) - m_was_iconic = m_cycling_last; - if (m_cycling_list) - // else window will raise itself (if desired) on FocusIn - fbwin->tempRaise(); - } - break; - } + fbwin = (*it)->fbwindow(); + if (!fbwin) + continue; + + // keep track of the originally selected window in a group + last_client = &fbwin->winClient(); + was_iconic = (fbwin->isIconic() ? last_client : 0); + + // now we actually try to focus the window + if (!doSkipWindow(**it, opts) && (*it)->focus()) + break; + } + + // if we're still in the same fbwin, there's nothing else to do + if (m_cycling_last && m_cycling_last->fbwindow() == fbwin) + return; + + // if we were already cycling, then restore the old state + if (m_cycling_last) { + m_screen.layerManager().restack(); + + // set back to originally selected window in that group + m_cycling_last->fbwindow()->setCurrentClient(*m_cycling_last, false); + + if (m_was_iconic == m_cycling_last) { + s_reverting = true; // little hack + m_cycling_last->fbwindow()->iconify(); + s_reverting = false; } } + + if (isCycling()) + fbwin->tempRaise(); + else + fbwin->raise(); + m_cycling_window = it; + m_cycling_last = last_client; + m_was_iconic = was_iconic; + } void FocusControl::addFocusBack(WinClient &client) { diff --git a/src/FocusControl.hh b/src/FocusControl.hh index c55aa6a..79d16d4 100644 --- a/src/FocusControl.hh +++ b/src/FocusControl.hh @@ -73,16 +73,16 @@ public: explicit FocusControl(BScreen &screen); /// cycle previous focuable - void prevFocus() { cycleFocus(&m_focused_list, 0, true); } + void prevFocus() { cycleFocus(m_focused_list, 0, true); } /// cycle next focusable - void nextFocus() { cycleFocus(&m_focused_list, 0, false); } + void nextFocus() { cycleFocus(m_focused_list, 0, false); } /** * Cycle focus for a set of windows. * @param winlist the windowlist to cycle through * @param options cycle options @see FocusOption * @param reverse reverse the cycle order */ - void cycleFocus(FocusedWindows *winlist, int options, bool reverse = false); + void cycleFocus(FocusedWindows &winlist, int options, bool reverse = false); /// sets the focused window on a screen void setScreenFocusedWindow(WinClient &win_client); /// sets the main focus model diff --git a/src/Screen.cc b/src/Screen.cc index a37b594..b0575f3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -865,7 +865,7 @@ void BScreen::cycleFocus(int options, bool reverse) { &focusControl().creationOrderList() : &focusControl().focusedOrderList(); - focusControl().cycleFocus(win_list, options, reverse); + focusControl().cycleFocus(*win_list, options, reverse); } FbTk::Menu *BScreen::createMenu(const string &label) { diff --git a/src/Window.cc b/src/Window.cc index 3a2801b..d8a3f46 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -780,14 +780,14 @@ void FluxboxWindow::nextClient() { if (numClients() <= 1) return; - screen().focusControl().cycleFocus(&m_clientlist, 0); + screen().focusControl().cycleFocus(m_clientlist, 0); } void FluxboxWindow::prevClient() { if (numClients() <= 1) return; - screen().focusControl().cycleFocus(&m_clientlist, 0, true); + screen().focusControl().cycleFocus(m_clientlist, 0, true); } -- cgit v0.11.2