mirror of
https://gitlab.gnome.org/GNOME/libmks.git
synced 2024-12-22 13:45:21 +00:00
Merge branch 'bilelmoussaoui/touch-support-v2' into 'main'
touch support: round 2 See merge request chergert/libmks!27
This commit is contained in:
commit
61846c127b
@ -41,7 +41,7 @@
|
|||||||
Interactions with a console may be done with
|
Interactions with a console may be done with
|
||||||
:dbus:iface:`org.qemu.Display1.Keyboard`,
|
:dbus:iface:`org.qemu.Display1.Keyboard`,
|
||||||
:dbus:iface:`org.qemu.Display1.Mouse` and
|
:dbus:iface:`org.qemu.Display1.Mouse` and
|
||||||
:dbus:iface:`org.qemu.Display1.Touch` interfaces when available.
|
:dbus:iface:`org.qemu.Display1.MultiTouch` interfaces when available.
|
||||||
-->
|
-->
|
||||||
<interface name="org.qemu.Display1.Console">
|
<interface name="org.qemu.Display1.Console">
|
||||||
<!--
|
<!--
|
||||||
@ -239,7 +239,7 @@
|
|||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
org.qemu.Display1.Touch:
|
org.qemu.Display1.MultiTouch:
|
||||||
|
|
||||||
This interface in implemented on ``/org/qemu/Display1/Console_$id`` (see
|
This interface in implemented on ``/org/qemu/Display1/Console_$id`` (see
|
||||||
:dbus:iface:`~org.qemu.Display1.Console` documentation).
|
:dbus:iface:`~org.qemu.Display1.Console` documentation).
|
||||||
@ -253,7 +253,7 @@
|
|||||||
End = 2
|
End = 2
|
||||||
Cancel = 3
|
Cancel = 3
|
||||||
-->
|
-->
|
||||||
<interface name="org.qemu.Display1.Touch">
|
<interface name="org.qemu.Display1.MultiTouch">
|
||||||
<!--
|
<!--
|
||||||
SendEvent:
|
SendEvent:
|
||||||
@kind: The touch event kind
|
@kind: The touch event kind
|
||||||
|
@ -45,5 +45,9 @@ void mks_display_picture_set_keyboard (MksDisplayPicture *self,
|
|||||||
MksTouchable *mks_display_picture_get_touchable (MksDisplayPicture *self);
|
MksTouchable *mks_display_picture_get_touchable (MksDisplayPicture *self);
|
||||||
void mks_display_picture_set_touchable (MksDisplayPicture *self,
|
void mks_display_picture_set_touchable (MksDisplayPicture *self,
|
||||||
MksTouchable *touchable);
|
MksTouchable *touchable);
|
||||||
|
gboolean
|
||||||
|
mks_display_picture_event_get_guest_position (MksDisplayPicture *self,
|
||||||
|
GdkEvent *event,
|
||||||
|
double *guest_x,
|
||||||
|
double *guest_y);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -193,7 +193,7 @@ mks_display_picture_mouse_release_cb (GObject *object,
|
|||||||
g_debug ("Mouse release failed: %s", error->message);
|
g_debug ("Mouse release failed: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
gboolean
|
||||||
mks_display_picture_event_get_guest_position (MksDisplayPicture *self,
|
mks_display_picture_event_get_guest_position (MksDisplayPicture *self,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
double *guest_x,
|
double *guest_x,
|
||||||
|
@ -569,3 +569,32 @@ mks_display_set_ungrab_trigger (MksDisplay *self,
|
|||||||
|
|
||||||
MKS_EXIT;
|
MKS_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mks_display_get_event_position_in_guest:
|
||||||
|
* @self: a #MksDisplay
|
||||||
|
* @event: A #GdkEvent
|
||||||
|
* @guest_x: (out): Guest's X position
|
||||||
|
* @guest_y: (out): Guest's Y position
|
||||||
|
*
|
||||||
|
* Retrieve the (`guest_x`, `guest_y`) position
|
||||||
|
* where the `event` happened.
|
||||||
|
*
|
||||||
|
* Could be useful for implementing touch support emulation.
|
||||||
|
*
|
||||||
|
* Returns: Whether the event has an associated position
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
mks_display_get_event_position_in_guest (MksDisplay *self,
|
||||||
|
GdkEvent *event,
|
||||||
|
double *guest_x,
|
||||||
|
double *guest_y)
|
||||||
|
{
|
||||||
|
MksDisplayPrivate *priv = mks_display_get_instance_private (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (MKS_IS_DISPLAY (self), FALSE);
|
||||||
|
g_return_val_if_fail (GDK_IS_EVENT (event), FALSE);
|
||||||
|
|
||||||
|
return mks_display_picture_event_get_guest_position (priv->picture, event,
|
||||||
|
guest_x, guest_y);
|
||||||
|
}
|
||||||
|
@ -58,4 +58,10 @@ gboolean mks_display_get_auto_resize (MksDisplay *self);
|
|||||||
MKS_AVAILABLE_IN_ALL
|
MKS_AVAILABLE_IN_ALL
|
||||||
void mks_display_set_auto_resize (MksDisplay *self,
|
void mks_display_set_auto_resize (MksDisplay *self,
|
||||||
gboolean auto_resize);
|
gboolean auto_resize);
|
||||||
|
MKS_AVAILABLE_IN_ALL
|
||||||
|
gboolean
|
||||||
|
mks_display_get_event_position_in_guest (MksDisplay *self,
|
||||||
|
GdkEvent *event,
|
||||||
|
double *guest_x,
|
||||||
|
double *guest_y);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -208,7 +208,7 @@ mks_screen_setup (MksDevice *device,
|
|||||||
self->keyboard = _mks_device_new (MKS_TYPE_KEYBOARD, device->session, object);
|
self->keyboard = _mks_device_new (MKS_TYPE_KEYBOARD, device->session, object);
|
||||||
else if (MKS_QEMU_IS_MOUSE (iface))
|
else if (MKS_QEMU_IS_MOUSE (iface))
|
||||||
self->mouse = _mks_device_new (MKS_TYPE_MOUSE, device->session, object);
|
self->mouse = _mks_device_new (MKS_TYPE_MOUSE, device->session, object);
|
||||||
else if (MKS_QEMU_IS_TOUCH (iface))
|
else if (MKS_QEMU_IS_MULTI_TOUCH (iface))
|
||||||
self->touchable = _mks_device_new (MKS_TYPE_TOUCHABLE, device->session, object);
|
self->touchable = _mks_device_new (MKS_TYPE_TOUCHABLE, device->session, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
struct _MksTouchable
|
struct _MksTouchable
|
||||||
{
|
{
|
||||||
MksDevice parent_instance;
|
MksDevice parent_instance;
|
||||||
MksQemuTouch *touch;
|
MksQemuMultiTouch *touch;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MksTouchableClass
|
struct _MksTouchableClass
|
||||||
@ -55,10 +55,10 @@ static GParamSpec *properties [N_PROPS];
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
mks_touchable_set_touch (MksTouchable *self,
|
mks_touchable_set_touch (MksTouchable *self,
|
||||||
MksQemuTouch *touch)
|
MksQemuMultiTouch *touch)
|
||||||
{
|
{
|
||||||
g_assert (MKS_IS_TOUCHABLE (self));
|
g_assert (MKS_IS_TOUCHABLE (self));
|
||||||
g_assert (!touch || MKS_QEMU_IS_TOUCH (touch));
|
g_assert (!touch || MKS_QEMU_IS_MULTI_TOUCH (touch));
|
||||||
|
|
||||||
g_set_object (&self->touch, touch);
|
g_set_object (&self->touch, touch);
|
||||||
}
|
}
|
||||||
@ -79,8 +79,8 @@ mks_touchable_setup (MksDevice *device,
|
|||||||
{
|
{
|
||||||
GDBusInterface *iface = iter->data;
|
GDBusInterface *iface = iter->data;
|
||||||
|
|
||||||
if (MKS_QEMU_IS_TOUCH (iface))
|
if (MKS_QEMU_IS_MULTI_TOUCH (iface))
|
||||||
mks_touchable_set_touch (self, MKS_QEMU_TOUCH (iface));
|
mks_touchable_set_touch (self, MKS_QEMU_MULTI_TOUCH (iface));
|
||||||
}
|
}
|
||||||
|
|
||||||
return self->touch != NULL;
|
return self->touch != NULL;
|
||||||
@ -165,17 +165,17 @@ mks_touchable_send_event_cb (GObject *object,
|
|||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MksQemuTouch *touch = (MksQemuTouch *)object;
|
MksQemuMultiTouch *touch = (MksQemuMultiTouch *)object;
|
||||||
g_autoptr(GTask) task = user_data;
|
g_autoptr(GTask) task = user_data;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
MKS_ENTRY;
|
MKS_ENTRY;
|
||||||
|
|
||||||
g_assert (MKS_QEMU_IS_TOUCH (touch));
|
g_assert (MKS_QEMU_IS_MULTI_TOUCH (touch));
|
||||||
g_assert (G_IS_ASYNC_RESULT (result));
|
g_assert (G_IS_ASYNC_RESULT (result));
|
||||||
g_assert (G_IS_TASK (task));
|
g_assert (G_IS_TASK (task));
|
||||||
|
|
||||||
if (!mks_qemu_touch_call_send_event_finish (touch, result, &error))
|
if (!mks_qemu_multi_touch_call_send_event_finish (touch, result, &error))
|
||||||
g_task_return_error (task, g_steal_pointer (&error));
|
g_task_return_error (task, g_steal_pointer (&error));
|
||||||
else
|
else
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
@ -219,7 +219,7 @@ mks_touchable_send_event (MksTouchable *self,
|
|||||||
if (!check_touch (self, &error))
|
if (!check_touch (self, &error))
|
||||||
g_task_return_error (task, g_steal_pointer (&error));
|
g_task_return_error (task, g_steal_pointer (&error));
|
||||||
else
|
else
|
||||||
mks_qemu_touch_call_send_event (self->touch, kind,
|
mks_qemu_multi_touch_call_send_event (self->touch, kind,
|
||||||
num_slot, x, y,
|
num_slot, x, y,
|
||||||
cancellable,
|
cancellable,
|
||||||
mks_touchable_send_event_cb,
|
mks_touchable_send_event_cb,
|
||||||
@ -291,7 +291,7 @@ mks_touchable_send_event_sync (MksTouchable *self,
|
|||||||
if (!check_touch (self, error))
|
if (!check_touch (self, error))
|
||||||
MKS_RETURN (FALSE);
|
MKS_RETURN (FALSE);
|
||||||
|
|
||||||
ret = mks_qemu_touch_call_send_event_sync (self->touch, kind,
|
ret = mks_qemu_multi_touch_call_send_event_sync (self->touch, kind,
|
||||||
num_slot, x, y,
|
num_slot, x, y,
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ mks_touchable_get_max_slots (MksTouchable *self)
|
|||||||
g_return_val_if_fail (MKS_IS_TOUCHABLE (self), 0);
|
g_return_val_if_fail (MKS_IS_TOUCHABLE (self), 0);
|
||||||
|
|
||||||
if (self->touch)
|
if (self->touch)
|
||||||
return mks_qemu_touch_get_max_slots (self->touch);
|
return mks_qemu_multi_touch_get_max_slots (self->touch);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user