aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-04-02 23:14:54 (GMT)
committerfluxgen <fluxgen>2002-04-02 23:14:54 (GMT)
commit0f8e4f1f2d9dc17ecaa6a819a918b859b11447d2 (patch)
tree9246b56c6e9ee3df34bc213136e297a67f62edbf /src
parent11324be64f2ee9f2a1b8dc1e9b1e92fa520d243e (diff)
downloadfluxbox-0f8e4f1f2d9dc17ecaa6a819a918b859b11447d2.zip
fluxbox-0f8e4f1f2d9dc17ecaa6a819a918b859b11447d2.tar.bz2
saner search in prev/next focus, and added bool doSkipWindow
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc124
-rw-r--r--src/Screen.hh3
2 files changed, 64 insertions, 63 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 1870e3e..c34e73c 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Screen.cc,v 1.39 2002/03/27 18:47:12 fluxgen Exp $ 25// $Id: Screen.cc,v 1.40 2002/04/02 23:14:54 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -1112,100 +1112,94 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ig
1112 1112
1113 1113
1114void BScreen::nextFocus(int opts) { 1114void BScreen::nextFocus(int opts) {
1115 Bool have_focused = False; 1115 bool have_focused = false;
1116 int focused_window_number = -1; 1116 int focused_window_number = -1;
1117 FluxboxWindow *next; 1117 FluxboxWindow *focused;
1118 const int num_windows = getCurrentWorkspace()->getCount(); 1118 const int num_windows = getCurrentWorkspace()->getCount();
1119 1119
1120 if (fluxbox->getFocusedWindow()) { 1120 if ((focused = fluxbox->getFocusedWindow())) {
1121 if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() == 1121 if (focused->getScreen()->getScreenNumber() ==
1122 getScreenNumber()) { 1122 getScreenNumber()) {
1123 have_focused = True; 1123 have_focused = true;
1124 focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber(); 1124 focused_window_number = focused->getWindowNumber();
1125 } 1125 }
1126 } 1126 }
1127 1127
1128 if (num_windows > 1 && have_focused) { 1128 if (num_windows > 1 && have_focused) {
1129 int next_window_number = focused_window_number; 1129 Workspace *wksp = getCurrentWorkspace();
1130 1130 Workspace::Windows wins = wksp->getWindowList();
1131 //try to set next window to focus 1131 Workspace::Windows::iterator it = wins.begin();
1132 for (; *it != focused; ++it);
1132 do { 1133 do {
1133 if ((++next_window_number) >= num_windows) 1134 ++it;
1134 next_window_number = 0; 1135 if (it == wins.end())
1135 1136 it = wins.begin();
1136 next = getCurrentWorkspace()->getWindow(next_window_number); 1137 // see if the window should be skipped
1137 1138 if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) )
1138 if (! ( (opts & CYCLESKIPSTUCK) != 0 && next->isStuck() || // skip if stuck
1139 (opts & CYCLESKIPLOWERTABS) != 0 && next->isLowerTab() || // skip if lower tab
1140 (opts & CYCLESKIPSHADED) != 0 && next->isShaded() || // skip if shaded
1141 !next->setInputFocus())) // skip unless set input focus
1142 break; 1139 break;
1143 1140 } while (*it != focused);
1144 } while (next_window_number != focused_window_number);
1145
1146 if (next_window_number != focused_window_number) {
1147 next->setInputFocus();
1148 getCurrentWorkspace()->raiseWindow(next);
1149 }
1150 1141
1142 if (*it != focused)
1143 wksp->raiseWindow(*it);
1151 } else if (num_windows >= 1) { 1144 } else if (num_windows >= 1) {
1152 next = current_workspace->getWindow(0); 1145 FluxboxWindow *next = current_workspace->getWindow(0);
1153
1154 //don't raise next window if input focus fails 1146 //don't raise next window if input focus fails
1155 if (next->setInputFocus()) 1147 if (next->setInputFocus())
1156 current_workspace->raiseWindow(next); 1148 current_workspace->raiseWindow(next);
1157 } 1149 }
1150
1158} 1151}
1159 1152
1160 1153
1161void BScreen::prevFocus(int opts) { 1154void BScreen::prevFocus(int opts) {
1162 Bool have_focused = False; 1155 bool have_focused = false;
1163 int focused_window_number = -1; 1156 int focused_window_number = -1;
1164 FluxboxWindow *prev; 1157 FluxboxWindow *focused;
1165 1158 int num_windows = getCurrentWorkspace()->getCount();
1166 if (fluxbox->getFocusedWindow()) 1159
1167 if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() == 1160 if ((focused = fluxbox->getFocusedWindow())) {
1168 getScreenNumber()) { 1161 if (focused->getScreen()->getScreenNumber() ==
1169 have_focused = True; 1162 getScreenNumber()) {
1170 focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber(); 1163 have_focused = true;
1164 focused_window_number = focused->getWindowNumber();
1171 } 1165 }
1166 }
1172 1167
1173 if ((getCurrentWorkspace()->getCount() > 1) && have_focused) { 1168 if (num_windows > 1 && have_focused) {
1174 int prev_window_number = focused_window_number; 1169 Workspace *wksp = getCurrentWorkspace();
1170 Workspace::Windows wins = wksp->getWindowList();
1171 Workspace::Windows::iterator it = wins.begin();
1172 for (; *it != focused; ++it);
1175 do { 1173 do {
1176 if ((--prev_window_number) < 0) 1174 if (it == wins.begin())
1177 prev_window_number = getCurrentWorkspace()->getCount() - 1; 1175 it = wins.end();
1178 1176 --it;
1179 prev = getCurrentWorkspace()->getWindow(prev_window_number); 1177 // see if the window should be skipped
1180 1178 if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) )
1181 if (! ( (opts & CYCLESKIPSTUCK) != 0 && prev->isStuck() || // skip if stuck
1182 (opts & CYCLESKIPLOWERTABS) != 0 && prev->isLowerTab() ||// skip if lower tab
1183 (opts & CYCLESKIPSHADED) != 0 && prev->isShaded() ||// skip if shaded
1184 !prev->setInputFocus()) ) // skip unless set input focus
1185 break; 1179 break;
1186 } while (prev_window_number != focused_window_number); 1180 } while (*it != focused);
1187 1181 if (*it != focused)
1188 if (prev_window_number != focused_window_number) 1182 wksp->raiseWindow(*it);
1189 getCurrentWorkspace()->raiseWindow(prev); 1183 } else if (num_windows >= 1) {
1190 } else if (getCurrentWorkspace()->getCount() >= 1) { 1184 FluxboxWindow *next = current_workspace->getWindow(0);
1191 prev = current_workspace->getWindow(0); 1185 //don't raise next window if input focus fails
1192 1186 if (next->setInputFocus())
1193 current_workspace->raiseWindow(prev); 1187 current_workspace->raiseWindow(next);
1194 prev->setInputFocus();
1195 } 1188 }
1189
1196} 1190}
1197 1191
1198//--------- raiseFocus ----------- 1192//--------- raiseFocus -----------
1199// Raise the current focused window 1193// Raise the current focused window
1200//-------------------------------- 1194//--------------------------------
1201void BScreen::raiseFocus(void) { 1195void BScreen::raiseFocus(void) {
1202 Bool have_focused = False; 1196 bool have_focused = false;
1203 int focused_window_number = -1; 1197 int focused_window_number = -1;
1204 1198
1205 if (fluxbox->getFocusedWindow()) 1199 if (fluxbox->getFocusedWindow())
1206 if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() == 1200 if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() ==
1207 getScreenNumber()) { 1201 getScreenNumber()) {
1208 have_focused = True; 1202 have_focused = true;
1209 focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber(); 1203 focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber();
1210 } 1204 }
1211 1205
@@ -1546,11 +1540,7 @@ Bool BScreen::parseMenuFile(ifstream &file, Rootmenu *menu, int &row) {
1546 if (!str_label.size()) { 1540 if (!str_label.size()) {
1547 fprintf(stderr, 1541 fprintf(stderr,
1548 i18n->getMessage( 1542 i18n->getMessage(
1549 #ifdef NLS
1550 ScreenSet, ScreenWORKSPACESError, 1543 ScreenSet, ScreenWORKSPACESError,
1551 #else // !NLS
1552 0, 0,
1553 #endif // NLS
1554 "BScreen:parseMenuFile: [workspaces] error, " 1544 "BScreen:parseMenuFile: [workspaces] error, "
1555 "no menu label defined\n")); 1545 "no menu label defined\n"));
1556 cerr<<"Row: "<<row<<endl; 1546 cerr<<"Row: "<<row<<endl;
@@ -1808,6 +1798,16 @@ void BScreen::leftWorkspace(const int delta) {
1808 changeWorkspaceID(getCurrentWorkspaceID()-delta); 1798 changeWorkspaceID(getCurrentWorkspaceID()-delta);
1809} 1799}
1810 1800
1801//-------- doSkipWindow
1802// Returns true if the windows should be skiped
1803// else false
1804//----------
1805bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) {
1806 return ((opts & CYCLESKIPSTUCK) != 0 && w->isStuck() || // skip if stuck
1807 (opts & CYCLESKIPLOWERTABS) != 0 && w->isLowerTab() || // skip if lower tab
1808 (opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded
1809}
1810
1811#ifdef GNOME 1811#ifdef GNOME
1812void BScreen::initGnomeAtoms(void) { 1812void BScreen::initGnomeAtoms(void) {
1813 1813
diff --git a/src/Screen.hh b/src/Screen.hh
index 9c3c39b..4109682 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Screen.hh,v 1.25 2002/03/23 15:14:45 fluxgen Exp $ 25// $Id: Screen.hh,v 1.26 2002/04/02 23:14:54 fluxgen Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -245,6 +245,7 @@ public:
245 CYCLEDEFAULT = 0x00 }; 245 CYCLEDEFAULT = 0x00 };
246 246
247private: 247private:
248 bool doSkipWindow(const FluxboxWindow *w, int options);
248 #ifdef GNOME 249 #ifdef GNOME
249 void initGnomeAtoms(); 250 void initGnomeAtoms();
250 void updateGnomeClientList(); 251 void updateGnomeClientList();