[Win32] Remove OS.IsAppThemed() — always true on Windows 10+#3345
Open
HeikoKlare wants to merge 1 commit into
Open
[Win32] Remove OS.IsAppThemed() — always true on Windows 10+#3345HeikoKlare wants to merge 1 commit into
HeikoKlare wants to merge 1 commit into
Conversation
Contributor
3009103 to
63b6de3
Compare
Windows Classic theme was removed in Windows 8. Since SWT targets Windows 10 and later, OS.IsAppThemed() unconditionally returns true, making every !OS.IsAppThemed() branch unreachable dead code and every if (OS.IsAppThemed()) guard reducible to its body. Removes all 70+ call sites across 21 widget files: - Dead !OS.IsAppThemed() else-branches are deleted (Classic theme fallbacks for DrawFrameControl, DFCS_* drawing, TBSTYLE_TRANSPARENT clearing, RTL text-clipping space-padding, ILC_MASK flag, etc.) - if (OS.IsAppThemed()) guards are unwrapped to unconditional code (Explorer theme setup in Tree/Table createHandle, themed checkbox image lists in Tree/Table, THEME_BACKGROUND checks, wmColorChild, WM_ERASEBKGND, WM_MOVE, wmNCPaint, widgetStyle bits, etc.) - Ternary OS.IsAppThemed() ? x : y expressions replaced with x (Group offsetY adjustments, ToolBar widgetStyle TBSTYLE_TRANSPARENT) - Stale TEMPORARY CODE commented-out blocks removed (CoolBar, TabFolder) - Group.fixText(boolean enabled): enabled parameter removed as it became unused once the Classic-theme space-padding workaround was deleted - OS.IsAppThemed() declaration removed from OS.java (and auto-generated os.c / os_stats.h updated accordingly) The following OS.java declarations became unused as a result and are also removed: - OS.DrawFrameControl() and its eleven associated constants (DFCS_BUTTONCHECK, DFCS_CHECKED, DFCS_FLAT, DFCS_INACTIVE, DFCS_PUSHED, DFCS_SCROLLDOWN, DFCS_SCROLLLEFT, DFCS_SCROLLRIGHT, DFCS_SCROLLUP, DFC_BUTTON, DFC_SCROLL) — only used in the non-themed checkbox and arrow-button drawing fallbacks - OS.ImageList_AddMasked() — only used in the non-themed setCheckboxImageList() path (replaced by ImageList_Add) - OS.BS_BITMAP and OS.BS_ICON — only used in the non-themed Button.enableWidget() RTL clipping workaround Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63b6de3 to
4d00ad4
Compare
There was a problem hiding this comment.
Pull request overview
This PR simplifies SWT’s Win32 widget code by removing all uses of OS.IsAppThemed() and associated classic/non-themed fallback paths, based on the Windows 10+ target where IsAppThemed() is effectively always true. It also cleans up the Win32 PI/native layer by deleting now-unused constants and JNI bindings.
Changes:
- Removed unreachable
!OS.IsAppThemed()branches and unwrappedif (OS.IsAppThemed())guards across Win32 widgets. - Standardized themed rendering paths for controls (checkbox image lists, themed backgrounds, explorer theme setup, etc.).
- Removed
OS.IsAppThemed()and related unused constants/native methods fromOS.java,os.c, andos_stats.h.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java | Makes themed non-client border printing unconditional for client-edge controls. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java | Always applies themed header sizing and forces header invalidation on sort updates. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java | Removes theming guards; always applies explorer theme behaviors and themed checkbox rendering. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java | Removes theme conditionals around layout/style workarounds and list-style toggling. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java | Unwraps theme-background logic and cancel-icon themed drawing. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java | Always applies themed header sizing in pack(). |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java | Removes theming guards for explorer theme setup and themed checkbox image list rendering. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java | Removes stale commented “TEMPORARY CODE” block. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java | Makes scrollbar visibility workaround unconditional. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java | Simplifies themed/background control detection for repaint workaround. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java | Removes XP-only marquee workaround code. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java | Makes the themed menu-image bitmap path unconditional. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java | Unwraps theme-control redraw detection. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java | Removes classic RTL workaround and simplifies text-direction adjustments. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java | Replaces OS.IsAppThemed() usage with a constant true (subject to custom colors/fonts). |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java | Unwraps UpdateWindow() call previously gated by theme/hung checks. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java | Removes classic-theme erase/background workarounds and temp blocks; simplifies theme background handling. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java | Unwraps theme-background painting paths. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java | Makes canvas non-client hit-test workaround unconditional. |
| bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java | Removes classic RTL/text clipping workarounds and non-themed drawing fallbacks; always uses theme APIs. |
| bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java | Deletes IsAppThemed() and now-unused constants/native declarations. |
| bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c | Removes JNI wrappers for deleted native calls. |
| bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h | Removes stats enum entries for deleted native calls. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OS.IsAppThemed()always returnstrueon Windows 8 and later, see https://learn.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-isappthemedSince SWT targets Windows 10+, every
!OS.IsAppThemed()branch is unreachable dead code and everyif (OS.IsAppThemed())guard can be reduced to its body.This removes all 70+ call sites across 21 widget files and cleans up the OS.java declarations that became unused as a result.
Changes to widget code
!OS.IsAppThemed()branches deleted — Classic theme fallbacks forDrawFrameControl/DFCS_*checkbox and arrow drawing,TBSTYLE_TRANSPARENTclearing, RTL text-clipping space-padding,ILC_MASKimage list flag, XP marquee workaround inProgressBar, separator workaround inCoolBarif (OS.IsAppThemed())guards unwrapped — Explorer theme setup inTree/TablecreateHandle, themed checkbox image lists,THEME_BACKGROUNDhandling indrawBackground/wmColorChild/WM_ERASEBKGND/WM_MOVE/wmNCPaint,setBoundsInPixels,widgetStylebits, and moreOS.IsAppThemed() ? x : yreplaced withx—GroupY-offset adjustments,ToolBarTBSTYLE_TRANSPARENTstyle bit//TEMPORARY CODEcommented-out blocks removed —CoolBar.javaandTabFolder.javaGroup.fixText(boolean enabled)—enabledparameter removed (became unused after the Classic-theme RTL space-padding workaround was deleted)Changes to OS.java
Removed
OS.IsAppThemed()itself (declaration + auto-generatedos.c/os_stats.h), and the following declarations that became entirely unused:DrawFrameControl()Table,Tree,ButtonDFCS_BUTTONCHECK/CHECKED/FLAT/INACTIVE/PUSHED/SCROLLDOWN/SCROLLLEFT/SCROLLRIGHT/SCROLLUP,DFC_BUTTON/SCROLLDrawFrameControlImageList_AddMasked()setCheckboxImageList()(replaced byImageList_Add)BS_BITMAP,BS_ICONButton.enableWidget()Test plan
TableandTree(checked, unchecked, mixed, disabled states)Buttondraws correctly via themeToolBarlayout withSWT.RIGHT,SWT.FLAT, and mixed text+image itemsGroupsize/trim/client-area calculations with RTL andFLIP_TEXT_DIRECTIONstylesExpandBarwith and without custom foreground/background/font🤖 Generated with Claude Code