Add a test for virtual pointer overflow
Browse files at this commite1d3b0c47ce5bb77f16e5006aba604d23b233649Parent: 3d8779d3 changed files +26 -0
- src/tests/client.rs +10 -0
- src/tests/mod.rs +1 -0
- src/tests/virtual_pointer.rs +15 -0
src/tests/client.rsmodified+10 -0
| @@ -22,6 +22,8 @@ use smithay::reexports::wayland_protocols_wlr::layer_shell::v1::client::zwlr_lay | |||
| 22 | use smithay::reexports::wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::{ | 22 | use smithay::reexports::wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::{ |
| 23 | self, ZwlrLayerSurfaceV1, | 23 | self, ZwlrLayerSurfaceV1, |
| 24 | }; | 24 | }; |
| 25 | +use smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::client::zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1; | ||
| 26 | +use smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::client::zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1; | ||
| 25 | use wayland_backend::client::Backend; | 27 | use wayland_backend::client::Backend; |
| 26 | use wayland_client::globals::Global; | 28 | use wayland_client::globals::Global; |
| 27 | use wayland_client::protocol::wl_buffer::{self, WlBuffer}; | 29 | use wayland_client::protocol::wl_buffer::{self, WlBuffer}; |
| @@ -53,6 +55,7 @@ pub struct State { | |||
| 53 | pub compositor: Option<WlCompositor>, | 55 | pub compositor: Option<WlCompositor>, |
| 54 | pub xdg_wm_base: Option<XdgWmBase>, | 56 | pub xdg_wm_base: Option<XdgWmBase>, |
| 55 | pub layer_shell: Option<ZwlrLayerShellV1>, | 57 | pub layer_shell: Option<ZwlrLayerShellV1>, |
| 58 | + pub virtual_pointer_manager: Option<ZwlrVirtualPointerManagerV1>, | ||
| 56 | pub spbm: Option<WpSinglePixelBufferManagerV1>, | 59 | pub spbm: Option<WpSinglePixelBufferManagerV1>, |
| 57 | pub viewporter: Option<WpViewporter>, | 60 | pub viewporter: Option<WpViewporter>, |
| 58 | 61 | ||
| @@ -179,6 +182,7 @@ impl Client { | |||
| 179 | compositor: None, | 182 | compositor: None, |
| 180 | xdg_wm_base: None, | 183 | xdg_wm_base: None, |
| 181 | layer_shell: None, | 184 | layer_shell: None, |
| 185 | + virtual_pointer_manager: None, | ||
| 182 | spbm: None, | 186 | spbm: None, |
| 183 | viewporter: None, | 187 | viewporter: None, |
| 184 | windows: Vec::new(), | 188 | windows: Vec::new(), |
| @@ -512,6 +516,9 @@ impl Dispatch<WlRegistry, ()> for State { | |||
| 512 | } else if interface == ZwlrLayerShellV1::interface().name { | 516 | } else if interface == ZwlrLayerShellV1::interface().name { |
| 513 | let version = min(version, ZwlrLayerShellV1::interface().version); | 517 | let version = min(version, ZwlrLayerShellV1::interface().version); |
| 514 | state.layer_shell = Some(registry.bind(name, version, qh, ())); | 518 | state.layer_shell = Some(registry.bind(name, version, qh, ())); |
| 519 | + } else if interface == ZwlrVirtualPointerManagerV1::interface().name { | ||
| 520 | + let version = min(version, ZwlrVirtualPointerManagerV1::interface().version); | ||
| 521 | + state.virtual_pointer_manager = Some(registry.bind(name, version, qh, ())); | ||
| 515 | } else if interface == WpSinglePixelBufferManagerV1::interface().name { | 522 | } else if interface == WpSinglePixelBufferManagerV1::interface().name { |
| 516 | let version = min(version, WpSinglePixelBufferManagerV1::interface().version); | 523 | let version = min(version, WpSinglePixelBufferManagerV1::interface().version); |
| 517 | state.spbm = Some(registry.bind(name, version, qh, ())); | 524 | state.spbm = Some(registry.bind(name, version, qh, ())); |
| @@ -604,6 +611,9 @@ impl Dispatch<ZwlrLayerShellV1, ()> for State { | |||
| 604 | } | 611 | } |
| 605 | } | 612 | } |
| 606 | 613 | ||
| 614 | +wayland_client::delegate_noop!(State: ZwlrVirtualPointerManagerV1); | ||
| 615 | +wayland_client::delegate_noop!(State: ZwlrVirtualPointerV1); | ||
| 616 | + | ||
| 607 | impl Dispatch<WlSurface, ()> for State { | 617 | impl Dispatch<WlSurface, ()> for State { |
| 608 | fn event( | 618 | fn event( |
| 609 | _state: &mut Self, | 619 | _state: &mut Self, |
src/tests/mod.rsmodified+1 -0
| @@ -10,4 +10,5 @@ mod fullscreen; | |||
| 10 | mod layer_shell; | 10 | mod layer_shell; |
| 11 | mod remove_output; | 11 | mod remove_output; |
| 12 | mod transactions; | 12 | mod transactions; |
| 13 | +mod virtual_pointer; | ||
| 13 | mod window_opening; | 14 | mod window_opening; |
src/tests/virtual_pointer.rsadded+15 -0
| @@ -0,0 +1,15 @@ | |||
| 1 | +use wayland_client::protocol::wl_pointer; | ||
| 2 | + | ||
| 3 | +use super::*; | ||
| 4 | + | ||
| 5 | +#[test] | ||
| 6 | +fn axis_discrete_overflow() { | ||
| 7 | + let mut f = Fixture::new(); | ||
| 8 | + let id = f.add_client(); | ||
| 9 | + | ||
| 10 | + let client = f.client(id); | ||
| 11 | + let manager = client.state.virtual_pointer_manager.as_ref().unwrap(); | ||
| 12 | + let pointer = manager.create_virtual_pointer(None, &client.qh, ()); | ||
| 13 | + pointer.axis_discrete(0, wl_pointer::Axis::VerticalScroll, 0., i32::MAX); | ||
| 14 | + f.roundtrip(id); | ||
| 15 | +} | ||