Skip to content

Commit

Permalink
Merge pull request #81 from mahkoh/jorth/cursor-fixes
Browse files Browse the repository at this point in the history
Various cursor fixes
  • Loading branch information
mahkoh authored Feb 7, 2024
2 parents e7709f6 + 71fc851 commit 4f7d39d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ fn create_dummy_output(state: &Rc<State>) {
hardware_cursor: Default::default(),
update_render_data_scheduled: Cell::new(false),
screencasts: Default::default(),
hardware_cursor_needs_render: Cell::new(false),
});
let dummy_workspace = Rc::new(WorkspaceNode {
id: state.node_ids.next(),
Expand Down
13 changes: 6 additions & 7 deletions src/gfx_apis/gl/renderer/framebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ impl Framebuffer {
if let Some(rect) = cursor_rect {
let seats = state.globals.lock_seats();
for seat in seats.values() {
if !render_hardware_cursor && seat.hardware_cursor() {
continue;
}
if let Some(cursor) = seat.get_cursor() {
let (mut x, mut y) = seat.get_position();
if let Some(dnd_icon) = seat.dnd_icon() {
Expand All @@ -205,10 +202,12 @@ impl Framebuffer {
renderer.render_surface(&dnd_icon, x, y, i32::MAX, i32::MAX);
}
}
cursor.tick();
x -= Fixed::from_int(rect.x1());
y -= Fixed::from_int(rect.y1());
cursor.render(&mut renderer, x, y);
if render_hardware_cursor || !seat.hardware_cursor() {
cursor.tick();
x -= Fixed::from_int(rect.x1());
y -= Fixed::from_int(rect.y1());
cursor.render(&mut renderer, x, y);
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/ifs/wl_seat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ impl WlSeatGlobal {
let (x, y) = self.get_position();
for output in self.state.root.outputs.lock().values() {
if let Some(hc) = output.hardware_cursor.get() {
let render = render | output.hardware_cursor_needs_render.take();
let scale = output.preferred_scale.get();
let extents = cursor.extents_at_scale(scale);
if render {
Expand Down Expand Up @@ -290,6 +291,9 @@ impl WlSeatGlobal {
hc.set_enabled(true);
hc.set_position(x_rel + extents.x1(), y_rel + extents.y1());
} else {
if render {
output.hardware_cursor_needs_render.set(true);
}
hc.set_enabled(false);
}
hc.commit();
Expand Down
7 changes: 7 additions & 0 deletions src/ifs/wl_seat/wl_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,20 @@ impl WlPointer {
Some(n) => n,
_ => {
// cannot happen
log::warn!("ignoring wl_pointer.set_cursor (1)");
return Ok(());
}
};
if pointer_node.node_client_id() != Some(self.seat.client.id) {
log::warn!("ignoring wl_pointer.set_cursor (2)");
return Ok(());
}
if req.serial != self.seat.client.last_enter_serial.get() {
log::warn!(
"ignoring wl_pointer.set_cursor (3) ({} != {})",
req.serial,
self.seat.client.last_enter_serial.get(),
);
return Ok(());
}
self.seat.global.set_app_cursor(cursor_opt);
Expand Down
1 change: 1 addition & 0 deletions src/tasks/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl ConnectorHandler {
jay_outputs: Default::default(),
screencasts: Default::default(),
update_render_data_scheduled: Cell::new(false),
hardware_cursor_needs_render: Cell::new(false),
});
self.state.add_output_scale(on.preferred_scale.get());
let mode = info.initial_mode;
Expand Down
1 change: 1 addition & 0 deletions src/tree/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct OutputNode {
pub lock_surface: CloneCell<Option<Rc<ExtSessionLockSurfaceV1>>>,
pub preferred_scale: Cell<Scale>,
pub hardware_cursor: CloneCell<Option<Rc<dyn HardwareCursor>>>,
pub hardware_cursor_needs_render: Cell<bool>,
pub update_render_data_scheduled: Cell<bool>,
pub screencasts: CopyHashMap<(ClientId, JayScreencastId), Rc<JayScreencast>>,
}
Expand Down

0 comments on commit 4f7d39d

Please sign in to comment.