mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
Upgrade to wlroots 0.15
- Update wlr_box includes to util/box.h: the wlroots header has been moved upstream. - Subsurface fields have been moved - Create renderer and allocator, stop using wlr_backend_get_renderer - Initalize output rendering
This commit is contained in:
parent
388d60d6b8
commit
395189fb05
12 changed files with 41 additions and 36 deletions
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
|
|
@ -31,7 +31,7 @@ jobs:
|
|||
pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc
|
||||
|
||||
- name: Fetch wlroots as a subproject
|
||||
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.14.0
|
||||
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.15.0
|
||||
|
||||
# TODO: use --fatal-meson-warnings when on wlroots 0.15.0
|
||||
- name: Compile Cage (XWayland=${{ matrix.xwayland }})
|
||||
|
|
@ -50,7 +50,7 @@ jobs:
|
|||
pacman-key --init
|
||||
pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc
|
||||
- name: Fetch wlroots as a subproject
|
||||
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.14.0
|
||||
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.15.0
|
||||
- name: Check for formatting changes
|
||||
run: |
|
||||
meson build-clang-format -Dxwayland=true
|
||||
|
|
@ -69,8 +69,8 @@ jobs:
|
|||
pacman-key --init
|
||||
pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc
|
||||
- name: Fetch wlroots as a subproject
|
||||
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.14.0
|
||||
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.15.0
|
||||
- name: Run scan-build
|
||||
run: |
|
||||
meson build-scan-build -Dxwayland=true
|
||||
ninja -C build-scan-build scan-build
|
||||
ninja -C build-scan-build scan-build
|
||||
|
|
|
|||
21
cage.c
21
cage.c
|
|
@ -19,6 +19,7 @@
|
|||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
|
|
@ -261,7 +262,6 @@ main(int argc, char *argv[])
|
|||
struct wl_event_source *sigint_source = NULL;
|
||||
struct wl_event_source *sigterm_source = NULL;
|
||||
struct wl_event_source *sigchld_source = NULL;
|
||||
struct wlr_renderer *renderer = NULL;
|
||||
struct wlr_compositor *compositor = NULL;
|
||||
struct wlr_data_device_manager *data_device_manager = NULL;
|
||||
struct wlr_server_decoration_manager *server_decoration_manager = NULL;
|
||||
|
|
@ -316,8 +316,21 @@ main(int argc, char *argv[])
|
|||
goto end;
|
||||
}
|
||||
|
||||
renderer = wlr_backend_get_renderer(server.backend);
|
||||
wlr_renderer_init_wl_display(renderer, server.wl_display);
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
if (!server.renderer) {
|
||||
wlr_log(WLR_ERROR, "Unable to create the wlroots renderer");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
server.allocator = wlr_allocator_autocreate(server.backend, server.renderer);
|
||||
if (!server.allocator) {
|
||||
wlr_log(WLR_ERROR, "Unable to create the wlroots allocator");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
wlr_renderer_init_wl_display(server.renderer, server.wl_display);
|
||||
|
||||
wl_list_init(&server.views);
|
||||
wl_list_init(&server.outputs);
|
||||
|
|
@ -329,7 +342,7 @@ main(int argc, char *argv[])
|
|||
goto end;
|
||||
}
|
||||
|
||||
compositor = wlr_compositor_create(server.wl_display, renderer);
|
||||
compositor = wlr_compositor_create(server.wl_display, server.renderer);
|
||||
if (!compositor) {
|
||||
wlr_log(WLR_ERROR, "Unable to create the wlroots compositor");
|
||||
ret = 1;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ if is_freebsd
|
|||
)
|
||||
endif
|
||||
|
||||
wlroots = dependency('wlroots', version: '>= 0.14.0', fallback: ['wlroots', 'wlroots'])
|
||||
wlroots = dependency('wlroots', version: '>= 0.15.0', fallback: ['wlroots', 'wlroots'])
|
||||
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
|
||||
wayland_server = dependency('wayland-server')
|
||||
pixman = dependency('pixman-1')
|
||||
|
|
|
|||
5
output.c
5
output.c
|
|
@ -442,6 +442,11 @@ handle_new_output(struct wl_listener *listener, void *data)
|
|||
struct cg_server *server = wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
|
||||
if (!wlr_output_init_render(wlr_output, server->allocator, server->renderer)) {
|
||||
wlr_log(WLR_ERROR, "Failed to initialize output rendering");
|
||||
return;
|
||||
}
|
||||
|
||||
struct cg_output *output = calloc(1, sizeof(struct cg_output));
|
||||
if (!output) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate output");
|
||||
|
|
|
|||
26
render.c
26
render.c
|
|
@ -10,11 +10,11 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
|
||||
|
|
@ -27,8 +27,6 @@
|
|||
static void
|
||||
scissor_output(struct wlr_output *output, pixman_box32_t *rect)
|
||||
{
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(output->backend);
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = rect->x1,
|
||||
.y = rect->y1,
|
||||
|
|
@ -41,7 +39,7 @@ scissor_output(struct wlr_output *output, pixman_box32_t *rect)
|
|||
enum wl_output_transform transform = wlr_output_transform_invert(output->transform);
|
||||
wlr_box_transform(&box, &box, transform, output_width, output_height);
|
||||
|
||||
wlr_renderer_scissor(renderer, &box);
|
||||
wlr_renderer_scissor(output->renderer, &box);
|
||||
}
|
||||
|
||||
struct render_data {
|
||||
|
|
@ -52,8 +50,6 @@ static void
|
|||
render_texture(struct wlr_output *wlr_output, pixman_region32_t *output_damage, struct wlr_texture *texture,
|
||||
const struct wlr_box *box, const float matrix[static 9])
|
||||
{
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
pixman_region32_union_rect(&damage, &damage, box->x, box->y, box->width, box->height);
|
||||
|
|
@ -66,7 +62,7 @@ render_texture(struct wlr_output *wlr_output, pixman_region32_t *output_damage,
|
|||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
||||
for (int i = 0; i < nrects; i++) {
|
||||
scissor_output(wlr_output, &rects[i]);
|
||||
wlr_render_texture_with_matrix(renderer, texture, matrix, 1.0f);
|
||||
wlr_render_texture_with_matrix(wlr_output->renderer, texture, matrix, 1.0f);
|
||||
}
|
||||
|
||||
damage_finish:
|
||||
|
|
@ -134,13 +130,7 @@ output_render(struct cg_output *output, pixman_region32_t *damage)
|
|||
struct cg_server *server = output->server;
|
||||
struct wlr_output *wlr_output = output->wlr_output;
|
||||
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
if (!renderer) {
|
||||
wlr_log(WLR_DEBUG, "Expected the output backend to have a renderer");
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
|
||||
wlr_renderer_begin(server->renderer, wlr_output->width, wlr_output->height);
|
||||
|
||||
if (!pixman_region32_not_empty(damage)) {
|
||||
wlr_log(WLR_DEBUG, "Output isn't damaged but needs a buffer swap");
|
||||
|
|
@ -149,7 +139,7 @@ output_render(struct cg_output *output, pixman_region32_t *damage)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (server->debug_damage_tracking) {
|
||||
wlr_renderer_clear(renderer, (float[]){1.0f, 0.0f, 0.0f, 1.0f});
|
||||
wlr_renderer_clear(server->renderer, (float[]){1.0f, 0.0f, 0.0f, 1.0f});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -158,7 +148,7 @@ output_render(struct cg_output *output, pixman_region32_t *damage)
|
|||
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
||||
for (int i = 0; i < nrects; i++) {
|
||||
scissor_output(wlr_output, &rects[i]);
|
||||
wlr_renderer_clear(renderer, color);
|
||||
wlr_renderer_clear(server->renderer, color);
|
||||
}
|
||||
|
||||
// TODO: render only top view, possibly use focused view for this, see #35.
|
||||
|
|
@ -178,8 +168,8 @@ renderer_end:
|
|||
/* Draw software cursor in case hardware cursors aren't
|
||||
available. This is a no-op when they are. */
|
||||
wlr_output_render_software_cursors(wlr_output, damage);
|
||||
wlr_renderer_scissor(renderer, NULL);
|
||||
wlr_renderer_end(renderer);
|
||||
wlr_renderer_scissor(server->renderer, NULL);
|
||||
wlr_renderer_end(server->renderer);
|
||||
|
||||
int output_width, output_height;
|
||||
wlr_output_transformed_resolution(wlr_output, &output_width, &output_height);
|
||||
|
|
|
|||
2
server.h
2
server.h
|
|
@ -25,6 +25,8 @@ struct cg_server {
|
|||
struct wl_display *wl_display;
|
||||
struct wl_list views;
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
|
||||
struct cg_seat *seat;
|
||||
struct wlr_idle *idle;
|
||||
|
|
|
|||
2
util.c
2
util.c
|
|
@ -6,8 +6,6 @@
|
|||
* See the LICENSE file accompanying this file.
|
||||
*/
|
||||
|
||||
#include <wlr/types/wlr_box.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
int
|
||||
|
|
|
|||
2
util.h
2
util.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CG_UTIL_H
|
||||
#define CG_UTIL_H
|
||||
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
/** Apply scale to a width or height. */
|
||||
int scale_length(int length, int offset, float scale);
|
||||
|
|
|
|||
5
view.c
5
view.c
|
|
@ -12,7 +12,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
|
||||
|
|
@ -235,10 +234,10 @@ view_map(struct cg_view *view, struct wlr_surface *surface)
|
|||
view->wlr_surface = surface;
|
||||
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each (subsurface, &view->wlr_surface->subsurfaces_below, parent_link) {
|
||||
wl_list_for_each (subsurface, &view->wlr_surface->current.subsurfaces_below, current.link) {
|
||||
subsurface_create(view, subsurface);
|
||||
}
|
||||
wl_list_for_each (subsurface, &view->wlr_surface->subsurfaces_above, parent_link) {
|
||||
wl_list_for_each (subsurface, &view->wlr_surface->current.subsurfaces_above, current.link) {
|
||||
subsurface_create(view, subsurface);
|
||||
}
|
||||
|
||||
|
|
|
|||
2
view.h
2
view.h
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/box.h>
|
||||
#if CAGE_HAS_XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/xwayland.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue