all: implement damage tracking
This commit is contained in:
parent
76a3c50560
commit
bb66abb817
28 changed files with 473 additions and 82 deletions
|
|
@ -3,6 +3,7 @@ use {
|
|||
cursor::{Cursor, KnownCursor, DEFAULT_CURSOR_SIZE},
|
||||
fixed::Fixed,
|
||||
rect::Rect,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
tree::OutputNode,
|
||||
utils::{
|
||||
|
|
@ -74,13 +75,26 @@ impl CursorUserGroup {
|
|||
group
|
||||
}
|
||||
|
||||
fn damage_active(&self) {
|
||||
if let Some(active) = self.active.get() {
|
||||
if let Some(cursor) = active.cursor.get() {
|
||||
let (x, y) = active.pos.get();
|
||||
let x_int = x.round_down();
|
||||
let y_int = y.round_down();
|
||||
let extents = cursor.extents_at_scale(Scale::default());
|
||||
self.state.damage(extents.move_(x_int, y_int));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deactivate(&self) {
|
||||
if self.hardware_cursor.get() {
|
||||
self.remove_hardware_cursor();
|
||||
} else {
|
||||
self.damage_active();
|
||||
}
|
||||
self.active_id.take();
|
||||
self.active.take();
|
||||
self.state.damage();
|
||||
}
|
||||
|
||||
pub fn latest_output(&self) -> Rc<OutputNode> {
|
||||
|
|
@ -150,6 +164,7 @@ impl CursorUserGroup {
|
|||
if self.hardware_cursor.replace(hardware_cursor) == hardware_cursor {
|
||||
return;
|
||||
}
|
||||
self.damage_active();
|
||||
if hardware_cursor {
|
||||
let prev = self
|
||||
.state
|
||||
|
|
@ -157,6 +172,7 @@ impl CursorUserGroup {
|
|||
.set(Some(self.clone()));
|
||||
if let Some(prev) = prev {
|
||||
prev.hardware_cursor.set(false);
|
||||
prev.damage_active();
|
||||
}
|
||||
match self.active.get() {
|
||||
None => self.remove_hardware_cursor(),
|
||||
|
|
@ -230,9 +246,7 @@ impl CursorUser {
|
|||
self.owner.take();
|
||||
self.group.users.remove(&self.id);
|
||||
if self.group.active_id.get() == Some(self.id) {
|
||||
self.group.active_id.take();
|
||||
self.group.active.take();
|
||||
self.group.state.damage();
|
||||
self.group.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -240,10 +254,15 @@ impl CursorUser {
|
|||
if self.group.active_id.replace(Some(self.id)) == Some(self.id) {
|
||||
return;
|
||||
}
|
||||
if self.software_cursor() {
|
||||
self.group.damage_active();
|
||||
}
|
||||
self.group.latest_output.set(self.output.get());
|
||||
self.group.active.set(Some(self.clone()));
|
||||
self.update_hardware_cursor();
|
||||
self.group.state.damage();
|
||||
if self.software_cursor() {
|
||||
self.group.damage_active();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "it"), allow(dead_code))]
|
||||
|
|
@ -341,6 +360,9 @@ impl CursorUser {
|
|||
}
|
||||
}
|
||||
old.handle_unset();
|
||||
if self.software_cursor() {
|
||||
self.group.damage_active();
|
||||
}
|
||||
}
|
||||
if let Some(cursor) = cursor.as_ref() {
|
||||
cursor.clone().handle_set();
|
||||
|
|
@ -348,6 +370,9 @@ impl CursorUser {
|
|||
}
|
||||
self.cursor.set(cursor.clone());
|
||||
self.update_hardware_cursor();
|
||||
if self.software_cursor() {
|
||||
self.group.damage_active();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn position(&self) -> (Fixed, Fixed) {
|
||||
|
|
@ -368,6 +393,16 @@ impl CursorUser {
|
|||
x = x.apply_fract(x_tmp);
|
||||
y = y.apply_fract(y_tmp);
|
||||
}
|
||||
if self.software_cursor() {
|
||||
if let Some(cursor) = self.cursor.get() {
|
||||
let (old_x, old_y) = self.pos.get();
|
||||
let old_x_int = old_x.round_down();
|
||||
let old_y_int = old_y.round_down();
|
||||
let extents = cursor.extents_at_scale(Scale::default());
|
||||
self.group.state.damage(extents.move_(old_x_int, old_y_int));
|
||||
self.group.state.damage(extents.move_(x_int, y_int));
|
||||
}
|
||||
}
|
||||
self.pos.set((x, y));
|
||||
self.update_hardware_cursor_(false);
|
||||
(x, y)
|
||||
|
|
@ -381,6 +416,10 @@ impl CursorUser {
|
|||
self.is_active() && self.group.hardware_cursor.get()
|
||||
}
|
||||
|
||||
pub fn software_cursor(&self) -> bool {
|
||||
self.is_active() && !self.group.hardware_cursor.get()
|
||||
}
|
||||
|
||||
fn update_hardware_cursor_(&self, render: bool) {
|
||||
if !self.hardware_cursor() {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue