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