From 271fb86b1525553e6075fff9ffedfd5acebe918b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 28 Aug 2023 22:16:06 +0200 Subject: [PATCH] eis: Add "viewport" interface A MetaEisViewport represents an absolute region backend by e.g. a pointer device. There are two kinds: a standalone viewport, which corresponds to a viewport that has no neighbours, and a non-standalone, which represents a region of a global coordinate space. The reason for having non-standalone viewports is to allow to mirror the logical monitor layout of a desktop, while the standalone are meant to represent things that are not part of the logical monitor layout. Part-of: --- src/backends/meta-eis-viewport.c | 80 ++++++++++++++++++++++++++++++++ src/backends/meta-eis-viewport.h | 70 ++++++++++++++++++++++++++++ src/backends/meta-eis.h | 1 + src/meson.build | 2 + 4 files changed, 153 insertions(+) create mode 100644 src/backends/meta-eis-viewport.c create mode 100644 src/backends/meta-eis-viewport.h diff --git a/src/backends/meta-eis-viewport.c b/src/backends/meta-eis-viewport.c new file mode 100644 index 000000000..74533a83d --- /dev/null +++ b/src/backends/meta-eis-viewport.c @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2023 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + */ + +#include "config.h" + +#include "backends/meta-eis-viewport.h" + +G_DEFINE_INTERFACE (MetaEisViewport, meta_eis_viewport, G_TYPE_OBJECT) + +static void +meta_eis_viewport_default_init (MetaEisViewportInterface *iface) +{ +} + +gboolean +meta_eis_viewport_is_standalone (MetaEisViewport *viewport) +{ + return META_EIS_VIEWPORT_GET_IFACE (viewport)->is_standalone (viewport); +} + +const char * +meta_eis_viewport_get_mapping_id (MetaEisViewport *viewport) +{ + return META_EIS_VIEWPORT_GET_IFACE (viewport)->get_mapping_id (viewport); +} + +gboolean +meta_eis_viewport_get_position (MetaEisViewport *viewport, + int *out_x, + int *out_y) +{ + return META_EIS_VIEWPORT_GET_IFACE (viewport)->get_position (viewport, + out_x, + out_y); +} + +void +meta_eis_viewport_get_size (MetaEisViewport *viewport, + int *out_width, + int *out_height) +{ + META_EIS_VIEWPORT_GET_IFACE (viewport)->get_size (viewport, + out_width, + out_height); +} + +double +meta_eis_viewport_get_physical_scale (MetaEisViewport *viewport) +{ + return META_EIS_VIEWPORT_GET_IFACE (viewport)->get_physical_scale (viewport); +} + +gboolean +meta_eis_viewport_transform_coordinate (MetaEisViewport *viewport, + double x, + double y, + double *out_x, + double *out_y) +{ + return META_EIS_VIEWPORT_GET_IFACE (viewport)->transform_coordinate (viewport, + x, + y, + out_x, + out_y); +} diff --git a/src/backends/meta-eis-viewport.h b/src/backends/meta-eis-viewport.h new file mode 100644 index 000000000..20fde137a --- /dev/null +++ b/src/backends/meta-eis-viewport.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2023 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + */ + +#pragma once + +#include + +#define META_TYPE_EIS_VIEWPORT (meta_eis_viewport_get_type ()) +G_DECLARE_INTERFACE (MetaEisViewport, meta_eis_viewport, + META, EIS_VIEWPORT, GObject) + +struct _MetaEisViewportInterface +{ + GTypeInterface parent_iface; + + gboolean (* is_standalone) (MetaEisViewport *viewport); + + const char * (* get_mapping_id) (MetaEisViewport *viewport); + + gboolean (* get_position) (MetaEisViewport *viewport, + int *out_x, + int *out_y); + + void (* get_size) (MetaEisViewport *viewport, + int *out_width, + int *out_height); + + double (* get_physical_scale) (MetaEisViewport *viewport); + + gboolean (* transform_coordinate) (MetaEisViewport *viewport, + double x, + double y, + double *out_x, + double *out_y); +}; + +gboolean meta_eis_viewport_is_standalone (MetaEisViewport *viewport); + +const char * meta_eis_viewport_get_mapping_id (MetaEisViewport *viewport); + +gboolean meta_eis_viewport_get_position (MetaEisViewport *viewport, + int *out_x, + int *out_y); + +void meta_eis_viewport_get_size (MetaEisViewport *viewport, + int *out_width, + int *out_height); + +double meta_eis_viewport_get_physical_scale (MetaEisViewport *viewport); + +gboolean meta_eis_viewport_transform_coordinate (MetaEisViewport *viewport, + double x, + double y, + double *out_x, + double *out_y); diff --git a/src/backends/meta-eis.h b/src/backends/meta-eis.h index 8160222be..897f9f019 100644 --- a/src/backends/meta-eis.h +++ b/src/backends/meta-eis.h @@ -23,6 +23,7 @@ #include #include "backends/meta-backend-types.h" +#include "backends/meta-eis-viewport.h" typedef enum _MetaEisDeviceTypes { diff --git a/src/meson.build b/src/meson.build index a5b6efd4d..ca2ef166c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -544,6 +544,8 @@ if have_remote_desktop 'backends/meta-eis.h', 'backends/meta-eis-client.c', 'backends/meta-eis-client.h', + 'backends/meta-eis-viewport.c', + 'backends/meta-eis-viewport.h', 'backends/meta-remote-desktop.c', 'backends/meta-remote-desktop.h', 'backends/meta-remote-desktop-session.c',