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
+120
@@ -0,0 +1,120 @@
|
||||
//go:build windows && (amd64 || arm64)
|
||||
|
||||
package windows
|
||||
|
||||
import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/egoist/mygo/internal/platform"
|
||||
)
|
||||
|
||||
var (
|
||||
wtsapi32 = systemDLL("wtsapi32.dll")
|
||||
|
||||
procWTSRegisterSessionNotification = wtsapi32.NewProc("WTSRegisterSessionNotification")
|
||||
procPowerCreateRequest = kernel32.NewProc("PowerCreateRequest")
|
||||
procPowerSetRequest = kernel32.NewProc("PowerSetRequest")
|
||||
procPowerClearRequest = kernel32.NewProc("PowerClearRequest")
|
||||
procCloseHandle = kernel32.NewProc("CloseHandle")
|
||||
procGetSystemPowerStatus = kernel32.NewProc("GetSystemPowerStatus")
|
||||
procGetTickCount = kernel32.NewProc("GetTickCount")
|
||||
procGetLastInputInfo = user32.NewProc("GetLastInputInfo")
|
||||
)
|
||||
|
||||
// Messages about power and the session, which the application window gets.
|
||||
const (
|
||||
wmPowerBroadcast = 0x0218
|
||||
wmWTSSessionChange = 0x02B1
|
||||
pbtAPMSuspend = 0x4
|
||||
pbtAPMResumeAutomatic = 0x12
|
||||
wtsSessionLock = 0x7
|
||||
wtsSessionUnlock = 0x8
|
||||
)
|
||||
|
||||
func (b *Backend) Power() platform.Power { return power{b} }
|
||||
func (b *Backend) Secrets() platform.Secrets { return secrets{} }
|
||||
|
||||
type power struct{ b *Backend }
|
||||
|
||||
func (p power) Watch() {
|
||||
p.b.watchingPower = true
|
||||
const notifyForThisSession = 0
|
||||
procWTSRegisterSessionNotification.Call(p.b.appHwnd, notifyForThisSession)
|
||||
}
|
||||
|
||||
// powerMessage reports the power and session messages of the application
|
||||
// window.
|
||||
func (b *Backend) powerMessage(m uint32, wp uintptr) {
|
||||
if !b.watchingPower {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case m == wmPowerBroadcast && wp == pbtAPMSuspend:
|
||||
b.h.PowerEvent("suspend")
|
||||
case m == wmPowerBroadcast && wp == pbtAPMResumeAutomatic:
|
||||
b.h.PowerEvent("resume")
|
||||
case m == wmWTSSessionChange && wp == wtsSessionLock:
|
||||
b.h.PowerEvent("lock-screen")
|
||||
case m == wmWTSSessionChange && wp == wtsSessionUnlock:
|
||||
b.h.PowerEvent("unlock-screen")
|
||||
}
|
||||
}
|
||||
|
||||
// reasonContext mirrors REASON_CONTEXT with a simple reason string.
|
||||
type reasonContext struct {
|
||||
version, flags uint32
|
||||
reason *uint16
|
||||
_ [2]uintptr // the rest of the union
|
||||
}
|
||||
|
||||
func (p power) KeepAwake(display bool, reason string) func() {
|
||||
const (
|
||||
contextSimpleString = 0x1
|
||||
requestDisplay = 0 // PowerRequestDisplayRequired
|
||||
requestSystem = 1 // PowerRequestSystemRequired
|
||||
)
|
||||
ctx := reasonContext{flags: contextSimpleString, reason: u16(reason)}
|
||||
h, _, _ := procPowerCreateRequest.Call(uintptr(unsafe.Pointer(&ctx)))
|
||||
if h == 0 || h == ^uintptr(0) {
|
||||
return nil
|
||||
}
|
||||
requests := []uintptr{requestSystem}
|
||||
if display {
|
||||
requests = append(requests, requestDisplay)
|
||||
}
|
||||
for _, r := range requests {
|
||||
procPowerSetRequest.Call(h, r)
|
||||
}
|
||||
return func() {
|
||||
for _, r := range requests {
|
||||
procPowerClearRequest.Call(h, r)
|
||||
}
|
||||
procCloseHandle.Call(h)
|
||||
}
|
||||
}
|
||||
|
||||
// KeepRunning does nothing for now. Windows slows some processes out of
|
||||
// sight too (power throttling, EcoQoS), which SetProcessInformation's
|
||||
// ProcessPowerThrottling would turn off.
|
||||
func (p power) KeepRunning(string) func() { return func() {} }
|
||||
|
||||
func (p power) OnBattery() bool {
|
||||
var status struct {
|
||||
acLineStatus, batteryFlag, batteryLifePercent, systemStatusFlag uint8
|
||||
batteryLifeTime, batteryFullLifeTime uint32
|
||||
}
|
||||
if r, _, _ := procGetSystemPowerStatus.Call(uintptr(unsafe.Pointer(&status))); r == 0 {
|
||||
return false
|
||||
}
|
||||
return status.acLineStatus == 0
|
||||
}
|
||||
|
||||
func (p power) IdleTime() time.Duration {
|
||||
info := struct{ size, time uint32 }{size: 8}
|
||||
if r, _, _ := procGetLastInputInfo.Call(uintptr(unsafe.Pointer(&info))); r == 0 {
|
||||
return 0
|
||||
}
|
||||
now, _, _ := procGetTickCount.Call()
|
||||
return time.Duration(uint32(now)-info.time) * time.Millisecond
|
||||
}
|
||||
Reference in new issue
Block a user