Merge pull request #7611 from electron/only-enable-msaa-if-needed
Check harder before enabling Accessibility support on Win32
This commit is contained in:
commit
3dd8377218
4 changed files with 23 additions and 11 deletions
|
@ -138,7 +138,7 @@ NativeWindowViews::NativeWindowViews(
|
||||||
menu_bar_visible_(false),
|
menu_bar_visible_(false),
|
||||||
menu_bar_alt_pressed_(false),
|
menu_bar_alt_pressed_(false),
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
enabled_a11y_support_(false),
|
checked_for_a11y_support_(false),
|
||||||
thick_frame_(true),
|
thick_frame_(true),
|
||||||
#endif
|
#endif
|
||||||
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "atom/browser/ui/win/message_handler_delegate.h"
|
#include "atom/browser/ui/win/message_handler_delegate.h"
|
||||||
#include "atom/browser/ui/win/taskbar_host.h"
|
#include "atom/browser/ui/win/taskbar_host.h"
|
||||||
#include "base/win/scoped_gdi_object.h"
|
#include "base/win/scoped_gdi_object.h"
|
||||||
|
#include "ui/base/win/accessibility_misc_utils.h"
|
||||||
|
#include <UIAutomationCoreApi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
|
@ -228,8 +230,8 @@ class NativeWindowViews : public NativeWindow,
|
||||||
// In charge of running taskbar related APIs.
|
// In charge of running taskbar related APIs.
|
||||||
TaskbarHost taskbar_host_;
|
TaskbarHost taskbar_host_;
|
||||||
|
|
||||||
// If true we have enabled a11y
|
// Memoized version of a11y check
|
||||||
bool enabled_a11y_support_;
|
bool checked_for_a11y_support_;
|
||||||
|
|
||||||
// Whether to show the WS_THICKFRAME style.
|
// Whether to show the WS_THICKFRAME style.
|
||||||
bool thick_frame_;
|
bool thick_frame_;
|
||||||
|
|
|
@ -92,15 +92,24 @@ bool NativeWindowViews::PreHandleMSG(
|
||||||
// accessibility object.
|
// accessibility object.
|
||||||
case WM_GETOBJECT: {
|
case WM_GETOBJECT: {
|
||||||
const DWORD obj_id = static_cast<DWORD>(l_param);
|
const DWORD obj_id = static_cast<DWORD>(l_param);
|
||||||
if (enabled_a11y_support_) return false;
|
|
||||||
|
|
||||||
if (obj_id == OBJID_CLIENT) {
|
if (obj_id != OBJID_CLIENT) {
|
||||||
const auto axState = content::BrowserAccessibilityState::GetInstance();
|
return false;
|
||||||
if (axState && !axState->IsAccessibleBrowser()) {
|
}
|
||||||
axState->OnScreenReaderDetected();
|
|
||||||
enabled_a11y_support_ = true;
|
if (checked_for_a11y_support_) return false;
|
||||||
Browser::Get()->OnAccessibilitySupportChanged();
|
checked_for_a11y_support_ = true;
|
||||||
}
|
|
||||||
|
UINT screenReader = 0;
|
||||||
|
SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenReader, 0);
|
||||||
|
if (!screenReader || !UiaClientsAreListening()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto axState = content::BrowserAccessibilityState::GetInstance();
|
||||||
|
if (axState && !axState->IsAccessibleBrowser()) {
|
||||||
|
axState->OnScreenReaderDetected();
|
||||||
|
Browser::Get()->OnAccessibilitySupportChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -281,6 +281,7 @@
|
||||||
'-lwininet.lib',
|
'-lwininet.lib',
|
||||||
'-lwinmm.lib',
|
'-lwinmm.lib',
|
||||||
'-lcrypt32.lib',
|
'-lcrypt32.lib',
|
||||||
|
'-luiautomationcore.lib',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue