diff --git a/.build.yml b/.build.yml index af6f674..ebb7c4e 100644 --- a/.build.yml +++ b/.build.yml @@ -9,7 +9,7 @@ packages: - libxkbcommon sources: - https://github.com/wizbright/waybox - - https://github.com/swaywm/wlroots + - https://gitlab.freedesktop.org/wlroots/wlroots tasks: - wlroots: | cd wlroots @@ -21,4 +21,4 @@ tasks: meson build - build: | cd waybox - ninja -C build \ No newline at end of file + ninja -C build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa11165..bf76887 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to waybox +# Contributing to Waybox Contributing just involves sending a pull request. You will probably be more successful with your contribution if you visit @@ -8,7 +8,8 @@ irc.freenode.net upfront and discuss your plans. Note: rules are made to be broken. Adjust or ignore any/all of these as you see fit, but be prepared to justify it to your peers. -This was amended from [wlroots](https://github.com/swaywm/wlroots) for the most part +This was amended from [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) +for the most part. ## Pull Requests diff --git a/README.md b/README.md index c2e39f0..5686160 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ contributing.](https://github.com/wizbright/waybox/blob/master/CONTRIBUTING.md) ### Dependencies -* meson -* wlroots -* wayland -* xkbcommon +* [Meson](https://mesonbuild.com/) +* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots/) +* [Wayland](https://wayland.freedesktop.org/) +* [xkbcommon](https://xkbcommon.org/) ### Build instructions diff --git a/include/waybox/server.h b/include/waybox/server.h index 1dfb5d9..61394df 100644 --- a/include/waybox/server.h +++ b/include/waybox/server.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,7 @@ struct wb_server { struct wlr_backend *backend; struct wlr_compositor *compositor; struct wlr_renderer *renderer; + struct wlr_allocator *allocator; struct wlr_output_layout *layout; struct wb_cursor *cursor; diff --git a/meson.build b/meson.build index 13112c1..100abf1 100644 --- a/meson.build +++ b/meson.build @@ -23,7 +23,9 @@ cc = meson.get_compiler('c') # Adding include directory inc_dir = include_directories('include') -wlroots = dependency('wlroots', version: '>=0.13.0') +# Due to the planned refactor of xdg_shell in wlroots 0.16.0, I doubt this will +# build when it's released +wlroots = dependency('wlroots', version: ['>=0.15.0', '<0.16.0']) wayland_server = dependency('wayland-server', version: '>=1.15') wayland_protos = dependency('wayland-protocols', version: '>=1.17') xkbcommon = dependency('xkbcommon') diff --git a/waybox/output.c b/waybox/output.c index 9fdd42f..c7563a4 100644 --- a/waybox/output.c +++ b/waybox/output.c @@ -124,6 +124,10 @@ void new_output_notify(struct wl_listener *listener, void *data) { struct wlr_output *wlr_output = data; wlr_log(WLR_INFO, "%s: %s", _("New output device detected"), wlr_output->name); + /* Configures the output created by the backend to use our allocator + * and our renderer */ + wlr_output_init_render(wlr_output, server->allocator, server->renderer); + if (!wl_list_empty(&wlr_output->modes)) { struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); wlr_output_set_mode(wlr_output, mode); diff --git a/waybox/server.c b/waybox/server.c index af74e06..e0b4552 100644 --- a/waybox/server.c +++ b/waybox/server.c @@ -2,22 +2,36 @@ #include "waybox/xdg_shell.h" bool wb_create_backend(struct wb_server* server) { - // create display + /* The Wayland display is managed by libwayland. It handles accepting + * clients from the Unix socket, manging Wayland globals, and so on. */ server->wl_display = wl_display_create(); if (server->wl_display == NULL) { wlr_log(WLR_ERROR, "%s", _("Failed to connect to a Wayland display")); return false; } - // create backend + /* The backend is a wlroots feature which abstracts the underlying input and + * output hardware. The autocreate option will choose the most suitable + * backend based on the current environment, such as opening an X11 window + * if an X11 server is running. */ server->backend = wlr_backend_autocreate(server->wl_display); if (server->backend == NULL) { return false; } - server->renderer = wlr_backend_get_renderer(server->backend); + /* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user + * can also specify a renderer using the WLR_RENDERER env var. + * The renderer is responsible for defining the various pixel formats it + * supports for shared memory, this configures that for clients. */ + server->renderer = wlr_renderer_autocreate(server->backend); wlr_renderer_init_wl_display(server->renderer, server->wl_display); + /* Autocreates an allocator for us. + * The allocator is the bridge between the renderer and the backend. It + * handles the buffer creation, allowing wlroots to render onto the + * screen */ + server->allocator = wlr_allocator_autocreate(server->backend, server->renderer); + server->compositor = wlr_compositor_create(server->wl_display, server->renderer); server->layout = wlr_output_layout_create(); diff --git a/waybox/xdg_shell.c b/waybox/xdg_shell.c index 4ea5389..625355b 100644 --- a/waybox/xdg_shell.c +++ b/waybox/xdg_shell.c @@ -8,7 +8,7 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) { struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(surface); if (xdg_surface) wlr_log(WLR_INFO, "%s: %s", _("Keyboard focus is now on surface"), - wlr_xdg_surface_from_wlr_surface(surface)->toplevel->app_id); + xdg_surface->toplevel->app_id); struct wb_server *server = view->server; struct wlr_seat *seat = server->seat->seat; struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;