Fixing Applications Which Resist Feeling Platform-Native

NOTE: I will update this post as I run into more application frameworks which need a little encouragement to feel native on my KDE desktop. While a lot of the technologies covered are strongly associated with Linux, they do still tend to be portable, so this information isn’t exclusively for Linux.

It seems like, these days, the rise of Electron and other web-based application toolkits has emboldened every two-bit UI designer to forget that the point of a user interface is to fade into the background and let the content gain full focus. (And that means consistency is paramount.)

I won’t go into detail on that, given that others have already done that:

It doesn’t help that everyone (including Apple) seems to have forgotten Joel Spolsky’s Things You Should Never Do, Part I and that the computing world in general has been sliding in this direction since 2002.

…but it is still my computer, and I still have to live with it… so here’s a reference for how to apply UI customizations to various applications and UI toolkits as an end-user.

Firefox

Call me crazy, but I have to wonder what’s going on at Mozilla headquarters that nobody seems to have asked “Is it possible that making our UI chrome feel less similar to platform-native UI than Google Chrome’s, and grabbing user attention with whizbang elements of dubious value… is hurting our user appeal, not helping it?”

Anyway, here’s a summary of the relevant guides on /r/FirefoxCSS (See also userChrome.org):

  1. Enable userChrome.css:
    • Open up about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true
    • Create chrome/userChrome.css inside your profile folder (There’s a button to open a file browser window for your profile inside about:support but I somehow broke it while locking down my Flatpak install of Firefox further.)
  2. Enable the browser inspector:
    • Open the developer tools (Ctrl + Shift + I on Linux or Windows), open Settings (the cog which may be inside the overflow/… menu), and enable “Enable browser chrome and add-on debugging toolboxes” and “Enable remote debugging”.
    • Restart Firefox
  3. Write your CSS tweak:
    • Press Ctrl + Alt + Shift + I and choose OK in the “Incoming Connection” dialog (It will probably have appeared behind the unnamed, empty window which will become the browser inspector)
    • You will now have something that looks like the browser’s developer tools but lets you inspect and manipulate the browser’s UI instead. It’ll initially be an ugly vertical split with a log on the left but that will eventually go away. (I don’t know how to make it go away faster)
    • Use the “Inspector” tab to identify what to change
    • To actually make changes, select “Style Editor” and use the “Filter style sheets” field to find userChrome.css. This way, if you like the changes, all it takes to persist them is to click “Save” in the userChrome.css entry in the vertical tabs down the left side.

Here are a few examples of tweaks you can create:

/* Remove pointless thumbnail in the Bookmark popup
   (Why?! You can always see the full version while bookmarking anyway.) */
#editBookmarkPanelImage,
#editBookmarkPanelFaviconContainer {
  display: none !important;
}

/* Hide "Saved to Library!" bookmark confirmation popup
   (The star in the address bar having stayed filled already says that.) */
#confirmation-hint {
  display: none !important;
}

/* Compact sidebar header to match my compact toolbars
 * BUG: https://bugzilla.mozilla.org/show_bug.cgi?id=1435184 */
#sidebar-header {
  height: 32px !important;
  padding: 0 !important;
  font-size: 12px !important;
}

Thunderbird

All the same steps as with Firefox apply (including the caution that the “Incoming Connection” dialog will probably fail to put itself at the top of the window stack), but the means to enable things are in slightly different places. (Thanks to this Superuser Q&A and this /r/Thunderbird thread for helping me piece things together)

  • To access about:config so you can enable toolkit.legacyUserProfileCustomizations.stylesheets, go into the “General” page of settings, scroll down to the bottom, and click the “Config Editor…” button.
  • Instead of typing about:support into the address bar, you can find the button to open your user profile to add chrome/userChrome.css under Help > More Troubleshooting Information.
  • The option to open the developer tools is at Tools > Developer Tools > Developer Toolbox

An example customization you can create would be this:

/* Override the horrendous UI font that Thunderbird suddenly started choosing
   (i.e. Match Qt, GTK+ 2.x, and GTK 3 apps)  */
* {
   font-family: "Noto Sans", "Nimbus Sans L", "Droid Sans", sans-serif !important;
}

NOTE: As of at least Thunderbird version 115, you’ll want to remove the @namespace line from any suggested userChrome.css content or you’ll be fighting an uphill battle to apply changes to the increasing number of elements of Thunderbird’s UI that are HTML instead of XUL.

GTK 3+

Starting with GTK 3, the GNOME people and I have… differences of opinion… made worse by how the links I started with find more fodder in GTK 3 than any other system. While I’ve managed to replace most GTK applications on my desktop with Qt equivalents by now, there still exist a few of them (eg. Inkscape) with no viable replacements.

While such apps are, thankfully, not trying to embrace GNOME-isms that run counter to hard-won design principles from HCI research, they’re still being dragged along for the ride by the GNOME-isms creeping into GTK components outside libadwaita.

  • Archlinux Users: If your intent is to make your GTK 3 stuff feel more native on a non-GNOME desktop, start by installing the gtk3-classic package from AUR. It contains a GTK 3.x patched to revert some of the hard-coded GNOME-isms.
  • Other Distros: If your goals include disabling some visual inconsistency caused by GNOME applying client-side window decorations (eg. drop shadows on context menus), gtk3-nocsd will resolve that… but it is an LD_PRELOAD hack, and getting it to work reliably when Flatpak isn’t designed to allow LD_PRELOAD hacks is iffy, so I’d suggest using it as a last resort.

Settings

No matter how much user-hostility we may feel is present in the GNOME developers’ behaviour these days, they do still allow some customization, so always check that before getting hacky.

For GTK 3, settings are customized by putting lines like gtk-dialogs-use-header=0 into ~/.config/gtk-3.0/settings.ini. For GTK 4, it’s ~/.config/gtk-4.0/settings.ini.

Valid settings.ini keys are documented as properties under the relevant GTK version’s GtkSettings API documentation. (eg GtkSettings for GTK 3)

Here are some suggested changes mentioned on Archwiki:

  • gtk-can-change-accels = 1 is a deprecated GTK 3 option that lets you hover your mouse over a menu item and then press a hotkey to assign to it.
  • gtk-toolbar-style=GTK_TOOLBAR_ICONS is another deprecated GTK 3 option that will give you icon-only toolbar buttons without needing to reach for the CSS overrides (That’s what tooltips are for, don’t you think?)
  • gtk-overlay-scrolling = false is listed as API-unstable, but should replace those touchscreen-style overlay scrollbars with ones where you don’t need to wiggle the mouse to see what your current scroll position is.

There’s also the gsettings set org.gtk.Settings.FileChooser startup-mode cwd command (which you may need to run inside your Flatpaks) to restore the “old-fashioned” behaviour of having GTK file chooser dialogs start in the current directory rather than the recent files list.

Themes

Flatpak should automatically install the Flatpak version of whatever GTK theme you’re using but, if it doesn’t the first two things to try are:

  • Make sure whatever settings daemon your desktop uses is installed and running. If the active theme isn’t being announced, then flatpak upgrade can’t install it.
  • It’s possible your theme hasn’t been packaged for Flatpak. The Stylepak tool will grab whatever GTK theme is active on the host and construct a Flatpak package from it.
  • There’s currently a bug that can cause Flatpak’d GTK applications to revert from Breeze to Adwaita on KDE desktops. To work around it, just go into the Application Style system settings module, click the Configure GNOME/GTK Application Style... button, fiddle around with one of the drop-downs to enable the Apply button, put the themes back to what you want, and click Apply. (I haven’t yet investigated a permanent fix.)
  • According to this thread, there are situations where a customized Breeze color scheme (I just use the default) won’t get applied to GTK 3 apps, and the workaround is a global filesystem override (either via Flatseal or manually editing ~/.local/share/flatpak/overrides/global) to grant access to filesystems=~/.local/share/icons:ro;~/.themes:ro;~/.icons:ro;xdg-config/gtk-3.0:ro;
  • libadwaita-based apps aren’t meant to be themed beyond the light/dark switch and the recolouring API they eventually want to add, but, if the theme was designed to support it, you can force the issue by setting the GTK_THEME environment variable. I recommend doing it on a per-application basis rather than globally.

Open/Save Dialogs

This is one area where things are actually getting better for desktop consistency and user customization instead of worse. If your goal is to get all apps using the same desktop-provided Open/Save dialogs, the GNOME people are on board with that. Thanks to the XDG Portal system, anything that uses GtkFileChooserNative (GTK 3) or GtkFileDialog (GTK 4) instead of GtkFileChooser (holdover from GTK+ 2) is capable of delegating to a common dialog service provided by your desktop.

  • Where possible, install applications through Flatpak or Snap. You’ll get the maximum amount of XDG Portal support by default, you won’t have to upgrade your whole distro to get access to new versions which add more portal support, and any testing the package maintainer does will be done with them enabled.
  • Anything using GtkFileDialog will use portals by default where available.
  • GtkFileChooserNative only uses portals when running under Flatpak/Snap by default, because of buggy behaviour in certain GNOME apps. However, if you’re not using those GNOME apps, you can set an environment variable named GDK_DEBUG=portals (formerly GTK_USE_PORTAL=1) to forcibly enable them.
  • Firefox/Thunderbird: If not using the official Flatpak or Snap packages, open up about:config and set widget.use-xdg-desktop-portal.file-picker to 1

Widgets and/or libadwaita

While I still think the need for it in this situation is a giant regression, I have to applaud the GTK developers for once again demonstrating that, regardless of my disagreements with them on what constitutes good UI design goals, their underlying infrastructure since the beginning of the GTK 3 era (GIR, gtk-rs, etc.) has been admirable.

