// 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" // Capture only the verified window manager's visible status container, before // background filtering or selected-child resolution. All native queries run // on the GLib owner; no native references or mutable switcher state survive. func (adapter *Adapter) window_switcher_event(event *C.AtspiEvent, eventType string) *Event { detail1 := int(C.cthulhu_event_detail1(event)) if !is_window_switcher_selection_type(eventType, detail1) || C.atspi_accessible_get_role(event.source, nil) != C.ATSPI_ROLE_STATUS_BAR || adapter.applicationProcess(event.source) != "marco" { return nil } // Insertions can precede accessible-name updates. Read the current name // and state instead of announcing the previous selection from the cache. C.atspi_accessible_clear_cache_single(event.source) snapshot := snapshotFromNativeWithCaret(event.source, false, false, false, false) snapshot.ApplicationProcess = "marco" selection := NewEvent(eventType, snapshot) selection.Detail1 = detail1 selection.Foreground = adapter.Foreground() selection.ForegroundMismatch = true window := C.cthulhu_window_ancestor(event.source) if window == nil { return nil } selection.Window = nativeObjectID(window) C.g_object_unref(C.gpointer(window)) if !IsWindowSwitcherSelection(selection) { return nil } return &selection }