67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package atspi
|
|
|
|
/*
|
|
#include "adapter_native.h"
|
|
*/
|
|
import "C"
|
|
|
|
type nativeLiveProperties struct {
|
|
politeness string
|
|
atomic, busy bool
|
|
}
|
|
|
|
func capture_live_properties(source *C.AtspiAccessible) nativeLiveProperties {
|
|
properties := C.cthulhu_capture_live_properties(source)
|
|
defer C.g_free(C.gpointer(properties.politeness))
|
|
return nativeLiveProperties{sanitizeSnapshotField(C.GoString(properties.politeness)), properties.atomic != 0, properties.busy != 0}
|
|
}
|
|
|
|
// Called after foreground filtering. A completion is transformed into a live
|
|
// insertion so it cannot acquire focus or enter document-loading policy.
|
|
func (adapter *Adapter) prepare_live_region(event *C.AtspiEvent, eventType string, origin ObjectID, properties nativeLiveProperties) (deferEvent, complete bool) {
|
|
if eventType != TextInsertedEvent && eventType != ChildrenAddedEvent && eventType != BusyStateEvent {
|
|
return false, false
|
|
}
|
|
var savedDocument ObjectID
|
|
if eventType == BusyStateEvent {
|
|
if C.cthulhu_event_detail1(event) != 0 {
|
|
return false, false
|
|
}
|
|
var found bool
|
|
savedDocument, found = adapter.deferredLiveRegions.take(origin)
|
|
if !found {
|
|
return false, false
|
|
}
|
|
}
|
|
if properties.politeness == "" || properties.politeness == "off" {
|
|
return eventType == BusyStateEvent, false
|
|
}
|
|
if eventType != BusyStateEvent && !properties.busy {
|
|
return false, false
|
|
}
|
|
if C.cthulhu_in_active_document(event.source) == 0 {
|
|
return eventType == BusyStateEvent, false
|
|
}
|
|
document := C.cthulhu_document_ancestor(event.source)
|
|
if document == nil {
|
|
return eventType == BusyStateEvent, false
|
|
}
|
|
documentID := nativeObjectID(document)
|
|
C.g_object_unref(C.gpointer(document))
|
|
if savedDocument.Valid() && savedDocument != documentID {
|
|
return true, false
|
|
}
|
|
if properties.busy {
|
|
if owner := C.cthulhu_busy_live_container(event.source); owner != nil {
|
|
adapter.deferredLiveRegions.remember(nativeObjectID(owner), documentID)
|
|
C.g_object_unref(C.gpointer(owner))
|
|
return true, false
|
|
}
|
|
}
|
|
return false, eventType == BusyStateEvent
|
|
}
|