Today I was working on a couple of remote systems from my Mac. First, I was working on an Xserve, to which I had connected via Screen Sharing (Apple’s built-in VNC client in Mac OS X). Secondly, I was working on a Linux virtual machine via the vSphere client running on a Windows 2003 server. I had connected to this Windows box via MS Remote Desktop. I had to reboot the Xserve to install updates, and while I was waiting for the VNC connection to be reestablished, I switched over to the RDC session and started working on the Linux VM.
I opened a terminal window and started working—downloading code, compiling it, etc. I was halfway through typing a command when all of a sudden it seemed as though the space bar had become stuck. I don’t write this because the space bar was physically stuck; it just seemed that way because in the Linux console, the command line was filling with spaces. I quickly typed Control-C, but nothing happened. The spaces continued to appear, many tens per second, until the first half of the command I had typed had scrolled off the top of the terminal window. What was going on?
It was then that I realized that the VNC session had been re-established to the rebooted Xserve, and that Screen Sharing had stolen focus, forcing itself to the foreground, albeit on another display. Screen Sharing must have stolen focus between the time when I pressed the space bar down and the time when I released it. The remote box I’d been working on just assumed I was still holding down the space bar. This time, no damage was caused by this bug; however, it’s easy to imagine scenarios where this sort of problem could wreak real havoc.
Focus stealing is evil. Fix it, Apple!