emoon / rust_minifb

Cross platfrom window and framebuffer crate for Rust
MIT License
1.01k stars 97 forks source link

Window is always borderless and hides mouse cursor under Wayland #224

Closed mvforell closed 3 years ago

mvforell commented 3 years ago

When running under Wayland the created window is always borderless. Also there no cursor while it is over the window.

Screenshot (Gnome on X11):

Screenshot (Gnome on Wayland, sway looks similar):

Running with WAYLAND_DEBUG=1 gives the following log:

[1604604020.617104] -> wl_display@1.get_registry(2)
[1604604020.617145] -> wl_display@1.sync(3)
[1604604020.617348] <- wl_display@1.delete_id(3)
[1604604020.617373] <- wl_registry@2.global(1, "wl_drm", 2)
[1604604020.617413] <- wl_registry@2.global(2, "wl_compositor", 4)
[1604604020.617451] <- wl_registry@2.global(3, "wl_shm", 1)
[1604604020.617481] <- wl_registry@2.global(4, "wl_output", 2)
[1604604020.617516] <- wl_registry@2.global(5, "wl_output", 2)
[1604604020.617556] <- wl_registry@2.global(6, "zxdg_output_manager_v1", 3)
[1604604020.617607] <- wl_registry@2.global(7, "wl_data_device_manager", 3)
[1604604020.617672] <- wl_registry@2.global(8, "zwp_primary_selection_device_manager_v1", 1)
[1604604020.617733] <- wl_registry@2.global(9, "gtk_primary_selection_device_manager", 1)
[1604604020.617808] <- wl_registry@2.global(10, "wl_subcompositor", 1)
[1604604020.617876] <- wl_registry@2.global(11, "xdg_wm_base", 3)
[1604604020.617912] <- wl_registry@2.global(12, "zxdg_shell_v6", 1)
[1604604020.617943] <- wl_registry@2.global(13, "wl_shell", 1)
[1604604020.617991] <- wl_registry@2.global(14, "gtk_shell1", 3)
[1604604020.618019] <- wl_registry@2.global(15, "wp_viewporter", 1)
[1604604020.618153] <- wl_registry@2.global(16, "zwp_pointer_gestures_v1", 1)
[1604604020.618200] <- wl_registry@2.global(17, "zwp_tablet_manager_v2", 1)
[1604604020.618253] <- wl_registry@2.global(18, "wl_seat", 5)
[1604604020.618287] <- wl_registry@2.global(19, "zwp_relative_pointer_manager_v1", 1)
[1604604020.618396] <- wl_registry@2.global(20, "zwp_pointer_constraints_v1", 1)
[1604604020.618459] <- wl_registry@2.global(21, "zxdg_exporter_v1", 1)
[1604604020.618508] <- wl_registry@2.global(22, "zxdg_importer_v1", 1)
[1604604020.618542] <- wl_registry@2.global(23, "zwp_linux_dmabuf_v1", 3)
[1604604020.618569] <- wl_registry@2.global(24, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[1604604020.618628] <- wl_registry@2.global(25, "zwp_text_input_manager_v3", 1)
[1604604020.618678] <- wl_registry@2.global(26, "gtk_text_input_manager", 1)
[1604604020.618730] <- wl_callback@3.done(1739)
[1604604020.618789] -> wl_registry@2.bind(18, "wl_seat", 5, 3)
[1604604020.618831] -> wl_seat@3.get_keyboard(4)
[1604604020.618853] -> wl_seat@3.get_pointer(5)
[1604604020.619123] -> wl_registry@2.bind(2, "wl_compositor", 4, 6)
[1604604020.619168] -> wl_registry@2.bind(3, "wl_shm", 1, 7)
[1604604020.619203] -> wl_compositor@6.create_surface(8)
[1604604020.619245] -> wl_shm@7.create_pool(9, 7, 1920000)
[1604604020.619278] -> wl_shm_pool@9.create_buffer(10, 0, 800, 600, 3200, 1)
[1604604020.636476] -> wl_registry@2.bind(11, "xdg_wm_base", 1, 11)
[1604604020.636561] -> xdg_wm_base@11.get_xdg_surface(12, 8)
[1604604020.636596] -> xdg_surface@12.get_toplevel(13)
Failed to create server-side surface decoration: Missing
[1604604020.636626] -> wl_surface@8.commit()
[1604604020.636648] -> wl_display@1.sync(14)
[1604604020.638806] <- wl_display@1.delete_id(14)
[1604604020.638853] <- wl_keyboard@4.keymap(1, 8, 52842)
[1604604020.638893] <- wl_keyboard@4.repeat_info(33, 500)
[1604604020.638929] <- xdg_surface@12.configure(66)
[1604604020.638949] -> xdg_surface@12.ack_configure(66)
[1604604020.638970] -> wl_surface@8.commit()
[1604604020.638988] <- wl_callback@14.done(1739)
[1604604020.639027] -> wl_surface@8.attach(10, 0, 0)
[1604604020.639051] -> wl_surface@8.damage(0, 0, 2147483647, 2147483647)
[1604604020.639072] -> wl_surface@8.commit()
[1604604020.639136] -> wl_shm@7.create_pool(14, 10, 1024)
[1604604020.639169] -> wl_compositor@6.create_surface(15)
[1604604020.639291] -> xdg_toplevel@13.set_title("Window")
[1604604020.673760] -> wl_shm@7.create_pool(16, 9, 1920000)
[1604604020.673829] -> wl_shm_pool@16.create_buffer(17, 0, 800, 600, 3200, 1)
[1604604020.674683] -> wl_surface@8.attach(17, 0, 0)
[1604604020.674734] -> wl_surface@8.damage(0, 0, 2147483647, 2147483647)
[1604604020.674766] -> wl_surface@8.commit()
[1604604020.678512] <- wl_buffer@10.release()
[1604604020.678539] <- wl_buffer@17.release()
[1604604020.681444] -> wl_surface@8.attach(17, 0, 0)
[1604604020.681492] -> wl_surface@8.damage(0, 0, 2147483647, 2147483647)
[1604604020.681511] -> wl_surface@8.commit()
[1604604020.683957] <- xdg_toplevel@13.configure(800, 600, [4, 0, 0, 0])
[1604604020.684008] <- xdg_surface@12.configure(67)
[1604604020.684035] <- wl_keyboard@4.modifiers(1741, 0, 0, 16, 0)
[1604604020.684073] <- wl_keyboard@4.enter(1741, 8, [])
[1604604020.697978] -> xdg_surface@12.ack_configure(67)
[1604604020.698046] -> wl_surface@8.attach(17, 0, 0)
[1604604020.698074] -> wl_surface@8.damage(0, 0, 2147483647, 2147483647)
[1604604020.698097] -> wl_surface@8.commit()
[1604604020.698209] <- wl_buffer@17.release()
[1604604020.714811] -> wl_surface@8.attach(17, 0, 0)
[1604604020.714883] -> wl_surface@8.damage(0, 0, 2147483647, 2147483647)
[1604604020.714912] -> wl_surface@8.commit()
[1604604020.715009] <- wl_buffer@17.release()
[...]

I'm not sure whether this may be an upstream issue of Smithay/wayland-rs; I've found no related issues.

emoon commented 3 years ago

Hey @nifker any idea about this one?

nyovaya commented 3 years ago

@emoon @mvforell It uses the ZxdgDecorationManagerV1 protocol(which looks like gnome doesnt support) for the decoration but I dont know if others exist. Seems like the default pointer_visibility is for some reason false. We need to change that value.

mvforell commented 3 years ago

It seems GNOME doesn't support Server Side Decorations: https://drewdevault.com/2018/01/27/Sway-and-client-side-decorations.html.

nyovaya commented 3 years ago

@mvforell You say sway doesnt draw serve-side decorations onto the window?

mvforell commented 3 years ago

My bad, I forgot that I disabled window borders in sway. If I reenable them, the window has a titlebar with the correct window title. I only thought this was an issue because the window also had no decorations in GNOME; but now I know that's GNOME's fault and not rust_minifb's.