Workaround for Floating Windows With Borders

I noticed the problem with Sway (or maybe with one of my scripts, but rather with Sway). Apparently, some GTK pop-up windows, like “Save before quit?” ones, draw on screen before Sway draws its borders around windows. Sway doesn’t resize windows after first draw and draws borders inside the windows, effectively hiding parts of it.

Video which illustrates the issue. New window has no borders for a short time around 0:04.

The workaround is to force Sway to always draw a certain border around all windows. To do it, add something like this in ~/.config/sway/config:

for_window [app_id=".*"] border pixel 5

Of course you can use other border styles than pixel. Con of this solution is that it overrides default_border and default_floating_border settings and can’t have e.g. thinner borders around floating windows this way.