From c6b11959cfa91b472ee6cc17ea45a1c6c5670c03 Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Mon, 18 Mar 2002 20:20:09 +0000
Subject: added parameter to next/prev Focus and optionsbits for them

---
 src/Screen.cc | 29 ++++++++++++++++++++---------
 src/Screen.hh |  9 ++++++---
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/Screen.cc b/src/Screen.cc
index a3a938f..41dfa53 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,10 +22,9 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Screen.cc,v 1.34 2002/03/08 12:18:22 fluxgen Exp $
+// $Id: Screen.cc,v 1.35 2002/03/18 20:20:09 fluxgen Exp $
 
-// stupid macros needed to access some functions in version 2 of the GNU C
-// library
+//use GNU extensions
 #ifndef	 _GNU_SOURCE
 #define	 _GNU_SOURCE
 #endif // _GNU_SOURCE
@@ -1102,7 +1101,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, int wkspc_id, Bool ignore_stic
 }
 
 
-void BScreen::nextFocus(void) {
+void BScreen::nextFocus(int opts) {
 	Bool have_focused = False;
 	int focused_window_number = -1;
 	FluxboxWindow *next;
@@ -1123,9 +1122,16 @@ void BScreen::nextFocus(void) {
 		do {
 			if ((++next_window_number) >= num_windows)
 				next_window_number = 0;	
+
 			next = getCurrentWorkspace()->getWindow(next_window_number);
-		} while ((!next->setInputFocus()) && next_window_number !=
-				 focused_window_number);
+
+			if (! ( (opts & CYCLESKIPSTUCK) != 0 && next->isStuck() || // skip if stuck
+					(opts & CYCLESKIPLOWERTABS) != 0 && next->isLowerTab() || // skip if lower tab
+				    (opts & CYCLESKIPSHADED) != 0 && next->isShaded() || // skip if shaded
+					!next->setInputFocus())) // skip unless set input focus
+				break;
+			
+		} while (next_window_number != focused_window_number);
 
 		if (next_window_number != focused_window_number) {
 			next->setInputFocus();
@@ -1142,7 +1148,7 @@ void BScreen::nextFocus(void) {
 }
 
 
-void BScreen::prevFocus(void) {
+void BScreen::prevFocus(int opts) {
 	Bool have_focused = False;
 	int focused_window_number = -1;
 	FluxboxWindow *prev;
@@ -1161,8 +1167,13 @@ void BScreen::prevFocus(void) {
 				prev_window_number = getCurrentWorkspace()->getCount() - 1;
 
 			prev = getCurrentWorkspace()->getWindow(prev_window_number);
-		} while ((! prev->setInputFocus()) && (prev_window_number !=
-						 focused_window_number));
+
+			if (! ( (opts & CYCLESKIPSTUCK) != 0 && prev->isStuck() || // skip if stuck
+					(opts & CYCLESKIPLOWERTABS) != 0 && prev->isLowerTab() ||// skip if lower tab
+					(opts & CYCLESKIPSHADED) != 0 && prev->isShaded() ||// skip if shaded
+					!prev->setInputFocus()) ) // skip unless set input focus
+				break;
+		} while (prev_window_number != focused_window_number);
 
 		if (prev_window_number != focused_window_number)
 			getCurrentWorkspace()->raiseWindow(prev);
diff --git a/src/Screen.hh b/src/Screen.hh
index 1e9c3bb..ffb5df4 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Screen.hh,v 1.22 2002/03/08 12:19:07 fluxgen Exp $
+// $Id: Screen.hh,v 1.23 2002/03/18 20:20:09 fluxgen Exp $
 
 #ifndef	 SCREEN_HH
 #define	 SCREEN_HH
@@ -203,8 +203,8 @@ public:
 	void sendToWorkspace(int, bool);
 	void raiseWindows(Window *, int);
 	void reassociateWindow(FluxboxWindow *, int, Bool);
-	void prevFocus(void);
-	void nextFocus(void);
+	void prevFocus(int = 0);
+	void nextFocus(int = 0);
 	void raiseFocus(void);
 	void reconfigure(void);	
 	void rereadMenu(void);
@@ -229,6 +229,9 @@ public:
 	enum { RESTART = 1, RESTARTOTHER, EXIT, SHUTDOWN, EXECUTE, RECONFIGURE,
 				 WINDOWSHADE, WINDOWICONIFY, WINDOWMAXIMIZE, WINDOWCLOSE, WINDOWRAISE,
 				 WINDOWLOWER, WINDOWSTICK, WINDOWKILL, SETSTYLE, WINDOWTAB};
+	// prevFocus/nextFocus option bits
+	enum { CYCLESKIPLOWERTABS = 0x01, CYCLESKIPSTUCK = 0x02, CYCLESKIPSHADED = 0x04,
+				CYCLEDEFAULT = 0x00 };
 
 private:
 	#ifdef GNOME
-- 
cgit v0.11.2