Tuesday, November 10, 2009

On the Difficulty of setting the Windows 7 Desktop Wallpaper

You need to be a software engineer to precisely and correctly set the Windows background in Windows 7.

I have a multi-monitor setup, and I use a very particular method for laying out windows on my secondary screen: I have them cascaded, from the top-left corner of the screen towards the bottom right, such that a little of the bottom-left corner of every window is visible on-screen at all times, like this:

The corners form a mechanism for switching between windows based on spatial layout. Certain windows, such as terminals, browsers, email apps, etc. have "natural" dimensions. Browsers generally like to be page-shaped; terminal windows are quite squat; documentation browsers are somewhere in between, with a treeview on the left and a content pane on the right. These natural shapes guide their spatial positioning. So, all my terminal windows end up cascaded one after the other on at the top left of the screen, followed by Firefox's downloads window, then my bug tracker client, then Thunderbird, then MSDN documentation, with Firefox at the bottom-right, filling the full height of the screen.

Switching between applications based on their spatial layout turns out to usually be more efficient than almost any other scheme, particularly when one's hands aren't on the keyboard. Even alt-tab doesn't distinguish very clearly between different instances of e.g. a terminal app, when in fact each one may be logged in via ssh to different machines and thus it matters very much which one I select.

This scheme works well enough, but the bottom-left corners can get a little ragged. To make aligning the corners easier, I have a special wallpaper which consists of a line carefully placed so that it shows up on the bottom-left corner of my second monitor. When the wallpaper mode is set to "tile", a wallpaper which is big enough to cover the entire desktop area will show up at the expected offset, and everything works out OK.

This wallpaper, a 16-colour bitmap, is so small when compressed that I can embed it here uuencoded directly:

begin 644 wallpaper2.bmp.bz2

If you save that to a file with a '.uue' extension, many common archivers, such as WinZip or WinRar, will be able to open it up. Here's what the meat of it looks like, anyway:

However, it turns out, if you try to set this background using the "Personalization" Control Panel applet in Windows 7, it does some helpful "conversions" on it: it appears to round-trip the damn bitmap through JPG, resulting in artefacts. I've enhanced a zoom of the line after Windows has butchered it:

The line looks unclean, and in particular, it ends up with wave of intensity throughout its length, which is quite distracting and not the desired effect.

Things can get worse though; if you try to use Windows Photo Viewer to set the background using the original bitmap, it will actually resize the thing down to fit the dimensions of your primary monitor (!!!), all but zooming the line out of existence. This drove me up the wall for about 20 minutes, as I tried to figure out where my line had gone when I first transitioned from XP to Windows 7.

The easiest way I currently know to correctly set the Windows 7 desktop wallpaper is to write a program that uses the SystemParametersInfo function directly, to ensure the bits get through unmolested.

I have a lot more Windows 7 annoyances where this came from, but this one cost me quite a bit of time, so it sticks out. My verdict on Windows 7 is pretty mixed. Many applications, particularly games, are incompatible, and overall I dislike the shell compared to XP, especially Windows Explorer and the Vista-esque Start Menu. About the best things I can say in favour of the move is having less concern about future compatibility, and having a 64-bit mode that mostly works, despite all the horrific hacks going on beneath the covers to make it happen. Oh, and I'm running with UAC disabled. I can only take so many access denied errors as I poke around the system before I crack - and command-line apps generally just give you the error, rather than popping up an elevation prompt.


David Heffernan said...

Running with UAC disabled? That's quite wimpy of you!

Actually I feel strongly the developers should have UAC on since it will help them learn how it works and discover when their software breaks under UAC.

I run an old version of Delphi and have to apply ACLs to the Delphi program files directories to let Delphi write various config files there! If the devs were running with no privileges then that would never have happened.

I also predict that once you get used to the search in the Vista/7 start menu you'll hate going back to games of mousy maze in XP.

Barry Kelly said...

I don't play mousy maze games with the menu - it is entirely organized in most often used order, with the most often used at the bottom, close to the mouse position. But I can't stand the treeview in the menu.

As for the search, I don't mind having a search feature, but if I wanted to type to start an application, I'd do it from one of my terminal windows. That way I get to control the search mechanism.

Unknown said...

This is a cheeky plea, having stumbled upon your blog a few weeks after entering the world of Windows 7, from NT. I am not a programmer but a user, a science researcher. I started computing with an IBM 1620 card reading monstrosity in the 60s, when you often edited the machine code directly with the console typewriter rather than spending time and cards for an intermediate deck in order to re-compile a program.

Windows Explorer has a "preview" pane. It will not preview a simple ascii text file if the extension is not standard, even if the default application for that extension has been specified.

How does the previewer decide how to read the beginning of a file and display it?? Can I force it to read a file that has a standard format??

Can you recommend a place where I can ask or discover the answer?

In hope!

Warren said...

Windows 7 has the distinct benefit so far, of not having Vista's buggy driver set. I used to get a lot of video driver "crash and restart" in vista, although not so much any more. But I do get the whole machine locking up (mouse not responding, screen frozen) as well as BSODs on Vista.

Win7 has been driving me nuts with UAC on, which I leave ON because I want to find the problems my users will have with the apps I write, if they have UAC on. I hate UAC but it's on because my customers will have it turned on. I use Win7 because my customers need apps from me that work well in XP, Win7 and Vista. Or I'd just run XP with the GUI crap dialed back to a Windows 2000 look and feel.


Anonymous said...

Found a solution to have your desktop wallpaper image without the jpeg artifact of windows 7 conversion.

Open your lossless BMP image in Firefox, right click the image, and select “Set As Desktop Background…” This solution is weird since it lets you use a bitmap as your wallpaper. So, obviously, the code is there to let you do this.

solution found on