Skip to content

Commit 48d06cd

Browse files
committedJan 29, 2025
winit: Set cursor instead of rendering it when possible
1 parent 9b4d73f commit 48d06cd

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed
 

‎src/backend/winit.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use smithay::backend::renderer::damage::OutputDamageTracker;
1010
use smithay::backend::renderer::gles::GlesRenderer;
1111
use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
1212
use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
13+
use smithay::input::pointer::CursorImageStatus;
1314
use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
1415
use smithay::reexports::calloop::LoopHandle;
1516
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
@@ -175,11 +176,26 @@ impl Winit {
175176
pub fn render(&mut self, niri: &mut Niri, output: &Output) -> RenderResult {
176177
let _span = tracy_client::span!("Winit::render");
177178

179+
let window = self.backend.window();
180+
181+
// Update the cursor.
182+
// TODO: Support surface cursors and dnd icons
183+
let include_pointer = if let (CursorImageStatus::Named(cursor_icon), None) =
184+
(niri.cursor_manager.cursor_image(), niri.dnd_icon.as_ref())
185+
{
186+
window.set_cursor(*cursor_icon);
187+
window.set_cursor_visible(true);
188+
false
189+
} else {
190+
window.set_cursor_visible(false);
191+
true
192+
};
193+
178194
// Render the elements.
179195
let mut elements = niri.render::<GlesRenderer>(
180196
self.backend.renderer(),
181197
output,
182-
true,
198+
include_pointer,
183199
RenderTarget::Output,
184200
);
185201

0 commit comments

Comments
 (0)
Failed to load comments.