32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package atspi
|
|
|
|
import "strings"
|
|
|
|
func is_window_switcher_selection_type(eventType string, detail1 int) bool {
|
|
switch eventType {
|
|
case TextInsertedEvent, SelectionChangedEvent:
|
|
return true
|
|
case ShowingStateEvent:
|
|
return detail1 != 0
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// IsWindowSwitcherSelection matches Marco's transient selection container.
|
|
// Like Orca's switcher script, it uses insert/show/selection events and the
|
|
// container's name. The following accessible-name signal is not another move.
|
|
// Process identity and visible state keep ordinary background status updates
|
|
// out of this exception. This does not grant native or application focus.
|
|
func IsWindowSwitcherSelection(event Event) bool {
|
|
source := event.Source
|
|
return is_window_switcher_selection_type(event.Type, event.Detail1) &&
|
|
source.ApplicationProcess == "marco" && strings.EqualFold(source.ApplicationName, "marco") &&
|
|
source.Role == "status bar" && source.StatesKnown && source.Visible && source.Showing && !source.Defunct &&
|
|
source.ID().Valid() && event.Window.Valid() && event.Window.BusName == source.BusName
|
|
}
|