As of GTK 3.14, they now have an equivalent to the Firefox Browser Toolbox that I pointed you at further up. It’s called GtkInspector, and it’s now a standard part of all GTK installs that just needs to be enabled through one of these means:

  • Run gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true. Any GTK application started after you did that will open GtkInspector when you press Ctrl+Shift+D.

    (If it’s a Flatpak, you may need to use flatpak run --command='sh' <AppID> or flatpak enter <AppID> and run the gsettings command inside the Flatpak.)
  • Run the application with the GTK_DEBUG=interactive environment variable set. The inspector will open automatically.

Here are some tips:

  • GTK extends CSS with a @define-color name #c01040; construct, and those defined colours are referenced by using @name where you might otherwise use something like #f0f0f0 or white.
  • If your Flatpak app isn’t obeying the colours you expect and the widgets used by the application are very similar in Adwaita and your chosen theme, check the Visual tab in the inspector to see if it’s just falling back to Adwaita. See my previous comment about an open KDE bug for a workaround for that.
  • Look at the class name (eg. GtkPaned) in the Object tab’s header (to the right of the drop-down button) and search for it in the online GTK API documentation for whichever version of GTK you’re dealing with. Each entry has a “CSS nodes” section (intended to allow application developers to customize their UI) which will help you craft your overrides. (eg. GtkPaned under GTK 4)
  • Don’t get demoralized if your changes don’t seem to be doing anything. It is more finicky than tweaking Firefox’s UI using the Browser Toolbox.

To make changes to GTK 3 apps global and persistent, put the CSS you figure out into ~/config/.gtk-3.0/gtk.css. Here’s a fix I’m currently using:

/* Workaround for [Breeze] [Bug 414763] */
scrollbar trough { min-width: 6px; }
scrollbar:hover trough { min-width: 6px; }
scrollbar.horizontal trough { min-height: 6px; }
scrollbar.horizontal:hover.horizontal trough { min-height: 6px; }
scrollbar slider { min-width: 6px; }
scrollbar slider:hover { min-width: 6px; }
scrollbar.horizontal slider { min-height: 6px; }
scrollbar.horizontal slider { min-height: 6px; }

Fonts

As of GTK 4, lots of people without HiDPI displays have been complaining about blurry text. (i.e. the forcing of the “accurate glyph positioning is more important than crisp glyph edges” approach to low-resolution font rendering that Apple has been using since they stopped using bitmap fonts, long before high-DPI displays as opposed to the approach Microsoft has historically taken of using “font hinting” to find the least bad way to nudge lines to line up with pixel boundaries.)

None of the remaining GTK apps on my desktop have upgraded off GTK 3 yet (in fact, the Geeqie Flatpak finally considered their GTK 3 port debugged enough to migrate off GTK+ 2.x today) but I’ve read that making sure you’re on GTK 4.6 or newer and adding gtk-hint-font-metrics=1 to ~/.config/gtk-4.0/settings.ini will help.

See also the GTK page on Archwiki and, if you’re trying to harmonize GTK and Qt, the Uniform look for Qt and GTK applications too.

Ttk (Themed Tk)

Here’s a list of Ttk themes you can browse through to find something as close as possible to the rest of your desktop.

If their Installation guide isn’t enough, I wrote about how to to it more manually years ago.

Wine

Last time I tried using Wine’s .msstyle support (many years ago), it made the UI sluggish to respond, so I just found a .reg patch to apply the default Breeze colour scheme to regular Windows 9x-style Win32 widgets instead.

From what I remember, applications have to opt into themed widgets on Windows, while basic colour schemes go back at least as far as Windows 3.1, so you’d probably benefit from one of these even if you do enable a .msstyle theme… though the comments on the Breeze Dark colour scheme do point out that Wine 7.4 gained an on-by-default msstyle named “Light” that you may need to switch back to “(No style)” in winecfg.

Here’s what I used, plus a dark variant of it:

Web Apps

Tons of people have written about restyling things with CSS userstyles, so I’ll just give a few tips:

  • You can access Firefox’s normal context menu with Shift+RightClick if it’s been overridden.
  • You can access things like Page Info without knowing their keyboard shortcuts by tapping Alt to reveal the traditional menu bar.
  • I recommend Stylus as a userstyle host for Firefox and Ungoogled Chromium.
  • Here’s an example where I worked around Discord’s lack of easy-to-match CSS classes to turn off the distracting visual cacophony of customized username colours:
/* I don't want my chat client to look like a Hawaiian shirt, thanks. */
span[class^=roleColor-], span[class*=' roleColor-'] {
    color: #72767d !important;
}
span[class^=username-], span[class*=' username-'] {
    color: #23262a !important;
}

For the record, the ability to do this is one of the reasons I prefer in-browser versions of unavoidable web-tech to Electron versions. (The other major reason is that they’ll accept tighter sandboxing.)

Posted in Geek Stuff | Leave a comment

Learning Materials for getting into Windows 3.1 programming

As with my other recent post (Learning Materials for getting into C programming for MS-DOS/PC-DOS/DR-DOS/FreeDOS), I’m also gearing up to do the Windows 3.1 hobby programming I wanted to do as a kid but couldn’t, and that means collecting learning resources for that too.

