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/.
This commit is contained in:
Christian Hergert 2023-02-09 17:30:38 -08:00
parent c9aa3a1a03
commit 5e75216318
3 changed files with 186 additions and 0 deletions

View File

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

View File

@ -0,0 +1,35 @@
/*
* mks-paintable-listener-private.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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

View File

@ -0,0 +1,150 @@
/*
* mks-paintable-listener.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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)
{
}