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.ScaledEmptyBorder;
import com.formdev.flatlaf.util.UIScale;
import com.ts3client.net.IconRepository;
import com.ts3client.net.TeamspeakConnection;
@@ -69,7 +71,7 @@ final class IconChooserDialog extends JDialog {
group("Local", localList, localFooter()));
split.setResizeWeight(0.6);
status.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 8));
status.setBorder(new ScaledEmptyBorder(2, 8, 2, 8));
status.setForeground(Theme.chatSystem());
getContentPane().setLayout(new BorderLayout());
@@ -81,7 +83,7 @@ final class IconChooserDialog extends JDialog {
Dialogs.closeOnEscape(this);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setSize(new Dimension(520, 360));
setSize(UIScale.scale(new Dimension(520, 360)));
setLocationRelativeTo(owner);
loadRemoteIcons();
@@ -101,8 +103,8 @@ final class IconChooserDialog extends JDialog {
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
list.setVisibleRowCount(-1);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setFixedCellWidth(32);
list.setFixedCellHeight(32);
list.setFixedCellWidth(UIScale.scale(32));
list.setFixedCellHeight(UIScale.scale(32));
list.setCellRenderer(new IconCellRenderer());
list.addListSelectionListener(e -> onSelectionChanged(list));
list.addMouseListener(new MouseAdapter() {
@@ -129,7 +131,7 @@ final class IconChooserDialog extends JDialog {
}
private JPanel group(String title, JList<Long> list, Component footer) {
JPanel panel = new JPanel(new BorderLayout(0, 4));
JPanel panel = new JPanel(new BorderLayout(0, UIScale.scale(4)));
panel.setBorder(BorderFactory.createTitledBorder(title));
panel.add(new JScrollPane(list), BorderLayout.CENTER);
panel.add(footer, BorderLayout.SOUTH);
@@ -150,7 +152,7 @@ final class IconChooserDialog extends JDialog {
private Component localFooter() {
com.ts3client.gfx.IconPack active = IconTheme.get().activePack();
JLabel pack = new JLabel("Icon Pack: " + (active == null ? "none" : active.name()));
pack.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
pack.setBorder(new ScaledEmptyBorder(0, 4, 0, 4));
return pack;
}