NOTE: I haven’t managed to research the intermediate and advanced materials as thoroughly as for DOS yet, so suggestions are welcome.

C Programming itself
As with DOS programming, I don’t want to recommend the books I just happened to use. Any book should do.
Segmented memory models in C, linked lists, hash tables, and the trade-offs therein
Win16 adds more to memory management on top of what’s available in DOS, but it’s fundamentally still just real-mode C or C++ programming, so start by learning the same things.
Borrow Microsoft C: Secrets, Shortcuts, and Solutions by Kris Jamsa from the Internet Archive’s book library and read chapters 25 (Dynamic Memory Allocation) and 28 (Understanding Memory Models) and borrow Advanced Turbo C by Herbert Schildt and read Chapter 3 (Dynamic Allocation) and Appendix A (Turbo C Memory Models).  (I didn’t find either to communicate the relevant ideas ideally, but seeing the same thing explained by two different people really helps.)

Alternatively, Schildt’s Advanced C, Second Edition from the following year appears to have all the same content in the relevant sections as Advanced Turbo C does. (The first edition spends less time on those topics and I didn’t see a section on memory models in it, so I advise only consulting it if you want a dead-tree edition and can’t find any of the other suggestions from Schildt cheaply.)

See also the Special Pointer Types for Open Watcom C/16 section of the Open Watcom 2.0 C Language Reference once you’ve had things start to click.
If you want to buy just one book, buy one of the books by Schildt. Jamsa’s phrasing on memory models was a bit more illuminating for me, but Schildt’s no slouch there and he goes into much more detail on data structures, including implementing and comparing the strengths and weaknesses of three different ways to implement sparse arrays.
Windows 3.1 Application Quick Start
Read Building Win16 GUI Applications in C by Transmission Zero. It’s a quick online article/post that goes through how to produce the working skeleton of a Windows 3.1 application using a 16-bit Microsoft C Compiler but explicitly points out Open Watcom C/C++ as one of example of the any other compilers with the “necessary headers and libraries for Win16 development” that should work too.
Beginner Windows 3.1 Programming
Programming Windows 3.1 by Charles Petzold is apparently considered the gold standard for an introduction to Windows 3.1 programming. Thankfully, it’s available in the Internet Archive’s lending library and, thankfully, Mr. Petzold still offers a download of the companion floppy on the old version of his website.
In the event that you can’t use that for some reason, another one which the Watcom manuals suggest, which isn’t in the Internet Archive’s collection is Windows Programming Primer Plus by Jim Conger from Waite Group Press. It’s not in the Internet Archive’s collection as far as I can tell, so you’d have to turn to WorldCat or AbeBooks for that one.
Windows 3.1 API Reference
If you’re using Open Watcom C/C++, then you won’t have the advantage of Microsoft’s Windows API documentation.
Their manuals recommend buying the Windows API Bible (Windows 3.0 APIs) and the Windows API New Testament (Windows 3.1 API additions) by James L. Conger from Waite Group Press… both of which are also in the Internet Archive’s lending library.
Intermediate Skills
This is where things get hazy. Historically, people tended to learn about this sort of thing through journals like Dr. Dobb’s Journal, The Windows Programmer’s Journal, and so on. There are also some journal issues included on the MSDN Library Archive CD that you could get as an option from Microsoft back in the Windows 9x era and install using the CD key from the corresponding release of the regular MSDN library disc. However, those don’t turn up very often on eBay.
That said, for a less involved way to start moving beyond beginner materials, my searches turned up a book named The Windows Programming Puzzle Book by Kim Crouse… and, yes, that is another link to the Internet Archive’s lending library. To put it simply, the first third of it is a set of questions, programming challenges, and buggy programs to be fixed, and the latter two thirds are answers, including explanations for why they’re the answer.
As for DDE references, I ran across a piece of advice in Dino Esposito’s Visual C++ Windows Shell Programming which recommends the documentation included with the Microsoft Internet Client SDKs as the best place for information on DDE… which I believe are the files archived here.
Advanced Stuff
Funny enough, the advanced stuff was easier for me to find, because there are good resources in the same series as Undocumented DOS and The Undocumented PC, which I already had. Specifically, Undocumented Windows by Andrew Schulman, David Maxey, and Matt Pietrek and Windows Internals by Matt Pietrek, both available in the Internet Archive’s lending library.

See Also: Useful Info On Win16-Targeting Compilers… And a List of DOS/Win16 Resources

A Note on Convenience Over Openness

If you find writing a Windows 3.1 application in C or C++ too daunting and your primary goal is solving your own problems conveniently with no concern for making available open-source code for anyone to contribute to, there are options which are generally much easier than C or C++, but require buying proprietary software.

Suggestion 1: Borland Delphi 1.x

My first recommendation would be to search eBay for a copy of Borland Delphi 1.x on CD (either on its own or included on the CDs for Delphi 2.x through 4.x to support 16-bit development.).

It produces fast, self-contained EXEs and, for the kinds of tasks taught by Petzold in Programming Windows 3.1, it’s stupid simple.

