scoop:scoop.ui:0.1.0
src/accessibility/activation.scoop
Selected production source · src/accessibility/activation.scoop
1
package scoop.ui3
import scoop.graphics.Point4
import scoop.window.LogicalPosition6
/** Runs on the normal owner publication path against the accepted input scene. */7
internal fun SemanticsHandle.refreshActivation() {8
resource.activationPoint = semanticActivation(this)9
}11
private 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.isInputAllowed18
)19
return None20
val target = handle.focus ?: return None21
if (!target.active)22
return None23
val visible = (handle.geometry?.visibleBounds ?: None) ?: return None24
if (visible.size.width <= 0.0 || visible.size.height <= 0.0)25
return None26
// 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 * y34
)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 None44
}