Extract set_lid_closed()
Browse files at this commita4f5c90cf00545cd942c6ae07e3ff727b0bbed30Parent: 79cdbc52 changed files +12 -3
- src/input/mod.rs +2 -3
- src/niri.rs +10 -0
src/input/mod.rsmodified+2 -3
| @@ -3931,9 +3931,8 @@ impl State { | |||
| 3931 | 3931 | ||
| 3932 | if switch == Switch::Lid { | 3932 | if switch == Switch::Lid { |
| 3933 | let is_closed = evt.state() == SwitchState::On; | 3933 | let is_closed = evt.state() == SwitchState::On; |
| 3934 | - debug!("lid switch {}", if is_closed { "closed" } else { "opened" }); | 3934 | + trace!("lid switch {}", if is_closed { "closed" } else { "opened" }); |
| 3935 | - self.niri.is_lid_closed = is_closed; | 3935 | + self.set_lid_closed(is_closed); |
| 3936 | - self.backend.on_output_config_changed(&mut self.niri); | ||
| 3937 | } | 3936 | } |
| 3938 | 3937 | ||
| 3939 | let action = { | 3938 | let action = { |
src/niri.rsmodified+10 -0
| @@ -726,6 +726,16 @@ impl State { | |||
| 726 | self.niri.notified_activity_this_iteration = false; | 726 | self.niri.notified_activity_this_iteration = false; |
| 727 | } | 727 | } |
| 728 | 728 | ||
| 729 | + pub fn set_lid_closed(&mut self, is_closed: bool) { | ||
| 730 | + if self.niri.is_lid_closed == is_closed { | ||
| 731 | + return; | ||
| 732 | + } | ||
| 733 | + | ||
| 734 | + debug!("laptop lid {}", if is_closed { "closed" } else { "opened" }); | ||
| 735 | + self.niri.is_lid_closed = is_closed; | ||
| 736 | + self.backend.on_output_config_changed(&mut self.niri); | ||
| 737 | + } | ||
| 738 | + | ||
| 729 | fn refresh(&mut self) { | 739 | fn refresh(&mut self) { |
| 730 | let _span = tracy_client::span!("State::refresh"); | 740 | let _span = tracy_client::span!("State::refresh"); |
| 731 | 741 | ||