The best way to protect the window frame from water damage is to install a drip cap flashing. This Z-shaped piece of metal fits under the shingles or siding, above the window frame. The other side of the drip cap flashing hangs over the window frame, allowing water to drip over the frame and not onto it. Even if water gets underneath the shingles or siding, the drip cap flashing will divert the water out of harm's way. Keep the flashing sloped to drain off the water.