aboutsummaryrefslogtreecommitdiff
path: root/src/grabs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-13 12:46:53 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-13 12:46:53 +0400
commit95c810c855a27a28f4dfa7dc6b949fef0901c7b2 (patch)
treec240dd8d8c6eac7cd18c507fbe35724ca7de8aeb /src/grabs
parente02e35f9c61e103a01640d3dc95a894e8855e1c9 (diff)
downloadniri-95c810c855a27a28f4dfa7dc6b949fef0901c7b2.tar.gz
niri-95c810c855a27a28f4dfa7dc6b949fef0901c7b2.tar.bz2
niri-95c810c855a27a28f4dfa7dc6b949fef0901c7b2.zip
Refactor everything, add initial tiling code
Diffstat (limited to 'src/grabs')
-rw-r--r--src/grabs/move_grab.rs12
-rw-r--r--src/grabs/resize_grab.rs82
2 files changed, 49 insertions, 45 deletions
diff --git a/src/grabs/move_grab.rs b/src/grabs/move_grab.rs
index 699921d1..67a1f285 100644
--- a/src/grabs/move_grab.rs
+++ b/src/grabs/move_grab.rs
@@ -5,6 +5,7 @@ use smithay::input::pointer::{
};
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::utils::{Logical, Point};
+use smithay::wayland::seat::WaylandFocus;
use crate::Niri;
@@ -25,10 +26,13 @@ impl PointerGrab<Niri> for MoveSurfaceGrab {
// While the grab is active, no client has pointer focus
handle.motion(data, None, event);
- let delta = event.location - self.start_data.location;
- let new_location = self.initial_window_location.to_f64() + delta;
- data.space
- .map_element(self.window.clone(), new_location.to_i32_round(), true);
+ // let delta = event.location - self.start_data.location;
+ // let new_location = self.initial_window_location.to_f64() + delta;
+ // let (window, space) = data
+ // .monitor_set
+ // .find_window_and_space(self.window.wl_surface().as_ref().unwrap())
+ // .unwrap();
+ // space.map_element(window.clone(), new_location.to_i32_round(), true);
}
fn relative_motion(
diff --git a/src/grabs/resize_grab.rs b/src/grabs/resize_grab.rs
index 2bc2f194..819e0b6a 100644
--- a/src/grabs/resize_grab.rs
+++ b/src/grabs/resize_grab.rs
@@ -1,6 +1,6 @@
use std::cell::RefCell;
-use smithay::desktop::{Space, Window};
+use smithay::desktop::Window;
use smithay::input::pointer::{
AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab,
PointerInnerHandle, RelativeMotionEvent,
@@ -241,48 +241,48 @@ impl ResizeSurfaceState {
}
}
-/// Should be called on `WlSurface::commit`
-pub fn handle_commit(space: &mut Space<Window>, surface: &WlSurface) -> Option<()> {
- let window = space
- .elements()
- .find(|w| w.toplevel().wl_surface() == surface)
- .cloned()?;
-
- let mut window_loc = space.element_location(&window)?;
- let geometry = window.geometry();
-
- let new_loc: Point<Option<i32>, Logical> = ResizeSurfaceState::with(surface, |state| {
- state
- .commit()
- .and_then(|(edges, initial_rect)| {
- // If the window is being resized by top or left, its location must be adjusted
- // accordingly.
- edges.intersects(ResizeEdge::TOP_LEFT).then(|| {
- let new_x = edges
- .intersects(ResizeEdge::LEFT)
- .then_some(initial_rect.loc.x + (initial_rect.size.w - geometry.size.w));
-
- let new_y = edges
- .intersects(ResizeEdge::TOP)
- .then_some(initial_rect.loc.y + (initial_rect.size.h - geometry.size.h));
-
- (new_x, new_y).into()
- })
- })
- .unwrap_or_default()
+pub fn handle_commit(window: &Window) -> Option<()> {
+ // FIXME
+ let surface = window.toplevel().wl_surface();
+ ResizeSurfaceState::with(surface, |state| {
+ state.commit();
});
- if let Some(new_x) = new_loc.x {
- window_loc.x = new_x;
- }
- if let Some(new_y) = new_loc.y {
- window_loc.y = new_y;
- }
-
- if new_loc.x.is_some() || new_loc.y.is_some() {
- // If TOP or LEFT side of the window got resized, we have to move it
- space.map_element(window, window_loc, false);
- }
+ // let mut window_loc = space.element_location(&window)?;
+ // let geometry = window.geometry();
+
+ // let new_loc: Point<Option<i32>, Logical> = ResizeSurfaceState::with(surface, |state| {
+ // state
+ // .commit()
+ // .and_then(|(edges, initial_rect)| {
+ // // If the window is being resized by top or left, its location must be adjusted
+ // // accordingly.
+ // edges.intersects(ResizeEdge::TOP_LEFT).then(|| {
+ // let new_x = edges
+ // .intersects(ResizeEdge::LEFT)
+ // .then_some(initial_rect.loc.x + (initial_rect.size.w - geometry.size.w));
+
+ // let new_y = edges
+ // .intersects(ResizeEdge::TOP)
+ // .then_some(initial_rect.loc.y + (initial_rect.size.h - geometry.size.h));
+
+ // (new_x, new_y).into()
+ // })
+ // })
+ // .unwrap_or_default()
+ // });
+
+ // if let Some(new_x) = new_loc.x {
+ // window_loc.x = new_x;
+ // }
+ // if let Some(new_y) = new_loc.y {
+ // window_loc.y = new_y;
+ // }
+
+ // if new_loc.x.is_some() || new_loc.y.is_some() {
+ // // If TOP or LEFT side of the window got resized, we have to move it
+ // space.map_element(window, window_loc, false);
+ // }
Some(())
}