You are looking for the focus follows mouse option, make sure it is turned on to get the functionality you desire.
Never used it myself, so I wouldn't know if it still works (got used to the click way of changing the focused window), but that is the option you are asking about.