Files
openchamber-android-native/third_party/mygo/internal/linux/input_region.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
2026-11-18 13:22:59 +08:00

50 lines
2.0 KiB
Go

//go:build linux && !android && (amd64 || arm64)
package linux
import "github.com/egoist/mygo/internal/platform"
// An input region (SetInputRegion) lets the pointer through a window but
// where its rectangles are, as a desktop pet's window lets clicks through
// to the windows under it but on its character: the window's input shape
// is the region (applyInputShape), which X11's SHAPE extension and
// Wayland's input region of the surface (wl_surface_set_input_region) put
// in place of the window's own. The X server and the compositor then hand
// a press outside it to what is beneath, another app's window too, as
// they would were the window not there.
// shapeInputRegion is (*window).shapeInputRegion once the app set an
// input region, for applyInputShape, which every app has, to call.
var shapeInputRegion func(w *window, win ptr)
func (w *window) SetInputRegion(region []platform.Rect) {
shapeInputRegion = (*window).shapeInputRegion
w.inputRegion = region
w.applyInputShape(true)
}
// shapeInputRegion gives the window's GdkWindow win the input shape of
// its region, where the content is in it.
func (w *window) shapeInputRegion(win ptr) {
region := cairoRegionCreateRectangle(&gdkRectangle{})
for _, r := range w.inputRegion {
cairoRegionUnionRectangle(region, &gdkRectangle{X: int32(r.X), Y: int32(r.Y), Width: int32(r.Width), Height: int32(r.Height)})
}
x, y := w.contentInWindow()
gdkWindowInputShapeCombineRegion(win, region, x, y)
cairoRegionDestroy(region)
}
// contentInWindow returns where the content is in the window's
// GdkWindow, which holds the menu bar, and the shadow GTK draws around a
// window it decorates itself, as flyouts are placed from it.
func (w *window) contentInWindow() (x, y int32) {
loadFlyouts() // binds gtk_widget_translate_coordinates
if c := w.contentWidget(); c == 0 || !gtkWidgetTranslateCoordinates(c, w.win, 0, 0, &x, &y) {
x, y = 0, w.contentInsets().top
}
var alloc gdkRectangle
gtkWidgetGetAllocation(w.win, &alloc)
return x + alloc.X, y + alloc.Y
}