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,8 @@
package com.ts3client.ui;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.formdev.flatlaf.util.UIScale;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
@@ -150,9 +153,9 @@ final class ServerTabPane extends JPanel {
/** A tab's label: title, microphone marker and a close button. */
private JComponent buildTabComponent(ServerTab tab, boolean hasMic) {
JPanel cell = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 0));
JPanel cell = new JPanel(new FlowLayout(FlowLayout.LEFT, UIScale.scale(4), 0));
cell.setOpaque(false);
cell.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
cell.setBorder(new ScaledEmptyBorder(1, 0, 1, 0));
JLabel label = new JLabel(tab.title(), hasMic ? Icons.micActiveSmall() : null, JLabel.LEADING);
label.setFont(Theme.uiFont());
@@ -175,7 +178,7 @@ final class ServerTabPane extends JPanel {
close.setContentAreaFilled(false);
close.setMargin(new Insets(0, 0, 0, 0));
close.setForeground(Theme.chatSystem());
close.setPreferredSize(new Dimension(14, 14));
close.setPreferredSize(UIScale.scale(new Dimension(14, 14)));
close.setToolTipText("Close this connection");
close.addActionListener(e -> listener.closeTab(tab));
cell.add(close);