diff --git a/.build.yml b/.build.yml index 1dca23a..e5272c3 100644 --- a/.build.yml +++ b/.build.yml @@ -1,36 +1,19 @@ +# A SourceHut build manifest. See https://man.sr.ht/builds.sr.ht/manifest.md +# for more information. +# image: archlinux packages: - # Base packages needed - meson - wayland - wayland-protocols - - libxkbcommon - # Packages needed by Waybox - - libxml2 - # Packages needed for wlroots - - mesa - - libdrm - - udev - - pixman - - seatd - # Packages needed for wlroots libinput backend - libinput - # Packages needed for wlroots Xwayland support + - libxkbcommon + - libxml2 + - wlroots - xorg-server-xwayland - - libxcb - - xcb-util-renderutil - - xcb-util-wm - - xcb-util-errors - - xcb-util-image sources: - https://github.com/wizbright/waybox - - https://gitlab.freedesktop.org/wlroots/wlroots tasks: - - wlroots: | - cd wlroots - meson --prefix=/usr build - ninja -C build - sudo ninja -C build install - setup: | cd waybox meson build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7302927 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +# A GitHub Actions port of the old .build.yml. This has the advantage of being +# able to use GitHub actions, contexts, secrets, etc, to do more in the future +# than merely check whether a build succeeds or fails. It also allows to see +# whether builds succeed or fail on forks, which also has its advantages. +# +# The disadvantage is that it's less portable than .build.yml, which will work +# on at least GitHub, GitLab, and SourceHut, where GitHub Actions only work on +# GitHub. +# +name: build +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + container: archlinux:base-devel + steps: + - name: packages + run: | + pacman-key --init + pacman -Syu --noconfirm + pacman -S --noconfirm git meson libxkbcommon libinput libxml2 wayland wayland-protocols wlroots xorg-server-xwayland + # actions/checkout@v2 clones the repository + - uses: actions/checkout@v2 + - name: setup + run: | + meson build + - name: build + run: | + ninja -C build diff --git a/include/waybox/output.h b/include/waybox/output.h index da572b9..98251a1 100644 --- a/include/waybox/output.h +++ b/include/waybox/output.h @@ -26,6 +26,9 @@ struct wb_view { struct wl_list link; struct wb_server *server; struct wlr_xdg_toplevel *xdg_toplevel; +#if !WLR_CHECK_VERSION(0, 16, 0) + struct wlr_xdg_surface *xdg_surface; +#endif struct wlr_xdg_toplevel_decoration_v1 *decoration; diff --git a/include/waybox/server.h b/include/waybox/server.h index 656871d..d8cb6c4 100644 --- a/include/waybox/server.h +++ b/include/waybox/server.h @@ -3,6 +3,9 @@ #include +#include +#define WLR_CHECK_VERSION(major, minor, micro) (WLR_VERSION_NUM >= ((major << 16) | (minor << 8) | (micro))) + #include #include #include @@ -14,7 +17,9 @@ #include #include #include +#if WLR_CHECK_VERSION(0, 16, 0) #include +#endif #include #include @@ -42,7 +47,9 @@ struct wb_server { struct wlr_output_layout *output_layout; struct wlr_xdg_output_manager_v1 *output_manager; struct wlr_renderer *renderer; +#if WLR_CHECK_VERSION(0, 16, 0) struct wlr_subcompositor *subcompositor; +#endif struct wb_config *config; char *config_file; diff --git a/meson.build b/meson.build index 8494fb6..c97bdb7 100644 --- a/meson.build +++ b/meson.build @@ -27,7 +27,7 @@ cc = meson.get_compiler('c') inc_dir = include_directories('include') libxml2 = dependency('libxml-2.0') -wlroots = dependency('wlroots', version: '>=0.16.0') +wlroots = dependency('wlroots', version: '>=0.15.0') wayland_server = dependency('wayland-server', version: '>=1.15') wayland_protos = dependency('wayland-protocols', version: '>=1.17') xkbcommon = dependency('xkbcommon') diff --git a/waybox/cursor.c b/waybox/cursor.c index 694c6a0..0512fee 100644 --- a/waybox/cursor.c +++ b/waybox/cursor.c @@ -47,7 +47,11 @@ static void process_cursor_resize(struct wb_server *server) { int new_width = new_right - new_left; int new_height = new_bottom - new_top; +#if WLR_CHECK_VERSION(0, 16, 0) wlr_xdg_toplevel_set_size(view->xdg_toplevel, new_width, new_height); +#else + wlr_xdg_toplevel_set_size(view->xdg_surface, new_width, new_height); +#endif } static void process_cursor_motion(struct wb_server *server, uint32_t time) { diff --git a/waybox/seat.c b/waybox/seat.c index f3ad5ec..98d2e89 100644 --- a/waybox/seat.c +++ b/waybox/seat.c @@ -76,7 +76,11 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32 struct wb_view *current_view = wl_container_of( server->views.next, current_view, link); if (wlr_surface_is_xdg_surface(current_view->xdg_toplevel->base->surface)) +#if WLR_CHECK_VERSION(0, 16, 0) wlr_xdg_toplevel_send_close(current_view->xdg_toplevel); +#else + wlr_xdg_toplevel_send_close(current_view->xdg_surface); +#endif return true; } case ACTION_EXECUTE: diff --git a/waybox/server.c b/waybox/server.c index 7df6ab0..5a7cdb8 100644 --- a/waybox/server.c +++ b/waybox/server.c @@ -34,7 +34,9 @@ bool wb_create_backend(struct wb_server* server) { server->compositor = wlr_compositor_create(server->wl_display, server->renderer); +#if WLR_CHECK_VERSION(0, 16, 0) server->subcompositor = wlr_subcompositor_create(server->wl_display); +#endif server->output_layout = wlr_output_layout_create(); server->seat = wb_seat_create(server); server->cursor = wb_cursor_create(server); diff --git a/waybox/xdg_shell.c b/waybox/xdg_shell.c index 79ac656..11f6c8d 100644 --- a/waybox/xdg_shell.c +++ b/waybox/xdg_shell.c @@ -24,14 +24,22 @@ 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); +#if WLR_CHECK_VERSION(0, 16, 0) wlr_xdg_toplevel_set_activated(previous->toplevel, false); +#else + wlr_xdg_toplevel_set_activated(previous, false); +#endif } 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 */ +#if WLR_CHECK_VERSION(0, 16, 0) wlr_xdg_toplevel_set_activated(view->xdg_toplevel, true); +#else + wlr_xdg_toplevel_set_activated(view->xdg_surface, true); +#endif /* * Tell the seat to have the keyboard enter this surface. wlroots will keep * track of this and automatically send key events to the appropriate @@ -62,7 +70,11 @@ static void xdg_surface_ack_configure(struct wl_listener *listener, void *data) view->configured = view->y > 0; /* Set size here, so the view->y value will be known */ +#if WLR_CHECK_VERSION(0, 16, 0) wlr_xdg_toplevel_set_size(view->xdg_toplevel, geo_box.width - view->x, geo_box.height - view->y); +#else + wlr_xdg_toplevel_set_size(view->xdg_surface, geo_box.width - view->x, geo_box.height - view->y); +#endif } } @@ -172,6 +184,9 @@ static void handle_new_xdg_surface(struct wl_listener *listener, void *data) { calloc(1, sizeof(struct wb_view)); view->server = server; view->xdg_toplevel = xdg_surface->toplevel; +#if !WLR_CHECK_VERSION(0, 16, 0) + view->xdg_surface = view->xdg_toplevel->base; +#endif /* Listen to the various events it can emit */ view->ack_configure.notify = xdg_surface_ack_configure;