forge
Explore
Log in

Don't you dare go Hollow

Replace current_state() with with_toplevel_role()

Browse files at this commit

0e7e398df3a816b7dec1de8902af83d29a08562aIvan MolodetskikhParent: 86bdc68
Avoid microallocations that happen in current_state().
src/handlers/mod.rsmodified+7 -7
@@ -74,7 +74,7 @@ use crate::protocols::gamma_control::{GammaControlHandler, GammaControlManagerSt
74 use crate::protocols::mutter_x11_interop::MutterX11InteropHandler;74 use crate::protocols::mutter_x11_interop::MutterX11InteropHandler;
75 use crate::protocols::output_management::{OutputManagementHandler, OutputManagementManagerState};75 use crate::protocols::output_management::{OutputManagementHandler, OutputManagementManagerState};
76 use crate::protocols::screencopy::{Screencopy, ScreencopyHandler, ScreencopyManagerState};76 use crate::protocols::screencopy::{Screencopy, ScreencopyHandler, ScreencopyManagerState};
77-use crate::utils::{output_size, send_scale_transform};77+use crate::utils::{output_size, send_scale_transform, with_toplevel_role};
78 use crate::{78 use crate::{
79 delegate_foreign_toplevel, delegate_gamma_control, delegate_mutter_x11_interop,79 delegate_foreign_toplevel, delegate_gamma_control, delegate_mutter_x11_interop,
80 delegate_output_management, delegate_screencopy,80 delegate_output_management, delegate_screencopy,
@@ -459,12 +459,12 @@ impl ForeignToplevelHandler for State {
459 fn set_fullscreen(&mut self, wl_surface: WlSurface, wl_output: Option<WlOutput>) {459 fn set_fullscreen(&mut self, wl_surface: WlSurface, wl_output: Option<WlOutput>) {
460 if let Some((mapped, current_output)) = self.niri.layout.find_window_and_output(&wl_surface)460 if let Some((mapped, current_output)) = self.niri.layout.find_window_and_output(&wl_surface)
461 {461 {
462- if !mapped462+ let has_fullscreen_cap = with_toplevel_role(mapped.toplevel(), |role| {
463- .toplevel()463+ role.current
464- .current_state()464+ .capabilities
465- .capabilities465+ .contains(xdg_toplevel::WmCapabilities::Fullscreen)
466- .contains(xdg_toplevel::WmCapabilities::Fullscreen)466+ });
467- {467+ if !has_fullscreen_cap {
468 return;468 return;
469 }469 }
470 470
src/window/mapped.rsmodified+6 -5
@@ -571,7 +571,7 @@ impl LayoutElement for Mapped {
571 571
572 fn has_ssd(&self) -> bool {572 fn has_ssd(&self) -> bool {
573 let toplevel = self.toplevel();573 let toplevel = self.toplevel();
574- let mode = toplevel.current_state().decoration_mode;574+ let mode = with_toplevel_role(self.toplevel(), |role| role.current.decoration_mode);
575 575
576 match mode {576 match mode {
577 Some(zxdg_toplevel_decoration_v1::Mode::ServerSide) => true,577 Some(zxdg_toplevel_decoration_v1::Mode::ServerSide) => true,
@@ -712,10 +712,11 @@ impl LayoutElement for Mapped {
712 }712 }
713 713
714 fn is_fullscreen(&self) -> bool {714 fn is_fullscreen(&self) -> bool {
715- self.toplevel()715+ with_toplevel_role(self.toplevel(), |role| {
716- .current_state()716+ role.current
717- .states717+ .states
718- .contains(xdg_toplevel::State::Fullscreen)718+ .contains(xdg_toplevel::State::Fullscreen)
719+ })
719 }720 }
720 721
721 fn is_pending_fullscreen(&self) -> bool {722 fn is_pending_fullscreen(&self) -> bool {