Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

floating: New window spawn positions #220

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions src/shell/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use std::{
collections::HashMap,
fmt,
hash::Hash,
sync::{Arc, Mutex},
sync::{atomic::AtomicBool, Arc, Mutex},
};

pub mod surface;
Expand All @@ -73,7 +73,10 @@ use tracing::debug;

use super::{
focus::FocusDirection,
layout::{floating::ResizeState, tiling::NodeDesc},
layout::{
floating::{ResizeState, TiledCorners},
tiling::NodeDesc,
},
Direction, ManagedLayer,
};

Expand Down Expand Up @@ -103,6 +106,8 @@ pub struct CosmicMapped {
//floating
pub(super) resize_state: Arc<Mutex<Option<ResizeState>>>,
pub last_geometry: Arc<Mutex<Option<Rectangle<i32, Local>>>>,
pub moved_since_mapped: Arc<AtomicBool>,
pub floating_tiled: Arc<Mutex<Option<TiledCorners>>>,

#[cfg(feature = "debug")]
debug: Arc<Mutex<Option<smithay_egui::EguiState>>>,
Expand All @@ -117,6 +122,8 @@ impl fmt::Debug for CosmicMapped {
.field("tiling_node_id", &self.tiling_node_id)
.field("resize_state", &self.resize_state)
.field("last_geometry", &self.last_geometry)
.field("moved_since_mapped", &self.moved_since_mapped)
.field("floating_tiled", &self.floating_tiled)
.finish()
}
}
Expand Down Expand Up @@ -224,7 +231,7 @@ impl CosmicMapped {
}

