|
|
@ -51,16 +51,17 @@ static void output_frame_notify(struct wl_listener *listener, void *_data) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void screenshooter_shoot(struct wl_client *client,
|
|
|
|
static void screenshooter_shoot(struct wl_client *client,
|
|
|
|
struct wl_resource *_screenshooter, uint32_t id,
|
|
|
|
struct wl_resource *screenshooter_resource, uint32_t id,
|
|
|
|
struct wl_resource *_output, struct wl_resource *_buffer) {
|
|
|
|
struct wl_resource *output_resource,
|
|
|
|
|
|
|
|
struct wl_resource *buffer_resource) {
|
|
|
|
struct wlr_screenshooter *screenshooter =
|
|
|
|
struct wlr_screenshooter *screenshooter =
|
|
|
|
wl_resource_get_user_data(_screenshooter);
|
|
|
|
wl_resource_get_user_data(screenshooter_resource);
|
|
|
|
struct wlr_output *output = wl_resource_get_user_data(_output);
|
|
|
|
struct wlr_output *output = wl_resource_get_user_data(output_resource);
|
|
|
|
if (!wl_shm_buffer_get(_buffer)) {
|
|
|
|
if (!wl_shm_buffer_get(buffer_resource)) {
|
|
|
|
wlr_log(L_ERROR, "Invalid buffer: not a shared memory buffer");
|
|
|
|
wlr_log(L_ERROR, "Invalid buffer: not a shared memory buffer");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get(_buffer);
|
|
|
|
struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get(buffer_resource);
|
|
|
|
int32_t width = wl_shm_buffer_get_width(shm_buffer);
|
|
|
|
int32_t width = wl_shm_buffer_get_width(shm_buffer);
|
|
|
|
int32_t height = wl_shm_buffer_get_height(shm_buffer);
|
|
|
|
int32_t height = wl_shm_buffer_get_height(shm_buffer);
|
|
|
|
int32_t stride = wl_shm_buffer_get_stride(shm_buffer);
|
|
|
|
int32_t stride = wl_shm_buffer_get_stride(shm_buffer);
|
|
|
@ -84,23 +85,31 @@ static void screenshooter_shoot(struct wl_client *client,
|
|
|
|
struct wlr_screenshot *screenshot =
|
|
|
|
struct wlr_screenshot *screenshot =
|
|
|
|
calloc(1, sizeof(struct wlr_screenshot));
|
|
|
|
calloc(1, sizeof(struct wlr_screenshot));
|
|
|
|
if (!screenshot) {
|
|
|
|
if (!screenshot) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
wl_resource_post_no_memory(screenshooter_resource);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
screenshot->output_resource = _output;
|
|
|
|
screenshot->output_resource = output_resource;
|
|
|
|
screenshot->output = output;
|
|
|
|
screenshot->output = output;
|
|
|
|
screenshot->screenshooter = screenshooter;
|
|
|
|
screenshot->screenshooter = screenshooter;
|
|
|
|
screenshot->resource = wl_resource_create(client,
|
|
|
|
screenshot->resource = wl_resource_create(client,
|
|
|
|
&orbital_screenshot_interface, wl_resource_get_version(_screenshooter),
|
|
|
|
&orbital_screenshot_interface,
|
|
|
|
id);
|
|
|
|
wl_resource_get_version(screenshooter_resource), id);
|
|
|
|
wlr_log(L_DEBUG, "new screenshot %p (res %p)", screenshot,
|
|
|
|
if (screenshot->resource == NULL) {
|
|
|
|
screenshot->resource);
|
|
|
|
free(screenshot);
|
|
|
|
|
|
|
|
wl_resource_post_no_memory(screenshooter_resource);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
wl_resource_set_implementation(screenshot->resource, NULL, screenshot,
|
|
|
|
wl_resource_set_implementation(screenshot->resource, NULL, screenshot,
|
|
|
|
NULL);
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(L_DEBUG, "new screenshot %p (res %p)", screenshot,
|
|
|
|
|
|
|
|
screenshot->resource);
|
|
|
|
|
|
|
|
|
|
|
|
struct screenshot_state *state = calloc(1, sizeof(struct screenshot_state));
|
|
|
|
struct screenshot_state *state = calloc(1, sizeof(struct screenshot_state));
|
|
|
|
if (!state) {
|
|
|
|
if (!state) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
wl_resource_destroy(screenshot->resource);
|
|
|
|
|
|
|
|
free(screenshot);
|
|
|
|
|
|
|
|
wl_resource_post_no_memory(screenshooter_resource);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
state->width = width;
|
|
|
|
state->width = width;
|
|
|
@ -117,13 +126,17 @@ static struct orbital_screenshooter_interface screenshooter_impl = {
|
|
|
|
.shoot = screenshooter_shoot,
|
|
|
|
.shoot = screenshooter_shoot,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void screenshooter_bind(struct wl_client *wl_client,
|
|
|
|
static void screenshooter_bind(struct wl_client *wl_client, void *data,
|
|
|
|
void *_screenshooter, uint32_t version, uint32_t id) {
|
|
|
|
uint32_t version, uint32_t id) {
|
|
|
|
struct wlr_screenshooter *screenshooter = _screenshooter;
|
|
|
|
struct wlr_screenshooter *screenshooter = data;
|
|
|
|
assert(wl_client && screenshooter);
|
|
|
|
assert(wl_client && screenshooter);
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_resource *wl_resource = wl_resource_create(wl_client,
|
|
|
|
struct wl_resource *wl_resource = wl_resource_create(wl_client,
|
|
|
|
&orbital_screenshooter_interface, version, id);
|
|
|
|
&orbital_screenshooter_interface, version, id);
|
|
|
|
|
|
|
|
if (wl_resource == NULL) {
|
|
|
|
|
|
|
|
wl_client_post_no_memory(wl_client);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
wl_resource_set_implementation(wl_resource, &screenshooter_impl,
|
|
|
|
wl_resource_set_implementation(wl_resource, &screenshooter_impl,
|
|
|
|
screenshooter, NULL);
|
|
|
|
screenshooter, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -137,13 +150,12 @@ struct wlr_screenshooter *wlr_screenshooter_create(struct wl_display *display,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
screenshooter->renderer = renderer;
|
|
|
|
screenshooter->renderer = renderer;
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_global *wl_global = wl_global_create(display,
|
|
|
|
screenshooter->wl_global = wl_global_create(display,
|
|
|
|
&orbital_screenshooter_interface, 1, screenshooter, screenshooter_bind);
|
|
|
|
&orbital_screenshooter_interface, 1, screenshooter, screenshooter_bind);
|
|
|
|
if (!wl_global) {
|
|
|
|
if (screenshooter->wl_global == NULL) {
|
|
|
|
free(screenshooter);
|
|
|
|
free(screenshooter);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
screenshooter->wl_global = wl_global;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return screenshooter;
|
|
|
|
return screenshooter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|