diff --git a/include/waybox/server.h b/include/waybox/server.h index 9c7b12d..5cf7492 100644 --- a/include/waybox/server.h +++ b/include/waybox/server.h @@ -49,6 +49,7 @@ struct wb_server { struct wlr_xdg_output_manager_v1 *output_manager; struct wlr_renderer *renderer; struct wlr_scene *scene; + struct wlr_scene_output_layout *scene_layout; struct wlr_subcompositor *subcompositor; struct wb_config *config; diff --git a/waybox/output.c b/waybox/output.c index b6e8d0d..811adbe 100644 --- a/waybox/output.c +++ b/waybox/output.c @@ -35,7 +35,11 @@ void output_frame_notify(struct wl_listener *listener, void *data) { } /* Render the scene if needed and commit the output */ +#if WLR_CHECK_VERSION(0, 17, 0) + wlr_scene_output_commit(scene_output, NULL); +#else wlr_scene_output_commit(scene_output); +#endif /* This lets the client know that we've displayed that frame and it can * prepare another one now if it likes. */ @@ -101,8 +105,8 @@ void new_output_notify(struct wl_listener *listener, void *data) { wlr_output_state_set_mode(&state, mode); } - wlr_output_state_finish(&state); wlr_output_commit_state(wlr_output, &state); + wlr_output_state_finish(&state); #else if (!wl_list_empty(&wlr_output->modes)) { struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); @@ -156,10 +160,15 @@ void new_output_notify(struct wl_listener *listener, void *data) { * output (such as DPI, scale factor, manufacturer, etc). */ #if WLR_CHECK_VERSION(0, 17, 0) - if (!wlr_output_layout_add_auto(server->output_layout, wlr_output)) { + struct wlr_output_layout_output *l_output = + wlr_output_layout_add_auto(server->output_layout, wlr_output); + if (!l_output) { wlr_log(WLR_ERROR, "%s", _("Could not add an output layout.")); return; } + + struct wlr_scene_output *scene_output = wlr_scene_output_create(server->scene, wlr_output); + wlr_scene_output_layout_add_output(server->scene_layout, l_output, scene_output); #else wlr_output_layout_add_auto(server->output_layout, wlr_output); #endif diff --git a/waybox/server.c b/waybox/server.c index 3a22a92..9c7f32d 100644 --- a/waybox/server.c +++ b/waybox/server.c @@ -78,7 +78,10 @@ bool wb_start_server(struct wb_server* server) { * necessary. */ server->scene = wlr_scene_create(); - wlr_scene_attach_output_layout(server->scene, server->output_layout); +#if WLR_CHECK_VERSION(0, 17, 0) + server->scene_layout = +#endif + wlr_scene_attach_output_layout(server->scene, server->output_layout); const char *socket = wl_display_add_socket_auto(server->wl_display); if (!socket) { diff --git a/waybox/xdg_shell.c b/waybox/xdg_shell.c index e399655..3ebc6c6 100644 --- a/waybox/xdg_shell.c +++ b/waybox/xdg_shell.c @@ -72,7 +72,8 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) { previous = wlr_xdg_surface_from_wlr_surface(prev_surface); } #endif - if (previous != NULL && previous->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) { + if (previous != NULL && previous->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && + previous->toplevel != NULL) { wlr_xdg_toplevel_set_activated(previous->toplevel, false); } } @@ -155,11 +156,13 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) { reset_cursor_mode(view->server); /* Focus the next view, if any. */ - struct wb_view *next_view = wl_container_of(view->link.next, next_view, link); - if (next_view && next_view->scene_tree && next_view->scene_tree->node.enabled) { - wlr_log(WLR_INFO, "%s: %s", _("Focusing next view"), - next_view->xdg_toplevel->app_id); - focus_view(next_view, next_view->xdg_toplevel->base->surface); + if (wl_list_length(&view->link) > 1) { + struct wb_view *next_view = wl_container_of(view->link.next, next_view, link); + if (next_view && next_view->xdg_toplevel && next_view->scene_tree && next_view->scene_tree->node.enabled) { + wlr_log(WLR_INFO, "%s: %s", _("Focusing next view"), + next_view->xdg_toplevel->app_id); + focus_view(next_view, next_view->xdg_toplevel->base->surface); + } } }