[Win32] Remove OS.IsAppThemed() — always true on Windows 10+#3345
Draft
HeikoKlare wants to merge 1 commit into
Draft
[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
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. Since 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