shithub: riow

Download patch

ref: 0c3b33270ab8c42f070d2894d2b2e47193cc7d3b
parent: f9c28b3c411bc2d59d3a5122662e6d66296b7ad3
author: Sigrid Haflínudóttir <[email protected]>
date: Sun Mar 29 21:09:38 EDT 2020

don't get in the way of winwatch and manual hiding/unhiding

--- a/riow
+++ b/riow
@@ -42,11 +42,20 @@
 }
 
 fn desktop {
+	# find and remember the current window
+	if(~ $shift 0){
+		for(f in /dev/wsys/*){
+			a=`{winread $f}
+			winid=`{basename $f}
+			if(~ $a(5) current)
+				echo -n $winid >/env/windeskcur_^$curdesktop
+		}
+	}
+
 	for(f in /dev/wsys/*){
 		if(! ~ `{winlabel $f} $sticky){
 			a=`{winread $f}
 			winid=`{basename $f}
-			windesk=`{test -f /env/windesk_^$winid && cat /env/windesk_^$winid}
 
 			if(~ $shift 1){ # moving the current window elsewhere
 				if(~ $a(5) current){
@@ -57,16 +66,13 @@
 			if not {
 				# go through all visible windows
 				if(~ $a(6) visible){
-					if(~ $a(5) current)
-						echo -n $f >/env/windeskcur_^$curdesktop
-					if(~ $#windesk 0){ # no desktop and visible
-						# assign to the current one
-						echo -n $curdesktop >/env/windesk_^$winid
-					}
+					# assign to the current one
+					echo -n $curdesktop >/env/windesk_^$winid
 					# and hide
 					echo hide >$f/wctl
 				}
 				if not { # hidden, unhide if should be shown now
+					windesk=`{test -f /env/windesk_^$winid && cat /env/windesk_^$winid}
 					if(~ $windesk $1)
 						echo unhide >$f/wctl
 				}
@@ -74,8 +80,11 @@
 		}
 	}
 	if(~ $shift 0){
-		if(test -f /env/windeskcur_^$1)
-			echo current >`{cat /env/windeskcur_^$1}^/wctl
+		if(test -f /env/windeskcur_^$1){
+			winid=`{cat /env/windeskcur_^$1}
+			if(test -f /env/windesk_^$winid && ~ `{cat /env/windesk_^$winid} $1)
+				echo current >/dev/wsys/^$winid^/wctl
+		}
 		curdesktop=$1
 	}
 }