From 3f86c5b94d222bcaf403d1e3cd74ba044604ef1a Mon Sep 17 00:00:00 2001 From: dragonn Date: Thu, 20 Jan 2022 20:43:04 +0100 Subject: [PATCH] small reorder in RenderZindex and change z_index logic in popups --- src/desktop/space/element.rs | 10 +++++----- src/desktop/space/popup.rs | 26 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/desktop/space/element.rs b/src/desktop/space/element.rs index 52075a9..ebb7a7b 100644 --- a/src/desktop/space/element.rs +++ b/src/desktop/space/element.rs @@ -20,14 +20,14 @@ pub enum RenderZindex { Bottom = 20, /// Default zindex for Windows Shell = 30, - /// Default zindex for Windows PopUps - PopUpsShell = 40, /// WlrLayer::Top default zindex - Top = 50, + Top = 40, + /// Default zindex for Windows PopUps + Popups = 50, /// Default Layer for RenderElements - Overlay = 80, + Overlay = 60, /// Default Layer for Overlay PopUp - PopUpsOverlay = 100, + PopupsOverlay = 70, } /// Elements rendered by [`Space::render_output`] in addition to windows, layers and popups. diff --git a/src/desktop/space/popup.rs b/src/desktop/space/popup.rs index 718d0d2..dd8cc47 100644 --- a/src/desktop/space/popup.rs +++ b/src/desktop/space/popup.rs @@ -8,7 +8,7 @@ use crate::{ window::Window, }, utils::{Logical, Point, Rectangle}, - wayland::output::Output, + wayland::{output::Output, shell::wlr_layer::Layer}, }; use std::any::TypeId; @@ -18,7 +18,7 @@ use super::RenderZindex; pub struct RenderPopup { location: Point, popup: PopupKind, - parent_layer: RenderZindex, + z_index: u8, } impl Window { @@ -42,7 +42,7 @@ impl Window { RenderPopup { location: offset, popup, - parent_layer: RenderZindex::Shell, + z_index: RenderZindex::Popups as u8, } }) }) @@ -52,7 +52,7 @@ impl Window { } impl LayerSurface { - pub(super) fn popup_elements(&self, space_id: usize) -> impl Iterator + pub(super) fn popup_elements(&self, space_id: usize) -> impl Iterator + '_ where R: Renderer + ImportAll + 'static, R::TextureId: 'static, @@ -71,10 +71,20 @@ impl LayerSurface { .flatten() .map(move |(popup, location)| { 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 { location: offset, popup, - parent_layer: RenderZindex::Overlay, + z_index, } }) }) @@ -133,10 +143,6 @@ where } fn z_index(&self) -> u8 { - match self.parent_layer { - RenderZindex::Shell => RenderZindex::PopUpsShell as u8, - RenderZindex::Overlay => RenderZindex::PopUpsOverlay as u8, - _ => 0, //Maybe better panic here? Or return u8::MAX? - } + self.z_index } }