floating: Limit resizing to current output
This commit is contained in:
parent
ba44289844
commit
d6434d322e
3 changed files with 57 additions and 6 deletions
|
|
@ -6,7 +6,10 @@ use crate::{
|
|||
shell::{
|
||||
focus::{target::PointerFocusTarget, FocusDirection},
|
||||
grabs::{ResizeEdge, SeatMoveGrabState},
|
||||
layout::tiling::{SwapWindowGrab, TilingLayout},
|
||||
layout::{
|
||||
floating::ResizeGrabMarker,
|
||||
tiling::{SwapWindowGrab, TilingLayout},
|
||||
},
|
||||
Direction, FocusResult, MoveResult, OverviewMode, ResizeDirection, ResizeMode, Trigger,
|
||||
Workspace,
|
||||
},
|
||||
|
|
@ -620,6 +623,20 @@ impl State {
|
|||
.find(|output| output.geometry().to_f64().contains(position))
|
||||
.cloned()
|
||||
.unwrap_or(current_output.clone());
|
||||
|
||||
if ptr.is_grabbed()
|
||||
&& seat
|
||||
.user_data()
|
||||
.get::<ResizeGrabMarker>()
|
||||
.map(|marker| marker.get())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if output != current_output {
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let output_geometry = output.geometry();
|
||||
|
||||
let workspace = self.common.shell.workspaces.active_mut(&output);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::{
|
||||
shell::{
|
||||
element::CosmicMapped, focus::target::PointerFocusTarget, grabs::ResizeEdge, CosmicSurface,
|
||||
|
|
@ -8,11 +10,15 @@ use crate::{
|
|||
};
|
||||
use smithay::{
|
||||
desktop::space::SpaceElement,
|
||||
input::pointer::{
|
||||
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,
|
||||
input::{
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
RelativeMotionEvent,
|
||||
},
|
||||
Seat,
|
||||
},
|
||||
utils::{IsAlive, Logical, Point, Rectangle, Size},
|
||||
};
|
||||
|
|
@ -39,6 +45,7 @@ pub enum ResizeState {
|
|||
|
||||
pub struct ResizeSurfaceGrab {
|
||||
start_data: PointerGrabStartData<State>,
|
||||
seat: Seat<State>,
|
||||
window: CosmicMapped,
|
||||
edges: ResizeEdge,
|
||||
initial_window_size: Size<i32, Logical>,
|
||||
|
|
@ -58,6 +65,12 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
|
||||
// It is impossible to get `min_size` and `max_size` of dead toplevel, so we return early.
|
||||
if !self.window.alive() {
|
||||
self.seat
|
||||
.user_data()
|
||||
.get::<ResizeGrabMarker>()
|
||||
.unwrap()
|
||||
.0
|
||||
.store(false, Ordering::SeqCst);
|
||||
handle.unset_grab(data, event.serial, event.time, true);
|
||||
return;
|
||||
}
|
||||
|
|
@ -129,6 +142,12 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
handle.button(data, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
// No more buttons are pressed, release the grab.
|
||||
self.seat
|
||||
.user_data()
|
||||
.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.
|
||||
|
|
@ -245,6 +264,14 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ResizeGrabMarker(AtomicBool);
|
||||
|
||||
impl ResizeGrabMarker {
|
||||
pub fn get(&self) -> bool {
|
||||
self.0.load(Ordering::SeqCst)
|
||||
}
|
||||
}
|
||||
|
||||
impl ResizeSurfaceGrab {
|
||||
pub fn new(
|
||||
start_data: PointerGrabStartData<State>,
|
||||
|
|
@ -252,6 +279,7 @@ impl ResizeSurfaceGrab {
|
|||
edges: ResizeEdge,
|
||||
initial_window_location: Point<i32, Logical>,
|
||||
initial_window_size: Size<i32, Logical>,
|
||||
seat: &Seat<State>,
|
||||
) -> ResizeSurfaceGrab {
|
||||
let resize_state = ResizeState::Resizing(ResizeData {
|
||||
edges,
|
||||
|
|
@ -260,9 +288,14 @@ impl ResizeSurfaceGrab {
|
|||
});
|
||||
|
||||
*mapped.resize_state.lock().unwrap() = Some(resize_state);
|
||||
seat.user_data()
|
||||
.get_or_insert::<ResizeGrabMarker, _>(|| ResizeGrabMarker(AtomicBool::new(true)))
|
||||
.0
|
||||
.store(true, Ordering::SeqCst);
|
||||
|
||||
ResizeSurfaceGrab {
|
||||
start_data,
|
||||
seat: seat.clone(),
|
||||
window: mapped,
|
||||
edges,
|
||||
initial_window_size,
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ impl FloatingLayout {
|
|||
edges,
|
||||
location,
|
||||
size,
|
||||
seat,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue