Python 2, 208 184 169 167 164163 bytes
w,h=input()
def f(x):global p;a=p;p&=~2**x;a>p>[xg;o=g;g&=~2**x;o>g>[x/w==(x+qx+s)/w<f(x+qx+s)or-1<x/w+q<h<fw+s<h<f(x+q*wx+s*w)for qs in[-1,1]]
i=k=1<<w*hn=i=1<<w*h
while ki:p=k=kg=i=i-1;f(len(bin(pg))-3);i;n-=p>0=g>0
print iprint~-1n