cursor: Add idle-hide timeout
Adds a cursor_hide_timeout config key (Option<u32> seconds) to CosmicCompConfig. When set, the cursor is hidden after the configured period of pointer inactivity and revealed again by any pointer event. Touch input does not count as activity (no visible cursor to surface). Implementation: - Per-seat hidden flag, calloop timer token, and last-armed Instant on CursorStateInner. - notify_cursor_activity called from each pointer-related input branch (motion, button, axis, tablet) resets the flag and reschedules the timer; rapid successive calls are coalesced behind a 100ms throttle so high-frequency mice don't churn the calloop timer source. - On timer fire, the hidden flag is set, draw_cursor short-circuits to an empty element list, and a render is scheduled. Active pointer grabs (drags, resizes) suppress the hide. - Config reload arms or cancels the timer immediately; None as the configured value collapses the cancel path into the same function. Closes #2231. Drafted with Claude (Anthropic); reviewed and tested by the committer.
This commit is contained in:
parent
6ebe2a1f04
commit
28258e5a5f
4 changed files with 124 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
backend::render::ElementFilter,
|
||||
backend::render::{ElementFilter, cursor::notify_cursor_activity},
|
||||
config::{
|
||||
Action, Config, PrivateAction,
|
||||
key_bindings::{
|
||||
|
|
@ -309,6 +309,7 @@ impl State {
|
|||
let shell = self.common.shell.write();
|
||||
if let Some(seat) = shell.seats.for_device(&event.device()).cloned() {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
let current_output = seat.active_output();
|
||||
|
||||
let mut position = seat.get_pointer().unwrap().current_location().as_global();
|
||||
|
|
@ -622,6 +623,7 @@ impl State {
|
|||
.cloned();
|
||||
if let Some(seat) = maybe_seat {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
let output = seat.active_output();
|
||||
let geometry = output.geometry();
|
||||
let position = geometry.loc.to_f64()
|
||||
|
|
@ -688,6 +690,7 @@ impl State {
|
|||
return;
|
||||
};
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
|
||||
let current_focus = seat.get_keyboard().unwrap().current_focus();
|
||||
let shortcuts_inhibited = current_focus.as_ref().is_some_and(|f| {
|
||||
|
|
@ -899,6 +902,7 @@ impl State {
|
|||
.cloned();
|
||||
if let Some(seat) = maybe_seat {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
|
||||
if seat.get_keyboard().unwrap().modifier_state().logo
|
||||
&& self
|
||||
|
|
@ -1367,6 +1371,7 @@ impl State {
|
|||
let shell = self.common.shell.write();
|
||||
if let Some(seat) = shell.seats.for_device(&event.device()).cloned() {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
let Some(output) =
|
||||
mapped_output_for_device(&self.common.config, &shell, &event.device())
|
||||
.cloned()
|
||||
|
|
@ -1432,6 +1437,7 @@ impl State {
|
|||
let shell = self.common.shell.write();
|
||||
if let Some(seat) = shell.seats.for_device(&event.device()).cloned() {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
let Some(output) =
|
||||
mapped_output_for_device(&self.common.config, &shell, &event.device())
|
||||
.cloned()
|
||||
|
|
@ -1493,6 +1499,7 @@ impl State {
|
|||
.cloned();
|
||||
if let Some(seat) = maybe_seat {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
if let Some(tool) = seat.tablet_seat().get_tool(&event.tool()) {
|
||||
match event.tip_state() {
|
||||
TabletToolTipState::Down => {
|
||||
|
|
@ -1515,6 +1522,7 @@ impl State {
|
|||
.cloned();
|
||||
if let Some(seat) = maybe_seat {
|
||||
self.common.idle_notifier_state.notify_activity(&seat);
|
||||
notify_cursor_activity(self, &seat);
|
||||
if let Some(tool) = seat.tablet_seat().get_tool(&event.tool()) {
|
||||
tool.button(
|
||||
event.button(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue