// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package xorg /* #include "commands_native.h" */ import "C" import ( "context" "errors" "image" ) // ClickOCR performs one X11 button press and release after review ownership // has been released. The native call checks active client and root dimensions. func (listener *CommandListener) ClickOCR(ctx context.Context, foreground uint64, root image.Rectangle, point image.Point) error { if ctx.Err() != nil { return ctx.Err() } listener.secureMutex.Lock() defer listener.secureMutex.Unlock() if listener.secure.Load() || listener.ocrApplied.Load() || foreground == 0 || root.Min != (image.Point{}) || !point.In(root) { return errors.New("OCR click unavailable") } if ctx.Err() != nil { return ctx.Err() } if C.cthulhu_ocr_click(C.ulong(foreground), C.int(point.X), C.int(point.Y), C.int(root.Dx()), C.int(root.Dy())) == 0 { return errors.New("OCR click source changed") } return nil }