shithub: riow

Download patch

ref: 3e85a5601786c3fee1e1f959f510ab8224ad025e
parent: 8a704263033e3242ba74ecb0356987f5e642cc1e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Apr 7 15:27:48 EDT 2020

reduce flickering by showing as many windows as possible first, then hiding the rest

--- a/riow
+++ b/riow
@@ -56,8 +56,18 @@
 			echo -n $winid >/env/windeskcur_^$curdesktop
 		if not
 			rm -f /env/windeskcur_^$curdesktop
+
+		# show current window right away
+		if(test -f /env/windeskcur_^$1){
+			winid=`{cat /env/windeskcur_^$1}
+			if(test -f /dev/wsys/^$winid && test -f /env/windesk_^$winid && ~ `{cat /env/windesk_^$winid} $1){
+				echo unhide >/dev/wsys/^$winid^/wctl
+				echo current >/dev/wsys/^$winid^/wctl
+			}
+		}
 	}
 
+	hide=()
 	for(f in /dev/wsys/*){
 		winid=`{basename $f}
 		if(! ~ `{winlabel $f} $sticky && ! test -f /env/winsticky_^$winid){
@@ -66,7 +76,7 @@
 			if(~ $shift 1){ # moving the current window elsewhere
 				if(~ $a(5) current){
 					echo -n $1 >/env/windesk_^$winid
-					echo hide >$f/wctl
+					hide=($hide $f/wctl)
 				}
 			}
 			if not {
@@ -76,8 +86,8 @@
 					echo -n $curdesktop >/env/windesk_^$winid
 					# it was visible, make sure riow doesn't think otherwise later on
 					rm -f /env/winhidden_^$winid
-					# and hide
-					echo hide >$f/wctl
+					# and hide later
+					hide=($hide $f/wctl)
 				}
 				if not { # hidden
 					windesk=`{test -f /env/windesk_^$winid && cat /env/windesk_^$winid}
@@ -93,14 +103,10 @@
 			}
 		}
 	}
-	if(~ $shift 0){
-		if(test -f /env/windeskcur_^$1){
-			winid=`{cat /env/windeskcur_^$1}
-			if(test -f /dev/wsys/^$winid && test -f /env/windesk_^$winid && ~ `{cat /env/windesk_^$winid} $1)
-				echo current >/dev/wsys/^$winid^/wctl
-		}
+	if(~ $shift 0)
 		curdesktop=$1
-	}
+	for(w in $hide)
+		echo hide >$w
 }
 
 fn togglesticky {