A square is inscribed in a right triangle whose short sides are in the ratio of 1:2. What is the length of the side of the square in terms of the length of the shortest side of the circumscribed triangle?

I tried assuming that the shortest sides were 1 and 2, which makes the hypotenuse sq. root 5

Then I solved for the area of the whole triangle and I got 1

So then I made 1 = (1/2)(1-w)(2-w)

But for some reason I got w = 3 or 0 which doesn't work out...