Scale the interface fractionally on Linux

Java2D on X11 (and so under XWayland) truncates its scale to a whole
number, drawing 150 % at 100 %. On Linux, pin Java2D to 1 and hand the
full factor to FlatLaf, taken from XSETTINGS Xft/DPI, KWin's Xwayland
scale or GDK_SCALE, or chosen in Options → Design.

The client's own sizes now go through UIScale: borders, gaps, dialog and
row sizes, icons (rendered at the scaled size, so they stay crisp),
custom-painted components and font sizes in the HTML views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 22:33:27 +00:00
co-authored by Claude Opus 5.5
parent 1fddae3f0b
commit 9d996f48a2
57 changed files with 643 additions and 311 deletions
@@ -1,5 +1,7 @@
package com.ts3client.ui;
import com.formdev.flatlaf.util.UIScale;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -22,7 +24,7 @@ final class AvatarView extends JComponent {
AvatarView(int boxSize) {
this.boxSize = boxSize;
setPreferredSize(new Dimension(boxSize, boxSize));
setPreferredSize(UIScale.scale(new Dimension(boxSize, boxSize)));
setMinimumSize(getPreferredSize());
}
@@ -47,7 +49,7 @@ final class AvatarView extends JComponent {
imageHeight = image.getHeight(this);
if (imageWidth < 0 || imageHeight < 0) return;
}
double scale = Math.min(1.0, Math.min((double) getWidth() / imageWidth, (double) getHeight() / imageHeight));
double scale = Math.min(UIScale.getUserScaleFactor(), Math.min((double) getWidth() / imageWidth, (double) getHeight() / imageHeight));
int w = Math.max(1, (int) Math.round(imageWidth * scale));
int h = Math.max(1, (int) Math.round(imageHeight * scale));
Graphics2D g2 = (Graphics2D) g.create();