mirror of
https://github.com/lwch/natpass.git
synced 2026-10-21 07:26:15 +00:00
增加鼠标显示逻辑
This commit is contained in:
@@ -26,16 +26,17 @@ type Link struct {
|
||||
targetIdx uint32 // target idx
|
||||
remote *pool.Conn
|
||||
// vnc
|
||||
ps *process.Process
|
||||
quality uint32
|
||||
img *image.RGBA
|
||||
ps *process.Process
|
||||
quality uint32
|
||||
showCursor bool
|
||||
img *image.RGBA
|
||||
// runtime
|
||||
sendBytes uint64
|
||||
recvBytes uint64
|
||||
sendPacket uint64
|
||||
recvPacket uint64
|
||||
idx int
|
||||
resetQuality bool
|
||||
sendBytes uint64
|
||||
recvBytes uint64
|
||||
sendPacket uint64
|
||||
recvPacket uint64
|
||||
idx int
|
||||
reDraw bool
|
||||
}
|
||||
|
||||
// GetID get link id
|
||||
@@ -61,12 +62,18 @@ func (link *Link) SetTargetIdx(idx uint32) {
|
||||
// SetQuality transfer quality
|
||||
func (link *Link) SetQuality(q uint32) {
|
||||
link.quality = q
|
||||
link.resetQuality = true
|
||||
link.reDraw = true
|
||||
}
|
||||
|
||||
// SetCursor set show cursor
|
||||
func (link *Link) SetCursor(b bool) {
|
||||
link.showCursor = b
|
||||
link.reDraw = true
|
||||
}
|
||||
|
||||
// Fork fork worker process
|
||||
func (link *Link) Fork(confDir string) error {
|
||||
p, err := process.CreateWorker(confDir)
|
||||
p, err := process.CreateWorker(confDir, link.showCursor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -116,10 +123,10 @@ func (link *Link) localRead() {
|
||||
}
|
||||
if img.Rect.Dx() != size.Dx() ||
|
||||
img.Rect.Dy() != size.Dy() ||
|
||||
link.resetQuality ||
|
||||
link.reDraw ||
|
||||
link.idx%100 == 0 {
|
||||
link.sendAll(img)
|
||||
link.resetQuality = false
|
||||
link.reDraw = false
|
||||
} else {
|
||||
link.sendDiff(img)
|
||||
}
|
||||
|
||||
@@ -79,15 +79,15 @@ func getSessionUserTokenWin() windows.Token {
|
||||
}
|
||||
|
||||
// CreateWorker create worker process
|
||||
func CreateWorker(confDir string) (*Process, error) {
|
||||
func CreateWorker(confDir string, showCursor bool) (*Process, error) {
|
||||
tk := getSessionUserTokenWin()
|
||||
if tk != 0 {
|
||||
defer windows.CloseHandle(windows.Handle(tk))
|
||||
}
|
||||
return createWorker(confDir, tk)
|
||||
return createWorker(confDir, tk, showCursor)
|
||||
}
|
||||
|
||||
func createWorker(confDir string, tk windows.Token) (*Process, error) {
|
||||
func createWorker(confDir string, tk windows.Token, showCursor bool) (*Process, error) {
|
||||
dir, err := os.Executable()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -104,7 +104,11 @@ func createWorker(confDir string, tk windows.Token) (*Process, error) {
|
||||
startup.Cb = uint32(unsafe.Sizeof(startup))
|
||||
startup.Desktop = windows.StringToUTF16Ptr("WinSta0\\default")
|
||||
startup.Flags = windows.STARTF_USESHOWWINDOW
|
||||
cmd := windows.StringToUTF16Ptr(dir + fmt.Sprintf(" -conf %s -action vnc.worker -vport %d", confDir, port))
|
||||
str := dir + fmt.Sprintf(" -conf %s -action vnc.worker -vport %d", confDir, port)
|
||||
if showCursor {
|
||||
str += "-vcursor"
|
||||
}
|
||||
cmd := windows.StringToUTF16Ptr(str)
|
||||
if tk == 0 {
|
||||
// only for debug
|
||||
startup.Flags = 0
|
||||
|
||||
Reference in New Issue
Block a user