Report foobar2000 Advanced settings check and radio states

Native tree descriptions previously omitted state-image bits. As a result,
foobar2000 Advanced Preferences read setting names without their boolean
values, and changing a checkbox without moving focus could go unnoticed.

Include TVIS_STATEIMAGEMASK in the native item key so polling observes
state changes even when Wine omits WinEvents. Report checked and not-checked
states for standard checkbox-tree images while preserving selected and
expanded/collapsed states. All queries remain read-only and retain the
existing target-architecture buffer layouts and bounded query behavior.

Foobar2000 also uses image indexes 3 and 4 for radio choices in its Advanced
settings tree. Expose those entries as radio buttons with the corresponding
check state. Restrict this application-defined mapping to foobar2000.exe
and its Preferences category/settings control identities. Leave unrelated
state images uninterpreted rather than inventing mixed checkbox states.

Extend the controls fixture with checkbox changes that emit no WinEvent,
custom images, and foobar-style radio transitions. Add a foobar-controls
runner mode using the application's basename. Exercise identical control
IDs and images under an unrelated basename to guard against applying the
compatibility mapping to other programs. Account for Wine initializing
checkbox images when the fixture first appears. Document support and the
manual Preferences acceptance procedure.

Validation:
- Controls and foobar-controls fixtures passed in both 64-bit and 32-bit.
- All six CTests passed: foreground focus, MSAA states, text limits,
  64/32-bit review capture, and hook safety.
- Existing menu and editor integrations passed, including Unicode,
  selection/deletion feedback, password exclusion and read-only controls.
- A private copy of foobar2000 2.26.1 exposed Advanced setting labels,
  numeric values, checkbox Space toggles and radio states, plus Components
  row names and version/module descriptions through the recording reader.
- Installed the verified helper alongside the Cthulhu session-bus fix;
  the user subsequently confirmed that the live changes look good.

Recorded events alone do not establish physical Braille acceptance. No
foobar2000 settings were changed in the user's live installation.
This commit is contained in:
deedra committed 2026-10-25 14:57:34 -07:00
1 parent 24c35d7954
commit 0763498472
5 files changed
+161 -8

No files matched your search

+35 -1
View File
@@ -14,6 +14,29 @@ bool is_tab(HWND window) {
return GetClassNameW(window, className, std::size(className)) &&
wine_access_class_matches(className, L"SysTabControl32");
}
// foobar2000's Advanced tree extends standard checkbox images with a pair
// of radio-button images. Restrict this application-defined mapping to it.
bool is_foobar_settings_tree(HWND window) {
if (GetDlgCtrlID(window) != 1181) return false;
HWND root = GetAncestor(window, GA_ROOT);
HWND categories = GetDlgItem(root, 1068);
wchar_t className[128] = {};
if (!categories || !GetClassNameW(categories, className, std::size(className)) ||
!wine_access_class_matches(className, L"SysTreeView32")) return false;
DWORD processId = 0;
GetWindowThreadProcessId(window, &processId);
HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);
if (!process) return false;
wchar_t path[1024] = {};
DWORD length = std::size(path);
const bool known = QueryFullProcessImageNameW(process, 0, path, &length);
CloseHandle(process);
if (!known) return false;
const wchar_t *name = path;
for (const wchar_t *at = path; *at; ++at)
if (*at == L'\\' || *at == L'/') name = at + 1;
return lstrcmpiW(name, L"foobar2000.exe") == 0;
}
struct Tab32 { uint32_t mask, state, stateMask, text; int32_t capacity; };
struct Tab64 { uint32_t mask, state, stateMask, padding; uint64_t text; int32_t capacity; };
struct Tree32 {
@@ -60,7 +83,7 @@ NativeItemKey native_item_key(HWND window) {
!query(window, TVM_GETNEXTITEM, TVGN_CARET, 0, &item)) return key;
key.item = item;
if (item && query(window, TVM_GETITEMSTATE, item,
TVIS_SELECTED | TVIS_EXPANDED, &state)) key.state = state;
TVIS_SELECTED | TVIS_EXPANDED | TVIS_STATEIMAGEMASK, &state)) key.state = state;
}
key.count = static_cast<int>(count);
return key;
@@ -109,6 +132,17 @@ NativeItem read_native_item(HWND window) {
if (tab) { item.position = static_cast<int>(key.item); item.count = key.count; }
else {
item.role = "tree item";
// Query state only; never toggle the item to discover its value.
const DWORD stateImage = (key.state & TVIS_STATEIMAGEMASK) >> 12;
const bool radio = (stateImage == 3 || stateImage == 4) &&
is_foobar_settings_tree(window);
const bool checkbox = (stateImage == 1 || stateImage == 2) &&
(GetWindowLongPtrW(window, GWL_STYLE) & TVS_CHECKBOXES);
if (radio || checkbox) {
if (!item.states.empty()) item.states += ", ";
item.states += stateImage == 2 || stateImage == 4 ? "checked" : "not checked";
if (radio) item.role = "radio button";
}
int32_t children = 0;
memcpy(&children, buffer + (wow64 ? offsetof(Tree32, children) : offsetof(Tree64, children)), sizeof(children));
if (children != 0) {