react to wlroots changes

This commit is contained in:
Keith Bowes 2022-02-17 10:33:15 -05:00
parent bed7e244c2
commit 4cee7c4014
10 changed files with 38 additions and 36 deletions

View file

@ -31,7 +31,7 @@ struct wb_output {
struct wb_view {
struct wl_list link;
struct wb_server *server;
struct wlr_xdg_surface *xdg_surface;
struct wlr_xdg_toplevel *xdg_toplevel;
struct wlr_xdg_toplevel_decoration_v1 *decoration;

View file

@ -18,6 +18,7 @@
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
@ -40,6 +41,7 @@ struct wb_server {
struct wlr_compositor *compositor;
struct wlr_output_layout *output_layout;
struct wlr_renderer *renderer;
struct wlr_subcompositor *subcompositor;
struct wb_config *config;
char *config_file;

View file

@ -24,7 +24,7 @@ cc = meson.get_compiler('c')
inc_dir = include_directories('include')
libxml2 = dependency('libxml-2.0')
wlroots = dependency('wlroots', version: '>=0.15.0')
wlroots = dependency('wlroots', version: '>=0.16.0')
wayland_server = dependency('wayland-server', version: '>=1.15')
wayland_protos = dependency('wayland-protocols', version: '>=1.17')
xkbcommon = dependency('xkbcommon')

View file

@ -41,13 +41,13 @@ static void process_cursor_resize(struct wb_server *server) {
}
struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
view->x = new_left - geo_box.x;
view->y = new_top - geo_box.y;
int new_width = new_right - new_left;
int new_height = new_bottom - new_top;
wlr_xdg_toplevel_set_size(view->xdg_surface, new_width, new_height);
wlr_xdg_toplevel_set_size(view->xdg_toplevel, new_width, new_height);
}
static void process_cursor_motion(struct wb_server *server, uint32_t time) {

View file

@ -201,7 +201,7 @@ void arrange_layers(struct wb_output *output) {
{
struct wb_view *view =
wl_container_of(output->server->views.next, view, link);
focus_view(view, view->xdg_surface->surface);
focus_view(view, view->xdg_toplevel->base->surface);
}
}

View file

@ -31,18 +31,18 @@ int main(int argc, char **argv) {
if (argc > 1) {
int i;
for (i = 0; i < argc; i++) {
if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i])) {
if (strcmp("--debug", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
debuglevel = WLR_INFO;
} else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i]))) {
} else if (strcmp("--startup", argv[i]) == 0 || strcmp("-s", argv[i]) == 0) {
if (i < argc - 1) {
startup_cmd = argv[i + 1];
} else {
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
}
} else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
} else if (strcmp("--version", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
return 0;
} else if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
} else if (strcmp("--help", argv[i]) == 0 || strcmp("-h", argv[i]) == 0) {
show_help(argv[0]);
return 0;
} else if (strcmp("--config-file", argv[i]) == 0) {
@ -51,7 +51,7 @@ int main(int argc, char **argv) {
} else {
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
}
} else if (!strcmp("--sm-disable", argv[i])) {
} else if (strcmp("--sm-disable", argv[i]) == 0) {
fprintf(stderr, _("%s hasn't been implemented yet.\n"), argv[i]);
if (i == argc - 1) {
fprintf(stderr, _("%s requires an argument\n"), argv[i]);

View file

@ -21,7 +21,7 @@ static void render_surface(struct wlr_surface *surface,
* means. You don't have to worry about this, wlroots takes care of it. */
struct wlr_texture *texture = wlr_surface_get_texture(surface);
if (texture == NULL) {
wlr_log(WLR_ERROR, "%s: %s", _("Couldn't get a surface texture"));
wlr_log(WLR_ERROR, "%s", _("Couldn't get a surface texture"));
return;
}
@ -139,7 +139,7 @@ void output_frame_notify(struct wl_listener *listener, void *data) {
.when = &now,
};
wlr_xdg_surface_for_each_surface(view->xdg_surface,
wlr_xdg_surface_for_each_surface(view->xdg_toplevel->base,
render_surface, &rdata);
}

View file

@ -12,7 +12,7 @@ static bool cycle_views(struct wb_server *server) {
server->views.prev, current_view, link);
struct wb_view *prev_view = wl_container_of(
server->views.next, prev_view, link);
focus_view(current_view, current_view->xdg_surface->surface);
focus_view(current_view, current_view->xdg_toplevel->base->surface);
/* Move the current view to the beginning of the list */
wl_list_remove(&current_view->link);
wl_list_insert(&server->views, &current_view->link);
@ -28,7 +28,7 @@ static bool cycle_views_reverse(struct wb_server *server) {
server->views.next, current_view, link);
struct wb_view *next_view = wl_container_of(
current_view->link.next, next_view, link);
focus_view(next_view, next_view->xdg_surface->surface);
focus_view(next_view, next_view->xdg_toplevel->base->surface);
/* Move the previous view to the end of the list */
wl_list_remove(&current_view->link);
wl_list_insert(server->views.prev, &current_view->link);
@ -71,7 +71,7 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
else if ((strcmp("Close", key_binding->action) == 0)) {
struct wb_view *current_view = wl_container_of(
server->views.next, current_view, link);
wlr_xdg_toplevel_send_close(current_view->xdg_surface);
wlr_xdg_toplevel_send_close(current_view->xdg_toplevel);
return true;
}
else if ((strcmp("Execute", key_binding->action) == 0)) {

View file

@ -34,6 +34,7 @@ bool wb_create_backend(struct wb_server* server) {
server->compositor = wlr_compositor_create(server->wl_display,
server->renderer);
server->subcompositor = wlr_subcompositor_create(server->wl_display);
server->output_layout = wlr_output_layout_create();
server->seat = wb_seat_create(server);
server->cursor = wb_cursor_create(server);

View file

@ -24,20 +24,20 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) {
*/
struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface(
seat->keyboard_state.focused_surface);
wlr_xdg_toplevel_set_activated(previous, false);
wlr_xdg_toplevel_set_activated(previous->toplevel, false);
}
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
/* Move the view to the front */
wl_list_remove(&view->link);
wl_list_insert(&server->views, &view->link);
/* Activate the new surface */
wlr_xdg_toplevel_set_activated(view->xdg_surface, true);
wlr_xdg_toplevel_set_activated(view->xdg_toplevel, true);
/*
* Tell the seat to have the keyboard enter this surface. wlroots will keep
* track of this and automatically send key events to the appropriate
* clients without additional work on your part.
*/
wlr_seat_keyboard_notify_enter(seat, view->xdg_surface->surface,
wlr_seat_keyboard_notify_enter(seat, view->xdg_toplevel->base->surface,
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
}
@ -56,7 +56,7 @@ static void xdg_surface_ack_configure(struct wl_listener *listener, void *data)
* return a negative y value, which can be used to determine the
* size of the CSD titlebar. */
struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
if (geo_box.y < 0)
{
view->y = geo_box.y * -1;
@ -64,7 +64,7 @@ static void xdg_surface_ack_configure(struct wl_listener *listener, void *data)
}
/* Set size here, so the view->y value will be known */
wlr_xdg_toplevel_set_size(view->xdg_surface, geo_box.width - view->x, geo_box.height - view->y);
wlr_xdg_toplevel_set_size(view->xdg_toplevel, geo_box.width - view->x, geo_box.height - view->y);
}
}
@ -72,7 +72,7 @@ static void xdg_surface_map(struct wl_listener *listener, void *data) {
/* Called when the surface is mapped, or ready to display on-screen. */
struct wb_view *view = wl_container_of(listener, view, map);
view->mapped = true;
focus_view(view, view->xdg_surface->surface);
focus_view(view, view->xdg_toplevel->base->surface);
}
static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
@ -80,21 +80,21 @@ static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
struct wb_view *view = wl_container_of(listener, view, unmap);
view->mapped = false;
struct wb_view *current_view = (struct wb_view *) view->server->views.next;
struct wb_view *next_view = (struct wb_view *) current_view->link.next;
struct wb_view *current_view = wl_container_of(view->server->views.next, current_view, link);
struct wb_view *next_view = wl_container_of(current_view->link.next, next_view, link);
/* If the current view is mapped, focus it. */
if (current_view->mapped) {
wlr_log(WLR_INFO, "%s: %s", _("Focusing current view"),
current_view->xdg_surface->toplevel->app_id);
focus_view(current_view, current_view->xdg_surface->surface);
current_view->xdg_toplevel->app_id);
focus_view(current_view, current_view->xdg_toplevel->base->surface);
}
/* Otherwise, focus the next view, if any. */
else if (next_view->xdg_surface->surface &&
wlr_surface_is_xdg_surface(next_view->xdg_surface->surface)) {
else if (next_view->xdg_toplevel->base->surface &&
wlr_surface_is_xdg_surface(next_view->xdg_toplevel->base->surface)) {
wlr_log(WLR_INFO, "%s: %s", _("Focusing next view"),
next_view->xdg_surface->toplevel->app_id);
focus_view(next_view, next_view->xdg_surface->surface);
next_view->xdg_toplevel->app_id);
focus_view(next_view, next_view->xdg_toplevel->base->surface);
}
}
@ -113,7 +113,7 @@ static void begin_interactive(struct wb_view *view,
struct wb_server *server = view->server;
struct wlr_surface *focused_surface =
server->seat->seat->pointer_state.focused_surface;
if (view->xdg_surface->surface != wlr_surface_get_root_surface(focused_surface)) {
if (view->xdg_toplevel->base->surface != wlr_surface_get_root_surface(focused_surface)) {
/* Deny move/resize requests from unfocused clients. */
return;
}
@ -125,7 +125,7 @@ static void begin_interactive(struct wb_view *view,
server->grab_y = server->cursor->cursor->y - view->y;
} else if (mode == WB_CURSOR_RESIZE) {
struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
double border_x = (view->x + geo_box.x) + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
double border_y = (view->y + geo_box.y) + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
@ -173,7 +173,7 @@ static void handle_new_xdg_surface(struct wl_listener *listener, void *data) {
struct wb_view *view =
calloc(1, sizeof(struct wb_view));
view->server = server;
view->xdg_surface = xdg_surface;
view->xdg_toplevel = xdg_surface->toplevel;
/* Listen to the various events it can emit */
view->ack_configure.notify = xdg_surface_ack_configure;
@ -185,11 +185,10 @@ static void handle_new_xdg_surface(struct wl_listener *listener, void *data) {
view->destroy.notify = xdg_surface_destroy;
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
view->request_move.notify = xdg_toplevel_request_move;
wl_signal_add(&toplevel->events.request_move, &view->request_move);
wl_signal_add(&view->xdg_toplevel->events.request_move, &view->request_move);
view->request_resize.notify = xdg_toplevel_request_resize;
wl_signal_add(&toplevel->events.request_resize, &view->request_resize);
wl_signal_add(&view->xdg_toplevel->events.request_resize, &view->request_resize);
/* Add it to the list of views. */
wl_list_insert(&server->views, &view->link);
@ -211,7 +210,7 @@ bool view_at(struct wb_view *view,
double _sx, _sy;
struct wlr_surface *_surface = NULL;
_surface = wlr_xdg_surface_surface_at(
view->xdg_surface, view_sx, view_sy, &_sx, &_sy);
view->xdg_toplevel->base, view_sx, view_sy, &_sx, &_sy);
if (_surface != NULL) {
*sx = _sx;