app: [linux,windows,wasm] scroll horizontally when shift key is pressed

Adds support for horizontal scroll using mousewheel with a shift key.
Support is added for windows, linux (wayland and x11), js (wasm).

Fixes: https://todo.sr.ht/~eliasnaur/gio/398
Signed-off-by: Mearaj <mearajbhagad@gmail.com>
This commit is contained in:
Mearaj
2023-05-04 02:44:24 +05:30
committed by Elias Naur
parent 59695984e5
commit febadd3145
4 changed files with 35 additions and 8 deletions
+12 -2
View File
@@ -953,7 +953,12 @@ func gio_onPointerAxis(data unsafe.Pointer, p *C.struct_wl_pointer, t, axis C.ui
case C.WL_POINTER_AXIS_HORIZONTAL_SCROLL:
w.scroll.dist.X += v
case C.WL_POINTER_AXIS_VERTICAL_SCROLL:
w.scroll.dist.Y += v
// horizontal scroll if shift + mousewheel(up/down) pressed.
if w.disp.xkb.Modifiers() == key.ModShift {
w.scroll.dist.X += v
} else {
w.scroll.dist.Y += v
}
}
}
@@ -1003,7 +1008,12 @@ func gio_onPointerAxisDiscrete(data unsafe.Pointer, p *C.struct_wl_pointer, axis
case C.WL_POINTER_AXIS_HORIZONTAL_SCROLL:
w.scroll.steps.X += int(discrete)
case C.WL_POINTER_AXIS_VERTICAL_SCROLL:
w.scroll.steps.Y += int(discrete)
// horizontal scroll if shift + mousewheel(up/down) pressed.
if w.disp.xkb.Modifiers() == key.ModShift {
w.scroll.steps.X += int(discrete)
} else {
w.scroll.steps.Y += int(discrete)
}
}
}