aboutsummaryrefslogtreecommitdiff
path: root/src/FocusControl.cc
diff options
context:
space:
mode:
authormarkt <markt>2006-07-14 06:00:37 (GMT)
committermarkt <markt>2006-07-14 06:00:37 (GMT)
commitfde970a21d62756cdbca1fe5acd75386b251814c (patch)
tree795f1415d22eb4131d8d602c0b4f56a6821a8df2 /src/FocusControl.cc
parentd32a7af7e6540221edbf43cee7b89a36e0755a66 (diff)
downloadfluxbox-fde970a21d62756cdbca1fe5acd75386b251814c.zip
fluxbox-fde970a21d62756cdbca1fe5acd75386b251814c.tar.bz2
include iconic windows when cycling
also, stop cycling on one screen when cycling begins on another
Diffstat (limited to 'src/FocusControl.cc')
-rw-r--r--src/FocusControl.cc41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index 6f919ef..6b4f64a 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -57,6 +57,7 @@ FocusControl::FocusControl(BScreen &screen):
57 screen.name()+".focusNewWindows", 57 screen.name()+".focusNewWindows",
58 screen.altName()+".FocusNewWindows"), 58 screen.altName()+".FocusNewWindows"),
59 m_cycling_focus(false), 59 m_cycling_focus(false),
60 m_was_iconic(false),
60 m_cycling_last(0) { 61 m_cycling_last(0) {
61 62
62 m_cycling_window = m_focused_list.end(); 63 m_cycling_window = m_focused_list.end();
@@ -73,38 +74,29 @@ bool doSkipWindow(const WinClient &winclient, int opts) {
73 (opts & FocusControl::CYCLEGROUPS) != 0 && win->winClient().window() != winclient.window() || 74 (opts & FocusControl::CYCLEGROUPS) != 0 && win->winClient().window() != winclient.window() ||
74 // skip if shaded 75 // skip if shaded
75 (opts & FocusControl::CYCLESKIPSHADED) != 0 && win->isShaded() || 76 (opts & FocusControl::CYCLESKIPSHADED) != 0 && win->isShaded() ||
77 // skip if iconic
78 (opts & FocusControl::CYCLESKIPICONIC) != 0 && win->isIconic() ||
76 // skip if hidden 79 // skip if hidden
77 win->isFocusHidden() 80 win->isFocusHidden()
78 ); 81 );
79} 82}
80 83
81void FocusControl::cycleFocus(int opts, bool cycle_reverse) { 84void FocusControl::cycleFocus(int opts, bool cycle_reverse) {
82 int num_windows = m_screen.currentWorkspace()->numberOfWindows();
83
84 if (num_windows < 1)
85 return;
86 85
87 FocusedWindows *window_list = (opts & CYCLELINEAR) ? &m_creation_order_list : &m_focused_list; 86 FocusedWindows *window_list = (opts & CYCLELINEAR) ? &m_creation_order_list : &m_focused_list;
88 if (!m_cycling_focus) { 87 if (!m_cycling_focus) {
89 if (Fluxbox::instance()->watchingScreen()) 88 if (&m_screen == Fluxbox::instance()->watchingScreen())
90 m_cycling_focus = true; 89 m_cycling_focus = true;
91 if (opts & CYCLELINEAR) { 90 m_cycling_window = find(window_list->begin(),window_list->end(),s_focused_window);
92 m_cycling_creation_order = true; 91 m_cycling_creation_order = (opts & CYCLELINEAR);
93 m_cycling_window = find(window_list->begin(),window_list->end(),s_focused_window); 92 m_was_iconic = false;
94 } else {
95 m_cycling_creation_order = (opts & CYCLELINEAR);
96 m_cycling_window = window_list->begin();
97 }
98 m_cycling_last = 0; 93 m_cycling_last = 0;
99 } else { 94 } else {
100 // already cycling, so restack to put windows back in their proper order 95 // already cycling, so restack to put windows back in their proper order
101 m_screen.layerManager().restack(); 96 m_screen.layerManager().restack();
102 if (m_cycling_creation_order ^ (bool)(opts & CYCLELINEAR)) { 97 if (m_cycling_creation_order ^ (bool)(opts & CYCLELINEAR)) {
103 m_cycling_creation_order ^= true; 98 m_cycling_creation_order ^= true;
104 if (m_cycling_window != m_focused_list.end() && m_cycling_window != m_creation_order_list.end()) 99 m_cycling_window = find(window_list->begin(),window_list->end(),*m_cycling_window);
105 m_cycling_window = find(window_list->begin(),window_list->end(),*m_cycling_window);
106 else
107 m_cycling_window = window_list->begin();
108 } 100 }
109 } 101 }
110 // if it is stacked, we want the highest window in the focused list 102 // if it is stacked, we want the highest window in the focused list
@@ -116,16 +108,18 @@ void FocusControl::cycleFocus(int opts, bool cycle_reverse) {
116 while (true) { 108 while (true) {
117 if (cycle_reverse && it == it_begin) 109 if (cycle_reverse && it == it_begin)
118 it = it_end; 110 it = it_end;
119 cycle_reverse ? --it : ++it; 111 else if (!cycle_reverse && it == it_end)
120 if (it == it_end)
121 it = it_begin; 112 it = it_begin;
113 else
114 cycle_reverse ? --it : ++it;
122 // give up [do nothing] if we reach the current focused again 115 // give up [do nothing] if we reach the current focused again
123 if ((*it) == (*m_cycling_window)) 116 if (it == m_cycling_window)
124 break; 117 break;
118 if (it == it_end)
119 continue;
125 120
126 FluxboxWindow *fbwin = (*it)->fbwindow(); 121 FluxboxWindow *fbwin = (*it)->fbwindow();
127 if (fbwin && !fbwin->isIconic() && 122 if (fbwin && (fbwin->isStuck()
128 (fbwin->isStuck()
129 || fbwin->workspaceNumber() == m_screen.currentWorkspaceID())) { 123 || fbwin->workspaceNumber() == m_screen.currentWorkspaceID())) {
130 // either on this workspace, or stuck 124 // either on this workspace, or stuck
131 125
@@ -140,6 +134,9 @@ void FocusControl::cycleFocus(int opts, bool cycle_reverse) {
140 m_cycling_last->fbwindow()->setCurrentClient(*m_cycling_last, false); 134 m_cycling_last->fbwindow()->setCurrentClient(*m_cycling_last, false);
141 } 135 }
142 m_cycling_last = &last_client; 136 m_cycling_last = &last_client;
137 if (m_was_iconic)
138 (*m_cycling_window)->fbwindow()->iconify();
139 m_was_iconic = fbwin->isIconic();
143 } 140 }
144 fbwin->tempRaise(); 141 fbwin->tempRaise();
145 break; 142 break;
@@ -362,6 +359,8 @@ void FocusControl::removeClient(WinClient &client) {
362 */ 359 */
363void FocusControl::revertFocus(BScreen &screen) { 360void FocusControl::revertFocus(BScreen &screen) {
364 361
362 if (screen.focusControl().isCycling())
363 return;
365 // Relevant resources: 364 // Relevant resources:
366 // resource.focus_last = whether we focus last focused when changing workspace 365 // resource.focus_last = whether we focus last focused when changing workspace
367 // BScreen::FocusModel = sloppy, click, whatever 366 // BScreen::FocusModel = sloppy, click, whatever