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
parent 1fddae3f0b
commit 9d996f48a2
57 changed files with 643 additions and 311 deletions

View File

@@ -1,5 +1,7 @@
package com.ts3client.ui;
import com.formdev.flatlaf.util.UIScale;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.Dimension;
@@ -25,11 +27,11 @@ public final class LevelMeter extends JComponent {
private volatile boolean transmitting;
public LevelMeter() {
setPreferredSize(new Dimension(240, 18));
setPreferredSize(UIScale.scale(new Dimension(240, 18)));
// A bare JComponent reports no minimum of its own, so a layout tight on space
// collapses the bar to nothing. Keep the height and let only the width give.
setMinimumSize(new Dimension(60, 18));
setMaximumSize(new Dimension(Integer.MAX_VALUE, 18));
setMinimumSize(UIScale.scale(new Dimension(60, 18)));
setMaximumSize(new Dimension(Integer.MAX_VALUE, UIScale.scale(18)));
}
public void setLevel(double db) {
@@ -70,16 +72,17 @@ public final class LevelMeter extends JComponent {
int h = getHeight();
g.setColor(new Color(0x2B2B2B));
g.fillRoundRect(0, 0, w - 1, h - 1, 6, 6);
int arc = UIScale.scale(6);
g.fillRoundRect(0, 0, w - 1, h - 1, arc, arc);
int level = dbToX(levelDb, w - 2);
g.setColor(transmitting ? Theme.talking() : new Color(0x5A9BD4));
g.fillRoundRect(1, 1, Math.max(0, level), h - 3, 5, 5);
g.fillRoundRect(1, 1, Math.max(0, level), h - 3, arc - 1, arc - 1);
if (showThreshold) {
int tx = dbToX(thresholdDb, w - 2);
g.setColor(new Color(0xF0C419));
g.fillRect(tx, 1, 2, h - 3);
g.fillRect(tx, 1, UIScale.scale(2), h - 3);
}
}
}