cursor: don't overwrite busy hardware buffers
This commit is contained in:
parent
b9ce5f22d8
commit
375d7da2f2
3 changed files with 13 additions and 4 deletions
|
|
@ -178,6 +178,7 @@ pub struct MetalConnector {
|
||||||
pub cursor_enabled: Cell<bool>,
|
pub cursor_enabled: Cell<bool>,
|
||||||
pub cursor_buffers: CloneCell<Option<Rc<[RenderBuffer; 2]>>>,
|
pub cursor_buffers: CloneCell<Option<Rc<[RenderBuffer; 2]>>>,
|
||||||
pub cursor_front_buffer: NumCell<usize>,
|
pub cursor_front_buffer: NumCell<usize>,
|
||||||
|
pub cursor_swap_buffer: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -228,7 +229,7 @@ impl HardwareCursor for MetalHardwareCursor {
|
||||||
self.connector.cursor_x.set(self.cursor_x_pending.get());
|
self.connector.cursor_x.set(self.cursor_x_pending.get());
|
||||||
self.connector.cursor_y.set(self.cursor_y_pending.get());
|
self.connector.cursor_y.set(self.cursor_y_pending.get());
|
||||||
if self.cursor_swap_buffer.take() {
|
if self.cursor_swap_buffer.take() {
|
||||||
self.connector.cursor_front_buffer.fetch_add(1);
|
self.connector.cursor_swap_buffer.set(true);
|
||||||
}
|
}
|
||||||
self.connector.cursor_changed.set(true);
|
self.connector.cursor_changed.set(true);
|
||||||
if self.connector.can_present.get() {
|
if self.connector.can_present.get() {
|
||||||
|
|
@ -363,6 +364,9 @@ impl MetalConnector {
|
||||||
if self.cursor_changed.get() && cursor.is_some() {
|
if self.cursor_changed.get() && cursor.is_some() {
|
||||||
let plane = cursor.unwrap();
|
let plane = cursor.unwrap();
|
||||||
if self.cursor_enabled.get() {
|
if self.cursor_enabled.get() {
|
||||||
|
if self.cursor_swap_buffer.take() {
|
||||||
|
self.cursor_front_buffer.fetch_add(1);
|
||||||
|
}
|
||||||
let buffers = self.cursor_buffers.get().unwrap();
|
let buffers = self.cursor_buffers.get().unwrap();
|
||||||
let buffer = &buffers[self.cursor_front_buffer.get() % buffers.len()];
|
let buffer = &buffers[self.cursor_front_buffer.get() % buffers.len()];
|
||||||
changes.change_object(plane.id, |c| {
|
changes.change_object(plane.id, |c| {
|
||||||
|
|
@ -545,6 +549,7 @@ fn create_connector(
|
||||||
connect_sent: Cell::new(false),
|
connect_sent: Cell::new(false),
|
||||||
cursor_changed: Cell::new(false),
|
cursor_changed: Cell::new(false),
|
||||||
cursor_front_buffer: Default::default(),
|
cursor_front_buffer: Default::default(),
|
||||||
|
cursor_swap_buffer: Cell::new(false),
|
||||||
});
|
});
|
||||||
let futures = ConnectorFutures {
|
let futures = ConnectorFutures {
|
||||||
present: backend
|
present: backend
|
||||||
|
|
|
||||||
|
|
@ -832,6 +832,7 @@ impl WlSurface {
|
||||||
if buffer_changed || transform_changed {
|
if buffer_changed || transform_changed {
|
||||||
for (_, cursor) in &self.cursors {
|
for (_, cursor) in &self.cursors {
|
||||||
cursor.handle_buffer_change();
|
cursor.handle_buffer_change();
|
||||||
|
cursor.update_hardware_cursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ext.post_commit();
|
ext.post_commit();
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,6 @@ impl CursorSurface {
|
||||||
let (hot_x, hot_y) = self.hotspot.get();
|
let (hot_x, hot_y) = self.hotspot.get();
|
||||||
self.extents
|
self.extents
|
||||||
.set(self.surface.extents.get().move_(-hot_x, -hot_y));
|
.set(self.surface.extents.get().move_(-hot_x, -hot_y));
|
||||||
if self.seat.hardware_cursor() {
|
|
||||||
self.seat.update_hardware_cursor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_surface_destroy(&self) {
|
pub fn handle_surface_destroy(&self) {
|
||||||
|
|
@ -57,6 +54,12 @@ impl CursorSurface {
|
||||||
self.hotspot.set((hot_x - hotspot_dx, hot_y - hotspot_dy));
|
self.hotspot.set((hot_x - hotspot_dx, hot_y - hotspot_dy));
|
||||||
self.update_extents();
|
self.update_extents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_hardware_cursor(&self) {
|
||||||
|
if self.seat.hardware_cursor() {
|
||||||
|
self.seat.update_hardware_cursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cursor for CursorSurface {
|
impl Cursor for CursorSurface {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue