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',