aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndri Yngvason <andri@yngvason.is>2020-02-05 21:50:03 +0000
committerSimon Ser <contact@emersion.fr>2020-02-10 21:01:38 +0100
commit273b280f469f5be3455f98f4230b169cc9ee67f2 (patch)
treed92b9e5432f9fe011a706e3a9d5f1e1fe9c3d2df
parent2fea2fced8350ce52b3ea9c2d3f62797f7e61b56 (diff)
virtual-pointer: Add request for mapping to specific output
-rw-r--r--include/wlr/types/wlr_virtual_pointer_v1.h2
-rw-r--r--protocol/wlr-virtual-pointer-unstable-v1.xml17
-rw-r--r--types/wlr_virtual_pointer_v1.c19
3 files changed, 33 insertions, 5 deletions
diff --git a/include/wlr/types/wlr_virtual_pointer_v1.h b/include/wlr/types/wlr_virtual_pointer_v1.h
index 7d2d80d9..ede9bebf 100644
--- a/include/wlr/types/wlr_virtual_pointer_v1.h
+++ b/include/wlr/types/wlr_virtual_pointer_v1.h
@@ -13,6 +13,7 @@
#include <wayland-server-protocol.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h>
+#include <wlr/interfaces/wlr_output.h>
struct wlr_virtual_pointer_manager_v1 {
struct wl_global *global;
@@ -45,6 +46,7 @@ struct wlr_virtual_pointer_v1_new_pointer_event {
struct wlr_virtual_pointer_v1 *new_pointer;
/** Suggested by client; may be NULL. */
struct wlr_seat *suggested_seat;
+ struct wlr_output *suggested_output;
};
struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create(
diff --git a/protocol/wlr-virtual-pointer-unstable-v1.xml b/protocol/wlr-virtual-pointer-unstable-v1.xml
index e21b4d71..ea243e7c 100644
--- a/protocol/wlr-virtual-pointer-unstable-v1.xml
+++ b/protocol/wlr-virtual-pointer-unstable-v1.xml
@@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
- <interface name="zwlr_virtual_pointer_v1" version="1">
+ <interface name="zwlr_virtual_pointer_v1" version="2">
<description summary="virtual pointer">
This protocol allows clients to emulate a physical pointer device. The
requests are mostly mirror opposites of those specified in wl_pointer.
@@ -118,7 +118,7 @@
</request>
</interface>
- <interface name="zwlr_virtual_pointer_manager_v1" version="1">
+ <interface name="zwlr_virtual_pointer_manager_v1" version="2">
<description summary="virtual pointer manager">
This object allows clients to create individual virtual pointer objects.
</description>
@@ -135,5 +135,18 @@
<request name="destroy" type="destructor" since="1">
<description summary="destroy the virtual pointer manager"/>
</request>
+
+ <!-- Version 2 additions -->
+ <request name="create_virtual_pointer_with_output" since="2">
+ <description summary="Create a new virtual pointer">
+ Creates a new virtual pointer. The seat and the output arguments are
+ optional. If the seat argument is set, the compositor should assign the
+ input device to the requested seat. If the output argument is set, the
+ compositor should map the input device to the requested output.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat" allow-null="true"/>
+ <arg name="output" type="object" interface="wl_output" allow-null="true"/>
+ <arg name="id" type="new_id" interface="zwlr_virtual_pointer_v1"/>
+ </request>
</interface>
</protocol>
diff --git a/types/wlr_virtual_pointer_v1.c b/types/wlr_virtual_pointer_v1.c
index 8483ae9b..aed3647b 100644
--- a/types/wlr_virtual_pointer_v1.c
+++ b/types/wlr_virtual_pointer_v1.c
@@ -233,9 +233,10 @@ static struct wlr_virtual_pointer_manager_v1 *manager_from_resource(
return wl_resource_get_user_data(resource);
}
-static void virtual_pointer_manager_create_virtual_pointer(
+static void virtual_pointer_manager_create_virtual_pointer_with_output(
struct wl_client *client, struct wl_resource *resource,
- struct wl_resource *seat, uint32_t id) {
+ struct wl_resource *seat, struct wl_resource *output,
+ uint32_t id) {
struct wlr_virtual_pointer_manager_v1 *manager = manager_from_resource(resource);
struct wlr_virtual_pointer_v1 *virtual_pointer = calloc(1,
@@ -281,6 +282,11 @@ static void virtual_pointer_manager_create_virtual_pointer(
event.suggested_seat = seat_client->seat;
}
+ if (output) {
+ struct wlr_output *wlr_output = wlr_output_from_resource(output);
+ event.suggested_output = wlr_output;
+ }
+
virtual_pointer->input_device.pointer = pointer;
virtual_pointer->resource = pointer_resource;
wl_signal_init(&virtual_pointer->events.destroy);
@@ -289,6 +295,12 @@ static void virtual_pointer_manager_create_virtual_pointer(
wlr_signal_emit_safe(&manager->events.new_virtual_pointer, &event);
}
+static void virtual_pointer_manager_create_virtual_pointer(
+ struct wl_client *client, struct wl_resource *resource,
+ struct wl_resource *seat, uint32_t id) {
+ virtual_pointer_manager_create_virtual_pointer_with_output(client,
+ resource, seat, NULL, id);
+}
static void virtual_pointer_manager_destroy(struct wl_client *client,
struct wl_resource *resource) {
wl_resource_destroy(resource);
@@ -296,6 +308,7 @@ static void virtual_pointer_manager_destroy(struct wl_client *client,
static const struct zwlr_virtual_pointer_manager_v1_interface manager_impl = {
.create_virtual_pointer = virtual_pointer_manager_create_virtual_pointer,
+ .create_virtual_pointer_with_output = virtual_pointer_manager_create_virtual_pointer_with_output,
.destroy = virtual_pointer_manager_destroy,
};
@@ -341,7 +354,7 @@ struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create(
wl_signal_init(&manager->events.new_virtual_pointer);
wl_signal_init(&manager->events.destroy);
manager->global = wl_global_create(display,
- &zwlr_virtual_pointer_manager_v1_interface, 1, manager,
+ &zwlr_virtual_pointer_manager_v1_interface, 2, manager,
virtual_pointer_manager_bind);
if (!manager->global) {
free(manager);