~eliasnaur/gio

cda73efa6a1c807603dd5d678921fc0bc32c721a — Dominik Honnef 1 year, 6 months ago b6e0376
app: [Windows] include keyboard modifiers in move, drag, and scroll pointer events

This matches the behavior on Linux and macOS.

Signed-off-by: Dominik Honnef <dominik@honnef.co>
1 files changed, 16 insertions(+), 14 deletions(-)

M app/os_windows.go
M app/os_windows.go => app/os_windows.go +16 -14
@@ 304,16 304,17 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
		x, y := coordsFromlParam(lParam)
		p := f32.Point{X: float32(x), Y: float32(y)}
		w.w.Event(pointer.Event{
			Type:     pointer.Move,
			Source:   pointer.Mouse,
			Position: p,
			Buttons:  w.pointerBtns,
			Time:     windows.GetMessageTime(),
			Type:      pointer.Move,
			Source:    pointer.Mouse,
			Position:  p,
			Buttons:   w.pointerBtns,
			Time:      windows.GetMessageTime(),
			Modifiers: getModifiers(),
		})
	case windows.WM_MOUSEWHEEL:
		w.scrollEvent(wParam, lParam, false)
		w.scrollEvent(wParam, lParam, false, getModifiers())
	case windows.WM_MOUSEHWHEEL:
		w.scrollEvent(wParam, lParam, true)
		w.scrollEvent(wParam, lParam, true, getModifiers())
	case windows.WM_DESTROY:
		w.w.Event(ViewEvent{})
		w.w.Event(system.DestroyEvent{})


@@ 518,7 519,7 @@ func coordsFromlParam(lParam uintptr) (int, int) {
	return x, y
}

func (w *window) scrollEvent(wParam, lParam uintptr, horizontal bool) {
func (w *window) scrollEvent(wParam, lParam uintptr, horizontal bool, kmods key.Modifiers) {
	x, y := coordsFromlParam(lParam)
	// The WM_MOUSEWHEEL coordinates are in screen coordinates, in contrast
	// to other mouse events.


@@ 533,12 534,13 @@ func (w *window) scrollEvent(wParam, lParam uintptr, horizontal bool) {
		sp.Y = -dist
	}
	w.w.Event(pointer.Event{
		Type:     pointer.Scroll,
		Source:   pointer.Mouse,
		Position: p,
		Buttons:  w.pointerBtns,
		Scroll:   sp,
		Time:     windows.GetMessageTime(),
		Type:      pointer.Scroll,
		Source:    pointer.Mouse,
		Position:  p,
		Buttons:   w.pointerBtns,
		Scroll:    sp,
		Modifiers: kmods,
		Time:      windows.GetMessageTime(),
	})
}