Skip to content

Commit

Permalink
winit: Set cursor instead of rendering it when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
bbb651 committed Jan 29, 2025
1 parent 9b4d73f commit 48d06cd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/backend/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use smithay::backend::renderer::damage::OutputDamageTracker;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
use smithay::input::pointer::CursorImageStatus;
use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
use smithay::reexports::calloop::LoopHandle;
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
Expand Down Expand Up @@ -175,11 +176,26 @@ impl Winit {
pub fn render(&mut self, niri: &mut Niri, output: &Output) -> RenderResult {
let _span = tracy_client::span!("Winit::render");

let window = self.backend.window();

// Update the cursor.
// TODO: Support surface cursors and dnd icons
let include_pointer = if let (CursorImageStatus::Named(cursor_icon), None) =
(niri.cursor_manager.cursor_image(), niri.dnd_icon.as_ref())
{
window.set_cursor(*cursor_icon);
window.set_cursor_visible(true);
false
} else {
window.set_cursor_visible(false);
true
};

// Render the elements.
let mut elements = niri.render::<GlesRenderer>(
self.backend.renderer(),
output,
true,
include_pointer,
RenderTarget::Output,
);

Expand Down

0 comments on commit 48d06cd

Please sign in to comment.