Why is the desktop treated so special in window ordering?

Raymond Chen

Clipboarder Gadget wants to know why the desktop is treated so special in window ordering. Specifically, when you double-click a folder icon on the desktop, and the immediately close it, why does focus not go back to the desktop? Instead it goes to some random window. Actually, it’s the other way around. Focus is going to a random window specifically because the desktop is not being treated special. The rules for focus transfer when a window is closed is that focus goes to the owner, if any. If there is no owner, then the window manager starts looking around, in a rather complicated way, but the next enabled window in the Z-order is on the candidate list. And since the desktop sits at the bottom of the Z-order, it almost never wins the “next enabled window in the Z-order” contest. Having the desktop somehow “jump the queue” and gain focus under certain conditions would mean giving the desktop special treatment. Even if you wanted to grant the desktop that special treatment, what would the rules be for deciding when to grant the desktop exception? The Explorer window for the folder you opened has no special connection to the desktop window in the window hierarchy. It belongs to a different thread. Depending on how your system is configured, it might even be in another process. What would you use to determine that closing that window should move focus to the desktop? Consider: You double-click the icon to open the folder. Then you click on Notepad. Then you click back on the folder window and close it. Shouldn’t focus go to Notepad? Why should the desktop be special?

[Raymond is currently away; this message was pre-recorded.]


Comments are closed. Login to edit/delete your existing comments

Feedback usabilla icon