diff --git a/src/handlers/wlr_layer_shell.rs b/src/handlers/wlr_layer_shell.rs index ae24d14..9a5ac87 100644 --- a/src/handlers/wlr_layer_shell.rs +++ b/src/handlers/wlr_layer_shell.rs @@ -24,7 +24,21 @@ impl WlrLayerShellHandler for State { .and_then(Output::from_resource) .unwrap_or_else(|| self.space.outputs().next().unwrap().clone()); let mut map = layer_map_for_output(&output); - map.map_layer(&LayerSurface::new(surface, namespace)) + map.map_layer(&LayerSurface::new(surface.clone(), namespace)) .unwrap(); + surface.send_configure(); + } + + fn layer_destroyed(&mut self, surface: smithay::wayland::shell::wlr_layer::LayerSurface) { + if let Some((mut map, layer)) = self.space.outputs().find_map(|o| { + let map = layer_map_for_output(o); + let layer = map + .layers() + .find(|&layer| layer.layer_surface() == &surface) + .cloned(); + layer.map(|layer| (map, layer)) + }) { + map.unmap_layer(&layer); + } } } diff --git a/src/input.rs b/src/input.rs index 2968780..3397cdf 100644 --- a/src/input.rs +++ b/src/input.rs @@ -3,6 +3,7 @@ use smithay::{ AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, }, + desktop::layer_map_for_output, input::{ keyboard::FilterResult, pointer::{AxisFrame, ButtonEvent, MotionEvent}, @@ -91,6 +92,17 @@ impl State { toplevel.send_pending_configure(); } }); + self.space.elements().for_each(|window| { + window.window.set_activated(false); + if let Some(actv_window) = actv_window.as_ref() { + if actv_window.window == window.window { + window.window.set_activated(true); + } + } + if let Some(toplevel) = window.window.toplevel() { + toplevel.send_pending_configure(); + } + }); }; pointer.button( diff --git a/src/render.rs b/src/render.rs index c39013e..03ad58d 100644 --- a/src/render.rs +++ b/src/render.rs @@ -1,4 +1,6 @@ #![allow(dead_code)] +use std::time::Duration; + use crate::State; use cairo::{Context, Format, ImageSurface}; use parking_lot::Mutex; @@ -419,6 +421,29 @@ impl State { framebuffer: &mut GlesTarget, damage_tracker: &mut OutputDamageTracker, ) -> Result<(), Box> { + self.space.elements().for_each(|window| { + if let Some(toplevel) = window.window.toplevel() { + toplevel.send_pending_configure(); + } + window.window.send_frame( + &output, + self.start_time.elapsed(), + Some(Duration::ZERO), + |_, _| Some(output.clone()), + ) + }); + self.space.outputs().for_each(|output| { + layer_map_for_output(output).layers().for_each(|layer| { + layer.layer_surface().send_pending_configure(); + layer.send_frame( + &output, + self.start_time.elapsed(), + Some(Duration::ZERO), + |_, _| Some(output.clone()), + ) + }) + }); + smithay::desktop::space::render_output::<_, OutputElement, _, _>( output, renderer, diff --git a/src/winit.rs b/src/winit.rs index c1a8dc7..2c4926f 100644 --- a/src/winit.rs +++ b/src/winit.rs @@ -14,15 +14,16 @@ use crate::State; pub fn init_winit(state: &mut State) -> Result<(), Box> { let (mut backend, winit) = winit::init()?; + let size = backend.window_size(); let mode = Mode { - size: backend.window_size(), + size, refresh: 60_000, }; let output = Output::new( "winit".to_string(), PhysicalProperties { - size: (0, 0).into(), + size: (size.w, size.h).into(), subpixel: Subpixel::Unknown, make: "Milkyway".into(), model: "Winit".into(), @@ -68,15 +69,6 @@ pub fn init_winit(state: &mut State) -> Result<(), Box> { } backend.submit(Some(&[damage])).unwrap(); - state.space.elements().for_each(|window| { - window.window.send_frame( - &output, - state.start_time.elapsed(), - Some(Duration::ZERO), - |_, _| Some(output.clone()), - ) - }); - state.space.refresh(); state.popups.cleanup(); let _ = state.display_handle.flush_clients(); diff --git a/src/xwayland.rs b/src/xwayland.rs index faf4abb..6fdf3ec 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -2,7 +2,7 @@ use std::process::Stdio; use smithay::{ desktop::Window, - reexports::calloop::{EventLoop, LoopHandle}, + reexports::calloop::LoopHandle, utils::{Logical, Rectangle}, wayland::xwayland_shell::{XWaylandShellHandler, XWaylandShellState}, xwayland::{ @@ -10,7 +10,7 @@ use smithay::{ X11Surface, X11Wm, XWayland, XWaylandEvent, XwmHandler, }, }; -use wayland_server::{Display, DisplayHandle}; +use wayland_server::DisplayHandle; use crate::{render::DecoratedWindow, state::State};