Files
wine-access/browser_bridge.h
Storm DragonandClaude Opus 5.5 9c1fc644ba Add browser accessibility for Chromium windows
Chromium-based Windows applications under Wine (Electron, CEF) exposed only
what the legacy MSAA path could announce, one event at a time. The helper now
starts a publisher for each Chromium window: a PE worker reads the page
through MSAA and IAccessible2 inside the prefix, and a native ATK publisher
presents it on the accessibility bus as toolkit Chromium, matching native
Linux Chromium, so the reader's own browser support handles browse mode,
structural navigation, forms, tables and live regions. Once a window is
published, legacy announcements for it stop, so nothing is spoken twice; if
the publisher fails, the window returns to the legacy path and the helper
retries with backoff. Publishers follow the helper's lifetime.

The publisher marks itself with WINE_ACCESS_BROWSER_PUBLISHER=1 and gives each
frame a wine-access-x11-window attribute so readers can verify window
ownership. Password text, values and boundaries never leave the worker.
Design, mapping rules and verification are in docs/browser.md; the
IAccessible2 IDL is vendored in third_party/ia2.

Checked: xvfb-run ctest (all 10, including the new
browser-publisher-snapshot comparison with native Chromium 158 and Electron
42), menu_integration.py with the menu and edit fixtures, the Orca extension
unit tests, and tests/browser/live_checks.sh against Electron 45: worker
protocol, helper lifecycle (publish, no legacy announcements while typing,
restart, no orphans), and live tree, text boundaries and AT-SPI event
sequence matching native Chromium. A live test with Cthulhu on Electron 45
read the fixture page correctly.

Remaining live checks: Orca with the extension, Firefox, WebView2, 32-bit
browsers, iframes, and window switching under other window managers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 23:15:21 -05:00

45 lines
1.5 KiB
C++

// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include <windows.h>
#include <map>
#include <string>
// Starts one wine-access-browser-publisher per Chromium window (Electron, CEF,
// Chrome) and tracks which windows it has published, so legacy announcements
// for those windows can stop. A window stays on the legacy path until its
// publisher reports "published", and returns to it if the publisher exits.
class BrowserBridge {
public:
~BrowserBridge();
// Locates the publisher and worker next to the helper and the prefix's Wine
// loader. Returns false when the bridge cannot run; legacy reading continues.
bool start();
// Call for WinEvents; looks for Chromium windows that need a publisher.
void window_event(HWND window, DWORD event);
// Call regularly: reads publisher readiness, reaps exits, retries failures,
// and checks the foreground window.
void poll();
// True once the window's publisher has published its tree.
bool owns(HWND window) const;
void stop();
private:
struct Publisher {
int pid = 0;
int output = -1; // publisher stdout: "published" once ready
bool published = false;
std::string buffered;
};
struct Attempts {
int failures = 0;
ULONGLONG retryAfter = 0;
};
void consider(HWND window);
bool launch(HWND window);
void read_output(Publisher &publisher);
std::map<HWND, Publisher> publishers_;
std::map<HWND, Attempts> attempts_;
std::string publisherPath_, workerPath_, loader_;
bool running_ = false;
};