diff options
Diffstat (limited to 'src/FocusControl.cc')
-rw-r--r-- | src/FocusControl.cc | 90 |
1 files changed, 49 insertions, 41 deletions
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) { | |||
86 | ); | 86 | ); |
87 | } | 87 | } |
88 | 88 | ||
89 | void FocusControl::cycleFocus(FocusedWindows *window_list, int opts, bool cycle_reverse) { | 89 | void FocusControl::cycleFocus(FocusedWindows &window_list, int opts, bool cycle_reverse) { |
90 | 90 | ||
91 | if (!m_cycling_list) { | 91 | if (!m_cycling_list) { |
92 | if (&m_screen == FbTk::EventManager::instance()->grabbingKeyboard()) | 92 | if (&m_screen == FbTk::EventManager::instance()->grabbingKeyboard()) |
93 | // only set this when we're waiting for modifiers | 93 | // only set this when we're waiting for modifiers |
94 | m_cycling_list = window_list; | 94 | m_cycling_list = &window_list; |
95 | m_was_iconic = 0; | 95 | m_was_iconic = 0; |
96 | m_cycling_last = 0; | 96 | m_cycling_last = 0; |
97 | } else if (m_cycling_list != window_list) | 97 | } else if (m_cycling_list != &window_list) |
98 | m_cycling_list = window_list; | 98 | m_cycling_list = &window_list; |
99 | |||
100 | FocusedWindows::iterator it_begin = window_list.begin(); | ||
101 | FocusedWindows::iterator it_end = window_list.end(); | ||
99 | 102 | ||
100 | // too many things can go wrong with remembering this | 103 | // too many things can go wrong with remembering this |
101 | m_cycling_window = find(window_list->begin(),window_list->end(),s_focused_window); | 104 | m_cycling_window = find(it_begin, it_end, s_focused_window); |
102 | 105 | ||
103 | FocusedWindows::iterator it = m_cycling_window; | 106 | FocusedWindows::iterator it = m_cycling_window; |
104 | FocusedWindows::iterator it_begin = window_list->begin(); | 107 | FluxboxWindow *fbwin = 0; |
105 | FocusedWindows::iterator it_end = window_list->end(); | 108 | WinClient *last_client = 0; |
109 | WinClient *was_iconic = 0; | ||
106 | 110 | ||
107 | // find the next window in the list that works | 111 | // find the next window in the list that works |
108 | while (true) { | 112 | while (true) { |
@@ -114,46 +118,50 @@ void FocusControl::cycleFocus(FocusedWindows *window_list, int opts, bool cycle_ | |||
114 | cycle_reverse ? --it : ++it; | 118 | cycle_reverse ? --it : ++it; |
115 | // give up [do nothing] if we reach the current focused again | 119 | // give up [do nothing] if we reach the current focused again |
116 | if (it == m_cycling_window) | 120 | if (it == m_cycling_window) |
117 | break; | 121 | return; |
118 | if (it == it_end) | 122 | if (it == it_end) |
119 | continue; | 123 | continue; |
120 | 124 | ||
121 | FluxboxWindow *fbwin = (*it)->fbwindow(); | 125 | fbwin = (*it)->fbwindow(); |
122 | if (fbwin && (fbwin->isStuck() | 126 | if (!fbwin) |
123 | || fbwin->workspaceNumber() == m_screen.currentWorkspaceID())) { | 127 | continue; |
124 | // either on this workspace, or stuck | 128 | |
125 | 129 | // keep track of the originally selected window in a group | |
126 | // keep track of the originally selected window in a set | 130 | last_client = &fbwin->winClient(); |
127 | WinClient &last_client = fbwin->winClient(); | 131 | was_iconic = (fbwin->isIconic() ? last_client : 0); |
128 | 132 | ||
129 | if (! (doSkipWindow(**it, opts) || !fbwin->setCurrentClient(**it)) ) { | 133 | // now we actually try to focus the window |
130 | // moved onto a new fbwin | 134 | if (!doSkipWindow(**it, opts) && (*it)->focus()) |
131 | if (!m_cycling_last || m_cycling_last->fbwindow() != fbwin) { | 135 | break; |
132 | if (m_cycling_last) { | 136 | } |
133 | // already cycling, so restack to put windows back in | 137 | |
134 | // their proper order | 138 | // if we're still in the same fbwin, there's nothing else to do |
135 | m_screen.layerManager().restack(); | 139 | if (m_cycling_last && m_cycling_last->fbwindow() == fbwin) |
136 | 140 | return; | |
137 | // set back to orig current Client in that fbwin | 141 | |
138 | m_cycling_last->fbwindow()->setCurrentClient(*m_cycling_last, false); | 142 | // if we were already cycling, then restore the old state |
139 | if (m_was_iconic == m_cycling_last) { | 143 | if (m_cycling_last) { |
140 | s_reverting = true; // little hack | 144 | m_screen.layerManager().restack(); |
141 | m_cycling_last->fbwindow()->iconify(); | 145 | |
142 | s_reverting = false; | 146 | // set back to originally selected window in that group |
143 | } | 147 | m_cycling_last->fbwindow()->setCurrentClient(*m_cycling_last, false); |
144 | } | 148 | |
145 | m_cycling_last = &last_client; | 149 | if (m_was_iconic == m_cycling_last) { |
146 | if (fbwin->isIconic()) | 150 | s_reverting = true; // little hack |
147 | m_was_iconic = m_cycling_last; | 151 | m_cycling_last->fbwindow()->iconify(); |
148 | if (m_cycling_list) | 152 | s_reverting = false; |
149 | // else window will raise itself (if desired) on FocusIn | ||
150 | fbwin->tempRaise(); | ||
151 | } | ||
152 | break; | ||
153 | } | ||
154 | } | 153 | } |
155 | } | 154 | } |
155 | |||
156 | if (isCycling()) | ||
157 | fbwin->tempRaise(); | ||
158 | else | ||
159 | fbwin->raise(); | ||
160 | |||
156 | m_cycling_window = it; | 161 | m_cycling_window = it; |
162 | m_cycling_last = last_client; | ||
163 | m_was_iconic = was_iconic; | ||
164 | |||
157 | } | 165 | } |
158 | 166 | ||
159 | void FocusControl::addFocusBack(WinClient &client) { | 167 | void FocusControl::addFocusBack(WinClient &client) { |