My Rxvt Patches

Rxvt is a pretty nice resource-saving terminal emulator and was actually the one I exclusively used from around 1998 until 2017. The reason why I switched back to xterm in the end was that I wanted to have better mainline UTF-8 support in a way that I could configure Cygwin and Unix to use the same configuration. Doing this would have required a couple of patches with rxvt and with its slightly complicated build system (at least on Cygwin), I simply decided to invest my time elsewhere.

Some of the patches I've been using over the years I explain below, maybe some people find them useful.

DPI awareness (Cygport version)

This is the patch (applies in a prepared cygport directory with -p1), which addresses the following concerns:

rxvt-cygport-20050409, which ships with Cygwin, does not read system DPI, so if DPI virtualization is enabled (Vista-onwards) it will be scaled if the desktop doesn't run at 96 DPI.

What you will get with the patch is "system DPI awareness". This means that Windows will not scale the application for the primary display. It will still be scaled for secondary displays, if their DPI differs (8.1-onwards). This is an acceptable compromise; it is also the level of DPI awareness that cmd.exe uses.

After applying the patch and building rxvt.exe, you need to add the manifest snippet that contains the actual DPI awareness declaration. This can be done with the following command:

mt.exe -outputresource:rxvt-20050409-21.i686/inst/usr/bin/rxvt.exe;#1 -manifest SystemDPIAware.manifest

Note that the patch does not scale scrollbars. This is still an open issue. For up to 150 DPI, this shouldn't matter much; above that it becomes a problem. It would be easy to scale the boundaries that rxvt communicates to its scrollbar plugins by the same factor that is used for the terminal window font, and this would already be quite usable; a better solution would also take care of X resources used by the scrollbar plugins. An even better solution would probably implement Win32 scrollbars in an rxvt scrollbar plugin. Anyway this is sort of out of scope for me at the moment.

Resize increments on Win32 (Cygport version)

This is the patch (applies in a prepared cygport directory with -p1), which addresses the following concerns:

rxvt-cygport-20050409, which ships with Cygwin, does not implement resize increments when running as GDI application. Only the X11 interface supports it.

However, it is possible to do that on Windows as Vim or GNU Emacs show. Vim does it by handling the WM_SIZING event, while Emacs uses the WM_WINDOWPOSCHANGING event. Both approaches are fine although WM_SIZING has better user feedback when resizing a window in "rubber band" mode, so I chose to base the implementation on that event.

Like in the GNU Emacs implementation, the resizing constraints are stored in extra window bytes; rxvt's window class is altered accordingly.

Scrollbar drawing errors in newer rxvt versions

This is the patch, which addresses the following concerns:

rxvt-2.7.x (this also applies to the Cygwin snapshot versions, such as rxvt-20050409-*.cygport) draws NeXT-style scrollbars in a slightly different manner compared to 2.6.x, extending the stipple pattern all the way below the buttons, which looks slightly awkward. It also gets the black border line wrong when the scrollbar is shown on the left hand side of the window. The 2.7.x code does use fewer drawing operations generally, so I think all in all it is an improvement, but the code needs to be patched to get the flawless 2.6.x appearance back.

Also, on Cygwin's rxvt build, the W11 library code introduces additional problems because the underlying GDI functions treat pixel boundaries in a slightly different way than X11 does. This causes NeXT-style and rxvt scrollbars to show missing pixels.

The patch includes adjustments to the W11 code to behave more like X11, eliminating the errors for NeXT-style and rxvt-style scrollbars. Note that this causes a few more GDI drawing operations than in vanilla rxvt-2.7.x; it should however be all but negligible.

Below are a few images for comparison of patched and unpatched versions.

This is the flawless appearance of rxvt-2.6.4 (with FVWM flat decor):



This is the slightly different way rxvt-2.7.10 draws the scrollbar. Note the stipple pattern leaking from the trough region, and the black border missing.

This is the appearance of 2.7.10 with the patch applied. It mimicks the 2.6.4 look.



Unpatched (left) and patched (right) versions of rxvt-20050409-21 running on Cygwin on Windows 7:



Unpatched (left) and patched (right) versions of rxvt-20050409-21 with rxvt scrollbar enabled running on Cygwin on Windows 7:


Last change 2017-10-03