if surface_type.contains(WindowSurfaceType::SUBSURFACE) {
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::atomic::Ordering;

let found = AtomicBool::new(false);
with_surface_tree_downward(
Expand Down Expand Up @@ -1102,6 +1109,8 @@ impl From<CosmicWindow> for CosmicMapped {
tiling_node_id: Arc::new(Mutex::new(None)),
resize_state: Arc::new(Mutex::new(None)),
last_geometry: Arc::new(Mutex::new(None)),
moved_since_mapped: Arc::new(AtomicBool::new(false)),
floating_tiled: Arc::new(Mutex::new(None)),
#[cfg(feature = "debug")]
debug: Arc::new(Mutex::new(None)),
}
Expand All @@ -1117,6 +1126,8 @@ impl From<CosmicStack> for CosmicMapped {
tiling_node_id: Arc::new(Mutex::new(None)),
resize_state: Arc::new(Mutex::new(None)),
last_geometry: Arc::new(Mutex::new(None)),
moved_since_mapped: Arc::new(AtomicBool::new(false)),
floating_tiled: Arc::new(Mutex::new(None)),
#[cfg(feature = "debug")]
debug: Arc::new(Mutex::new(None)),
}
Expand All @@ -1143,6 +1154,12 @@ where
TiledOverlay(
RelocateRenderElement<RescaleRenderElement<CropRenderElement<PixelShaderElement>>>,
),
MovingStack(
RelocateRenderElement<RescaleRenderElement<self::stack::CosmicStackRenderElement<R>>>,
),
MovingWindow(
RelocateRenderElement<RescaleRenderElement<self::window::CosmicWindowRenderElement<R>>>,
),
GrabbedStack(RescaleRenderElement<self::stack::CosmicStackRenderElement<R>>),
GrabbedWindow(RescaleRenderElement<self::window::CosmicWindowRenderElement<R>>),
FocusIndicator(PixelShaderElement),
Expand All @@ -1164,6 +1181,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.id(),
CosmicMappedRenderElement::TiledWindow(elem) => elem.id(),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.id(),
CosmicMappedRenderElement::MovingStack(elem) => elem.id(),
CosmicMappedRenderElement::MovingWindow(elem) => elem.id(),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.id(),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.id(),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.id(),
Expand All @@ -1181,6 +1200,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.current_commit(),
CosmicMappedRenderElement::TiledWindow(elem) => elem.current_commit(),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.current_commit(),
CosmicMappedRenderElement::MovingStack(elem) => elem.current_commit(),
CosmicMappedRenderElement::MovingWindow(elem) => elem.current_commit(),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.current_commit(),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.current_commit(),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.current_commit(),
Expand All @@ -1198,6 +1219,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.src(),
CosmicMappedRenderElement::TiledWindow(elem) => elem.src(),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.src(),
CosmicMappedRenderElement::MovingStack(elem) => elem.src(),
CosmicMappedRenderElement::MovingWindow(elem) => elem.src(),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.src(),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.src(),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.src(),
Expand All @@ -1215,6 +1238,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.geometry(scale),
CosmicMappedRenderElement::TiledWindow(elem) => elem.geometry(scale),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.geometry(scale),
CosmicMappedRenderElement::MovingStack(elem) => elem.geometry(scale),
CosmicMappedRenderElement::MovingWindow(elem) => elem.geometry(scale),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.geometry(scale),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.geometry(scale),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.geometry(scale),
Expand All @@ -1232,6 +1257,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.location(scale),
CosmicMappedRenderElement::TiledWindow(elem) => elem.location(scale),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.location(scale),
CosmicMappedRenderElement::MovingStack(elem) => elem.location(scale),
CosmicMappedRenderElement::MovingWindow(elem) => elem.location(scale),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.location(scale),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.location(scale),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.location(scale),
Expand All @@ -1249,6 +1276,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.transform(),
CosmicMappedRenderElement::TiledWindow(elem) => elem.transform(),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.transform(),
CosmicMappedRenderElement::MovingStack(elem) => elem.transform(),
CosmicMappedRenderElement::MovingWindow(elem) => elem.transform(),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.transform(),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.transform(),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.transform(),
Expand All @@ -1270,6 +1299,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::TiledWindow(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::MovingStack(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::MovingWindow(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.damage_since(scale, commit),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.damage_since(scale, commit),
Expand All @@ -1289,6 +1320,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::TiledWindow(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::MovingStack(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::MovingWindow(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.opaque_regions(scale),
Expand All @@ -1306,6 +1339,8 @@ where
CosmicMappedRenderElement::TiledStack(elem) => elem.alpha(),
CosmicMappedRenderElement::TiledWindow(elem) => elem.alpha(),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.alpha(),
CosmicMappedRenderElement::MovingStack(elem) => elem.alpha(),
CosmicMappedRenderElement::MovingWindow(elem) => elem.alpha(),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.alpha(),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.alpha(),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.alpha(),
Expand Down Expand Up @@ -1333,6 +1368,8 @@ impl RenderElement<GlowRenderer> for CosmicMappedRenderElement<GlowRenderer> {
CosmicMappedRenderElement::TiledOverlay(elem) => {
RenderElement::<GlowRenderer>::draw(elem, frame, src, dst, damage)
}
CosmicMappedRenderElement::MovingStack(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::MovingWindow(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::FocusIndicator(elem) => {
Expand All @@ -1358,6 +1395,8 @@ impl RenderElement<GlowRenderer> for CosmicMappedRenderElement<GlowRenderer> {
CosmicMappedRenderElement::TiledStack(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::TiledWindow(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::TiledOverlay(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::MovingStack(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::MovingWindow(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::FocusIndicator(elem) => elem.underlying_storage(renderer),
Expand Down Expand Up @@ -1390,6 +1429,8 @@ impl<'a, 'b> RenderElement<GlMultiRenderer<'a, 'b>>
RenderElement::<GlowRenderer>::draw(elem, frame.glow_frame_mut(), src, dst, damage)
.map_err(|err| GlMultiError::Render(err))
}
CosmicMappedRenderElement::MovingStack(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::MovingWindow(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.draw(frame, src, dst, damage),
CosmicMappedRenderElement::FocusIndicator(elem) => {
Expand Down Expand Up @@ -1424,6 +1465,8 @@ impl<'a, 'b> RenderElement<GlMultiRenderer<'a, 'b>>
CosmicMappedRenderElement::TiledOverlay(elem) => {
elem.underlying_storage(renderer.glow_renderer_mut())
}
CosmicMappedRenderElement::MovingStack(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::MovingWindow(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::GrabbedStack(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::GrabbedWindow(elem) => elem.underlying_storage(renderer),
CosmicMappedRenderElement::FocusIndicator(elem) => {
Expand Down
2 changes: 2 additions & 0 deletions src/shell/grabs/moving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use smithay::{
use std::{
cell::RefCell,
collections::HashSet,
sync::atomic::Ordering,
time::{Duration, Instant},
};

Expand Down Expand Up @@ -442,6 +443,7 @@ impl MoveGrab {
let mut outputs = HashSet::new();
outputs.insert(output.clone());
window.output_enter(&output, window.geometry()); // not accurate but...
window.moved_since_mapped.store(true, Ordering::SeqCst);

let grab_state = MoveGrabState {
window: window.clone(),
Expand Down
Loading