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

tiling: Check for popups before tiles in element_under #341

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ inherits = "release"
lto = "fat"

[patch."https://github.com/Smithay/smithay.git"]
smithay = {git = "https://github.com/smithay//smithay", rev = "c17297b"}
smithay = {git = "https://github.com/pop-os/smithay", branch = "fix-iteration"}
10 changes: 10 additions & 0 deletions src/shell/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,16 @@ impl CosmicMapped {
CosmicMappedInternal::_GenericCatcher(_) => {}
}
}

pub fn is_in_popup_input_region(&self, point: &Point<f64, Logical>) -> bool {
match &self.element {
CosmicMappedInternal::Window(w) => w.is_in_popup_input_region(point),
CosmicMappedInternal::Stack(s) => s.is_in_popup_input_region(point),
CosmicMappedInternal::_GenericCatcher(_) => {
unreachable!()
}
}
}
}

impl IsAlive for CosmicMapped {
Expand Down
8 changes: 8 additions & 0 deletions src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,14 @@ impl CosmicStack {
pub(crate) fn force_redraw(&self) {
self.0.force_redraw();
}

pub fn is_in_popup_input_region(&self, point: &Point<f64, Logical>) -> bool {
self.0.with_program(|p| {
let active = p.active.load(Ordering::SeqCst);
let windows = p.windows.lock().unwrap();
windows[active].is_in_popup_input_region(point)
})
}
}

#[derive(Debug, Clone, Copy)]
Expand Down
14 changes: 12 additions & 2 deletions src/shell/element/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use smithay::{
ImportAll, Renderer,
},
desktop::{
space::SpaceElement, utils::OutputPresentationFeedback, PopupManager, Window, WindowSurface,
space::SpaceElement, utils::OutputPresentationFeedback, PopupManager, Window,
WindowSurface, WindowSurfaceType,
},
input::{
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
Expand All @@ -37,7 +38,7 @@ use smithay::{
},
wayland_server::protocol::wl_surface::WlSurface,
},
utils::{user_data::UserDataMap, IsAlive, Logical, Rectangle, Serial, Size},
utils::{user_data::UserDataMap, IsAlive, Logical, Point, Rectangle, Serial, Size},
wayland::{
compositor::{with_states, SurfaceData},
seat::WaylandFocus,
Expand Down Expand Up @@ -597,6 +598,15 @@ impl CosmicSurface {
pub fn x11_surface(&self) -> Option<&X11Surface> {
self.0.x11_surface()
}

pub fn is_in_popup_input_region(&self, point: &Point<f64, Logical>) -> bool {
self.0
.surface_under(
*point,
WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE,
)
.is_some()
}
}

impl IsAlive for CosmicSurface {
Expand Down
5 changes: 5 additions & 0 deletions src/shell/element/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ impl CosmicWindow {
pub(crate) fn force_redraw(&self) {
self.0.force_redraw();
}

pub fn is_in_popup_input_region(&self, point: &Point<f64, Logical>) -> bool {
self.0
.with_program(|p| p.window.is_in_popup_input_region(point))
}
}

#[derive(Debug, Clone, Copy)]
Expand Down
6 changes: 2 additions & 4 deletions src/shell/layout/tiling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3113,11 +3113,9 @@ impl TilingLayout {
}

if matches!(overview, OverviewMode::None) {
// first check popups
for (mapped, geo) in self.mapped() {
if !mapped.bbox().contains((location - geo.loc).as_logical()) {
continue;
}
if mapped.is_in_input_region(
if mapped.is_in_popup_input_region(
&((location_f64 - geo.loc.to_f64()).as_logical()
+ mapped.geometry().loc.to_f64()),
) {
Expand Down