diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-07 19:45:55 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 14:49:38 +0400 |
| commit | c6838b08e2f65285f1391cec93f918cadb804117 (patch) | |
| tree | 2cd593a120a91b8e2b0759b252eda1f08700d5ea /src/grabs | |
| parent | ad3c3f8cefd38d2bf26b466d8e34eccde3bca443 (diff) | |
| download | niri-c6838b08e2f65285f1391cec93f918cadb804117.tar.gz niri-c6838b08e2f65285f1391cec93f918cadb804117.tar.bz2 niri-c6838b08e2f65285f1391cec93f918cadb804117.zip | |
Add rustfmt.toml and reformat
Diffstat (limited to 'src/grabs')
| -rw-r--r-- | src/grabs/move_grab.rs | 17 | ||||
| -rw-r--r-- | src/grabs/resize_grab.rs | 50 |
2 files changed, 38 insertions, 29 deletions
diff --git a/src/grabs/move_grab.rs b/src/grabs/move_grab.rs index c9aacbec..63cdb3bd 100644 --- a/src/grabs/move_grab.rs +++ b/src/grabs/move_grab.rs @@ -1,13 +1,12 @@ -use crate::Smallvil; -use smithay::{ - desktop::Window, - input::pointer::{ - AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, - PointerInnerHandle, RelativeMotionEvent, - }, - reexports::wayland_server::protocol::wl_surface::WlSurface, - utils::{Logical, Point}, +use smithay::desktop::Window; +use smithay::input::pointer::{ + AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, + PointerInnerHandle, RelativeMotionEvent, }; +use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +use smithay::utils::{Logical, Point}; + +use crate::Smallvil; pub struct MoveSurfaceGrab { pub start_data: PointerGrabStartData<Smallvil>, diff --git a/src/grabs/resize_grab.rs b/src/grabs/resize_grab.rs index 6a39cfcd..ee8aae5d 100644 --- a/src/grabs/resize_grab.rs +++ b/src/grabs/resize_grab.rs @@ -1,18 +1,18 @@ -use crate::Smallvil; -use smithay::{ - desktop::{Space, Window}, - input::pointer::{ - AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, - PointerInnerHandle, RelativeMotionEvent, - }, - reexports::{ - wayland_protocols::xdg::shell::server::xdg_toplevel, wayland_server::protocol::wl_surface::WlSurface, - }, - utils::{Logical, Point, Rectangle, Size}, - wayland::{compositor, shell::xdg::SurfaceCachedState}, -}; use std::cell::RefCell; +use smithay::desktop::{Space, Window}; +use smithay::input::pointer::{ + AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, + PointerInnerHandle, RelativeMotionEvent, +}; +use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; +use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +use smithay::utils::{Logical, Point, Rectangle, Size}; +use smithay::wayland::compositor; +use smithay::wayland::shell::xdg::SurfaceCachedState; + +use crate::Smallvil; + bitflags::bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct ResizeEdge: u32 { @@ -56,7 +56,10 @@ impl ResizeSurfaceGrab { let initial_rect = initial_window_rect; ResizeSurfaceState::with(window.toplevel().wl_surface(), |state| { - *state = ResizeSurfaceState::Resizing { edges, initial_rect }; + *state = ResizeSurfaceState::Resizing { + edges, + initial_rect, + }; }); Self { @@ -101,10 +104,11 @@ impl PointerGrab<Smallvil> for ResizeSurfaceGrab { new_window_height = (self.initial_rect.size.h as f64 + delta.y) as i32; } - let (min_size, max_size) = compositor::with_states(self.window.toplevel().wl_surface(), |states| { - let data = states.cached_state.current::<SurfaceCachedState>(); - (data.min_size, data.max_size) - }); + let (min_size, max_size) = + compositor::with_states(self.window.toplevel().wl_surface(), |states| { + let data = states.cached_state.current::<SurfaceCachedState>(); + (data.min_size, data.max_size) + }); let min_width = min_size.w.max(1); let min_height = min_size.h.max(1); @@ -219,8 +223,14 @@ impl ResizeSurfaceState { fn commit(&mut self) -> Option<(ResizeEdge, Rectangle<i32, Logical>)> { match *self { - Self::Resizing { edges, initial_rect } => Some((edges, initial_rect)), - Self::WaitingForLastCommit { edges, initial_rect } => { + Self::Resizing { + edges, + initial_rect, + } => Some((edges, initial_rect)), + Self::WaitingForLastCommit { + edges, + initial_rect, + } => { // The resize is done, let's go back to idle *self = Self::Idle; |
