srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2024-11-26 23:16:00 +0200
committersrdusr <[email protected]>2024-11-26 23:16:00 +0200
commit87f5c04b2593dc49409644e69e7962b73d26b9d8 (patch)
tree5a1da319c9f5e81489af44a4a576eada595b9a22 /crates/wayland/src
parentfe92f6e6b8ab680c9603cc6bcf16c98555c378ae (diff)
downloadsrdwm-87f5c04b2593dc49409644e69e7962b73d26b9d8.tar.gz
srdwm-87f5c04b2593dc49409644e69e7962b73d26b9d8.zip
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.
Diffstat (limited to 'crates/wayland/src')
-rw-r--r--crates/wayland/src/input.rs28
1 files changed, 27 insertions, 1 deletions
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<f64,
layer_surface_under_layers(state, pos, [Layer::Bottom, Layer::Background])
}
+/// `full` with only a top-anchored layer surface's exclusive zone (a menu
+/// bar) subtracted back out - see `Monitor::maximize_geometry`'s own doc
+/// comment for why maximize needs this third rect, distinct from both
+/// `geometry` (every zone subtracted) and `full_geometry` (none). Shared by
+/// both backends' `monitors()`, same as everything else in this module.
+/// Deliberately re-derived from the layer list rather than reusing
+/// `non_exclusive_zone()`: that smithay helper folds every anchor
+/// together, with no way to ask it to skip a bottom-anchored dock while
+/// still respecting a top-anchored bar.
+pub(crate) fn maximize_geometry_for(output: &Output, full: srdwm_core::Rect) -> 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::<LayerSurfaceCachedState>().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