small reorder in RenderZindex and change z_index logic in popups

This commit is contained in:
dragonn 2022-01-20 20:43:04 +01:00
parent 15c9e9adf0
commit 3f86c5b94d
2 changed files with 21 additions and 15 deletions

View File

@ -20,14 +20,14 @@ pub enum RenderZindex {
Bottom = 20, Bottom = 20,
/// Default zindex for Windows /// Default zindex for Windows
Shell = 30, Shell = 30,
/// Default zindex for Windows PopUps
PopUpsShell = 40,
/// WlrLayer::Top default zindex /// WlrLayer::Top default zindex
Top = 50, Top = 40,
/// Default zindex for Windows PopUps
Popups = 50,
/// Default Layer for RenderElements /// Default Layer for RenderElements
Overlay = 80, Overlay = 60,
/// Default Layer for Overlay PopUp /// Default Layer for Overlay PopUp
PopUpsOverlay = 100, PopupsOverlay = 70,
} }
/// Elements rendered by [`Space::render_output`] in addition to windows, layers and popups. /// Elements rendered by [`Space::render_output`] in addition to windows, layers and popups.

View File

@ -8,7 +8,7 @@ use crate::{
window::Window, window::Window,
}, },
utils::{Logical, Point, Rectangle}, utils::{Logical, Point, Rectangle},
wayland::output::Output, wayland::{output::Output, shell::wlr_layer::Layer},
}; };
use std::any::TypeId; use std::any::TypeId;
@ -18,7 +18,7 @@ use super::RenderZindex;
pub struct RenderPopup { pub struct RenderPopup {
location: Point<i32, Logical>, location: Point<i32, Logical>,
popup: PopupKind, popup: PopupKind,
parent_layer: RenderZindex, z_index: u8,
} }
impl Window { impl Window {
@ -42,7 +42,7 @@ impl Window {
RenderPopup { RenderPopup {
location: offset, location: offset,
popup, popup,
parent_layer: RenderZindex::Shell, z_index: RenderZindex::Popups as u8,
} }
}) })
}) })
@ -52,7 +52,7 @@ impl Window {
} }
impl LayerSurface { impl LayerSurface {
pub(super) fn popup_elements<R>(&self, space_id: usize) -> impl Iterator<Item = RenderPopup> pub(super) fn popup_elements<R>(&self, space_id: usize) -> impl Iterator<Item = RenderPopup> + '_
where where
R: Renderer + ImportAll + 'static, R: Renderer + ImportAll + 'static,
R::TextureId: 'static, R::TextureId: 'static,
@ -71,10 +71,20 @@ impl LayerSurface {
.flatten() .flatten()
.map(move |(popup, location)| { .map(move |(popup, location)| {
let offset = loc + location - popup.geometry().loc; let offset = loc + location - popup.geometry().loc;
let z_index = if let Some(layer) = self.layer() {
if layer == Layer::Overlay {
RenderZindex::PopupsOverlay as u8
} else {
RenderZindex::Popups as u8
}
} else {
0
};
RenderPopup { RenderPopup {
location: offset, location: offset,
popup, popup,
parent_layer: RenderZindex::Overlay, z_index,
} }
}) })
}) })
@ -133,10 +143,6 @@ where
} }
fn z_index(&self) -> u8 { fn z_index(&self) -> u8 {
match self.parent_layer { self.z_index
RenderZindex::Shell => RenderZindex::PopUpsShell as u8,
RenderZindex::Overlay => RenderZindex::PopUpsOverlay as u8,
_ => 0, //Maybe better panic here? Or return u8::MAX?
}
} }
} }