Updated for wlroots 0.15.0

This commit is contained in:
Keith Bowes 2022-01-29 14:34:55 -05:00
parent 309ccd2faf
commit 87c32d58ab
8 changed files with 36 additions and 13 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -8,6 +8,7 @@
#include <stdio.h>
#include <wlr/backend.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/render/wlr_texture.h>
#include <wlr/types/wlr_compositor.h>
@ -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;

View file

@ -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')

View file

@ -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);

View file

@ -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();

View file

@ -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;