From 1fb49824f9c9ddcab877841f455bb34e8adaacfc Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 7 Jul 2022 19:45:04 +0200 Subject: [PATCH] deps: Update smithay Fixes misbehaving floating windows --- Cargo.lock | 45 ++++++++++++++++++++++++--- Cargo.toml | 8 ++--- src/backend/render/cursor.rs | 7 +++++ src/backend/render/mod.rs | 7 +++++ src/shell/layout/floating/grabs.rs | 4 ++- src/shell/layout/floating/mod.rs | 19 ++++++----- src/shell/layout/tiling/mod.rs | 5 +-- src/shell/mod.rs | 2 +- src/wayland/handlers/compositor.rs | 9 ++++-- src/wayland/handlers/xdg_shell/mod.rs | 4 +-- 10 files changed, 87 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25d508f1..085c9d75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,6 +44,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" version = "1.0.58" @@ -329,7 +338,9 @@ dependencies = [ "indexmap", "lazy_static", "libsystemd", + "regex", "ron", + "sendfd", "serde", "serde_json", "slog", @@ -1145,9 +1156,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8b1a9b2518dc799a2271eff1688707eb315f0d4697aa6b0871369ca4c4da55" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "owned_ttf_parser" @@ -1311,6 +1322,23 @@ dependencies = [ "thiserror", ] +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -1367,6 +1395,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sendfd" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604b71b8fc267e13bb3023a2c901126c8f349393666a6d98ac1ae5729b701798" +dependencies = [ + "libc", +] + [[package]] name = "serde" version = "1.0.138" @@ -1480,7 +1517,7 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/Smithay/smithay.git?rev=11d48a76#11d48a76082a1efddb7dbfeef2aa1d7c13f8f67d" +source = "git+https://github.com/pop-os/smithay?branch=main#bb4bdc613ff91e06b2205d4021d8c2003e9ef660" dependencies = [ "appendlist", "bitflags", @@ -1540,7 +1577,7 @@ dependencies = [ [[package]] name = "smithay-egui" version = "0.1.0" -source = "git+https://github.com/Smithay/smithay-egui.git?rev=1969c96d#1969c96d21743134bb11eadde4866245ae7c0478" +source = "git+https://github.com/Smithay/smithay-egui.git?rev=9bba86a7#9bba86a743b8bc1c30f236d2407525fde8bcad50" dependencies = [ "cgmath", "egui", diff --git a/Cargo.toml b/Cargo.toml index e9430dc6..cb5ba2f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,13 +36,13 @@ cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch [dependencies.smithay] version = "0.3" git = "https://github.com/Smithay/smithay.git" -rev = "11d48a76" +rev = "e9599b80" default-features = false features = ["backend_drm", "backend_gbm", "backend_egl", "backend_libinput", "backend_session_libseat", "backend_udev", "backend_winit", "backend_x11", "desktop", "use_system_lib", "renderer_gl", "renderer_multi", "wayland_frontend", "slog-stdlog"] [dependencies.smithay-egui] git = "https://github.com/Smithay/smithay-egui.git" -rev = "1969c96d" +rev = "9bba86a7" optional = true [features] @@ -60,5 +60,5 @@ debug = true [profile.release] lto = "fat" -#[patch."https://github.com/Smithay/smithay.git"] -#smithay = { git = "https://github.com/pop-os/smithay", branch = "main" } +[patch."https://github.com/Smithay/smithay.git"] +smithay = { git = "https://github.com/pop-os/smithay", branch = "main" } diff --git a/src/backend/render/cursor.rs b/src/backend/render/cursor.rs index 6266837f..4ae26b9c 100644 --- a/src/backend/render/cursor.rs +++ b/src/backend/render/cursor.rs @@ -215,6 +215,13 @@ where } } + fn opaque_regions( + &self, + _scale: impl Into>, + ) -> Option>> { + None + } + fn draw( &self, _renderer: &mut R, diff --git a/src/backend/render/mod.rs b/src/backend/render/mod.rs index c9b5a4a2..13f23fef 100644 --- a/src/backend/render/mod.rs +++ b/src/backend/render/mod.rs @@ -70,6 +70,13 @@ impl RenderElement> for CustomElem { RenderElement::::accumulated_damage(self, scale, for_values) } + fn opaque_regions( + &self, + scale: impl Into>, + ) -> Option>> { + RenderElement::::opaque_regions(self, scale) + } + fn draw( &self, renderer: &mut GlMultiRenderer<'_>, diff --git a/src/shell/layout/floating/grabs.rs b/src/shell/layout/floating/grabs.rs index 99886d44..34b50691 100644 --- a/src/shell/layout/floating/grabs.rs +++ b/src/shell/layout/floating/grabs.rs @@ -44,7 +44,9 @@ impl PointerGrab for MoveSurfaceGrab { .space_for_surface_mut(self.window.toplevel().wl_surface()) { let new_location = (self.initial_window_location.to_f64() + self.delta).to_i32_round(); - workspace.space.map_window(&self.window, new_location, true); + workspace + .space + .map_window(&self.window, new_location, super::FLOATING_INDEX, true); } } diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 96010c19..17be1f2e 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -9,7 +9,7 @@ use smithay::{ wayland::{ compositor::with_states, output::Output, - seat::{PointerGrabStartData, Seat}, + seat::{Focus, PointerGrabStartData, Seat}, shell::xdg::XdgToplevelSurfaceRoleAttributes, Serial, }, @@ -21,6 +21,8 @@ use crate::state::State; mod grabs; pub use self::grabs::*; +pub const FLOATING_INDEX: u8 = RenderZindex::Shell as u8 + 1; + #[derive(Debug, Default)] pub struct FloatingLayout { pending_windows: Vec, @@ -117,13 +119,11 @@ impl FloatingLayout { xdg.send_configure(); } - window.override_z_index(RenderZindex::Shell as u8 + 1); - space.map_window(&window, position, false); + space.map_window(&window, position, FLOATING_INDEX, false); self.windows.insert(window); } pub fn unmap_window(&mut self, space: &mut Space, window: &Window) { - window.clear_z_index(); space.unmap_window(window); self.pending_windows.retain(|w| w != window); self.windows.remove(window); @@ -133,7 +133,12 @@ impl FloatingLayout { let layers = layer_map_for_output(&output); let geometry = layers.non_exclusive_zone(); - space.map_window(&window, (geometry.loc.x, geometry.loc.y), true); + space.map_window( + &window, + (geometry.loc.x, geometry.loc.y), + FLOATING_INDEX, + true, + ); #[allow(irrefutable_let_patterns)] if let Kind::Xdg(surface) = &window.toplevel() { surface.with_pending_state(|state| { @@ -183,7 +188,7 @@ impl FloatingLayout { let grab = MoveSurfaceGrab::new(start_data, window.clone(), initial_window_location); - pointer.set_grab(grab, serial, 0); + pointer.set_grab(grab, serial, Focus::Clear); } } @@ -203,7 +208,7 @@ impl FloatingLayout { let grab = grabs::ResizeSurfaceGrab::new(start_data, window.clone(), edges, location, size); - pointer.set_grab(grab, serial, 0); + pointer.set_grab(grab, serial, Focus::Clear); } } } diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index b505c94f..88d20244 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -14,7 +14,7 @@ use smithay::{ }, utils::{IsAlive, Rectangle}, wayland::{ - seat::{PointerGrabStartData, Seat}, + seat::{Focus, PointerGrabStartData, Seat}, Serial, }, }; @@ -272,7 +272,7 @@ impl TilingLayout { ratio: ratio.clone(), }; - pointer.set_grab(grab, serial, 0); + pointer.set_grab(grab, serial, Focus::Clear); } return; } @@ -590,6 +590,7 @@ impl TilingLayout { space.map_window( &window, (geo.loc.x + inner, geo.loc.y + inner), + None, false, ); } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 431cb7e5..9ae67a64 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -523,7 +523,7 @@ impl Shell { state.add_workspace_state(&workspace.handle, WState::Hidden); } let mut map = layer_map_for_output(output); - map.cleanup(); + map.cleanup(dh); } std::mem::drop(state); self.toplevel_info_state diff --git a/src/wayland/handlers/compositor.rs b/src/wayland/handlers/compositor.rs index a2888154..4bf6f30e 100644 --- a/src/wayland/handlers/compositor.rs +++ b/src/wayland/handlers/compositor.rs @@ -2,7 +2,7 @@ use crate::{state::BackendData, utils::prelude::*}; use smithay::{ - backend::renderer::utils::on_commit_buffer_handler, + backend::renderer::utils::{on_commit_buffer_handler, with_renderer_surface_state}, delegate_compositor, desktop::{layer_map_for_output, Kind, LayerSurface, PopupKind, WindowSurfaceType}, reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle}, @@ -178,7 +178,12 @@ impl CompositorHandler for State { window.geometry().size, ); if let Some(location) = new_location { - space.map_window(&window, location, true); + space.map_window( + &window, + location, + crate::shell::layout::floating::FLOATING_INDEX, + true, + ); for window in space.windows() { update_reactive_popups(space, window); } diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index 33753554..ef72ebef 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -16,7 +16,7 @@ use smithay::{ }, wayland::{ output::Output, - seat::{PointerGrabStartData, Seat}, + seat::{Focus, PointerGrabStartData, Seat}, shell::xdg::{ Configure, PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState, @@ -123,7 +123,7 @@ impl XdgShellHandler for State { grab.ungrab(dh, PopupUngrabStrategy::All); return; } - pointer.set_grab(PopupPointerGrab::new(&grab), serial, 0); + pointer.set_grab(PopupPointerGrab::new(&grab), serial, Focus::Keep); } seat.user_data()