diff options
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/compositor.rs | 18 | ||||
| -rw-r--r-- | src/handlers/xdg_shell.rs | 44 |
2 files changed, 55 insertions, 7 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index 0bdd7690..5f39d47c 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -13,6 +13,7 @@ use smithay::wayland::compositor::{ SurfaceAttributes, }; use smithay::wayland::dmabuf::get_dmabuf; +use smithay::wayland::shell::xdg::XdgToplevelSurfaceData; use smithay::wayland::shm::{ShmHandler, ShmState}; use smithay::{delegate_compositor, delegate_shm}; @@ -237,8 +238,21 @@ impl CompositorHandler for State { return; } + let serial = with_states(surface, |states| { + let role = states + .data_map + .get::<XdgToplevelSurfaceData>() + .unwrap() + .lock() + .unwrap(); + role.configure_serial + }); + if serial.is_none() { + error!("commit on a mapped surface without a configured serial"); + } + // The toplevel remains mapped. - self.niri.layout.update_window(&window); + self.niri.layout.update_window(&window, serial); // Popup placement depends on window size which might have changed. self.update_reactive_popups(&window, &output); @@ -256,7 +270,7 @@ impl CompositorHandler for State { let window = mapped.window.clone(); let output = output.clone(); window.on_commit(); - self.niri.layout.update_window(&window); + self.niri.layout.update_window(&window, None); self.niri.queue_redraw(&output); return; } diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 9864ccdc..5e255d17 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -11,6 +11,7 @@ use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::{se use smithay::reexports::wayland_server::protocol::wl_output; use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +use smithay::reexports::wayland_server::Resource; use smithay::utils::{Logical, Rectangle, Serial}; use smithay::wayland::compositor::{ add_pre_commit_hook, send_surface_state, with_states, BufferAssignment, HookId, @@ -31,6 +32,7 @@ use smithay::{ use crate::layout::workspace::ColumnWidth; use crate::niri::{PopupGrabState, State}; +use crate::resize_grab::ResizeGrab; use crate::window::{InitialConfigureState, ResolvedWindowRules, Unmapped, WindowRef}; impl XdgShellHandler for State { @@ -60,12 +62,44 @@ impl XdgShellHandler for State { fn resize_request( &mut self, - _surface: ToplevelSurface, + surface: ToplevelSurface, _seat: WlSeat, - _serial: Serial, - _edges: ResizeEdge, + serial: Serial, + edges: ResizeEdge, ) { - // FIXME + let pointer = self.niri.seat.get_pointer().unwrap(); + if !pointer.has_grab(serial) { + return; + } + + let Some(start_data) = pointer.grab_start_data() else { + return; + }; + + let Some((focus, _)) = &start_data.focus else { + return; + }; + + let wl_surface = surface.wl_surface(); + if !focus.id().same_client_as(&wl_surface.id()) { + return; + } + + let Some((mapped, _)) = self.niri.layout.find_window_and_output(wl_surface) else { + return; + }; + + let window = mapped.window.clone(); + if !self + .niri + .layout + .interactive_resize_begin(window.clone(), edges.into()) + { + return; + } + + let grab = ResizeGrab::new(start_data, window); + pointer.set_grab(self, grab, serial, Focus::Clear); } fn reposition_request( @@ -799,7 +833,7 @@ impl State { drop(config); let output = output.cloned(); let window = mapped.window.clone(); - self.niri.layout.update_window(&window); + self.niri.layout.update_window(&window, None); if let Some(output) = output { self.niri.queue_redraw(&output); |
