~bl4ckb0ne/kaiju-dev

gojira: wayland: ditch xdg-output logic for wl_output v4 v1 APPLIED

Pedro Lucas Porcellis: 1
 wayland: ditch xdg-output logic for wl_output v4

 5 files changed, 11 insertions(+), 66 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~bl4ckb0ne/kaiju-dev/patches/30089/mbox | git am -3
Learn more about email & git

[PATCH gojira] wayland: ditch xdg-output logic for wl_output v4 Export this patch

Implements: https://todo.sr.ht/~bl4ckb0ne/kaiju/6
---
 include/state.h   |  1 -
 include/wayland.h |  3 ---
 meson.build       |  2 +-
 output.c          | 54 ++++++++---------------------------------------
 wayland.c         | 17 +--------------
 5 files changed, 11 insertions(+), 66 deletions(-)

diff --git a/include/state.h b/include/state.h
index e2d15a5..22ab467 100644
--- a/include/state.h
+++ b/include/state.h
@@ -15,7 +15,6 @@ struct state {
	struct wl_compositor *compositor;
	struct wl_shm *shm;
	struct zwlr_layer_shell_v1 *layer_shell;
	struct zxdg_output_manager_v1 *xdg_output_manager;
	struct zwp_input_method_manager_v2 *input_method_manager;

	struct xkb_context *ctx;
diff --git a/include/wayland.h b/include/wayland.h
index 1eb499a..8febd5a 100644
--- a/include/wayland.h
+++ b/include/wayland.h
@@ -15,7 +15,6 @@ void wayland_finish(struct state *state);

struct output {
	struct wl_output *wl_output;
	struct zxdg_output_v1 *xdg_output;

	char *name;
	enum wl_output_subpixel subpixel;
@@ -31,8 +30,6 @@ struct output *output_create(struct state *state, struct wl_output *wl_output,
		uint32_t id);
void output_destroy(struct output *output);

void output_init_xdg_output(struct output *output);

struct seat {
	struct wl_seat *wl_seat;

diff --git a/meson.build b/meson.build
index 8973a42..25f216c 100644
--- a/meson.build
+++ b/meson.build
@@ -40,7 +40,7 @@ add_project_arguments(cc.get_supported_arguments([
rt = cc.find_library('rt')

wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols', version: '>=1.17')
wayland_protos = dependency('wayland-protocols', version: '>=1.20.0')
xkbcommon = dependency('xkbcommon')

scfg = subproject('libscfg').get_variable('scfg')
diff --git a/output.c b/output.c
index 28fe699..4341e16 100644
--- a/output.c
+++ b/output.c
@@ -7,12 +7,17 @@
#include "state.h"
#include "wayland.h"

#include "xdg-output-unstable-v1-client-protocol.h"

static void
noop()
{}

static void
output_name(void *data, struct wl_output *wl_output, const char *name)
{
	struct output *output = data;
	output->name = strdup(name);
}

static void
output_handle_geometry(void *data, struct wl_output *wl_output,
		int32_t x, int32_t y, int32_t phy_width, int32_t phy_height,
@@ -35,7 +40,9 @@ static const struct wl_output_listener output_listener = {
	.geometry = output_handle_geometry,
	.mode = noop,
	.done = noop,
	.name = output_name,
	.scale = output_handle_scale,
	.description = noop,
};

struct output *
@@ -58,8 +65,6 @@ output_create(struct state *state, struct wl_output *wl_output, uint32_t id)
	output->state = state;
	wl_list_insert(&state->outputs, &output->link);

	output_init_xdg_output(output);

	return output;
}

@@ -68,47 +73,6 @@ output_destroy(struct output *output)
{
	wl_list_remove(&output->link);
	wl_output_destroy(output->wl_output);
	zxdg_output_v1_destroy(output->xdg_output);
	free(output->name);
	free(output);
}

static void
xdg_output_logical_size(void *data, struct zxdg_output_v1 *xdg_output,
		int32_t width, int32_t height)
{
	struct output *output = data;
	output->width = width;
	output->height = height;
}

static void
xdg_output_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name)
{
	struct output *output = data;
	output->name = strdup(name);
}

static const struct zxdg_output_v1_listener xdg_output_listener = {
	.logical_position = noop,
	.logical_size = xdg_output_logical_size,
	.done = noop,
	.name = xdg_output_name,
	.description = noop,
};

void
output_init_xdg_output(struct output *output)
{
	struct state *state = output->state;
	if (state->xdg_output_manager == NULL || output->xdg_output != NULL) {
		return;
	}


	output->xdg_output = zxdg_output_manager_v1_get_xdg_output(
		state->xdg_output_manager, output->wl_output);

	zxdg_output_v1_add_listener(output->xdg_output, &xdg_output_listener,
		output);
}
diff --git a/wayland.c b/wayland.c
index e6199d4..8b4e953 100644
--- a/wayland.c
+++ b/wayland.c
@@ -7,7 +7,6 @@

#include "input-method-unstable-v2-client-protocol.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"

static void
registry_global(void *data, struct wl_registry *registry, uint32_t name,
@@ -23,12 +22,9 @@ registry_global(void *data, struct wl_registry *registry, uint32_t name,
	} else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
		state->layer_shell = wl_registry_bind(registry, name,
			&zwlr_layer_shell_v1_interface, version);
	} else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
		state->xdg_output_manager = wl_registry_bind(registry, name,
			&zxdg_output_manager_v1_interface, version);
	} else if (strcmp(interface, wl_output_interface.name) == 0) {
		struct wl_output *output = wl_registry_bind(registry, name,
			&wl_output_interface, 3);
			&wl_output_interface, 4);
		output_create(state, output, name);
	} else if (strcmp(interface, wl_seat_interface.name) == 0) {
		struct wl_seat *seat = wl_registry_bind(registry, name,
@@ -88,16 +84,6 @@ wayland_init(struct state *state)
		return false;
	}

	if (state->xdg_output_manager == NULL) {
		fprintf(stderr, "zxdg_output_manager_v1 not supported\n");
		return false;
	}

	struct output *output;
	wl_list_for_each(output, &state->outputs, link) {
		output_init_xdg_output(output);
	}

	struct seat *seat;
	wl_list_for_each(seat, &state->seats, link) {
		seat_init_inputs(seat);
@@ -121,7 +107,6 @@ wayland_finish(struct state *state)
		seat_destroy(seat);
	}

	zxdg_output_manager_v1_destroy(state->xdg_output_manager);
	zwlr_layer_shell_v1_destroy(state->layer_shell);
	wl_shm_destroy(state->shm);
	wl_compositor_destroy(state->compositor);
-- 
2.35.1
Thanks for the commit, applied in 4435558ebac4145bc993d39cc0d1efb406c91476

You forgot to remove the protocol from the client protocols list in the meson
build file `protocol/meson.build`, I amended the change it in your commit.