Trace window focus, blur and visibility in pen input
From the development repository at 0304046. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
db4cb3a731
commit
2de843143d
2 files changed
+17
-2
No files matched your search
+16
-1
@@ -178,7 +178,8 @@ export function attachPenInput(surface, target) {
|
||||
/** @param {PointerEvent} event @returns {string} The press, for the trace. */
|
||||
function describe(event) {
|
||||
const where = event.target === surface ? '' : ` on ${describeTarget(event.target)}`;
|
||||
return `${event.pointerType} ${event.pointerId} buttons ${event.buttons} pressure ${event.pressure.toFixed(2)}${where}`;
|
||||
const focus = document.hasFocus() ? 'in front' : 'behind';
|
||||
return `${event.pointerType} ${event.pointerId} buttons ${event.buttons} pressure ${event.pressure.toFixed(2)} (${focus})${where}`;
|
||||
}
|
||||
|
||||
surface.addEventListener('pointerdown', (event) => {
|
||||
@@ -314,6 +315,20 @@ export function attachPenInput(surface, target) {
|
||||
// The side button of a pen asks for a context menu.
|
||||
surface.addEventListener('contextmenu', (event) => event.preventDefault());
|
||||
|
||||
// The window's focus, blur and the tab's visibility, traced into the
|
||||
// Session log but acting on nothing yet (2026-10-11): Andy's pages
|
||||
// sometimes gained a lone dot when he clicked the page to bring the
|
||||
// browser to the front from the terminal, with the Pen chosen. A
|
||||
// press that only raised the window should draw nothing, but whether
|
||||
// the browser reports the focus before that press or after it, and
|
||||
// whether the document is focused when the press arrives, must be
|
||||
// learned on his machine before the rule is written (a window focus
|
||||
// is faked by the test harness on every tab switch, so it cannot be
|
||||
// learned here). The press trace already carries "in front"/"behind".
|
||||
window.addEventListener('focus', () => trace('window: focus'));
|
||||
window.addEventListener('blur', () => trace('window: blur'));
|
||||
document.addEventListener('visibilitychange', () => trace(`visibility: ${document.visibilityState}`));
|
||||
|
||||
// Safari on iOS: cancelling pointerdown leaves the touch's own
|
||||
// behaviour (selection, the magnifier, the callout) to WebKit; only a
|
||||
// cancelled touchstart stops it. The text field is a child of the
|
||||
|
||||
@@ -781,7 +781,7 @@ class EndToEndTest(unittest.TestCase):
|
||||
# and a release of the pen, after the browser's name.
|
||||
shown = firefox.run("return document.getElementById('event_log').textContent;")
|
||||
self.assertRegex(shown, r"^\d\d:\d\d:\d\d\.\d\d\d Browser: Mozilla")
|
||||
self.assertRegex(shown, r"\n\S+ press pen \d+ buttons 1 pressure \d\.\d\d, pen\n")
|
||||
self.assertRegex(shown, r"\n\S+ press pen \d+ buttons 1 pressure \d\.\d\d \((?:in front|behind)\), pen\n")
|
||||
self.assertRegex(shown, r"\n\S+ pointerup pen \d+, \d+ points")
|
||||
firefox.run("document.getElementById('session_close').click();")
|
||||
self.assertFalse(firefox.run("return document.getElementById('session_dialog').open;"))
|
||||
|
||||
Reference in new issue
Block a user