diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:35:25 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:53:55 +0300 |
| commit | 0e7e398df3a816b7dec1de8902af83d29a08562a (patch) | |
| tree | 68df6a7952484139d12af6fd2c9b10e6b292a443 /src | |
| parent | 86bdc6898bc8a13368ba852692ff0cc248345128 (diff) | |
| download | niri-0e7e398df3a816b7dec1de8902af83d29a08562a.tar.gz niri-0e7e398df3a816b7dec1de8902af83d29a08562a.tar.bz2 niri-0e7e398df3a816b7dec1de8902af83d29a08562a.zip | |
Replace current_state() with with_toplevel_role()
Avoid microallocations that happen in current_state().
Diffstat (limited to 'src')
| -rw-r--r-- | src/handlers/mod.rs | 14 | ||||
| -rw-r--r-- | src/window/mapped.rs | 11 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 5b44caf0..ed9f224c 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -74,7 +74,7 @@ use crate::protocols::gamma_control::{GammaControlHandler, GammaControlManagerSt use crate::protocols::mutter_x11_interop::MutterX11InteropHandler; use crate::protocols::output_management::{OutputManagementHandler, OutputManagementManagerState}; use crate::protocols::screencopy::{Screencopy, ScreencopyHandler, ScreencopyManagerState}; -use crate::utils::{output_size, send_scale_transform}; +use crate::utils::{output_size, send_scale_transform, with_toplevel_role}; use crate::{ delegate_foreign_toplevel, delegate_gamma_control, delegate_mutter_x11_interop, delegate_output_management, delegate_screencopy, @@ -459,12 +459,12 @@ impl ForeignToplevelHandler for State { fn set_fullscreen(&mut self, wl_surface: WlSurface, wl_output: Option<WlOutput>) { if let Some((mapped, current_output)) = self.niri.layout.find_window_and_output(&wl_surface) { - if !mapped - .toplevel() - .current_state() - .capabilities - .contains(xdg_toplevel::WmCapabilities::Fullscreen) - { + let has_fullscreen_cap = with_toplevel_role(mapped.toplevel(), |role| { + role.current + .capabilities + .contains(xdg_toplevel::WmCapabilities::Fullscreen) + }); + if !has_fullscreen_cap { return; } diff --git a/src/window/mapped.rs b/src/window/mapped.rs index bf4aaa9b..e9f087bd 100644 --- a/src/window/mapped.rs +++ b/src/window/mapped.rs @@ -571,7 +571,7 @@ impl LayoutElement for Mapped { fn has_ssd(&self) -> bool { let toplevel = self.toplevel(); - let mode = toplevel.current_state().decoration_mode; + let mode = with_toplevel_role(self.toplevel(), |role| role.current.decoration_mode); match mode { Some(zxdg_toplevel_decoration_v1::Mode::ServerSide) => true, @@ -712,10 +712,11 @@ impl LayoutElement for Mapped { } fn is_fullscreen(&self) -> bool { - self.toplevel() - .current_state() - .states - .contains(xdg_toplevel::State::Fullscreen) + with_toplevel_role(self.toplevel(), |role| { + role.current + .states + .contains(xdg_toplevel::State::Fullscreen) + }) } fn is_pending_fullscreen(&self) -> bool { |
