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
|
|
@ -1,7 +1,10 @@
|
||||||
use super::{CosmicMapped, CosmicSurface, CosmicWindow};
|
use super::{CosmicMapped, CosmicSurface, CosmicWindow};
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{
|
shell::{
|
||||||
focus::FocusDirection, grabs::MoveGrab, layout::tiling::NodeDesc, Direction, Shell, Trigger,
|
focus::FocusDirection,
|
||||||
|
grabs::{MoveGrab, ReleaseMode},
|
||||||
|
layout::tiling::NodeDesc,
|
||||||
|
Direction, Shell, Trigger,
|
||||||
},
|
},
|
||||||
state::State,
|
state::State,
|
||||||
utils::iced::{IcedElement, Program},
|
utils::iced::{IcedElement, Program},
|
||||||
|
|
@ -650,7 +653,13 @@ impl Program for CosmicStackInternal {
|
||||||
.wl_surface()
|
.wl_surface()
|
||||||
{
|
{
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
Shell::move_request(state, &surface, &seat, serial);
|
Shell::move_request(
|
||||||
|
state,
|
||||||
|
&surface,
|
||||||
|
&seat,
|
||||||
|
serial,
|
||||||
|
ReleaseMode::NoMouseButtons,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1113,6 +1122,7 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
pos.to_i32_round() - Point::from((elem_geo.size.w / 2, 24)),
|
pos.to_i32_round() - Point::from((elem_geo.size.w / 2, 24)),
|
||||||
indicator_thickness,
|
indicator_thickness,
|
||||||
was_tiled,
|
was_tiled,
|
||||||
|
ReleaseMode::NoMouseButtons,
|
||||||
);
|
);
|
||||||
if grab.is_tiling_grab() {
|
if grab.is_tiling_grab() {
|
||||||
data.common.shell.set_overview_mode(
|
data.common.shell.set_overview_mode(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::Shell,
|
shell::{grabs::ReleaseMode, Shell},
|
||||||
state::State,
|
state::State,
|
||||||
utils::{
|
utils::{
|
||||||
iced::{IcedElement, Program},
|
iced::{IcedElement, Program},
|
||||||
|
|
@ -255,7 +255,13 @@ impl Program for CosmicWindowInternal {
|
||||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||||
if let Some(surface) = self.window.wl_surface() {
|
if let Some(surface) = self.window.wl_surface() {
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
Shell::move_request(state, &surface, &seat, serial);
|
Shell::move_request(
|
||||||
|
state,
|
||||||
|
&surface,
|
||||||
|
&seat,
|
||||||
|
serial,
|
||||||
|
ReleaseMode::NoMouseButtons,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ use super::{
|
||||||
layout::{floating::ResizeSurfaceGrab, tiling::ResizeForkGrab},
|
layout::{floating::ResizeSurfaceGrab, tiling::ResizeForkGrab},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub enum ReleaseMode {
|
||||||
|
Click,
|
||||||
|
NoMouseButtons,
|
||||||
|
}
|
||||||
mod moving;
|
mod moving;
|
||||||
pub use self::moving::*;
|
pub use self::moving::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,12 @@ use crate::{
|
||||||
|
|
||||||
use cosmic::theme::CosmicTheme;
|
use cosmic::theme::CosmicTheme;
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::renderer::{
|
backend::{
|
||||||
element::{utils::RescaleRenderElement, AsRenderElements, RenderElement},
|
input::ButtonState,
|
||||||
ImportAll, ImportMem, Renderer,
|
renderer::{
|
||||||
|
element::{utils::RescaleRenderElement, AsRenderElements, RenderElement},
|
||||||
|
ImportAll, ImportMem, Renderer,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
desktop::space::SpaceElement,
|
desktop::space::SpaceElement,
|
||||||
input::{
|
input::{
|
||||||
|
|
@ -46,6 +49,8 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::ReleaseMode;
|
||||||
|
|
||||||
pub type SeatMoveGrabState = RefCell<Option<MoveGrabState>>;
|
pub type SeatMoveGrabState = RefCell<Option<MoveGrabState>>;
|
||||||
|
|
||||||
const RESCALE_ANIMATION_DURATION: f64 = 150.0;
|
const RESCALE_ANIMATION_DURATION: f64 = 150.0;
|
||||||
|
|
@ -217,6 +222,7 @@ pub struct MoveGrab {
|
||||||
cursor_output: Output,
|
cursor_output: Output,
|
||||||
window_outputs: HashSet<Output>,
|
window_outputs: HashSet<Output>,
|
||||||
tiling: bool,
|
tiling: bool,
|
||||||
|
release: ReleaseMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PointerGrab<State> for MoveGrab {
|
impl PointerGrab<State> for MoveGrab {
|
||||||
|
|
@ -334,8 +340,17 @@ impl PointerGrab<State> for MoveGrab {
|
||||||
event: &ButtonEvent,
|
event: &ButtonEvent,
|
||||||
) {
|
) {
|
||||||
handle.button(state, event);
|
handle.button(state, event);
|
||||||
if handle.current_pressed().is_empty() {
|
match self.release {
|
||||||
self.ungrab(state, handle, event.serial, event.time);
|
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>,
|
initial_window_location: Point<i32, Global>,
|
||||||
indicator_thickness: u8,
|
indicator_thickness: u8,
|
||||||
was_tiled: bool,
|
was_tiled: bool,
|
||||||
|
release: ReleaseMode,
|
||||||
) -> MoveGrab {
|
) -> MoveGrab {
|
||||||
let output = seat.active_output();
|
let output = seat.active_output();
|
||||||
let mut outputs = HashSet::new();
|
let mut outputs = HashSet::new();
|
||||||
|
|
@ -473,6 +489,7 @@ impl MoveGrab {
|
||||||
window_outputs: outputs,
|
window_outputs: outputs,
|
||||||
cursor_output: output,
|
cursor_output: output,
|
||||||
tiling: was_tiled,
|
tiling: was_tiled,
|
||||||
|
release,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,15 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{
|
shell::{
|
||||||
element::CosmicMapped, focus::target::PointerFocusTarget, grabs::ResizeEdge, CosmicSurface,
|
element::CosmicMapped,
|
||||||
|
focus::target::PointerFocusTarget,
|
||||||
|
grabs::{ReleaseMode, ResizeEdge},
|
||||||
|
CosmicSurface,
|
||||||
},
|
},
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
};
|
};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
|
backend::input::ButtonState,
|
||||||
desktop::space::SpaceElement,
|
desktop::space::SpaceElement,
|
||||||
input::{
|
input::{
|
||||||
pointer::{
|
pointer::{
|
||||||
|
|
@ -20,7 +24,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
Seat,
|
Seat,
|
||||||
},
|
},
|
||||||
utils::{IsAlive, Logical, Point, Rectangle, Size},
|
utils::{IsAlive, Logical, Point, Rectangle, Serial, Size},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Information about the resize operation.
|
/// Information about the resize operation.
|
||||||
|
|
@ -50,6 +54,7 @@ pub struct ResizeSurfaceGrab {
|
||||||
edges: ResizeEdge,
|
edges: ResizeEdge,
|
||||||
initial_window_size: Size<i32, Logical>,
|
initial_window_size: Size<i32, Logical>,
|
||||||
last_window_size: Size<i32, Logical>,
|
last_window_size: Size<i32, Logical>,
|
||||||
|
release: ReleaseMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PointerGrab<State> for ResizeSurfaceGrab {
|
impl PointerGrab<State> for ResizeSurfaceGrab {
|
||||||
|
|
@ -140,36 +145,16 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
||||||
event: &ButtonEvent,
|
event: &ButtonEvent,
|
||||||
) {
|
) {
|
||||||
handle.button(data, event);
|
handle.button(data, event);
|
||||||
if handle.current_pressed().is_empty() {
|
match self.release {
|
||||||
// No more buttons are pressed, release the grab.
|
ReleaseMode::NoMouseButtons => {
|
||||||
self.seat
|
if handle.current_pressed().is_empty() {
|
||||||
.user_data()
|
self.ungrab(data, handle, event.serial, event.time);
|
||||||
.get::<ResizeGrabMarker>()
|
}
|
||||||
.unwrap()
|
|
||||||
.0
|
|
||||||
.store(false, Ordering::SeqCst);
|
|
||||||
handle.unset_grab(data, event.serial, event.time, true);
|
|
||||||
|
|
||||||
// If toplevel is dead, we can't resize it, so we return early.
|
|
||||||
if !self.window.alive() {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
ReleaseMode::Click => {
|
||||||
self.window.set_resizing(false);
|
if event.state == ButtonState::Pressed {
|
||||||
self.window.set_geometry(Rectangle::from_loc_and_size(
|
self.ungrab(data, handle, event.serial, event.time);
|
||||||
match self.window.active_window() {
|
}
|
||||||
CosmicSurface::X11(s) => s.geometry().loc.as_global(),
|
|
||||||
_ => (0, 0).into(),
|
|
||||||
},
|
|
||||||
self.last_window_size.as_global(),
|
|
||||||
));
|
|
||||||
self.window.configure();
|
|
||||||
|
|
||||||
let mut resize_state = self.window.resize_state.lock().unwrap();
|
|
||||||
if let Some(ResizeState::Resizing(resize_data)) = *resize_state {
|
|
||||||
*resize_state = Some(ResizeState::WaitingForCommit(resize_data));
|
|
||||||
} else {
|
|
||||||
panic!("invalid resize state: {:?}", resize_state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -280,6 +265,7 @@ impl ResizeSurfaceGrab {
|
||||||
initial_window_location: Point<i32, Local>,
|
initial_window_location: Point<i32, Local>,
|
||||||
initial_window_size: Size<i32, Logical>,
|
initial_window_size: Size<i32, Logical>,
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
|
release: ReleaseMode,
|
||||||
) -> ResizeSurfaceGrab {
|
) -> ResizeSurfaceGrab {
|
||||||
let resize_state = ResizeState::Resizing(ResizeData {
|
let resize_state = ResizeState::Resizing(ResizeData {
|
||||||
edges,
|
edges,
|
||||||
|
|
@ -300,6 +286,7 @@ impl ResizeSurfaceGrab {
|
||||||
edges,
|
edges,
|
||||||
initial_window_size,
|
initial_window_size,
|
||||||
last_window_size: initial_window_size,
|
last_window_size: initial_window_size,
|
||||||
|
release,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -375,4 +362,43 @@ impl ResizeSurfaceGrab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ungrab(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut PointerInnerHandle<'_, State>,
|
||||||
|
serial: Serial,
|
||||||
|
time: u32,
|
||||||
|
) {
|
||||||
|
// No more buttons are pressed, release the grab.
|
||||||
|
self.seat
|
||||||
|
.user_data()
|
||||||
|
.get::<ResizeGrabMarker>()
|
||||||
|
.unwrap()
|
||||||
|
.0
|
||||||
|
.store(false, Ordering::SeqCst);
|
||||||
|
handle.unset_grab(data, serial, time, true);
|
||||||
|
|
||||||
|
// If toplevel is dead, we can't resize it, so we return early.
|
||||||
|
if !self.window.alive() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.window.set_resizing(false);
|
||||||
|
self.window.set_geometry(Rectangle::from_loc_and_size(
|
||||||
|
match self.window.active_window() {
|
||||||
|
CosmicSurface::X11(s) => s.geometry().loc.as_global(),
|
||||||
|
_ => (0, 0).into(),
|
||||||
|
},
|
||||||
|
self.last_window_size.as_global(),
|
||||||
|
));
|
||||||
|
self.window.configure();
|
||||||
|
|
||||||
|
let mut resize_state = self.window.resize_state.lock().unwrap();
|
||||||
|
if let Some(ResizeState::Resizing(resize_data)) = *resize_state {
|
||||||
|
*resize_state = Some(ResizeState::WaitingForCommit(resize_data));
|
||||||
|
} else {
|
||||||
|
panic!("invalid resize state: {:?}", resize_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ use crate::{
|
||||||
CosmicMapped, CosmicMappedRenderElement, CosmicWindow,
|
CosmicMapped, CosmicMappedRenderElement, CosmicWindow,
|
||||||
},
|
},
|
||||||
focus::{target::KeyboardFocusTarget, FocusDirection, FocusStackMut},
|
focus::{target::KeyboardFocusTarget, FocusDirection, FocusStackMut},
|
||||||
grabs::ResizeEdge,
|
grabs::{ReleaseMode, ResizeEdge},
|
||||||
CosmicSurface, Direction, FocusResult, MoveResult, ResizeDirection, ResizeMode,
|
CosmicSurface, Direction, FocusResult, MoveResult, ResizeDirection, ResizeMode,
|
||||||
},
|
},
|
||||||
state::State,
|
state::State,
|
||||||
|
|
@ -459,6 +459,7 @@ impl FloatingLayout {
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
start_data: PointerGrabStartData<State>,
|
start_data: PointerGrabStartData<State>,
|
||||||
edges: ResizeEdge,
|
edges: ResizeEdge,
|
||||||
|
release: ReleaseMode,
|
||||||
) -> Option<ResizeSurfaceGrab> {
|
) -> Option<ResizeSurfaceGrab> {
|
||||||
if seat.get_pointer().is_some() {
|
if seat.get_pointer().is_some() {
|
||||||
let location = self.space.element_location(&mapped).unwrap().as_local();
|
let location = self.space.element_location(&mapped).unwrap().as_local();
|
||||||
|
|
@ -472,6 +473,7 @@ impl FloatingLayout {
|
||||||
location,
|
location,
|
||||||
size,
|
size,
|
||||||
seat,
|
seat,
|
||||||
|
release,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::render::cursor::{CursorShape, CursorState},
|
backend::render::cursor::{CursorShape, CursorState},
|
||||||
shell::{focus::target::PointerFocusTarget, layout::Orientation},
|
shell::{focus::target::PointerFocusTarget, grabs::ReleaseMode, layout::Orientation},
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
};
|
};
|
||||||
use id_tree::{NodeId, Tree};
|
use id_tree::{NodeId, Tree};
|
||||||
|
|
@ -74,20 +74,19 @@ impl PointerTarget<State> for ResizeForkTarget {
|
||||||
let location = pointer.current_location();
|
let location = pointer.current_location();
|
||||||
pointer.set_grab(
|
pointer.set_grab(
|
||||||
state,
|
state,
|
||||||
ResizeForkGrab {
|
ResizeForkGrab::new(
|
||||||
start_data: PointerGrabStartData {
|
PointerGrabStartData {
|
||||||
focus: None,
|
focus: None,
|
||||||
button,
|
button,
|
||||||
location,
|
location,
|
||||||
},
|
},
|
||||||
old_tree: None,
|
location.as_global(),
|
||||||
accumulated_delta: 0.0,
|
|
||||||
last_loc: location,
|
|
||||||
node,
|
node,
|
||||||
output,
|
|
||||||
left_up_idx,
|
left_up_idx,
|
||||||
orientation,
|
orientation,
|
||||||
},
|
output,
|
||||||
|
ReleaseMode::NoMouseButtons,
|
||||||
|
),
|
||||||
serial,
|
serial,
|
||||||
Focus::Clear,
|
Focus::Clear,
|
||||||
)
|
)
|
||||||
|
|
@ -117,13 +116,38 @@ impl PointerTarget<State> for ResizeForkTarget {
|
||||||
|
|
||||||
pub struct ResizeForkGrab {
|
pub struct ResizeForkGrab {
|
||||||
start_data: PointerGrabStartData<State>,
|
start_data: PointerGrabStartData<State>,
|
||||||
last_loc: Point<f64, Logical>,
|
last_loc: Point<f64, Global>,
|
||||||
old_tree: Option<Tree<Data>>,
|
old_tree: Option<Tree<Data>>,
|
||||||
accumulated_delta: f64,
|
accumulated_delta: f64,
|
||||||
node: NodeId,
|
node: NodeId,
|
||||||
output: WeakOutput,
|
output: WeakOutput,
|
||||||
left_up_idx: usize,
|
left_up_idx: usize,
|
||||||
orientation: Orientation,
|
orientation: Orientation,
|
||||||
|
release: ReleaseMode,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ResizeForkGrab {
|
||||||
|
pub fn new(
|
||||||
|
start_data: PointerGrabStartData<State>,
|
||||||
|
pointer_loc: Point<f64, Global>,
|
||||||
|
node: NodeId,
|
||||||
|
idx: usize,
|
||||||
|
orientation: Orientation,
|
||||||
|
output: WeakOutput,
|
||||||
|
release: ReleaseMode,
|
||||||
|
) -> ResizeForkGrab {
|
||||||
|
ResizeForkGrab {
|
||||||
|
start_data,
|
||||||
|
last_loc: pointer_loc,
|
||||||
|
old_tree: None,
|
||||||
|
accumulated_delta: 0.0,
|
||||||
|
node,
|
||||||
|
output,
|
||||||
|
left_up_idx: idx,
|
||||||
|
orientation,
|
||||||
|
release,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PointerGrab<State> for ResizeForkGrab {
|
impl PointerGrab<State> for ResizeForkGrab {
|
||||||
|
|
@ -137,7 +161,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
||||||
// While the grab is active, no client has pointer focus
|
// While the grab is active, no client has pointer focus
|
||||||
handle.motion(data, None, event);
|
handle.motion(data, None, event);
|
||||||
|
|
||||||
let delta = event.location - self.last_loc;
|
let delta = event.location - self.last_loc.as_logical();
|
||||||
|
|
||||||
if let Some(output) = self.output.upgrade() {
|
if let Some(output) = self.output.upgrade() {
|
||||||
let tiling_layer = &mut data.common.shell.active_space_mut(&output).tiling_layer;
|
let tiling_layer = &mut data.common.shell.active_space_mut(&output).tiling_layer;
|
||||||
|
|
@ -234,7 +258,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_loc = event.location;
|
self.last_loc = event.location.as_global();
|
||||||
let blocker = TilingLayout::update_positions(&output, tree, gaps);
|
let blocker = TilingLayout::update_positions(&output, tree, gaps);
|
||||||
tiling_layer.pending_blockers.extend(blocker);
|
tiling_layer.pending_blockers.extend(blocker);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -261,9 +285,17 @@ impl PointerGrab<State> for ResizeForkGrab {
|
||||||
event: &ButtonEvent,
|
event: &ButtonEvent,
|
||||||
) {
|
) {
|
||||||
handle.button(data, event);
|
handle.button(data, event);
|
||||||
if handle.current_pressed().is_empty() {
|
match self.release {
|
||||||
// No more buttons are pressed, release the grab.
|
ReleaseMode::NoMouseButtons => {
|
||||||
handle.unset_grab(data, event.serial, event.time, true);
|
if handle.current_pressed().is_empty() {
|
||||||
|
handle.unset_grab(data, event.serial, event.time, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReleaseMode::Click => {
|
||||||
|
if event.state == ButtonState::Pressed {
|
||||||
|
handle.unset_grab(data, event.serial, event.time, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1883,9 +1883,10 @@ impl Shell {
|
||||||
surface: &WlSurface,
|
surface: &WlSurface,
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
serial: impl Into<Option<Serial>>,
|
serial: impl Into<Option<Serial>>,
|
||||||
|
release: ReleaseMode,
|
||||||
) {
|
) {
|
||||||
let serial = serial.into();
|
let serial = serial.into();
|
||||||
if let Some(start_data) = check_grab_preconditions(&seat, surface, serial) {
|
if let Some(start_data) = check_grab_preconditions(&seat, surface, serial, release) {
|
||||||
if let Some(mapped) = state.common.shell.element_for_wl_surface(surface).cloned() {
|
if let Some(mapped) = state.common.shell.element_for_wl_surface(surface).cloned() {
|
||||||
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
||||||
let output = seat.active_output();
|
let output = seat.active_output();
|
||||||
|
|
@ -1901,6 +1902,7 @@ impl Shell {
|
||||||
&output,
|
&output,
|
||||||
start_data,
|
start_data,
|
||||||
active_hint as u8,
|
active_hint as u8,
|
||||||
|
release,
|
||||||
) {
|
) {
|
||||||
let handle = workspace.handle;
|
let handle = workspace.handle;
|
||||||
state
|
state
|
||||||
|
|
@ -1939,7 +1941,9 @@ impl Shell {
|
||||||
edges: ResizeEdge,
|
edges: ResizeEdge,
|
||||||
) {
|
) {
|
||||||
let serial = serial.into();
|
let serial = serial.into();
|
||||||
if let Some(start_data) = check_grab_preconditions(&seat, surface, serial) {
|
if let Some(start_data) =
|
||||||
|
check_grab_preconditions(&seat, surface, serial, ReleaseMode::NoMouseButtons)
|
||||||
|
{
|
||||||
if let Some(mapped) = state.common.shell.element_for_wl_surface(surface).cloned() {
|
if let Some(mapped) = state.common.shell.element_for_wl_surface(surface).cloned() {
|
||||||
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
||||||
if let Some(grab) = workspace.resize_request(&mapped, &seat, start_data, edges)
|
if let Some(grab) = workspace.resize_request(&mapped, &seat, start_data, edges)
|
||||||
|
|
@ -2028,32 +2032,41 @@ pub fn check_grab_preconditions(
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
surface: &WlSurface,
|
surface: &WlSurface,
|
||||||
serial: Option<Serial>,
|
serial: Option<Serial>,
|
||||||
|
release: ReleaseMode,
|
||||||
) -> Option<PointerGrabStartData<State>> {
|
) -> Option<PointerGrabStartData<State>> {
|
||||||
use smithay::reexports::wayland_server::Resource;
|
use smithay::reexports::wayland_server::Resource;
|
||||||
|
|
||||||
// TODO: touch resize.
|
// TODO: touch resize.
|
||||||
let pointer = seat.get_pointer().unwrap();
|
let pointer = seat.get_pointer().unwrap();
|
||||||
|
|
||||||
// Check that this surface has a click grab.
|
let start_data = pointer
|
||||||
if !match serial {
|
.grab_start_data()
|
||||||
Some(serial) => pointer.has_grab(serial),
|
.unwrap_or_else(|| PointerGrabStartData {
|
||||||
None => pointer.is_grabbed(),
|
focus: pointer.current_focus().map(|f| (f, Point::from((0, 0)))),
|
||||||
} {
|
button: 0x110,
|
||||||
return None;
|
location: pointer.current_location(),
|
||||||
}
|
});
|
||||||
|
|
||||||
let start_data = pointer.grab_start_data().unwrap();
|
if release == ReleaseMode::NoMouseButtons {
|
||||||
|
// Check that this surface has a click grab.
|
||||||
|
if !match serial {
|
||||||
|
Some(serial) => pointer.has_grab(serial),
|
||||||
|
None => pointer.is_grabbed(),
|
||||||
|
} {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
// If the focus was for a different surface, ignore the request.
|
// If the focus was for a different surface, ignore the request.
|
||||||
if start_data.focus.is_none()
|
if start_data.focus.is_none()
|
||||||
|| !start_data
|
|| !start_data
|
||||||
.focus
|
.focus
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.0
|
.0
|
||||||
.same_client_as(&surface.id())
|
.same_client_as(&surface.id())
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(start_data)
|
Some(start_data)
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ use super::{
|
||||||
target::{KeyboardFocusTarget, PointerFocusTarget, WindowGroup},
|
target::{KeyboardFocusTarget, PointerFocusTarget, WindowGroup},
|
||||||
FocusDirection, FocusStack, FocusStackMut,
|
FocusDirection, FocusStack, FocusStackMut,
|
||||||
},
|
},
|
||||||
grabs::{ResizeEdge, ResizeGrab},
|
grabs::{ReleaseMode, ResizeEdge, ResizeGrab},
|
||||||
layout::tiling::{Data, NodeDesc},
|
layout::tiling::{Data, NodeDesc},
|
||||||
CosmicMappedRenderElement, CosmicSurface, ResizeDirection, ResizeMode,
|
CosmicMappedRenderElement, CosmicSurface, ResizeDirection, ResizeMode,
|
||||||
};
|
};
|
||||||
|
|
@ -640,7 +640,13 @@ impl Workspace {
|
||||||
|
|
||||||
if self.floating_layer.mapped().any(|m| m == mapped) {
|
if self.floating_layer.mapped().any(|m| m == mapped) {
|
||||||
self.floating_layer
|
self.floating_layer
|
||||||
.resize_request(mapped, seat, start_data.clone(), edges)
|
.resize_request(
|
||||||
|
mapped,
|
||||||
|
seat,
|
||||||
|
start_data.clone(),
|
||||||
|
edges,
|
||||||
|
ReleaseMode::NoMouseButtons,
|
||||||
|
)
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -678,6 +684,7 @@ impl Workspace {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
start_data: PointerGrabStartData<State>,
|
start_data: PointerGrabStartData<State>,
|
||||||
indicator_thickness: u8,
|
indicator_thickness: u8,
|
||||||
|
release: ReleaseMode,
|
||||||
) -> Option<MoveGrab> {
|
) -> Option<MoveGrab> {
|
||||||
let pointer = seat.get_pointer().unwrap();
|
let pointer = seat.get_pointer().unwrap();
|
||||||
let pos = pointer.current_location().as_global();
|
let pos = pointer.current_location().as_global();
|
||||||
|
|
@ -720,6 +727,7 @@ impl Workspace {
|
||||||
initial_window_location,
|
initial_window_location,
|
||||||
indicator_thickness,
|
indicator_thickness,
|
||||||
was_tiled.is_some(),
|
was_tiled.is_some(),
|
||||||
|
release,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{element::CosmicWindow, CosmicMapped, CosmicSurface, ManagedLayer},
|
shell::{element::CosmicWindow, grabs::ReleaseMode, CosmicMapped, CosmicSurface, ManagedLayer},
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
wayland::protocols::screencopy::SessionType,
|
wayland::protocols::screencopy::SessionType,
|
||||||
};
|
};
|
||||||
|
|
@ -139,7 +139,13 @@ impl XdgShellHandler for State {
|
||||||
|
|
||||||
fn move_request(&mut self, surface: ToplevelSurface, seat: WlSeat, serial: Serial) {
|
fn move_request(&mut self, surface: ToplevelSurface, seat: WlSeat, serial: Serial) {
|
||||||
let seat = Seat::from_resource(&seat).unwrap();
|
let seat = Seat::from_resource(&seat).unwrap();
|
||||||
Shell::move_request(self, surface.wl_surface(), &seat, serial)
|
Shell::move_request(
|
||||||
|
self,
|
||||||
|
surface.wl_surface(),
|
||||||
|
&seat,
|
||||||
|
serial,
|
||||||
|
ReleaseMode::NoMouseButtons,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resize_request(
|
fn resize_request(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::{ffi::OsString, os::unix::io::OwnedFd};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::render::cursor::{load_cursor_theme, Cursor, CursorShape},
|
backend::render::cursor::{load_cursor_theme, Cursor, CursorShape},
|
||||||
shell::{focus::target::KeyboardFocusTarget, CosmicSurface, Shell},
|
shell::{focus::target::KeyboardFocusTarget, grabs::ReleaseMode, CosmicSurface, Shell},
|
||||||
state::State,
|
state::State,
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
wayland::{
|
wayland::{
|
||||||
|
|
@ -410,7 +410,7 @@ impl XwmHandler for State {
|
||||||
fn move_request(&mut self, _xwm: XwmId, window: X11Surface, _button: u32) {
|
fn move_request(&mut self, _xwm: XwmId, window: X11Surface, _button: u32) {
|
||||||
if let Some(wl_surface) = window.wl_surface() {
|
if let Some(wl_surface) = window.wl_surface() {
|
||||||
let seat = self.common.last_active_seat().clone();
|
let seat = self.common.last_active_seat().clone();
|
||||||
Shell::move_request(self, &wl_surface, &seat, None)
|
Shell::move_request(self, &wl_surface, &seat, None, ReleaseMode::NoMouseButtons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue