grabs: Add ReleaseMode for menu-initiated grabs
This commit is contained in:
parent
85771dff5e
commit
edfb0edda7
11 changed files with 206 additions and 81 deletions
|
|
@ -17,6 +17,11 @@ use super::{
|
|||
layout::{floating::ResizeSurfaceGrab, tiling::ResizeForkGrab},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum ReleaseMode {
|
||||
Click,
|
||||
NoMouseButtons,
|
||||
}
|
||||
mod moving;
|
||||
pub use self::moving::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@ use crate::{
|
|||
|
||||
use cosmic::theme::CosmicTheme;
|
||||
use smithay::{
|
||||
backend::renderer::{
|
||||
element::{utils::RescaleRenderElement, AsRenderElements, RenderElement},
|
||||
ImportAll, ImportMem, Renderer,
|
||||
backend::{
|
||||
input::ButtonState,
|
||||
renderer::{
|
||||
element::{utils::RescaleRenderElement, AsRenderElements, RenderElement},
|
||||
ImportAll, ImportMem, Renderer,
|
||||
},
|
||||
},
|
||||
desktop::space::SpaceElement,
|
||||
input::{
|
||||
|
|
@ -46,6 +49,8 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use super::ReleaseMode;
|
||||
|
||||
pub type SeatMoveGrabState = RefCell<Option<MoveGrabState>>;
|
||||
|
||||
const RESCALE_ANIMATION_DURATION: f64 = 150.0;
|
||||
|
|
@ -217,6 +222,7 @@ pub struct MoveGrab {
|
|||
cursor_output: Output,
|
||||
window_outputs: HashSet<Output>,
|
||||
tiling: bool,
|
||||
release: ReleaseMode,
|
||||
}
|
||||
|
||||
impl PointerGrab<State> for MoveGrab {
|
||||
|
|
@ -334,8 +340,17 @@ impl PointerGrab<State> for MoveGrab {
|
|||
event: &ButtonEvent,
|
||||
) {
|
||||
handle.button(state, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
self.ungrab(state, handle, event.serial, event.time);
|
||||
match self.release {
|
||||
ReleaseMode::NoMouseButtons => {
|
||||
if handle.current_pressed().is_empty() {
|
||||
self.ungrab(state, handle, event.serial, event.time);
|
||||
}
|
||||
}
|
||||
ReleaseMode::Click => {
|
||||
if event.state == ButtonState::Pressed {
|
||||
self.ungrab(state, handle, event.serial, event.time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -438,6 +453,7 @@ impl MoveGrab {
|
|||
initial_window_location: Point<i32, Global>,
|
||||
indicator_thickness: u8,
|
||||
was_tiled: bool,
|
||||
release: ReleaseMode,
|
||||
) -> MoveGrab {
|
||||
let output = seat.active_output();
|
||||
let mut outputs = HashSet::new();
|
||||
|
|
@ -473,6 +489,7 @@ impl MoveGrab {
|
|||
window_outputs: outputs,
|
||||
cursor_output: output,
|
||||
tiling: was_tiled,
|
||||
release,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue