diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-10 16:58:53 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-10 20:23:08 +0400 |
| commit | 9dfa121b8e31082314d1c9347a60ef2e596494cb (patch) | |
| tree | 6e9b90f2f1d54213444fb89b4739e0c8948ed1e9 /src/utils/mod.rs | |
| parent | c4ebb9f58e7ea1d2e688d3ee9483a7a1b3dd52b4 (diff) | |
| download | niri-9dfa121b8e31082314d1c9347a60ef2e596494cb.tar.gz niri-9dfa121b8e31082314d1c9347a60ef2e596494cb.tar.bz2 niri-9dfa121b8e31082314d1c9347a60ef2e596494cb.zip | |
Implement interactive mouse resizing
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index db715874..e22bd979 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -7,11 +7,13 @@ use std::sync::atomic::AtomicBool; use std::time::Duration; use anyhow::{ensure, Context}; +use bitflags::bitflags; use directories::UserDirs; use git_version::git_version; use niri_config::Config; use smithay::output::Output; use smithay::reexports::rustix::time::{clock_gettime, ClockId}; +use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::utils::{Logical, Point, Rectangle, Size, Transform}; pub mod id; @@ -21,6 +23,32 @@ pub mod watcher; pub static IS_SYSTEMD_SERVICE: AtomicBool = AtomicBool::new(false); +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + pub struct ResizeEdge: u32 { + const TOP = 0b0001; + const BOTTOM = 0b0010; + const LEFT = 0b0100; + const RIGHT = 0b1000; + + const TOP_LEFT = Self::TOP.bits() | Self::LEFT.bits(); + const BOTTOM_LEFT = Self::BOTTOM.bits() | Self::LEFT.bits(); + + const TOP_RIGHT = Self::TOP.bits() | Self::RIGHT.bits(); + const BOTTOM_RIGHT = Self::BOTTOM.bits() | Self::RIGHT.bits(); + + const LEFT_RIGHT = Self::LEFT.bits() | Self::RIGHT.bits(); + const TOP_BOTTOM = Self::TOP.bits() | Self::BOTTOM.bits(); + } +} + +impl From<xdg_toplevel::ResizeEdge> for ResizeEdge { + #[inline] + fn from(x: xdg_toplevel::ResizeEdge) -> Self { + Self::from_bits(x as u32).unwrap() + } +} + pub fn version() -> String { format!( "{} ({})", |
