1
0
mirror of https://codeberg.org/vyivel/dulcepan/ synced 2025-06-24 22:44:18 +03:00

4 Commits

3 changed files with 27 additions and 6 deletions

View File

@ -1,7 +1,7 @@
project( project(
'dulcepan', 'dulcepan',
'c', 'c',
version: '1.0.1', version: '1.0.2',
license: 'GPL-3.0-only', license: 'GPL-3.0-only',
default_options: [ default_options: [
'c_std=c11', 'c_std=c11',

View File

@ -1,6 +1,7 @@
#include <getopt.h> #include <getopt.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <wayland-client-core.h> #include <wayland-client-core.h>
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
@ -167,8 +168,9 @@ static void help(const char *prog) {
" -o <path> Specify the output file path.\n" " -o <path> Specify the output file path.\n"
"\n" "\n"
"If the output file path is not specified, the resuling image will be printed to\n" "If the output file path is not specified, the resuling image will be printed to\n"
"the standard output. If the output file format is not specified, it is guessed\n" "the standard output, which is expected to not be a terminal. If the output file\n"
"from the output file path if it's specified, and assumed to be PNG otherwise.\n" "format is not specified, it is guessed from the output file path if it's\n"
"specified, and assumed to be PNG otherwise.\n"
"\n" "\n"
"Supported formats: png, ppm.\n" "Supported formats: png, ppm.\n"
"\n" "\n"
@ -210,9 +212,13 @@ int main(int argc, char **argv) {
} }
} }
state.basedir_ctx = sfdo_basedir_ctx_create(); if (state.output_path == NULL && isatty(STDOUT_FILENO)) {
fprintf(stderr,
dp_config_load(&state, config_path); "Refusing to run as the standard output is a terminal and there's no output file\n"
"path specified.\n\n");
help(argv[0]);
exit(1);
}
if (state.output_format == DP_FILE_UNKNOWN) { if (state.output_format == DP_FILE_UNKNOWN) {
if (state.output_path != NULL) { if (state.output_path != NULL) {
@ -227,6 +233,10 @@ int main(int argc, char **argv) {
} }
} }
state.basedir_ctx = sfdo_basedir_ctx_create();
dp_config_load(&state, config_path);
wl_list_init(&state.outputs); wl_list_init(&state.outputs);
wl_list_init(&state.seats); wl_list_init(&state.seats);

View File

@ -79,6 +79,12 @@ static void frame_handle_buffer(void *data, struct zwlr_screencopy_frame_v1 *fra
wl_buffer_destroy(output->frame_buffer); wl_buffer_destroy(output->frame_buffer);
} }
if ((int32_t)width != output->width || (int32_t)height != output->height) {
dp_log_fatal("Output/buffer size mismatch: mode=%" PRIi32 "x%" PRIi32 ", buffer=%" PRIu32
"x%" PRIu32,
output->width, output->height, width, height);
}
output->frame_format = format; output->frame_format = format;
output->frame_stride = (int)stride; output->frame_stride = (int)stride;
output->frame_buffer = dp_buffer_create(output->state, output->width, output->height, output->frame_buffer = dp_buffer_create(output->state, output->width, output->height,
@ -156,6 +162,10 @@ static void output_handle_geometry(void *data, struct wl_output *wl_output, int3
static void output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, static void output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
int32_t width, int32_t height, int32_t refresh) { int32_t width, int32_t height, int32_t refresh) {
if ((flags & WL_OUTPUT_MODE_CURRENT) == 0) {
return;
}
struct dp_output *output = data; struct dp_output *output = data;
if (output->has_geom) { if (output->has_geom) {
@ -178,6 +188,7 @@ static void output_handle_done(void *data, struct wl_output *wl_output) {
assert(output->name != NULL); assert(output->name != NULL);
assert(output->width > 0 && output->height > 0);
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;