(Having never used it before, I was able to create a “mirror a text field’s contents in a label” application in five minutes, just by dragging a couple of controls into the dialog builder that it opens into, double-clicking the text field to open up the Edit1Change handler, tentatively typing Label1.Text = Edit1.Value into it, pressing F9 (Run) to get an error message telling me my guess was wrong, and then selecting identifiers and pressing F1 or choosing “Topic Search” from the context menu to discover that it should be Label1.Caption := Edit1.Text.)

Seriously. Delphi is a ridiculously polished way to quickly whip up a GUI application, even for 2023, let alone for 1993.

Suggestion 2: Visual Basic 4 or lower

My second choice would be Microsoft Visual Basic 1, 2, 3, or 4.

It’ll be harder to find copies on eBay, they’ll probably cost more, the resulting binaries won’t run as fast, it doesn’t produce self-contained single-file executables, the IDE-Help integration can’t automatically resolve an identifier’s name to the corresponding widget’s documentation, CD-ROM versions of anything older than Visual Basic 4 are practically unobtanium, and Visual Basic 4 splits binaries across many more files than Visual Basic 3… but its ease of use is comparable to Delphi and I was still able to make the same test app in under 5 minutes when I haven’t touched BASIC of any kind in over 20 years.

Visual Basic 3 is generally agreed to be the best version for Windows 3.1 development.

Suggestion 3: WinBatch

If something more like AutoHotKey for Windows 3.1 would meet your needs, go grab a copy of the trial version of WinBatch 4.0L from the Internet Archive and see if it does what you want.

If so, go to the WinBatch website and buy a copy. They explicitly say “Support for Windows XP, Vista, 7, 8, 8.1, 10, 11, 2003, 2008, 2012, 2016, 2019, and 2022. Older versions are available for 95, 98, ME, NT, 2000, and even Windows 3.1”.

Posted in Retrocomputing | Leave a comment

Learning Materials for getting into C programming for MS-DOS/PC-DOS/DR-DOS/FreeDOS

For a while now, I’ve been wanting to get into some DOS hobby programming using Open Watcom C/C++ (or maybe gcc-ia16), but, given that DOS programming was on the wane before the Internet came around, and my childhood programming stuff is either for BASIC or a copy of Microsoft C/C++ 7.0 with reference manuals but no tutorials, that was proving kind of difficult.

However, recently, I was clued into the fact that there are actually some pretty good books I could borrow for free on the Internet Archive as a way to either determine that I wanted to buy them, or just read those crucial few pages that would make other resources make sense in the mind of a more modern programmer… so here’s what I’ve found so far:

C Programming itself
Literally any decent learning materials will do, so I don’t want to recommend the books I just happened to use.
Segmented memory models in C, linked lists, hash tables, and the trade-offs therein
Borrow Microsoft C: Secrets, Shortcuts, and Solutions by Kris Jamsa from the Internet Archive’s book library and read chapters 25 (Dynamic Memory Allocation) and 28 (Understanding Memory Models) and borrow Advanced Turbo C by Herbert Schildt and read Chapter 3 (Dynamic Allocation) and Appendix A (Turbo C Memory Models).  (I didn’t find either to communicate the relevant ideas ideally, but seeing the same thing explained by two different people really helps.)

Alternatively, Schildt’s Advanced C, Second Edition from the following year appears to have all the same content in the relevant sections as Advanced Turbo C does. (The first edition spends less time on those topics and I didn’t see a section on memory models in it, so I advise only consulting it if you want a dead-tree edition and can’t find any of the other suggestions from Schildt cheaply.)

