Why not just link a keypress to a /window -h/w and save yourself the hassle of monitoring window states. i.e.

alias lock {
set %lock $iif($1 == -r,0,1)
var %i = $window(*,0)
while (%i) {
window $iif($1 == -r,-w,-h) $+(",$window(*,%i),")
dec %i
}
}

alias cf12 { lock $iif(%lock,-r) }

ctrl+f12 to un/lock, simply hides the switchbar data.

Eamonn.