Bug fixes and reorganization of code.
This commit is contained in:
1 parent
5f78168c57
commit
cbce83581a
10 files changed
+148
-81
No files matched your search
@@ -140,15 +140,21 @@ std::string accessible_property(
|
||||
|
||||
// Standard-control queries follow the LGPL wine-a11y reader published by
|
||||
// Mudb0y, while presentation remains on Cthulhu's D-Bus interface.
|
||||
void tidy_text(wchar_t *text, bool label = false) {
|
||||
void strip_mnemonics(wchar_t *text) {
|
||||
wchar_t *output = text;
|
||||
for (wchar_t *input = text; *input != L'\0'; ++input) {
|
||||
if (*input != L'&')
|
||||
*output++ = *input;
|
||||
if (*input == L'&') {
|
||||
if (input[1] != L'&') continue;
|
||||
++input;
|
||||
}
|
||||
*output++ = *input;
|
||||
}
|
||||
*output = L'\0';
|
||||
if (label && output > text && output[-1] == L':')
|
||||
output[-1] = L'\0';
|
||||
}
|
||||
|
||||
void trim_label(wchar_t *text) {
|
||||
const int length = lstrlenW(text);
|
||||
if (length && text[length - 1] == L':') text[length - 1] = L'\0';
|
||||
}
|
||||
|
||||
bool get_control_text(HWND window, wchar_t *text, int capacity) {
|
||||
@@ -158,7 +164,14 @@ bool get_control_text(HWND window, wchar_t *text, int capacity) {
|
||||
reinterpret_cast<LPARAM>(text), SMTO_ABORTIFHUNG,
|
||||
200, &result))
|
||||
return false;
|
||||
tidy_text(text);
|
||||
// Only captions interpret mnemonic markers. Values and window titles
|
||||
// contain literal text; even captions escape a literal ampersand as &&.
|
||||
wchar_t className[128] = {};
|
||||
if (GetClassNameW(window, className, std::size(className)) &&
|
||||
(wine_access_class_matches(className, L"Button") ||
|
||||
(wine_access_class_matches(className, L"Static") &&
|
||||
!(GetWindowLongPtrW(window, GWL_STYLE) & SS_NOPREFIX))))
|
||||
strip_mnemonics(text);
|
||||
return text[0] != L'\0';
|
||||
}
|
||||
|
||||
@@ -195,7 +208,7 @@ void find_control_label(HWND window, wchar_t *text, int capacity) {
|
||||
}
|
||||
}
|
||||
if (label && get_control_text(label, text, capacity)) {
|
||||
tidy_text(text, true);
|
||||
trim_label(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +223,7 @@ void find_control_label(HWND window, wchar_t *text, int capacity) {
|
||||
if (!wine_access_class_matches(className, L"Static") && !wine_access_class_matches(className, L"Button"))
|
||||
continue;
|
||||
if (get_control_text(previous, text, capacity))
|
||||
tidy_text(text, true);
|
||||
trim_label(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +231,6 @@ void find_control_label(HWND window, wchar_t *text, int capacity) {
|
||||
std::string window_title(HWND window) {
|
||||
wchar_t title[512] = {};
|
||||
GetWindowTextW(GetAncestor(window, GA_ROOT), title, std::size(title));
|
||||
tidy_text(title);
|
||||
return to_utf8(title);
|
||||
}
|
||||
|
||||
@@ -362,7 +374,6 @@ ControlDescription describe_standard_control(HWND window) {
|
||||
SendMessageTimeoutW(window, LB_GETTEXT, selected,
|
||||
reinterpret_cast<LPARAM>(text), SMTO_ABORTIFHUNG,
|
||||
200, &length)) {
|
||||
tidy_text(text);
|
||||
control.value = to_utf8(text);
|
||||
}
|
||||
control.position = static_cast<int>(selected) + 1;
|
||||
|
||||
Reference in new issue
Block a user