Skip to content

ext-screencopy-v1

Andri Yngvason requested to merge andri/wlroots:ext-screencopy-v1 into master

This is the second draft of the ext-screencopy-v1 protocol implementation.

Some things are not yet implemented, most notable of which is any sort of output transform handling with regard to cursor rendering.

The protocol PR is here: wayland/wayland-protocols!124, and a client implementation can be found here: https://github.com/any1/wayvnc/tree/ext-screencopy-v1

Previous implementation is here: https://github.com/swaywm/wlroots/pull/3320

Sway requires the following change for enabling the protocol:

diff --git a/sway/server.c b/sway/server.c
index 8de9f629..82a80de5 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -23,6 +23,7 @@
 #include <wlr/types/wlr_primary_selection_v1.h>
 #include <wlr/types/wlr_relative_pointer_v1.h>
 #include <wlr/types/wlr_screencopy_v1.h>
+#include <wlr/types/wlr_ext_screencopy_v1.h>
 #include <wlr/types/wlr_server_decoration.h>
 #include <wlr/types/wlr_subcompositor.h>
 #include <wlr/types/wlr_tablet_v2.h>
@@ -196,6 +197,7 @@ bool server_init(struct sway_server *server) {
 
 	wlr_export_dmabuf_manager_v1_create(server->wl_display);
 	wlr_screencopy_manager_v1_create(server->wl_display);
+	wlr_ext_screencopy_manager_v1_create(server->wl_display);
 	wlr_data_control_manager_v1_create(server->wl_display);
 	wlr_primary_selection_v1_device_manager_create(server->wl_display);
 	wlr_viewporter_create(server->wl_display);

For testing, it's useful to enable hardware cursors in the headless backend:

diff --git a/backend/headless/output.c b/backend/headless/output.c
index f03d6ee0..ef2362d7 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -73,6 +73,16 @@ static bool output_commit(struct wlr_output *wlr_output) {
 	return true;
 }
 
+static bool output_set_cursor(struct wlr_output *wlr_output,
+		struct wlr_buffer *wlr_buffer, int hotspot_x, int hotspot_y) {
+	return true;
+}
+
+static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
+	// TODO: only return true if x == current x and y == current y
+	return true;
+}
+
 static void output_destroy(struct wlr_output *wlr_output) {
 	struct wlr_headless_output *output =
 		headless_output_from_output(wlr_output);
@@ -84,6 +94,8 @@ static void output_destroy(struct wlr_output *wlr_output) {
 static const struct wlr_output_impl output_impl = {
 	.destroy = output_destroy,
 	.commit = output_commit,
+	.set_cursor = output_set_cursor,
+	.move_cursor = output_move_cursor,
 };
 
 bool wlr_output_is_headless(struct wlr_output *wlr_output) {
Edited by Andri Yngvason

Merge request reports