See also the Special Pointer Types for Open Watcom C/16 section of the Open Watcom 2.0 C Language Reference once you’ve had things start to click.
If you want to buy just one book, buy one of the books by Schildt. Jamsa’s phrasing on memory models was a bit more illuminating for me, but Schildt’s no slouch there and he goes into much more detail on data structures, including implementing and comparing the strengths and weaknesses of three different ways to implement sparse arrays.
Using VGA’s 640x480x16color planar graphics mode
Borrow or buy Richard F. Ferraro’s Programmer’s Guide to the EGA and VGA Cards, Second Edition or Third Edition (Internet Archive links) or, if you want nicer illustrations and only need a brief introduction to EGA/VGA planar video rather than an entire book about DOS graphics, borrow The Waite Group’s Microsoft C programming For The PC, Second Edition by Robert Lafore and read chapter 11 (Direct-Access Graphics).
If you want to buy something, go for the second edition of Ferraro’s book. It’ll get you 500 pages on EGA and VGA and 500 pages on SVGA, including VESA and model-specific extensions offered by cards like the ATi VGA Wonder and the Tseng ET4000. The third edition is rarer and more expensive, has cover art that, in my opinion, has aged much more poorly, and what you’re paying for is having twice as many vendors covered in the part of the book about how to use model-specific SVGA stuff not covered by VESA… but, if you’ve got the cash and you’re going to be writing enough demoscene code for things like the XGA, the 8514/A, or S3 SVGA cards, the third edition may be worth buying.
See also chapter 2 (Icon-Based Interfaces) of The Craft of C by Herbert Schildt.
Using 256-color linear graphics modes on VGA and reading the mouse
Read David Brackeen’s 256-Color VGA Programming in C. (It’s a free series of online tutorials with source downloads for DJGPP and “Borland C, Turbo C, etc.”)
If that’s not enough, borrow Richard F. Ferraro’s Programmer’s Guide to the EGA and VGA Cards, Second Edition or Third Edition from the Internet Archive for the video and read Chapter 9, “Interfacing to the Mouse” of Herbert Schildt’s C Power User’s Guide (alt) (apparently also sold as “The Art of C: Elegant Programming Solutions”). (Schildt also covers using the PC speaker.)
Playing music on an Adlib-compatible sound card
Download Programming the AdLib/Sound Blaster v2.0 (A.K.A. adlf.zip) from the Internet Archive. (local copy)
Playing digital audio on a SoundBlaster-compatible sound card
Download SoundBlaster Programming Information v0.90 (local copy), Soundblaster programming routines (C++ src) (utility code under MIT-like license terms) (local copy), and Programming the SoundBlaster 16 DSP (local copy).
I’m not recommending a print book because, as far as I can tell, reverse-engineered free eBooks by hardware hackers are the only place to find info that doesn’t assume you bought the SDK from Creative Labs.
Reading from the PC Gameport
Read ePanorama.net – PC analogue joystick interface.
DOS/BIOS interrupt API reference
See Ralf Brown’s Interrupt List (alt, download).
Turbo Vision API documentation
When Borland released the source code for the C++ version of their Turbo Vision TUI library and the Free Pascal people ported it back to Pascal as Free Vision, neither released API documentation.
The recommended Borland Turbo Vision Version 2.0 Programming Guide from Turbo Pascal 7.0 is in the Internet Archive’s collection. However, the Turbo Vision Programming Guide from Turbo Pascal 6.0 is a decent runner-up if you can’t use it for some reason.
Assembly Language
I’m still working on this, but John Socha and Peter Noton’s Assembly Language for the PC, Third Edition looks like a good candidate.
Everything else I’ve been interested in about DOS programming so far
Start by borrowing The Craft of C by Herbert Schildt and The C Toolbox, Second Edition by William James Hunt from the Internet Archive’s library. (Among other things, the former covers TSRs in C, writing a rudimentary C interpreter, basic EGA graphics, interacting with the DOS mouse drivers, implementing a screen editor, and building an icon-based interface and icon and bitmap font editors while the latter covers other useful things like TUI popup windows and using the serial port.)
If you want another book that I found useful, Herbert Schildt’s C Power User’s Guide (alt) (apparently also sold as “The Art of C: Elegant Programming Solutions”) has a fair bit of useful non-overlap. Its chapters cover TUI pop-up and pull-down menus and pop-up windows, writing TSRs in C, Mode 4 (CGA) graphics including 2D rotation, basic DOS game development, using the serial port, writing a rudimentary BASIC interpreter, miscellaneous text-mode stuff like using color and changing the text cursor size, controlling the PC speaker, interacting with DOS mouse drivers, and drawing bar graphs.

Beyond that, you’re into more advanced stuff:

I hope this helps you and you may also want to check out my Useful Info On Win16-Targeting Compilers… And a List of DOS/Win16 Resources post and my similar list of learning materials for Windows 3.1.

Posted in Retrocomputing | 2 Comments

How to Hack gtk3-nocsd Into Flatpak Applications

WARNING: Use at your own risk. This is NOT a supported configuration and you’ll want to turn this off and re-test before reporting any bugs. (i.e. Report bugs gtk3-nocsd fixes, not ones it causes.)

OK, so you’ve got a desktop that’s using gtk3-nocsd and a GTK app that renders fine outside Flatpak, but does something unacceptably CSD-ish inside Flatpak. (For me, among other things, it’s non-GNOME GTK-using applications like Deluge displaying big black borders on things like context menus when KWin’s compositing is disabled.)

TIP: If it’s only the shadows on the context menus you don’t like, then it’s easier and more reliable to toss decoration, decoration:backdrop { box-shadow: none; } into your ~/.config/gtk-3.0/gtk.css.

The Flatpak developers don’t appear to see this as an issue, and not all applications have a good Qt-based counterpart, so what’s a stubborn “It’s my ****ing computer” person supposed to do?

…what about taking advantage of how Flatpak applications were already probably printing this to the terminal every time you launched them?

ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Here’s how you shoe-horn your gtk3-nocsd into Flatpak without rebuilding the Flatpak Runtime or the application package:

  1. Create a folder that Flatpak isn’t going to overlay, like /gtk3-nocsd and make sure it’s got the same 0755 root:root permissions as anything else nobody but root should be able to muck in.
  2. sudo cp -p /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 /gtk3-nocsd (substitute whatever path your host distro uses for the original, non-symlinked library file and note the -p to preserve the permissions and ownership. You need the sticky bit to pass certain safety checks.)
  3. Go into Flatseal or use flatpak override and grant your application filesystem access to /gtk3-nocsd:ro, then add an environment variable override to LD_PRELOAD=/gtk3-nocsd/libgtk3-nocsd.so.0

