mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-18 22:26:12 +01:00
Update led state properly and don't render when inactive
Some checks are pending
CI (Pinnacle) / Build (push) Waiting to run
CI (Pinnacle) / Run tests (push) Waiting to run
CI (Pinnacle) / Check formatting (push) Waiting to run
CI (Pinnacle) / Clippy check (push) Waiting to run
Some checks are pending
CI (Pinnacle) / Build (push) Waiting to run
CI (Pinnacle) / Run tests (push) Waiting to run
CI (Pinnacle) / Check formatting (push) Waiting to run
CI (Pinnacle) / Clippy check (push) Waiting to run
This commit is contained in:
parent
65f2dce246
commit
6999ff8dc6
3 changed files with 32 additions and 18 deletions
|
@ -1274,19 +1274,41 @@ impl Udev {
|
|||
/// Render to the [`RenderSurface`] associated with the given `output`.
|
||||
#[tracing::instrument(level = "debug", skip(self, pinnacle), fields(output = output.name()))]
|
||||
fn render_surface(&mut self, pinnacle: &mut Pinnacle, output: &Output) {
|
||||
let UdevOutputData { device_id, .. } = output.user_data().get().unwrap();
|
||||
let is_active = self
|
||||
.backends
|
||||
.get(device_id)
|
||||
.map(|device| device.drm.is_active())
|
||||
.unwrap_or_default();
|
||||
|
||||
let Some(surface) = render_surface_for_output(output, &mut self.backends) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let make_idle = |render_state: &mut RenderState,
|
||||
loop_handle: &LoopHandle<'static, State>| {
|
||||
if let RenderState::WaitingForEstimatedVblankAndScheduled(token)
|
||||
| RenderState::WaitingForEstimatedVblank(token) = mem::take(render_state)
|
||||
{
|
||||
loop_handle.remove(token);
|
||||
}
|
||||
};
|
||||
|
||||
if !is_active {
|
||||
warn!("Device is inactive");
|
||||
make_idle(&mut surface.render_state, &pinnacle.loop_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if !pinnacle.outputs.contains_key(output) {
|
||||
surface.render_state = RenderState::Idle;
|
||||
make_idle(&mut surface.render_state, &pinnacle.loop_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: possibly lift this out and make it so that scheduling a render
|
||||
// does nothing on powered off outputs
|
||||
if output.with_state(|state| !state.powered) {
|
||||
surface.render_state = RenderState::Idle;
|
||||
make_idle(&mut surface.render_state, &pinnacle.loop_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ use smithay::{
|
|||
PopupManager, WindowSurfaceType,
|
||||
},
|
||||
input::{
|
||||
keyboard::LedState,
|
||||
pointer::{CursorImageStatus, PointerHandle},
|
||||
Seat, SeatHandler, SeatState,
|
||||
},
|
||||
|
@ -670,6 +671,12 @@ impl SeatHandler for State {
|
|||
set_data_device_focus(&self.pinnacle.display_handle, seat, focus_client.clone());
|
||||
set_primary_focus(&self.pinnacle.display_handle, seat, focus_client);
|
||||
}
|
||||
|
||||
fn led_state_changed(&mut self, _seat: &Seat<Self>, led_state: LedState) {
|
||||
for device in self.pinnacle.input_state.libinput_devices.iter_mut() {
|
||||
device.led_update(led_state.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate_seat!(State);
|
||||
|
||||
|
|
17
src/input.rs
17
src/input.rs
|
@ -37,7 +37,7 @@ use smithay::{
|
|||
RelativeMotionEvent,
|
||||
},
|
||||
},
|
||||
reexports::input::{self, Led},
|
||||
reexports::input,
|
||||
utils::{Logical, Point, Rectangle, SERIAL_COUNTER},
|
||||
wayland::{
|
||||
compositor::{self, RegionAttributes, SurfaceAttributes},
|
||||
|
@ -439,21 +439,6 @@ impl State {
|
|||
.get_keyboard()
|
||||
.expect("Seat has no keyboard");
|
||||
|
||||
let modifiers = keyboard.modifier_state();
|
||||
|
||||
let mut leds = Led::empty();
|
||||
if modifiers.num_lock {
|
||||
leds |= Led::NUMLOCK;
|
||||
}
|
||||
if modifiers.caps_lock {
|
||||
leds |= Led::CAPSLOCK;
|
||||
}
|
||||
|
||||
// FIXME: Leds only update once another key is pressed.
|
||||
for device in self.pinnacle.input_state.libinput_devices.iter_mut() {
|
||||
device.led_update(leds);
|
||||
}
|
||||
|
||||
if self.pinnacle.lock_state.is_unlocked() {
|
||||
// Focus the topmost exclusive layer, if any
|
||||
for layer in self.pinnacle.layer_shell_state.layer_surfaces().rev() {
|
||||
|
|
Loading…
Reference in a new issue