Files
cthulhu/internal/atspi/adapter_window_title.go

37 lines
1022 B
Go

// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package atspi
import "git.stormux.org/storm/cthulhu/internal/platform/xorg"
// ForegroundTitle binds copied title metadata to the foreground ownership epoch.
type ForegroundTitle struct {
Title xorg.WindowTitle
Epoch uint64
}
func (adapter *Adapter) ForegroundTitle() ForegroundTitle {
if title := adapter.foregroundTitle.Load(); title != nil {
return *title
}
return ForegroundTitle{}
}
func (adapter *Adapter) TitleChanges() <-chan struct{} { return adapter.titleChanges }
// Called only by the GLib owner; consumers never issue X11 requests.
func (adapter *Adapter) refreshWindowTitle() {
state := adapter.Foreground()
value := ForegroundTitle{Title: adapter.foregroundReader.ReadTitle(state.Client.Window), Epoch: state.Epoch}
if value == adapter.ForegroundTitle() {
return
}
adapter.foregroundTitle.Store(&value)
select {
case adapter.titleChanges <- struct{}{}:
default:
}
}