Scoop API

scoop:scoop.ui:0.1.0

src/accessibility/activation.scoop

Selected production source · src/accessibility/activation.scoop

1package scoop.ui
3import scoop.graphics.Point
4import scoop.window.LogicalPosition
6/** Runs on the normal owner publication path against the accepted input scene. */
7internal fun SemanticsHandle.refreshActivation() {
8 resource.activationPoint = semanticActivation(this)
9}
11private fun semanticActivation(handle: SemanticsHandle): LogicalPosition? {
12 if (
13 !handle.active ||
14 !handle.properties.enabled ||
15 handle.properties.hidden ||
16 handle.properties.ignored ||
17 !handle.owner.scope.input.isInputAllowed
18 )
19 return None
20 val target = handle.focus ?: return None
21 if (!target.active)
22 return None
23 val visible = (handle.geometry?.visibleBounds ?: None) ?: return None
24 if (visible.size.width <= 0.0 || visible.size.height <= 0.0)
25 return None
26 // Every candidate is tested through the actual input path, including foreground areas.
27 val fractions = [0.5, 0.25, 0.75, 0.1, 0.9]
28 for (y in fractions)
29 for (x in fractions) {
30 val point =
31 Point(
32 visible.origin.x + visible.size.width * x,
33 visible.origin.y + visible.size.height * y
34 )
35 if (
36 target.area.hitTest(point) &&
37 handle.resource.containsPoint(LogicalPosition(point.x, point.y))
38 ) {
39 // The Window layer also checks the semantic native shape when publishing the point.
40 return Some(LogicalPosition(point.x, point.y))
41 }
42 }
43 return None