Skip to content

Commit

Permalink
react to wlroots changes
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbowes committed Aug 26, 2023
1 parent 2b38536 commit 7fb889d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/waybox/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions waybox/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion waybox/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 9 additions & 6 deletions waybox/xdg_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 7fb889d

Please sign in to comment.