mirror of
https://codeberg.org/vyivel/dulcepan/
synced 2025-12-18 08:05:12 +02:00
output: store name
This commit is contained in:
@@ -31,6 +31,8 @@ struct dp_output {
|
|||||||
uint32_t global_name;
|
uint32_t global_name;
|
||||||
struct wl_output *wl_output;
|
struct wl_output *wl_output;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
struct wl_surface *main_surface;
|
struct wl_surface *main_surface;
|
||||||
struct zwlr_layer_surface_v1 *main_layer_surface;
|
struct zwlr_layer_surface_v1 *main_layer_surface;
|
||||||
struct wp_viewport *main_viewport;
|
struct wp_viewport *main_viewport;
|
||||||
@@ -198,6 +200,7 @@ void dp_log_error(const char *fmt, ...);
|
|||||||
void dp_log_fatal(const char *fmt, ...);
|
void dp_log_fatal(const char *fmt, ...);
|
||||||
|
|
||||||
void *dp_zalloc(size_t size);
|
void *dp_zalloc(size_t size);
|
||||||
|
char *dp_strdup(const char *str);
|
||||||
|
|
||||||
const char *dp_ext_from_path(const char *path);
|
const char *dp_ext_from_path(const char *path);
|
||||||
enum dp_file_format dp_ext_to_format(const char *ext);
|
enum dp_file_format dp_ext_to_format(const char *ext);
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ static void registry_handle_global(void *data, struct wl_registry *registry, uin
|
|||||||
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
||||||
if (state->initialized) {
|
if (state->initialized) {
|
||||||
dp_log_fatal("An output was added after initialization");
|
dp_log_fatal("An output was added after initialization");
|
||||||
} else if (version < 2) {
|
} else if (version < 4) {
|
||||||
dp_log_fatal("An output has too low version (%d)", version);
|
dp_log_fatal("An output has too low version (%d)", version);
|
||||||
}
|
}
|
||||||
struct wl_output *global = wl_registry_bind(registry, name, &wl_output_interface, 2);
|
struct wl_output *global = wl_registry_bind(registry, name, &wl_output_interface, 4);
|
||||||
dp_output_create(state, name, global);
|
dp_output_create(state, name, global);
|
||||||
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
||||||
struct wl_seat *global = wl_registry_bind(registry, name, &wl_seat_interface, 1);
|
struct wl_seat *global = wl_registry_bind(registry, name, &wl_seat_interface, 1);
|
||||||
|
|||||||
36
src/output.c
36
src/output.c
@@ -32,8 +32,8 @@ static void layer_surface_handle_configure(void *data, struct zwlr_layer_surface
|
|||||||
|
|
||||||
if (output->initialized) {
|
if (output->initialized) {
|
||||||
if (i_width != output->effective_width || i_height != output->effective_height) {
|
if (i_width != output->effective_width || i_height != output->effective_height) {
|
||||||
dp_log_fatal("Layer surface size has changed: %dx%d => %dx%d", output->effective_width,
|
dp_log_fatal("Output %s: layer surface size has changed: %dx%d => %dx%d", output->name,
|
||||||
output->effective_height, i_width, i_height);
|
output->effective_width, output->effective_height, i_width, i_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_commit(output->main_surface);
|
wl_surface_commit(output->main_surface);
|
||||||
@@ -61,7 +61,8 @@ static void layer_surface_handle_configure(void *data, struct zwlr_layer_surface
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_handle_closed(void *data, struct zwlr_layer_surface_v1 *layer_surface) {
|
static void layer_surface_handle_closed(void *data, struct zwlr_layer_surface_v1 *layer_surface) {
|
||||||
dp_log_fatal("A layer surface was closed");
|
struct dp_output *output = data;
|
||||||
|
dp_log_fatal("Output %s: a layer surface was closed", output->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
|
static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
|
||||||
@@ -104,7 +105,8 @@ static void frame_handle_ready(void *data, struct zwlr_screencopy_frame_v1 *fram
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void frame_handle_failed(void *data, struct zwlr_screencopy_frame_v1 *frame) {
|
static void frame_handle_failed(void *data, struct zwlr_screencopy_frame_v1 *frame) {
|
||||||
dp_log_fatal("Failed to copy a frame");
|
struct dp_output *output = data;
|
||||||
|
dp_log_fatal("Output %s: failed to copy a frame", output->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct zwlr_screencopy_frame_v1_listener frame_listener = {
|
static const struct zwlr_screencopy_frame_v1_listener frame_listener = {
|
||||||
@@ -130,8 +132,8 @@ static void output_handle_geometry(void *data, struct wl_output *wl_output, int3
|
|||||||
|
|
||||||
if (output->has_geom) {
|
if (output->has_geom) {
|
||||||
if (transform != output->transform) {
|
if (transform != output->transform) {
|
||||||
dp_log_fatal("Output transform has changed: %d (%#x) => %d (%#x)", output->transform,
|
dp_log_fatal("Output %s: transform has changed: %d (%#x) => %d (%#x)", output->name,
|
||||||
output->transform, transform, transform);
|
output->transform, output->transform, transform, transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +146,8 @@ static void output_handle_mode(void *data, struct wl_output *wl_output, uint32_t
|
|||||||
|
|
||||||
if (output->has_geom) {
|
if (output->has_geom) {
|
||||||
if (width != output->width || height != output->height) {
|
if (width != output->width || height != output->height) {
|
||||||
dp_log_fatal("Output mode has changed: %dx%d => %dx%d", output->width, output->height,
|
dp_log_fatal("Output %s: mode has changed: %dx%d => %dx%d", output->name, output->width,
|
||||||
width, height);
|
output->height, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +162,8 @@ static void output_handle_done(void *data, struct wl_output *wl_output) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(output->name != NULL);
|
||||||
|
|
||||||
if ((output->transform & WL_OUTPUT_TRANSFORM_90) != 0) {
|
if ((output->transform & WL_OUTPUT_TRANSFORM_90) != 0) {
|
||||||
output->transformed_width = output->height;
|
output->transformed_width = output->height;
|
||||||
output->transformed_height = output->width;
|
output->transformed_height = output->width;
|
||||||
@@ -222,11 +226,23 @@ static void output_handle_scale(void *data, struct wl_output *wl_output, int32_t
|
|||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void output_handle_name(void *data, struct wl_output *wl_output, const char *name) {
|
||||||
|
struct dp_output *output = data;
|
||||||
|
assert(output->name == NULL);
|
||||||
|
output->name = dp_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void output_handle_description(void *data, struct wl_output *wl_output, const char *name) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
|
||||||
static const struct wl_output_listener output_listener = {
|
static const struct wl_output_listener output_listener = {
|
||||||
.geometry = output_handle_geometry,
|
.geometry = output_handle_geometry,
|
||||||
.mode = output_handle_mode,
|
.mode = output_handle_mode,
|
||||||
.done = output_handle_done,
|
.done = output_handle_done,
|
||||||
.scale = output_handle_scale,
|
.scale = output_handle_scale,
|
||||||
|
.name = output_handle_name,
|
||||||
|
.description = output_handle_description,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void redraw(struct dp_output *output);
|
static void redraw(struct dp_output *output);
|
||||||
@@ -261,7 +277,7 @@ static void redraw(struct dp_output *output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
dp_log_error("No free buffers in a swapchain\n");
|
dp_log_error("Output %s: no free buffers in a swapchain\n", output->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer->used = true;
|
buffer->used = true;
|
||||||
@@ -331,6 +347,8 @@ void dp_output_create(struct dp_state *state, uint32_t name, struct wl_output *w
|
|||||||
void dp_output_destroy(struct dp_output *output) {
|
void dp_output_destroy(struct dp_output *output) {
|
||||||
wl_output_release(output->wl_output);
|
wl_output_release(output->wl_output);
|
||||||
|
|
||||||
|
free(output->name);
|
||||||
|
|
||||||
assert(output->frame == NULL);
|
assert(output->frame == NULL);
|
||||||
wl_buffer_destroy(output->frame_buffer);
|
wl_buffer_destroy(output->frame_buffer);
|
||||||
munmap(output->frame_data, output->frame_size);
|
munmap(output->frame_data, output->frame_size);
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ void *dp_zalloc(size_t size) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *dp_strdup(const char *str) {
|
||||||
|
char *ptr = strdup(str);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
dp_log_fatal("Failed to duplicate %s", str);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
const char *dp_ext_from_path(const char *path) {
|
const char *dp_ext_from_path(const char *path) {
|
||||||
size_t len = strlen(path);
|
size_t len = strlen(path);
|
||||||
for (size_t i = len; i-- > 0;) {
|
for (size_t i = len; i-- > 0;) {
|
||||||
|
|||||||
Reference in New Issue
Block a user