fix crash on new toplevel when running on tty

This commit is contained in:
2026-01-13 11:35:02 +07:00
parent e7f194ed8d
commit 6416e742ac
2 changed files with 20 additions and 10 deletions
+12 -8
View File
@@ -24,14 +24,6 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
struct wlr_xdg_toplevel *xdg_toplevel; struct wlr_xdg_toplevel *xdg_toplevel;
struct absinthe_toplevel *toplevel; struct absinthe_toplevel *toplevel;
surface = server->seat->pointer_state.focused_surface;
if (surface)
xdg_toplevel = wlr_xdg_toplevel_try_from_wlr_surface(surface);
if (xdg_toplevel)
toplevel = xdg_toplevel->base->data;
switch (keysym) { switch (keysym) {
case XKB_KEY_Escape: case XKB_KEY_Escape:
wl_display_terminate(server->display); wl_display_terminate(server->display);
@@ -40,7 +32,19 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
if (fork() == 0) if (fork() == 0)
execl("/bin/sh", "sh", "-c", "alacritty", NULL); execl("/bin/sh", "sh", "-c", "alacritty", NULL);
break; break;
case XKB_KEY_r:
if (fork() == 0)
execl("/bin/sh", "sh", "-c", "wofi --show drun", NULL);
break;
case XKB_KEY_f: case XKB_KEY_f:
surface = server->seat->pointer_state.focused_surface;
if (surface)
xdg_toplevel = wlr_xdg_toplevel_try_from_wlr_surface(surface);
if (xdg_toplevel)
toplevel = xdg_toplevel->base->data;
if (toplevel) if (toplevel)
absinthe_toplevel_set_fullscreen(toplevel, !toplevel->fullscreen); absinthe_toplevel_set_fullscreen(toplevel, !toplevel->fullscreen);
break; break;
+8 -2
View File
@@ -3,6 +3,7 @@
#include <wlr/types/wlr_subcompositor.h> #include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_screencopy_v1.h> #include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_data_control_v1.h> #include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_viewporter.h> #include <wlr/types/wlr_viewporter.h>
@@ -45,7 +46,13 @@ int main(int argc, char **argv)
return 1; return 1;
} }
wlr_renderer_init_wl_display(server.renderer, server.display); wlr_renderer_init_wl_shm(server.renderer, server.display);
server.scene = wlr_scene_create();
if (wlr_renderer_get_texture_formats(server.renderer, WLR_BUFFER_CAP_DMABUF)) {
wlr_drm_create(server.display, server.renderer);
wlr_scene_set_linux_dmabuf_v1(server.scene, wlr_linux_dmabuf_v1_create_with_renderer(server.display, 5, server.renderer));
}
server.allocator = wlr_allocator_autocreate(server.backend, server.renderer); server.allocator = wlr_allocator_autocreate(server.backend, server.renderer);
if (!server.allocator) { if (!server.allocator) {
@@ -85,7 +92,6 @@ int main(int argc, char **argv)
wlr_xdg_output_manager_v1_create(server.display, server.output_layout); wlr_xdg_output_manager_v1_create(server.display, server.output_layout);
server.scene = wlr_scene_create();
server.scene_layout = wlr_scene_attach_output_layout(server.scene, server.output_layout); server.scene_layout = wlr_scene_attach_output_layout(server.scene, server.output_layout);
wl_list_init(&server.toplevels); wl_list_init(&server.toplevels);