Congratulations. For better or for worse, you should now have your Flatpak’d application loading gtk3-nocsd like an un-Flatpak’d application. It seems to have solved the “big black borders on context menus with compositing disabled” issue in Deluge-GTK for me… but I make no guarantees that it’ll work for you.

You can check if it’s getting loaded by:

  1. flatpak enter <app ID> sh
  2. ps ax to get the PID of the process (probably 2 in my experience)
  3. grep nocsd /proc/<PID>/maps

In theory, you could do this in Flatseal’s “All Applications” tab, but why tempt fate. Do as I did. Apply it selectively to just the applications that exhibit problems.

I doubt the Flatpak devs will ever enable ld.so‘s secure execution mode, since it disables LD_LIBRARY_PATH, which is used in some launcher scripts to make some applications find their libraries under /app rather than /usr/lib (I had to use it to get a custom build of SDL_mixer to find libmodplug at runtime even though it found it without issue at compile time) but, if so, the next step would be to try injecting gtk3-nocsd.so.0 into /var/lib/flatpak/runtime/org.freedesktop.Platform/x86_64/<VERSION>/active/files/lib/ so it’ll show up in the list of standard paths ld.so‘s secure mode is whitelisted to.

Posted in Geek Stuff | Leave a comment

Update to Update to My Flatpak CLI Shortcut Proof of Concept

Well, it’s a bit silly, but I got nerd-sniped by how it was taking a little over six seconds to regenerate my Flatpak CLI wrappers with the shell script version I just announced yesterday, so I rewrote it in Python.

(Still the same GitHub Gist URL)

The new version completes basically instantly after the split-second pause to start the Python interpreter, thanks to using PyGObject to go straight to libflatpak so it doesn’t have to launch a whole new copy of flatpak info to query each package.

Other enhancements the rewrite brought are:

  1. Flatpak info parsing is now done using Glib.KeyFile, which is a proper parser for the format
  2. Command lines are now extracted from the .desktop files using Gio.DesktopAppInfo, but with a forced fallback to the old flatpak run generator if the upstream devs omitted --file-forwarding to ensure that things like ScummVM don’t regress in their ability to invoke them with command-line arguments.
  3. EXTRA_CMDS now takes a list of commands, so you can expose more than one secondary command from each package.
  4. CMD_REMAPPINGS Now maps from flatpak package IDs rather than internal command names so that there’s no risk of collisions if the undesired name is undesired because it’s something generic like launcher.
  5. The template for wrapper scripts is now using a proper multi-line string for easy auditing and editing.
  6. The script checks if BIN_DIR is in your path and, if not, warns you that you’ll need to add it, which has the side benefit of telling you what BIN_DIR is set to without needing to read the source.
  7. There’s now basic collision resolution where the first Flatpak package to claim a name wins and a message is printed asking you to add an entry to CMD_REMAPPINGS to resolve the problem.
  8. There’s now collision detection where, whether or not this script is responsible for both of them, a warning will be printed indicating which command from which package is colliding and whether your PATH will favour the Flatpak version or the external version.

Yeah, aside from the lack of manpages (which I can’t solve if they’re just not in the package), the sledgehammer-y approach of just expecting that it’s allowed full freedom to blow away all files inside the BIN_DIR it creates and manages, and the fact that you have to edit constants in the source code rather than an external config file, this is now about as perfect as I can think to make it… maybe I’ll rewrite it in Rust next time the mood hits me.

UPDATE: I’ll also need to add autodetection for when a Flatpak is exporting secondary launchers so EXTRA_CMDS is only necessary for things like audtool and mednafen that are present but not exported.

Posted in Geek Stuff | Leave a comment

Update to My Flatpak CLI Shortcut Proof of Concept

This morning, I finally got around to rewriting my update_nvidia helper to unbreak the whole “defer driver updates until reboot to keep the kernel module and libGL in sync” thing I have going and, this afternoon, while working on something else, I realize that anything running in Flatpak was working all along because the Flatpak devs did too good a job of detecting and supplying matching in-runtime libraries for video drivers.

Why is this relevant? Well, because I realized it while fixing something else that had been bugging me: The papercuts in my script for generating flatpak CLI launcher wrappers.

For those who missed my initial announcement, it’s a script you run after installing something through Flatpak and it generates a wrapper so you can type mpv instead of flatpak run io.mpv.Mpv in a terminal window, and it’ll even handle --file-forwarding for you so you get an experience comparable to what the XDG File Chooser portal gives you with Open/Save dialogs.

So, what did I improve? Well, here’s the features list now:

  1. Run it with no arguments and it’ll set up or update a ~/.local/bin/flatpak you can add to your PATH. (not new)
  2. Add things to the CMD_REMAPPINGS list (which comes with entries like [scummvm_wrapper]='scummvm' and ["com.github.tchx84.Flatseal"]='flatseal' pre-populated) to fix stuff it couldn’t quite get right. (NEW)
  3. Add things to the EXTRA_CMDS list (which comes with ["com.github.AmatCoder.mednaffe"]='mednafen' and ["org.atheme.audacious"]='audtool' pre-populated) and you can optionally expose a second command from inside each Flatpak. (NEW)
  4. Unsets LD_PRELOAD before launching the Flatpak application to silence spurious “Can’t find libgtk3-nocsd.so.0 in the Flatpak runtime” errors. (not new)
  5. If any arguments are valid relative paths, make them absolute to fix an annoying bug with how --file-forwarding behaves without breaking non-path arguments. (NEW)

I did have to switch from dash-compatible shell script to bash script to take advantage of proper array support, but, from what I remember, the Linux Standard Base required that /bin/bash exist, so that shouldn’t be too big a hardship.

It still doesn’t solve the problem of Flatpak’s not coming with man pages, but there’s not a lot I can do when the files just aren’t included. Aside from that, I’m very impressed at how polished this feels when I’m hacking around the Flatpak developers’ putting their foot down and declaring comfortable command-line operation to be out of scope.

Enjoy. 🙂

Posted in Geek Stuff | Leave a comment

Fanfiction – Wyvern

Wyvern by ack1308

Length: 128,724 words
Status: Ongoing

…and here’s that Worm fic I mentioned I’d be reviewing soon when I did my feature for ack1308.

In it, Taylor is a Changer with a Hulk-esque trigger she needs to learn to control.

That on its own doesn’t sound particularly special, but she turns into a fire-breathing dragon, she can’t speak English in dragon form, and she gets “I talked her into following me home. Can we keep her?”‘d by Glory Girl. (There’s also a twist I don’t want to spoil that becomes very significant later on.)

This is a heavily New Wave focused fic, both because Taylor decides to join New Wave and because it’s a story where the author recognizes that there’s a lot of wiggle room in a setting to pace and focus things the way you want.

Tonally, this starts out reminiscent of something like many Human in Equestria stories from the My Little Pony fandom, where you have a lot of time spent just enjoying the back and forth between the characters as they get to know each other and show off their personalities… including things like an “Amy comes face-to-face with a dragon” scene after she ignores the instruction to knock before entering Vicky’s room.

Through various techniques, like playing with the pacing and focusing on the moment-to-moment humanity of the characters, the fic does a good job of keeping things fairly light and fun for quite a while still acknowledging that the setting isn’t light and fun and things will turn sooner or later. (For example, the need to go back over Taylor’s trigger event or getting to see Amy comment on how doctors get paid more to do less, only to have it go nowhere.)

It also helps that, when Armsmaster does show up to try to push Taylor into the Wards, she has support from Carol in her role as a lawyer to counter his efforts.

That said, thought it happens slowly, it does build and things do escalate. Given the pacing, as of this writing, it’s not gotten that far into its story arc, but it’s still long enough to be worthwhile.

This is one of those stories where it’s hard to say a lot, because what I enjoy about it is just the overall experience. There aren’t a lot of really punchy quotes (though there is a moment when Taylor stops a criminal from trying to shoot her, and Vicky comments that “he looked exactly like a cartoon character after a bomb’s gone off in his face.”) …just the moment-to-moment story of character who are enjoyable to read about.

There’s also a twist In her powers and the villain roster that’s kind of interesting, though I’m not sure whether I enjoy it more or less than what I imagine the story could have been without it. (For those willing to accept a spoiler, Lung doesn’t exist, the ABB has a different leader, and she’s got Lung’s “scale up to the threat given enough time” thing. It’s kind of a shame that it’s a twist, because “Lung’s powers on a protagonist” has a ton of potential for a variety of reasons, including Taylor being much more body-shy than Lung, and it meshes nicely with the character-centric, generally light style.)

Looking back, it’s actually a good plot twist in the proper sense of the word. Specifically, it changes how I see the character going forward and that’s particularly elegant because it serves to help the reader follow Taylor on her journey rather than seeing more than she does from the beginning.

Carol also sets up a very satisfying sting operation against Sophia, Emma, and Madison, where you really get to savour the experience, and it’s also the most realistic one I’ve ever run across in fanfiction.

That said, after the sting operation, there’s a time skip that I’m not so sure about, given the pacing of what follows.

I’d give this maybe a 4.7 out of 5 for the stuff before the very end of chapter 18, leading into the timeskip, and the courtroom scene following that. Maybe a 4.0 for the rest of what follows, since I’m not yet confident in the author’s ability to do what they seem to be aiming for with the arrival of the Slaughterhouse Nine, and I’m reluctant to rate it too highly when I have so little data. 4.5 overall, maybe?

Before that point, it’s novel, I really enjoy the focus and writing style, and I like how it uses world-building for twists without overdoing it.

Posted in Fanfiction | 2 Comments