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.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
@@ -0,0 +1,74 @@
|
||||
//go:build windows
|
||||
|
||||
// Package device creates Direct3D 11 devices: the device of package d3d11's
|
||||
// renderer, and that of the Windows backend, which shows the controls of
|
||||
// windows with a material through DirectComposition without the renderer.
|
||||
// It depends on nothing of MyGo, so apps that draw no native UI link none
|
||||
// of the renderer.
|
||||
package device
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var procD3D11CreateDevice = syscall.NewLazyDLL(SystemDir() + `\d3d11.dll`).NewProc("D3D11CreateDevice")
|
||||
|
||||
// SystemDir returns the system directory, which system DLLs load from,
|
||||
// never from the application directory or the search path.
|
||||
func SystemDir() string {
|
||||
buf := make([]uint16, 260)
|
||||
n, _, _ := syscall.NewLazyDLL("kernel32.dll").NewProc("GetSystemDirectoryW").Call(uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)))
|
||||
if n == 0 || int(n) > len(buf) {
|
||||
return `C:\Windows\System32`
|
||||
}
|
||||
return syscall.UTF16ToString(buf[:n])
|
||||
}
|
||||
|
||||
// New creates a Direct3D 11 device and its immediate context, on the GPU
|
||||
// or, when there is none, with Windows' software rasterizer (WARP), which
|
||||
// software reports. The caller releases the device and the context.
|
||||
func New() (device, context uintptr, software bool, err error) {
|
||||
return create(0, hardware, warp)
|
||||
}
|
||||
|
||||
// NewOnGPU is New for a device on the GPU only: it fails where New would
|
||||
// make one with WARP.
|
||||
func NewOnGPU() (device, context uintptr, err error) {
|
||||
device, context, _, err = create(0, hardware)
|
||||
return device, context, err
|
||||
}
|
||||
|
||||
// NewForVideo is New for a device that decodes and converts video, as
|
||||
// Media Foundation's: one that supports Direct3D's video API where the
|
||||
// GPU has it, else as New.
|
||||
func NewForVideo() (device, context uintptr, software bool, err error) {
|
||||
const videoSupport = 0x800
|
||||
if d, c, sw, err := create(videoSupport, hardware, warp); err == nil {
|
||||
return d, c, sw, nil
|
||||
}
|
||||
return create(0, hardware, warp)
|
||||
}
|
||||
|
||||
// The drivers create tries, in order.
|
||||
const hardware, warp = 1, 5
|
||||
|
||||
func create(flags uintptr, drivers ...uintptr) (device, context uintptr, software bool, err error) {
|
||||
if err := procD3D11CreateDevice.Find(); err != nil {
|
||||
return 0, 0, false, err
|
||||
}
|
||||
levels := []uint32{0xb000, 0xa100, 0xa000} // 11_0, 10_1, 10_0
|
||||
const bgraSupport = 0x20
|
||||
var hr uintptr
|
||||
for _, driver := range drivers {
|
||||
var level uint32
|
||||
hr, _, _ = procD3D11CreateDevice.Call(0, driver, 0, bgraSupport|flags,
|
||||
uintptr(unsafe.Pointer(&levels[0])), uintptr(len(levels)), 7,
|
||||
uintptr(unsafe.Pointer(&device)), uintptr(unsafe.Pointer(&level)), uintptr(unsafe.Pointer(&context)))
|
||||
if int32(uint32(hr)) >= 0 {
|
||||
return device, context, driver == warp, nil
|
||||
}
|
||||
}
|
||||
return 0, 0, false, fmt.Errorf("d3d11: cannot create a device: %#x", uint32(hr))
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//go:build windows
|
||||
|
||||
package device
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// IID_IDXGIDevice
|
||||
var iidIDXGIDevice = [16]byte{0xfa, 0x77, 0xec, 0x54, 0x77, 0x13, 0xe6, 0x44, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c}
|
||||
|
||||
// call calls method i of the COM interface obj.
|
||||
func call(obj uintptr, i int, args ...uintptr) uintptr {
|
||||
vtbl := *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&obj)))
|
||||
fn := *(*uintptr)(unsafe.Add(*(*unsafe.Pointer)(unsafe.Pointer(&vtbl)), i*int(unsafe.Sizeof(uintptr(0)))))
|
||||
r, _, _ := syscall.SyscallN(fn, append([]uintptr{obj}, args...)...)
|
||||
return r
|
||||
}
|
||||
|
||||
// TestNew checks that New gives a device and a context, and that the device
|
||||
// is a DXGI device, which DirectComposition needs.
|
||||
func TestNew(t *testing.T) {
|
||||
device, context, software, err := New()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer call(device, 2)
|
||||
defer call(context, 2)
|
||||
if device == 0 || context == 0 {
|
||||
t.Fatalf("device %#x, context %#x", device, context)
|
||||
}
|
||||
var dxgi uintptr
|
||||
if hr := call(device, 0, uintptr(unsafe.Pointer(&iidIDXGIDevice)), uintptr(unsafe.Pointer(&dxgi))); int32(uint32(hr)) < 0 {
|
||||
t.Fatalf("the device is no DXGI device: %#x", uint32(hr))
|
||||
}
|
||||
call(dxgi, 2)
|
||||
t.Logf("software (WARP): %v", software)
|
||||
}
|
||||
Reference in new issue
Block a user