From 87f5c04b2593dc49409644e69e7962b73d26b9d8 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:16:00 +0200 Subject: Add Monitor::maximize_geometry: maximize covers a dock, still stops at a top bar toggle_maximize previously targeted full_geometry outright (past every reserved zone), on an earlier request specifically about the dock - which also silently let it extend behind a top bar's zone, reported back as its own bug once live-tested. maximize_geometry is a third rect distinct from geometry (every zone) and full_geometry (none): full_geometry with only a top-anchored bar's exclusive zone subtracted back out. New test locks in dock-covered/bar-respected together. --- crates/wayland/src/input.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'crates/wayland/src/input.rs') diff --git a/crates/wayland/src/input.rs b/crates/wayland/src/input.rs index 4b98a8a..af296db 100644 --- a/crates/wayland/src/input.rs +++ b/crates/wayland/src/input.rs @@ -11,12 +11,15 @@ //! [`crate::lock`]. use smithay::backend::input::{ButtonState as BackendButtonState, KeyState as BackendKeyState, KeyboardKeyEvent}; +use smithay::backend::session::Session as _; use smithay::desktop::{layer_map_for_output, Window as DWindow, WindowSurfaceType}; use smithay::input::keyboard::FilterResult; use smithay::input::pointer::{ButtonEvent, MotionEvent}; +use smithay::output::Output; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::utils::{Logical, Point, SERIAL_COUNTER}; -use smithay::wayland::shell::wlr_layer::{KeyboardInteractivity, Layer}; +use smithay::wayland::compositor::with_states; +use smithay::wayland::shell::wlr_layer::{Anchor, ExclusiveZone, KeyboardInteractivity, Layer, LayerSurfaceCachedState}; use std::time::{Duration, Instant}; use srdwm_core::{Event as CoreEvent, Modifiers, TitlebarHit, WindowId}; @@ -83,6 +86,29 @@ pub(crate) fn background_layer_surface_under(state: &CompState, pos: Point srdwm_core::Rect { + let mut rect = full; + for layer in layer_map_for_output(output).layers() { + let data = with_states(layer.wl_surface(), |states| *states.cached_state.get::().current()); + let ExclusiveZone::Exclusive(amount) = data.exclusive_zone else { continue }; + if data.anchor.contains(Anchor::TOP) && !data.anchor.contains(Anchor::BOTTOM) { + let shrink = (amount as i32 + data.margin.top).max(0); + rect.y += shrink; + rect.height = rect.height.saturating_sub(shrink as u32); + } + } + rect +} + /// `ext_idle_notify_v1`'s whole job is answering "has the user touched an /// input device recently" - `IdleNotifierState` does the actual timer /// bookkeeping (see its own doc comment), this just has to be called from -- cgit v1.2.3