Skip to content

Wayland: CursorGrabMode::Locked + set_cursor_position error if cursor outside of window #4557

@karolinepauls

Description

@karolinepauls

Description

The following program issues window.set_cursor_grab(CursorGrabMode::Locked) just after the window is created, and then tries to call window.set_cursor_position(PhysicalPosition::new(100, 100)) in the KeyboardEvent handler to give the user control as to when this happens.

Observed behaviour:

A) If the window opens with the cursor within it or the cursor is moved over it, pressing any key (which triggers setting cursor position) does not result in an error but doesn't move the cursor either (which is probably by the design of Wayland and relative motion needs to be issued instead).

B) If the window opens without the cursor over it, pressing any key (which triggers setting cursor position) causes an error: setting cursor position: Os(OsError { line: 951, file: [...]/winit-0.30.13/src/platform_impl/linux/wayland/window/state.rs", error: Misc("cursor position can be set only for locked cursor.") }).

Notes:

  1. Moving set_cursor_grab to the event handler just before set_cursor_position doesn't fix the error.
  2. Moving set_cursor_position to resumed just after set_cursor_grab moves the error to startup time.
use softbuffer::{Context, Surface};
use std::num::NonZero;
use std::rc::Rc;
use winit::application::ApplicationHandler;
use winit::dpi::PhysicalPosition;
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, EventLoop, OwnedDisplayHandle};
use winit::window::{CursorGrabMode, Window, WindowId};

#[derive(Default)]
struct App {
    window: Option<Rc<Window>>,
    surface: Option<Box<Surface<OwnedDisplayHandle, Rc<Window>>>>,
}

impl ApplicationHandler for App {
    fn resumed(&mut self, event_loop: &ActiveEventLoop) {
        let window = event_loop
            .create_window(Window::default_attributes())
            .unwrap();

        window
            //.set_cursor_grab(CursorGrabMode::Confined)
            .set_cursor_grab(CursorGrabMode::Locked)
            .expect("confining cursor");

        let context = Context::new(event_loop.owned_display_handle())
            .expect("Failed to create a softbuffer context");

        let window_rc = Rc::new(window);
        self.surface = Some(Box::new(Surface::new(&context, window_rc.clone()).unwrap()));
        self.window = Some(window_rc);
    }

    fn window_event(&mut self, event_loop: &ActiveEventLoop, _id: WindowId, event: WindowEvent) {
        dbg!(&event);

        match event {
            WindowEvent::CloseRequested => {
                event_loop.exit();
            }
            WindowEvent::RedrawRequested => {
                let window = self
                    .window
                    .as_ref()
                    .expect("redraw request without a window");

                // Notify that you're about to draw.
                window.pre_present_notify();

                // Fill a buffer with a solid color
                let size = window.inner_size();
                let width = NonZero::new(size.width).expect("width non-zero");
                let height = NonZero::new(size.height).expect("height non-zero");
                let surface = self
                    .surface
                    .as_mut()
                    .expect("surface when handling events")
                    .as_mut();

                surface
                    .resize(width, height)
                    .expect("Failed to resize the softbuffer surface");

                let mut buffer = surface.buffer_mut().unwrap();
                buffer.fill(0xdd33ff);

                buffer
                    .present()
                    .expect("Failed to present the softbuffer buffer");
            }
            WindowEvent::KeyboardInput { .. } => {
                self.window
                    .as_ref()
                    .expect("window at event time")
                    .set_cursor_position(PhysicalPosition::new(100, 100))
                    .expect("setting cursor position");
                println!("set cursor position");
            }
            _ => (),
        };
    }
}

fn main() {
    let event_loop = EventLoop::new().unwrap();

    let mut app = App::default();
    let _ = event_loop.run_app(&mut app);
}

Debugging output

Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/winit-repro`
[4198636.857]  -> wl_display#1.get_registry(new id wl_registry#2)
[4198636.904]  -> wl_display#1.sync(new id wl_callback#3)
[4198644.013] {Display Queue} wl_display#1.delete_id(3)
[4198644.056] wl_registry#2.global(1, "wl_compositor", 6)
[4198644.162] wl_registry#2.global(3, "zwp_tablet_manager_v2", 2)
[4198644.173] wl_registry#2.global(4, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[4198644.182] wl_registry#2.global(5, "zxdg_decoration_manager_v1", 1)
[4198644.191] wl_registry#2.global(6, "wp_viewporter", 1)
[4198644.202] wl_registry#2.global(7, "wp_security_context_manager_v1", 1)
[4198644.211] wl_registry#2.global(8, "wp_fractional_scale_manager_v1", 1)
[4198644.220] wl_registry#2.global(9, "wl_shm", 2)
[4198644.230] wl_registry#2.global(10, "wl_seat", 9)
[4198644.239] wl_registry#2.global(11, "zwp_pointer_gestures_v1", 3)
[4198644.248] wl_registry#2.global(12, "zwp_pointer_constraints_v1", 1)
[4198644.258] wl_registry#2.global(13, "zwp_relative_pointer_manager_v1", 1)
[4198644.266] wl_registry#2.global(14, "wl_data_device_manager", 3)
[4198644.275] wl_registry#2.global(15, "ext_data_control_manager_v1", 1)
[4198644.284] wl_registry#2.global(16, "zwlr_data_control_manager_v1", 2)
[4198644.293] wl_registry#2.global(17, "wp_cursor_shape_manager_v1", 2)
[4198644.302] wl_registry#2.global(18, "org_kde_kwin_idle", 1)
[4198644.312] wl_registry#2.global(19, "zwp_idle_inhibit_manager_v1", 1)
[4198644.322] wl_registry#2.global(20, "ext_idle_notifier_v1", 2)
[4198644.331] wl_registry#2.global(21, "org_kde_plasma_shell", 8)
[4198644.340] wl_registry#2.global(22, "org_kde_kwin_appmenu_manager", 2)
[4198644.349] wl_registry#2.global(23, "org_kde_kwin_server_decoration_palette_manager", 1)
[4198644.360] wl_registry#2.global(25, "org_kde_plasma_virtual_desktop_management", 2)
[4198644.369] wl_registry#2.global(27, "org_kde_kwin_shadow_manager", 2)
[4198644.377] wl_registry#2.global(28, "org_kde_kwin_dpms_manager", 1)
[4198644.386] wl_registry#2.global(29, "org_kde_kwin_server_decoration_manager", 1)
[4198644.395] wl_registry#2.global(30, "kde_output_management_v2", 16)
[4198644.404] wl_registry#2.global(31, "zxdg_output_manager_v1", 3)
[4198644.413] wl_registry#2.global(32, "wl_subcompositor", 1)
[4198644.422] wl_registry#2.global(33, "zxdg_exporter_v2", 1)
[4198644.431] wl_registry#2.global(34, "zxdg_importer_v2", 1)
[4198644.440] wl_registry#2.global(37, "xdg_activation_v1", 1)
[4198644.449] wl_registry#2.global(39, "wp_content_type_manager_v1", 1)
[4198644.459] wl_registry#2.global(40, "wp_tearing_control_manager_v1", 1)
[4198644.468] wl_registry#2.global(41, "xdg_toplevel_drag_manager_v1", 1)
[4198644.477] wl_registry#2.global(42, "xdg_toplevel_icon_manager_v1", 1)
[4198644.486] wl_registry#2.global(43, "kde_screen_edge_manager_v1", 1)
[4198644.495] wl_registry#2.global(44, "frog_color_management_factory_v1", 1)
[4198644.504] wl_registry#2.global(45, "wp_presentation", 2)
[4198644.512] wl_registry#2.global(46, "wp_color_manager_v1", 1)
[4198644.521] wl_registry#2.global(47, "xdg_wm_dialog_v1", 1)
[4198644.530] wl_registry#2.global(48, "kde_external_brightness_v1", 3)
[4198644.538] wl_registry#2.global(49, "wp_alpha_modifier_v1", 1)
[4198644.547] wl_registry#2.global(50, "wl_fixes", 1)
[4198644.621]  -> wl_registry#2.bind(50, "wl_fixes", 1, new id [unknown]#4)
[4198644.650] wl_registry#2.global(51, "wp_fifo_manager_v1", 1)
[4198644.659] wl_registry#2.global(52, "wp_single_pixel_buffer_manager_v1", 1)
[4198644.668] wl_registry#2.global(53, "xdg_toplevel_tag_manager_v1", 1)
[4198644.678] wl_registry#2.global(54, "wp_color_representation_manager_v1", 1)
[4198644.687] wl_registry#2.global(56, "wl_drm", 2)
[4198644.696] wl_registry#2.global(57, "zwp_linux_dmabuf_v1", 5)
[4198644.704] wl_registry#2.global(58, "wp_linux_drm_syncobj_manager_v1", 1)
[4198644.713] wl_registry#2.global(60, "xdg_wm_base", 6)
[4198644.722] wl_registry#2.global(61, "zwlr_layer_shell_v1", 5)
[4198644.731] wl_registry#2.global(63, "kde_output_device_v2", 16)
[4198644.740] wl_registry#2.global(67, "wp_drm_lease_device_v1", 1)
[4198644.748] wl_registry#2.global(68, "kde_output_order_v1", 1)
[4198644.756] wl_registry#2.global(69, "zwp_text_input_manager_v1", 1)
[4198644.766] wl_registry#2.global(70, "zwp_text_input_manager_v2", 1)
[4198644.774] wl_registry#2.global(71, "zwp_text_input_manager_v3", 1)
[4198644.783] wl_registry#2.global(73, "org_kde_kwin_blur_manager", 1)
[4198644.792] wl_registry#2.global(74, "org_kde_kwin_contrast_manager", 2)
[4198644.801] wl_registry#2.global(75, "org_kde_kwin_slide_manager", 1)
[4198644.811] wl_registry#2.global(76, "xdg_system_bell_v1", 1)
[4198644.820] wl_registry#2.global(84, "kde_output_device_v2", 16)
[4198644.829] wl_registry#2.global(85, "wl_output", 4)
[4198644.839] wl_registry#2.global(86, "wl_output", 4)
[4198644.848] wl_callback#3.done(1607202)
[4198644.998]  -> wl_registry#2.bind(1, "wl_compositor", 6, new id [unknown]#3)
[4198645.025]  -> wl_registry#2.bind(32, "wl_subcompositor", 1, new id [unknown]#5)
[4198645.055]  -> wl_registry#2.bind(85, "wl_output", 4, new id [unknown]#6)
[4198645.074]  -> wl_registry#2.bind(86, "wl_output", 4, new id [unknown]#7)
[4198645.091]  -> wl_registry#2.bind(31, "zxdg_output_manager_v1", 3, new id [unknown]#8)
[4198645.146]  -> zxdg_output_manager_v1#8.get_xdg_output(new id zxdg_output_v1#9, wl_output#6)
[4198645.169]  -> zxdg_output_manager_v1#8.get_xdg_output(new id zxdg_output_v1#10, wl_output#7)
[4198645.214]  -> wl_registry#2.bind(10, "wl_seat", 7, new id [unknown]#11)
[4198645.294]  -> wl_registry#2.bind(8, "wp_fractional_scale_manager_v1", 1, new id [unknown]#12)
[4198645.313]  -> wl_registry#2.bind(6, "wp_viewporter", 1, new id [unknown]#13)
[4198645.333]  -> wl_registry#2.bind(9, "wl_shm", 1, new id [unknown]#14)
[4198645.399]  -> wl_shm#14.create_pool(new id wl_shm_pool#15, fd 8, 2)
[4198645.468]  -> wl_registry#2.bind(60, "xdg_wm_base", 6, new id [unknown]#16)
[4198645.494]  -> wl_registry#2.bind(5, "zxdg_decoration_manager_v1", 1, new id [unknown]#17)
[4198645.515]  -> wl_registry#2.bind(37, "xdg_activation_v1", 1, new id [unknown]#18)
[4198645.540]  -> wl_registry#2.bind(73, "org_kde_kwin_blur_manager", 1, new id [unknown]#19)
[4198645.559]  -> wl_registry#2.bind(71, "zwp_text_input_manager_v3", 1, new id [unknown]#20)
[4198645.578]  -> wl_registry#2.bind(13, "zwp_relative_pointer_manager_v1", 1, new id [unknown]#21)
[4198645.597]  -> wl_registry#2.bind(12, "zwp_pointer_constraints_v1", 1, new id [unknown]#22)
[4198645.637]  -> wl_display#1.sync(new id wl_callback#23)
[4198645.972] {Display Queue} wl_display#1.delete_id(23)
[4198645.983] wl_output#6.name("DP-2")
[4198646.002] wl_output#6.description("Dell Inc. DELL P3424WE")
[4198646.009] wl_output#6.mode(1, 3440, 1440, 59973)
[4198646.016] wl_output#6.scale(1)
[4198646.021] wl_output#6.geometry(0, 0, 800, 335, 0, "Dell Inc.", "DELL P3424WE", 0)
[4198646.036] wl_output#6.done()
[4198646.041] wl_output#7.name("eDP-1")
[4198646.048] wl_output#7.description("Lenovo Group Limited eDP-1-0x403D")
[4198646.053] wl_output#7.mode(1, 1680, 1050, 60002)
[4198646.060] wl_output#7.scale(2)
[4198646.065] wl_output#7.geometry(1442, 1440, 302, 188, 0, "Lenovo Group Limited", "eDP-1-0x403D", 0)
[4198646.073] wl_output#7.done()
[4198646.077] zxdg_output_v1#9.logical_position(0, 0)
[4198646.086] zxdg_output_v1#9.logical_size(3440, 1440)
[4198646.092] zxdg_output_v1#9.name("DP-2")
[4198646.098] zxdg_output_v1#9.description("Dell Inc. DELL P3424WE")
[4198646.103] wl_output#6.done()
[4198646.111] zxdg_output_v1#10.logical_position(1442, 1440)
[4198646.116] zxdg_output_v1#10.logical_size(1344, 840)
[4198646.120] zxdg_output_v1#10.name("eDP-1")
[4198646.124] zxdg_output_v1#10.description("Lenovo Group Limited eDP-1-0x403D")
[4198646.130] wl_output#7.done()
[4198646.134] wl_seat#11.name("seat0")
[4198646.142] wl_seat#11.capabilities(7)
[4198646.148] wl_shm#14.format(0)
[4198646.154] wl_shm#14.format(1)
[4198646.158] wl_shm#14.format(808669761)
[4198646.163] wl_shm#14.format(808669784)
[4198646.167] wl_shm#14.format(808665665)
[4198646.171] wl_shm#14.format(808665688)
[4198646.175] wl_shm#14.format(942948929)
[4198646.179] wl_shm#14.format(942948952)
[4198646.183] wl_shm#14.format(875710274)
[4198646.192] wl_shm#14.format(875710290)
[4198646.197] wl_callback#23.done(1607202)
[4198646.353]  -> wl_seat#11.get_keyboard(new id wl_keyboard#23)
[4198650.946]  -> zwp_text_input_manager_v3#20.get_text_input(new id zwp_text_input_v3#24, wl_seat#11)
[4198650.999]  -> wl_compositor#3.create_surface(new id wl_surface#25)
[4198651.020]  -> wp_viewporter#13.get_viewport(new id wp_viewport#26, wl_surface#25)
[4198651.047]  -> wl_seat#11.get_pointer(new id wl_pointer#27)
[4198651.068]  -> wl_registry#2.bind(17, "wp_cursor_shape_manager_v1", 1, new id [unknown]#28)
[4198651.092]  -> wp_cursor_shape_manager_v1#28.get_pointer(new id wp_cursor_shape_device_v1#29, wl_pointer#27)
[4198651.121]  -> zwp_relative_pointer_manager_v1#21.get_relative_pointer(new id zwp_relative_pointer_v1#30, wl_pointer#27)
[4198651.157]  -> wl_seat#11.get_touch(new id wl_touch#31)
[4198651.291]  -> wl_compositor#3.create_surface(new id wl_surface#32)
[4198651.316]  -> xdg_wm_base#16.get_xdg_surface(new id xdg_surface#33, wl_surface#32)
[4198651.331]  -> xdg_surface#33.get_toplevel(new id xdg_toplevel#34)
[4198651.348]  -> zxdg_decoration_manager_v1#17.get_toplevel_decoration(new id zxdg_toplevel_decoration_v1#35, xdg_toplevel#34)
[4198651.363]  -> zxdg_toplevel_decoration_v1#35.set_mode(2)
[4198651.377]  -> wp_viewporter#13.get_viewport(new id wp_viewport#36, wl_surface#32)
[4198651.391]  -> wp_fractional_scale_manager_v1#12.get_fractional_scale(new id wp_fractional_scale_v1#37, wl_surface#32)
[4198651.413]  -> wl_compositor#3.create_region(new id wl_region#38)
[4198651.428]  -> wl_region#38.add(0, 0, 2147483647, 2147483647)
[4198651.442]  -> wl_surface#32.set_opaque_region(wl_region#38)
[4198651.449]  -> wl_region#38.destroy()
[4198651.469]  -> xdg_toplevel#34.set_title("winit window")
[4198651.489]  -> xdg_toplevel#34.set_min_size(2, 1)
[4198651.498]  -> xdg_toplevel#34.set_max_size(0, 0)
[4198651.507]  -> wl_surface#32.commit()
[4198651.530]  -> wl_display#1.sync(new id wl_callback#39)
[4198653.241] {Display Queue} wl_display#1.delete_id(38)
[4198653.262] {Display Queue} wl_display#1.delete_id(39)
[4198653.270] wl_keyboard#23.repeat_info(25, 350)
[4198653.300] wl_keyboard#23.keymap(1, fd 10, 66575)
[4198653.310] xdg_toplevel#34.wm_capabilities(array[16])
[4198653.330] zxdg_toplevel_decoration_v1#35.configure(2)
[4198653.342] wl_callback#39.done(1607202)
[4198653.361] wp_fractional_scale_v1#37.preferred_scale(120)
[4198653.371] wl_surface#32.preferred_buffer_scale(1)
[4198653.384] wl_surface#32.preferred_buffer_transform(0)
[4198653.391] xdg_toplevel#34.configure_bounds(3438, 1411)
[4198653.399] xdg_toplevel#34.configure(0, 0, array[0])
[4198653.410] xdg_surface#33.configure(1607203)
[4198656.624]  -> xdg_surface#33.ack_configure(1607203)
[4198656.679]  -> wl_compositor#3.create_region(new id wl_region#39)
[4198656.706]  -> wl_region#39.add(0, 0, 2147483647, 2147483647)
[4198656.729]  -> wl_surface#32.set_opaque_region(wl_region#39)
[4198656.739]  -> wl_region#39.destroy()
[4198656.759]  -> xdg_surface#33.set_window_geometry(0, 0, 800, 600)
[4198656.779]  -> wp_viewport#36.set_destination(800, 600)
[4198656.866]  -> wl_display#1.get_registry(new id wl_registry#38)
[4198656.890]  -> wl_display#1.sync(new id wl_callback#40)
[4198657.097] {Display Queue} wl_display#1.delete_id(39)
[4198657.105] {Display Queue} wl_display#1.delete_id(40)
[4198657.111] wl_registry#38.global(1, "wl_compositor", 6)
[4198657.153] wl_registry#38.global(3, "zwp_tablet_manager_v2", 2)
[4198657.167] wl_registry#38.global(4, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[4198657.179] wl_registry#38.global(5, "zxdg_decoration_manager_v1", 1)
[4198657.191] wl_registry#38.global(6, "wp_viewporter", 1)
[4198657.205] wl_registry#38.global(7, "wp_security_context_manager_v1", 1)
[4198657.214] wl_registry#38.global(8, "wp_fractional_scale_manager_v1", 1)
[4198657.226] wl_registry#38.global(9, "wl_shm", 2)
[4198657.238] wl_registry#38.global(10, "wl_seat", 9)
[4198657.252] wl_registry#38.global(11, "zwp_pointer_gestures_v1", 3)
[4198657.264] wl_registry#38.global(12, "zwp_pointer_constraints_v1", 1)
[4198657.277] wl_registry#38.global(13, "zwp_relative_pointer_manager_v1", 1)
[4198657.286] wl_registry#38.global(14, "wl_data_device_manager", 3)
[4198657.297] wl_registry#38.global(15, "ext_data_control_manager_v1", 1)
[4198657.309] wl_registry#38.global(16, "zwlr_data_control_manager_v1", 2)
[4198657.322] wl_registry#38.global(17, "wp_cursor_shape_manager_v1", 2)
[4198657.333] wl_registry#38.global(18, "org_kde_kwin_idle", 1)
[4198657.346] wl_registry#38.global(19, "zwp_idle_inhibit_manager_v1", 1)
[4198657.355] wl_registry#38.global(20, "ext_idle_notifier_v1", 2)
[4198657.364] wl_registry#38.global(21, "org_kde_plasma_shell", 8)
[4198657.375] wl_registry#38.global(22, "org_kde_kwin_appmenu_manager", 2)
[4198657.387] wl_registry#38.global(23, "org_kde_kwin_server_decoration_palette_manager", 1)
[4198657.399] wl_registry#38.global(25, "org_kde_plasma_virtual_desktop_management", 2)
[4198657.408] wl_registry#38.global(27, "org_kde_kwin_shadow_manager", 2)
[4198657.420] wl_registry#38.global(28, "org_kde_kwin_dpms_manager", 1)
[4198657.432] wl_registry#38.global(29, "org_kde_kwin_server_decoration_manager", 1)
[4198657.444] wl_registry#38.global(30, "kde_output_management_v2", 16)
[4198657.453] wl_registry#38.global(31, "zxdg_output_manager_v1", 3)
[4198657.462] wl_registry#38.global(32, "wl_subcompositor", 1)
[4198657.471] wl_registry#38.global(33, "zxdg_exporter_v2", 1)
[4198657.480] wl_registry#38.global(34, "zxdg_importer_v2", 1)
[4198657.489] wl_registry#38.global(37, "xdg_activation_v1", 1)
[4198657.498] wl_registry#38.global(39, "wp_content_type_manager_v1", 1)
[4198657.508] wl_registry#38.global(40, "wp_tearing_control_manager_v1", 1)
[4198657.519] wl_registry#38.global(41, "xdg_toplevel_drag_manager_v1", 1)
[4198657.531] wl_registry#38.global(42, "xdg_toplevel_icon_manager_v1", 1)
[4198657.543] wl_registry#38.global(43, "kde_screen_edge_manager_v1", 1)
[4198657.552] wl_registry#38.global(44, "frog_color_management_factory_v1", 1)
[4198657.564] wl_registry#38.global(45, "wp_presentation", 2)
[4198657.576] wl_registry#38.global(46, "wp_color_manager_v1", 1)
[4198657.589] wl_registry#38.global(47, "xdg_wm_dialog_v1", 1)
[4198657.600] wl_registry#38.global(48, "kde_external_brightness_v1", 3)
[4198657.622] wl_registry#38.global(49, "wp_alpha_modifier_v1", 1)
[4198657.631] wl_registry#38.global(50, "wl_fixes", 1)
[4198657.657]  -> wl_registry#38.bind(50, "wl_fixes", 1, new id [unknown]#39)
[4198657.675] wl_registry#38.global(51, "wp_fifo_manager_v1", 1)
[4198657.687] wl_registry#38.global(52, "wp_single_pixel_buffer_manager_v1", 1)
[4198657.701] wl_registry#38.global(53, "xdg_toplevel_tag_manager_v1", 1)
[4198657.713] wl_registry#38.global(54, "wp_color_representation_manager_v1", 1)
[4198657.726] wl_registry#38.global(56, "wl_drm", 2)
[4198657.736] wl_registry#38.global(57, "zwp_linux_dmabuf_v1", 5)
[4198657.747] wl_registry#38.global(58, "wp_linux_drm_syncobj_manager_v1", 1)
[4198657.759] wl_registry#38.global(60, "xdg_wm_base", 6)
[4198657.772] wl_registry#38.global(61, "zwlr_layer_shell_v1", 5)
[4198657.780] wl_registry#38.global(63, "kde_output_device_v2", 16)
[4198657.792] wl_registry#38.global(67, "wp_drm_lease_device_v1", 1)
[4198657.804] wl_registry#38.global(68, "kde_output_order_v1", 1)
[4198657.816] wl_registry#38.global(69, "zwp_text_input_manager_v1", 1)
[4198657.824] wl_registry#38.global(70, "zwp_text_input_manager_v2", 1)
[4198657.836] wl_registry#38.global(71, "zwp_text_input_manager_v3", 1)
[4198657.848] wl_registry#38.global(73, "org_kde_kwin_blur_manager", 1)
[4198657.860] wl_registry#38.global(74, "org_kde_kwin_contrast_manager", 2)
[4198657.872] wl_registry#38.global(75, "org_kde_kwin_slide_manager", 1)
[4198657.884] wl_registry#38.global(76, "xdg_system_bell_v1", 1)
[4198657.893] wl_registry#38.global(84, "kde_output_device_v2", 16)
[4198657.904] wl_registry#38.global(85, "wl_output", 4)
[4198657.917] wl_registry#38.global(86, "wl_output", 4)
[4198657.930] wl_callback#40.done(1607203)
[4198657.956]  -> wl_registry#38.bind(9, "wl_shm", 1, new id [unknown]#40)
[src/main.rs:36:9] &event = ScaleFactorChanged {
    scale_factor: 1.0,
    inner_size_writer: InnerSizeWriter {
        new_inner_size: (Weak),
    },
}
[src/main.rs:36:9] &event = Resized(
    PhysicalSize {
        width: 800,
        height: 600,
    },
)
[src/main.rs:36:9] &event = RedrawRequested
[4198658.157]  -> wl_surface#32.frame(new id wl_callback#41)
[4198658.250]  -> wl_shm#40.create_pool(new id wl_shm_pool#42, fd 11, 2097152)
[4198658.288]  -> wl_shm_pool#42.create_buffer(new id wl_buffer#43, 0, 800, 600, 3200, 1)
[4198658.322]  -> wl_shm#40.create_pool(new id wl_shm_pool#44, fd 13, 2097152)
[4198658.341]  -> wl_shm_pool#44.create_buffer(new id wl_buffer#45, 0, 800, 600, 3200, 1)
[4198660.790]  -> wl_surface#32.attach(wl_buffer#45, 0, 0)
[4198660.820]  -> wl_surface#32.damage_buffer(0, 0, 800, 600)
[4198660.833]  -> wl_surface#32.commit()
[4198662.244] wl_surface#32.enter(wl_output#6)
[4198662.276] xdg_wm_base#16.ping(1607204)
[4198662.288] wl_keyboard#23.enter(1607207, wl_surface#32, array[0])
[4198662.303] wl_keyboard#23.modifiers(1607186, 0, 0, 0, 0)
[4198662.316] zwp_text_input_v3#24.enter(wl_surface#32)
[4198662.329] xdg_toplevel#34.configure(800, 600, array[4])
[4198662.342] xdg_surface#33.configure(1607210)
[4198662.414]  -> xdg_wm_base#16.pong(1607204)
[4198662.533]  -> xdg_surface#33.ack_configure(1607210)
[src/main.rs:36:9] &event = Focused(
    true,
)
[src/main.rs:36:9] &event = ModifiersChanged(
    Modifiers {
        state: ModifiersState(
            0x0,
        ),
        pressed_mods: ModifiersKeys(
            0x0,
        ),
    },
)
[4198676.582] {Display Queue} wl_display#1.delete_id(41)
[4198676.623] wl_callback#41.done(703971240)
[src/main.rs:36:9] &event = RedrawRequested
[4198676.858]  -> wl_surface#32.frame(new id wl_callback#41)
[4198679.449] wl_shm#40.format(0)
[4198679.483] wl_shm#40.format(1)
[4198679.489] wl_shm#40.format(808669761)
[4198679.499] wl_shm#40.format(808669784)
[4198679.508] wl_shm#40.format(808665665)
[4198679.516] wl_shm#40.format(808665688)
[4198679.521] wl_shm#40.format(942948929)
[4198679.529] wl_shm#40.format(942948952)
[4198679.536] wl_shm#40.format(875710274)
[4198679.545] wl_shm#40.format(875710290)
[4198679.620]  -> wl_surface#32.attach(wl_buffer#43, 0, 0)
[4198679.645]  -> wl_surface#32.damage_buffer(0, 0, 800, 600)
[4198679.659]  -> wl_surface#32.commit()
[4198682.287] {Display Queue} wl_display#1.delete_id(41)
[4198682.297] wl_callback#41.done(703971240)
[4199571.291] wl_keyboard#23.key(1607211, 703972241, 57, 1)
[src/main.rs:36:9] &event = KeyboardInput {
    device_id: DeviceId(
        Wayland(
            DeviceId,
        ),
    ),
    event: KeyEvent {
        physical_key: Code(
            Space,
        ),
        logical_key: Named(
            Space,
        ),
        text: Some(
            " ",
        ),
        location: Standard,
        state: Pressed,
        repeat: false,
        platform_specific: KeyEventExtra {
            text_with_all_modifiers: Some(
                " ",
            ),
            key_without_modifiers: Named(
                Space,
            ),
        },
    },
    is_synthetic: false,
}

thread 'main' (2060959) panicked at src/main.rs:77:22:
setting cursor position: Os(OsError { line: 951, file: "/home/karoline/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/winit-0.30.13/src/platform_impl/linux/wayland/window/state.rs", error: Misc("cursor position can be set only for locked cursor.") })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[4199572.395]  -> wl_keyboard#23.release()
[4199572.735]  -> wp_cursor_shape_device_v1#29.destroy()
[4199572.756]  -> wl_pointer#27.release()
[4199572.771]  -> wl_surface#25.destroy()
[4199572.791]  -> wp_viewport#26.destroy()
[4199573.296]  -> wp_fractional_scale_v1#37.destroy()
[4199573.309]  -> wp_viewport#36.destroy()

Window isn't shown unless you draw

  • I understand that windows aren't shown on Wayland unless I draw and present to them.

Winit version

0.30.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - waylandAffects the Wayland backend, or generally free Unix platforms

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions