updated behavior of alt-tab to match pre-devel, fixing bug #1755698

This commit is contained in:
markt 2007-07-17 21:21:17 +00:00
parent 5aecf58d47
commit 8de73d0fd4
5 changed files with 53 additions and 44 deletions

View file

@ -111,6 +111,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
m_internal_menu =
m_moving =
m_closing =
m_torn =
m_visible = false;

View file

@ -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
fbwin = (*it)->fbwindow();
if (!fbwin)
continue;
// keep track of the originally selected window in a set
WinClient &last_client = fbwin->winClient();
// keep track of the originally selected window in a group
last_client = &fbwin->winClient();
was_iconic = (fbwin->isIconic() ? last_client : 0);
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();
// now we actually try to focus the window
if (!doSkipWindow(**it, opts) && (*it)->focus())
break;
}
// 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;
}
// 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) {

View file

@ -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

View file

@ -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) {

View file

@ -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);
}