March 4th, 2015

Why are the dimensions of a maximized window larger than the monitor?

When you inspect the window rectangle of a maximized window, you might notice that its dimension are actually slightly larger than the screen. The upper left corner is something like (−8, −8) and the lower right corner is correspondingly eight pixels beyond the bottom right corner of the screen. Why is that?

The extra eight pixels that hang off the screen are the window borders. When you maximize a window, the window manager arranges things so that the client area of the window fills the width of your work area, and it plus the caption bar fills the height of the work area. After all, you want to see as much of your document as possible; there’s no need to show you the window borders that aren’t doing you any good. (It leaves the caption bar on the screen for obvious reasons.)

These extra pixels hanging off the edge of the screen don’t normally cause any distress. At least, not until you have multiple monitors. And then they kind of annoy you, because they bleed over into the adjacent monitor.

Oh well.

Bonus chatter: When the taskbar was originally written, multiple monitor support did not yet exist in Windows, and the taskbar took advantage of this by simply letting its borders hang off screen, and when it went into auto-hide mode, it just moved itself off-screen save for a sliver of pixels. When multiple monitor support was added, those pixels bled over into adjacent monitors, and in the case of an auto-hide taskbar, you could see where the taskbar was hiding, because it merely slide onto the adjacent monitor. The taskbar fixed this by explicitly clipping itself to the target monitor.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.