Saturday, October 18, 2014

TopIt - Window utility for Windows

It's been many years since Linux became my #1 OS of choice, for a variety of reasons. However, I changed job recently and one unfortunate side effect of that, is that I'm now having to spend my work hours on Windows again. Apart from the lackluster command-line, bloated environment, inhospitable development experience etc. etc. one of the annoying aspects, is how desktop and window management basically haven't changed since Windows 95 - for instance, it's still up to the individual application in question, whether it wants to allow the user to pin down a window, promoting its z-order to always be on top. This blog entry is about my attempt at bringing a bit more power to window management as seen from a Linux user.

Gnome Linux desktop
Talking about "the Linux desktop" is a bit of a misnomer. There are of course countless of XOrg window managers. All the recent KDE and Gnome versions I've come across, supports being able to pin a window on top (promote z-order), move a window to a specific workspace/desktop and control a windows transparency/opacity.


In Cinnamon, the Mint fork of Gnome Shell, z-order behavior is build right in!


Crap-ware nightmare 
There have never been a shortage of 3'rd part tools available for Windows to empower users, the problem is... finding them and knowing the flowers from the bad weed. Traditionally there's lots of spy-ware, share-ware, trial-ware in the Windows Eco-system.

I set out with a relatively modest goal, to find a simple application that would allow me to pin a window as the top-level window - something I use all the time for small TODO lists, calculator, chat applications etc.

One application turns up in Google searches as the de-facto solution to the problem, namely Window On Top, which also got a favorable mention on LifeHacker. I downloaded the application, installed it and all seemed fine and dandy... until I was met by a nag screen.


Bait-n-switch in action, Window On Top appears to be trial-ware!

Although neither the authors website, nor LifeHacker, has any mentioning of it being trial-ware, the application costs a whopping $20 - a ridiculous amount for something so simple! A similar utility called MooO which also got a mentioning on LifeHacker, is apparently infested with tool-bars and who knows what other crap.

Realizing full well how I may sound like a grumpy old fart with a long beard and entirely too much time on my hands, these crap-ware experiences made me want to try to solve this problem for myself.

Introducing TopIt
It's been some 10-15 years since I played around with the Windows API's. Back in the Visual Basic and MFC days, if you had to do something just remotely interesting, you had to call C/C++ functions from the core DLL's, so I had a pretty good idea as to how to go about this.

It took a few mornings and evenings of tinkering (when the wife and baby are sleeping), but I now have something entirely functional. In fact, it does more than just toggle a window on/off top - I guess you could argue that it already suffers from feature creep.


TopIt manipulating opacity/transparancy of a third-part window

These features are to be considered stable and tested:
  • <Alt>+<Z> Toggles the "always on top" Z-order lock of a window
  • <Alt>+<X> Completely hides the window temporarily (until combo hit again)
  • <Alt>+<C> Toggles the re-sizable/movable border of a window on/off
  • <Alt>+<Num Plus> Increases opacity (removes transparency) of a window
  • <Alt>+<Num Minus> Decreases opacity (adds transparency) of a window
The following features are tested but somewhat experimental:
  • <Alt>+<Num 5> Tries to expand window to take as much desktop space as available
  • <Alt>+<Num 2> Selects bottom edge of window for manipulation
  • <Alt>+<Num 8> Selects top edge of window for manipulation
  • <Alt>+<Num 4> Selects left edge of window for manipulation
  • <Alt>+<Num 6> Selects right edge of window for manipulation
These features are highly experimental and may or may not work:
  • <Alt>+<Num 7> Selects  top-left edges of window for manipulation
  • <Alt>+<Num 9> Selects  top-right edges of window for manipulation
  • <Alt>+<Num 1> Selects  lower-left edges of window for manipulation
  • <Alt>+<Num 3> Selects  lower-right edges of window for manipulation

You can get TopIt by downloading the raw x86/x64 executable or by cloning my reposatory on GitHub and building it yourself from source. The latter is preferable, as its the bona-fide approach to ensuring what you install on your computer. The memory footprint is absolutely minuscule, requiring just about 800KB of RAM.

Note that if you download the binary executables, you will have to launch it automatically when Windows boots. You can do so by including it in the Windows Start Menu "Startup" folder.

Since starting out on this project, I have since become aware of the utility called PowerMenu which looks very close to what I wanted originally, apparently without being crap-ware. The application is donor-ware, so should be safe to download and you'll likely want to use it rather than TopIt, since it is older and thus better tested. However, my efforts are not entirely wasted, as I plan to expand on TopIt further to get me some more power-features at a minimum overhead. Lot's of ideas come to mind:
  • Application screenshot (invoking "Save as..." dialog)
  • Emulation of multiple workspaces/desktops
  • Dockable and snapping windows
  • Menu item injection
  • Move applications to/from systray
  • Programmable hotkeys
Should you have any cool ideas which would boost your productivity on Windows, you are of course more than welcome to drop me a line about it or fork the code on GitHub and add it yourself. :)