Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor smallvil fixes #1095

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions smallvil/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Smallvil {

let pointer = self.seat.get_pointer().unwrap();

let under = self.surface_under_pointer(&pointer);
let under = self.surface_under(pos);

pointer.motion(
self,
Expand Down Expand Up @@ -98,10 +98,10 @@ impl Smallvil {

let horizontal_amount = event
.amount(Axis::Horizontal)
.unwrap_or_else(|| event.amount_discrete(Axis::Horizontal).unwrap() * 3.0);
.unwrap_or_else(|| event.amount_discrete(Axis::Horizontal).unwrap_or(0.0) * 3.0);
let vertical_amount = event
.amount(Axis::Vertical)
.unwrap_or_else(|| event.amount_discrete(Axis::Vertical).unwrap() * 3.0);
.unwrap_or_else(|| event.amount_discrete(Axis::Vertical).unwrap_or(0.0) * 3.0);
let horizontal_amount_discrete = event.amount_discrete(Axis::Horizontal);
let vertical_amount_discrete = event.amount_discrete(Axis::Vertical);

Expand Down
10 changes: 3 additions & 7 deletions smallvil/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{ffi::OsString, os::unix::io::AsRawFd, sync::Arc};

use smithay::{
desktop::{Space, Window, WindowSurfaceType},
input::{pointer::PointerHandle, Seat, SeatState},
input::{Seat, SeatState},
reexports::{
calloop::{generic::Generic, EventLoop, Interest, LoopSignal, Mode, PostAction},
wayland_server::{
Expand Down Expand Up @@ -61,7 +61,7 @@ impl Smallvil {

// Notify clients that we have a keyboard, for the sake of the example we assume that keyboard is always present.
// You may want to track keyboard hot-plug in real compositor.
seat.add_keyboard(Default::default(), 200, 200).unwrap();
seat.add_keyboard(Default::default(), 200, 25).unwrap();

// Notify clients that we have a pointer (mouse)
// Here we assume that there is always pointer plugged in
Expand Down Expand Up @@ -140,11 +140,7 @@ impl Smallvil {
socket_name
}

pub fn surface_under_pointer(
&self,
pointer: &PointerHandle<Self>,
) -> Option<(WlSurface, Point<i32, Logical>)> {
let pos = pointer.current_location();
pub fn surface_under(&self, pos: Point<f64, Logical>) -> Option<(WlSurface, Point<i32, Logical>)> {
self.space.element_under(pos).and_then(|(window, location)| {
window
.surface_under(pos - location.to_f64(), WindowSurfaceType::ALL)
Expand Down
15 changes: 1 addition & 14 deletions smallvil/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,9 @@ pub fn init_winit(

std::env::set_var("WAYLAND_DISPLAY", &state.socket_name);

let mut full_redraw = 0u8;

let timer = Timer::immediate();
event_loop.handle().insert_source(timer, move |_, _, data| {
winit_dispatch(
&mut backend,
&mut winit,
data,
&output,
&mut damage_tracker,
&mut full_redraw,
)
.unwrap();
winit_dispatch(&mut backend, &mut winit, data, &output, &mut damage_tracker).unwrap();
TimeoutAction::ToDuration(Duration::from_millis(16))
})?;

Expand All @@ -75,7 +65,6 @@ pub fn winit_dispatch(
data: &mut CalloopData,
output: &Output,
damage_tracker: &mut OutputDamageTracker,
full_redraw: &mut u8,
) -> Result<(), Box<dyn std::error::Error>> {
let display = &mut data.display;
let state = &mut data.state;
Expand Down Expand Up @@ -105,8 +94,6 @@ pub fn winit_dispatch(
res?;
}

*full_redraw = full_redraw.saturating_sub(1);

let size = backend.window_size().physical_size;
let damage = Rectangle::from_loc_and_size((0, 0), size);

Expand Down