From 5e752163189ecea349bc891aac042a259bdd8b65 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 9 Feb 2023 17:30:38 -0800 Subject: [PATCH] lib: stub internal listener skeleton This is an org.qemu.Listener using the gdbus-codegen generated skeleton as the parent type. What will probably happen here, is that we create a MksPaintable which is given to the listener to call internal API upon. The paintable code will be a bit more complex than originally anticipated in that we are going to need to do our own tessellation so that we get damage regions which are not the whole widget. Very similar to what I did in the GdkMacosTile for gdk/macos/. --- lib/meson.build | 1 + lib/mks-paintable-listener-private.h | 35 +++++++ lib/mks-paintable-listener.c | 150 +++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 lib/mks-paintable-listener-private.h create mode 100644 lib/mks-paintable-listener.c diff --git a/lib/meson.build b/lib/meson.build index 55c6040..56136cb 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -31,6 +31,7 @@ libmks_enums = gnome.mkenums_simple('mks-enums', ) libmks_private_sources = [ + 'mks-paintable-listener.c', 'mks-read-only-list-model.c', gnome.gdbus_codegen('mks-qemu', diff --git a/lib/mks-paintable-listener-private.h b/lib/mks-paintable-listener-private.h new file mode 100644 index 0000000..072f1f6 --- /dev/null +++ b/lib/mks-paintable-listener-private.h @@ -0,0 +1,35 @@ +/* + * mks-paintable-listener-private.h + * + * Copyright 2023 Christian Hergert + * + * 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 3 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "mks-qemu.h" + +G_BEGIN_DECLS + +#define MKS_TYPE_PAINTABLE_LISTENER (mks_paintable_listener_get_type()) +#define MKS_PAINTABLE_LISTENER_OBJECT_PATH "/org/qemu/Display1/Listener" + +G_DECLARE_FINAL_TYPE (MksPaintableListener, mks_paintable_listener, MKS, PAINTABLE_LISTENER, MksQemuListenerSkeleton) + +MksPaintableListener *mks_paintable_listener_new (void); + +G_END_DECLS diff --git a/lib/mks-paintable-listener.c b/lib/mks-paintable-listener.c new file mode 100644 index 0000000..dc72106 --- /dev/null +++ b/lib/mks-paintable-listener.c @@ -0,0 +1,150 @@ +/* + * mks-paintable-listener.c + * + * Copyright 2023 Christian Hergert + * + * 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 3 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "config.h" + +#include "mks-paintable-listener-private.h" + +struct _MksPaintableListener +{ + MksQemuListenerSkeleton parent_instance; +}; + +static gboolean +mks_paintable_listener_update_dmabuf (MksQemuListener *listener, + GDBusMethodInvocation *invocation, + int x, + int y, + int width, + int height) +{ + return FALSE; +} + +static gboolean +mks_paintable_listener_scanout_dmabuf (MksQemuListener *listener, + GDBusMethodInvocation *invocation, + GUnixFDList *unix_fd_list, + GVariant *dmabuf, + guint width, + guint height, + guint stride, + guint fourcc, + guint64 modifier, + gboolean y0_top) +{ + return FALSE; +} + +static gboolean +mks_paintable_listener_update (MksQemuListener *listener, + GDBusMethodInvocation *invocation, + int x, + int y, + int width, + int height, + guint stride, + guint pixman_format, + GVariant *bytes) +{ + return TRUE; +} + +static gboolean +mks_paintable_listener_scanout (MksQemuListener *listener, + GDBusMethodInvocation *invocation, + guint width, + guint height, + guint stride, + guint pixman_format, + GVariant *bytes) +{ + return TRUE; +} + +static gboolean +mks_paintable_listener_cursor_define (MksQemuListener *listener, + GDBusMethodInvocation *invocation, + int width, + int height, + int hot_x, + int hot_y, + GVariant *bytes) +{ + return FALSE; +} + +static gboolean +mks_paintable_listener_mouse_set (MksQemuListener *listener, + GDBusMethodInvocation *invocation, + int x, + int y, + int on) +{ + return FALSE; +} + +static gboolean +mks_paintable_listener_disable (MksQemuListener *listener, + GDBusMethodInvocation *invocation) +{ + return TRUE; +} + +static void +listener_iface_init (MksQemuListenerIface *iface) +{ + iface->handle_update = mks_paintable_listener_update; + iface->handle_scanout = mks_paintable_listener_scanout; + iface->handle_update_dmabuf = mks_paintable_listener_update_dmabuf; + iface->handle_scanout_dmabuf = mks_paintable_listener_scanout_dmabuf; + iface->handle_cursor_define = mks_paintable_listener_cursor_define; + iface->handle_mouse_set = mks_paintable_listener_mouse_set; + iface->handle_disable = mks_paintable_listener_disable; +} + +G_DEFINE_FINAL_TYPE_WITH_CODE (MksPaintableListener, mks_paintable_listener, MKS_QEMU_TYPE_LISTENER_SKELETON, + G_IMPLEMENT_INTERFACE (MKS_QEMU_TYPE_LISTENER, listener_iface_init)) + +MksPaintableListener * +mks_paintable_listener_new (void) +{ + return g_object_new (MKS_TYPE_PAINTABLE_LISTENER, NULL); +} + +static void +mks_paintable_listener_finalize (GObject *object) +{ + G_OBJECT_CLASS (mks_paintable_listener_parent_class)->finalize (object); +} + +static void +mks_paintable_listener_class_init (MksPaintableListenerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = mks_paintable_listener_finalize; +} + +static void +mks_paintable_listener_init (MksPaintableListener *self) +{ +}