From c3b03fe3e7e65ba1ffa3ed8b891a1cdd3a1e83d5 Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Tue, 2 Sep 2025 11:35:38 +0200 Subject: [PATCH] Remove the additional SORT_WIDTH spacing logic in Tree column rendering. Since Windows 7, the sort indicator in tree columns is rendered above the column header text, whereas in Windows XP it was placed next to the text. The original SWT implementation added extra pixels (SORT_WIDTH) to the column width to make space for the indicator. --- .../win32/org/eclipse/swt/widgets/Tree.java | 1 - .../win32/org/eclipse/swt/widgets/TreeColumn.java | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index 73f45dffa13..7e52e05628d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -114,7 +114,6 @@ public class Tree extends Composite { static final int TIMER_MAX_COUNT = 8; static final int INSET = 3; static final int GRID_WIDTH = 1; - static final int SORT_WIDTH = 10; static final int HEADER_MARGIN = 12; static final int HEADER_EXTRA = 3; static final int INCREMENT = 5; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java index 844eac0c29b..a5e5e81bd5f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java @@ -377,17 +377,9 @@ public void pack () { OS.DrawText (hDC, buffer, buffer.length, rect, flags); int headerWidth = rect.right - rect.left + Win32DPIUtils.pointToPixel(Tree.HEADER_MARGIN, getZoom()); if (OS.IsAppThemed ()) headerWidth += Win32DPIUtils.pointToPixel(Tree.HEADER_EXTRA, getZoom()); - if (image != null || parent.sortColumn == this) { - Image headerImage = null; - if (parent.sortColumn == this && parent.sortDirection != SWT.NONE) { - headerWidth += Win32DPIUtils.pointToPixel(Tree.SORT_WIDTH, getZoom()) ; - } else { - headerImage = image; - } - if (headerImage != null) { - Rectangle bounds = Win32DPIUtils.pointToPixel(headerImage.getBounds(), getZoom()); - headerWidth += bounds.width; - } + if (image != null) { + Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + headerWidth += bounds.width; int margin = 0; if (hwndHeader != 0) { margin = (int)OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);