I explored a lot of forums but most of them assumed that the problem was caused by some application that was running in the background. In some cases, the problem and solution might be in that direction; but in mine, it didn't have anything to do with background applications, browsers, etc.

I bet the actual source of the problem in my case might be the actual case for many people.

I'm using a laptop and the touch pad is active. (It happens to be a Samsung Chronos Series 7.)

The problem lies in some of the fancy features of modern touch pads; in particular, actions that are triggered by "swiping in" on the touch pad from the left, right, top, or bottom. The default settings tend to involve doing something or going somewhere that results in the current window losing focus.

So what happens is that the user, for example, is typing away and unknowingly brushes against the touch pad near its edge with part of their hand or their shirt. The computer interprets it as "brushing from left (or right or top or bottom)" and then does something and a byproduct of that action is that the current window loses focus.

The solution (if the user wishes) is to turn those "sweep from..." settings off.

On my laptop, that involved the following steps:
  • go to <control panel>
  • click <touch pad>
  • In the "touch pad settings> dialogue, deselect the following:
    • left edge swipe
    • right edge swipe
    • top edge swipe